Compare commits

...

196 Commits
1.0.1 ... 1.1.1

Author SHA1 Message Date
DRC
ba29357611 Can't assume that current directory is in PATH
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@614 632fc199-4ca6-4c93-a231-07263d6284db
2011-05-18 03:50:53 +00:00
DRC
2c289bfa9b git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@612 632fc199-4ca6-4c93-a231-07263d6284db 2011-05-10 22:15:04 +00:00
DRC
5ee81f43cf Fix I/O redirection in cjpeg and djpeg on Windows
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@603 632fc199-4ca6-4c93-a231-07263d6284db
2011-05-02 00:35:50 +00:00
DRC
4f81526385 New libjpeg-turbo domain
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@601 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-27 00:33:14 +00:00
DRC
fad469f51e New libjpeg-turbo domain
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@602 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-30 04:43:23 +00:00
DRC
83c8f14fa2 Eliminate excessive I/O overhead when reading BMP files in cjpeg
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@595 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-25 22:53:44 +00:00
DRC
049aef51d4 Eliminate excessive I/O overhead when reading BMP files in cjpeg
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@592 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-25 22:41:14 +00:00
DRC
c56a74cdac Get rid of unused IS_WIN32 conditional
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@589 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-17 15:36:38 +00:00
DRC
51705fb967 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@588 632fc199-4ca6-4c93-a231-07263d6284db 2011-04-17 15:31:46 +00:00
DRC
e43d21d57f git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@586 632fc199-4ca6-4c93-a231-07263d6284db 2011-04-17 15:28:32 +00:00
DRC
9e6378c448 The previous attempt to handle unexpected markers in the data stream caused breakage in applications that attempted to set bytes_in_buffer to a larger value than the actual size of the JPEG image. The latter behavior was causing the fast decoder to be used for the last MCU in the image under certain circumstances, and this sometimes caused the EOI marker to be encountered by the fast decoder, which was treating it as an "unexpected" marker and throwing an error. Now, the fast decoder simply hands off the decoding of the block to the slow decoder if any marker is encountered.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@585 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 18:54:12 +00:00
DRC
62de12281a This is subtle, but an unread marker is not an error unless we run out of bits, which may not occur in the same MCU in which the unread marker is encountered. Thus, don't try to use the fast decoder as long as there is an outstanding unread marker.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@583 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 18:50:42 +00:00
DRC
5c36465fd5 The previous attempt to handle unexpected markers in the data stream caused breakage in applications that attempted to set bytes_in_buffer to a larger value than the actual size of the JPEG image. The latter behavior was causing the fast decoder to be used for the last MCU in the image under certain circumstances, and this sometimes caused the EOI marker to be encountered by the fast decoder, which was treating it as an "unexpected" marker and throwing an error. Now, the fast decoder simply hands off the decoding of the block to the slow decoder if any marker is encountered.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@582 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 17:39:58 +00:00
DRC
9026b37c0b "OS/X"="OS X"
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@581 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 13:37:22 +00:00
DRC
254937b33b Update build instructions to reflect the fact that 32-bit LJT build doesn't work with NASM 0.99 or 2.00
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@580 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 13:35:35 +00:00
DRC
58454c74cc Update build instructions to reflect the fact that 32-bit LJT build doesn't work with NASM 0.99 or 2.00
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@578 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-16 13:26:36 +00:00
DRC
98b8529d1f Use option() to handle configuration variables, so they will show up in the CMake GUI
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@576 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-15 00:20:15 +00:00
DRC
577ae78c30 Don't need MSVC definition in assembler code anymore
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@574 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-07 05:26:52 +00:00
DRC
926e01ffe1 Attempt to make build work with Visual Studio 2010 (still doesn't work if SIMD or Java are enabled-- see bug tracker)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@573 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-06 06:35:38 +00:00
DRC
2a33dfcaab git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@571 632fc199-4ca6-4c93-a231-07263d6284db 2011-04-05 06:51:59 +00:00
DRC
e7fde87ca5 Fix jpegoptim with v7 emulation as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@568 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-03 07:09:49 +00:00
DRC
59a58343ea Ensure that image_width and image_height are initialized if libjpeg v8 emulation is enabled.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@565 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-02 05:40:16 +00:00
Guido Vollbeding
c39ec149e8 The Independent JPEG Group's JPEG software v8c 2015-07-27 13:49:31 -05:00
Guido Vollbeding
a4ecaacde6 The Independent JPEG Group's JPEG software v8b 2015-07-27 13:48:40 -05:00
Guido Vollbeding
f18f81b7e2 The Independent JPEG Group's JPEG software v8a 2015-07-27 13:46:36 -05:00
Guido Vollbeding
989630f70c The Independent JPEG Group's JPEG software v8 2015-07-27 13:45:31 -05:00
Guido Vollbeding
5996a25e2f The Independent JPEG Group's JPEG software v7 2015-07-27 13:44:25 -05:00
Guido Vollbeding
1e247ac854 The Independent JPEG Group's JPEG software v6b with arithmetic coding support 2015-07-27 14:40:46 -05:00
DRC
9e50fa7fbe Fixed a regression bug in the NSIS script that caused the Windows installer
build to fail when using the Visual Studio IDE.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@554 632fc199-4ca6-4c93-a231-07263d6284db
2011-04-01 11:24:31 +00:00
DRC
e44f8c0112 make testclean should clean up .yuv files as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@544 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-31 09:19:53 +00:00
DRC
1e14b47c22 Get rid of unused IS_WIN32 conditional
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@542 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-31 04:15:50 +00:00
DRC
a8eabfebd1 Create local round up function for jmemmgr.c so we can revert the original argument types of jround_up() without breaking the build on 64-bit Windows.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@539 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-29 04:58:40 +00:00
DRC
1da7858d24 MinGW64 no longer prefixes symbols with underscores by default
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@538 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 09:34:01 +00:00
DRC
1c87e45cff We want to keep the same name for the install directory, even though the installer name has changed
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@535 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 06:49:31 +00:00
DRC
539b288780 Typo
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@534 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 06:28:04 +00:00
DRC
47aaf6fa15 MinGW64 no longer prefixes symbols with underscores by default
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@533 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 05:40:39 +00:00
DRC
328c4388b7 Oops. Forgot to generate makecygwinpkg
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@532 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 05:04:30 +00:00
DRC
e6f597f28f Don't use architecture extension in package name, since we're building a combined package
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@531 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 03:19:11 +00:00
DRC
bfa34cf143 "release/"="pkgscripts/"
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@530 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 01:38:04 +00:00
DRC
5e091d4d1f Need to put the generated packaging scripts in a directory other than release/ so they won't get distributed
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@529 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 01:21:42 +00:00
DRC
95db4f48a5 Clean up packaging system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@528 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-22 00:20:43 +00:00
DRC
1a79ede633 1.1.1
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@527 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-21 22:42:31 +00:00
DRC
a6471c34ed git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@526 632fc199-4ca6-4c93-a231-07263d6284db 2011-03-18 05:59:21 +00:00
DRC
fe6a2ee5a1 Throw a warning if an unexpected marker is found in the middle of the JPEG data stream
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@524 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-18 05:49:26 +00:00
DRC
df1c38df74 Throw a warning if an unexpected marker is found in the middle of the JPEG data stream
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@521 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-18 05:40:33 +00:00
DRC
6ee5459459 Don't call jpeg_finish_compress() with YUV output, because it tries to insert an EOI marker right in the middle of our image data.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@475 632fc199-4ca6-4c93-a231-07263d6284db
2011-03-01 08:18:30 +00:00
DRC
66df5eca03 Oops. cconvert is still needed for 12-bit samples
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@470 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-27 09:48:48 +00:00
DRC
da58a91d1e Make Visual C++ happy
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@465 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-27 00:07:51 +00:00
DRC
0769f505bf Fix compiler warnings
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@461 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-26 21:08:39 +00:00
DRC
b4a50ceefb Enable full GCC compiler warnings by default
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@460 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-26 21:07:50 +00:00
DRC
361a637174 Fix uninitialized variables
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@455 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-26 19:46:27 +00:00
DRC
3484e0b160 Add RGB-->Grayscale YUV decode test
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@453 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 06:21:15 +00:00
DRC
d5a69afa5a Fix the buffer size regression test so that it generates the intended pixel patterns
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@450 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 02:13:07 +00:00
DRC
0745c0fb6a Correct memory allocation failure messages
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@447 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 01:31:13 +00:00
DRC
94476c648b Only access TJBUFSIZEYUV symbol if YUV encoding is enabled, and add 1 to the buffer size; This allows jpgtest to be used to benchmark the old TurboJPEG/IPP libraries.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@446 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 01:14:46 +00:00
DRC
0cc1279e03 Use correct size for YUV buffers
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@445 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 00:54:29 +00:00
DRC
10e3193373 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@441 632fc199-4ca6-4c93-a231-07263d6284db 2011-02-25 00:14:12 +00:00
DRC
eeab6957dd Replace the TJ_YUV flag with two new API functions, and add TJBUFSIZEYUV() from trunk
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@440 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-25 00:02:04 +00:00
DRC
5cb1b68d39 Tiling doesn't work with YUV encoding either
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@439 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-24 22:13:20 +00:00
DRC
0b11d1c815 Fix various CR/LF issues
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@438 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-24 21:43:35 +00:00
DRC
582a46a59e Ensure that libjpeg state is reset if an error occurs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@437 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-24 21:16:10 +00:00
DRC
6e51e19b1c Use a proper version script for libturbojpeg, since we've added functions to it since 1.0
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@436 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-24 19:36:02 +00:00
DRC
cce6b43463 Oops. dumpbuf() was displaying only red components.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@430 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-23 01:41:26 +00:00
DRC
2ca3eb5660 Oops. dumpbuf() was displaying only red components.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@429 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-23 01:40:44 +00:00
DRC
404e82e070 Test all YUV decode paths
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@427 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-22 19:59:54 +00:00
DRC
7d9d434826 "TurboJPEG/OSS"="TurboJPEG", since the TurboJPEG header is used with other codecs besides libjpeg-turbo
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@420 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-22 00:31:27 +00:00
DRC
b4b31403c7 RGBA=RGBX, BGRA=BGRX, ABGR=XBGR, ARGB=XRGB
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@412 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-19 17:31:24 +00:00
DRC
2a28599343 Implement "ultra quiet mode" for generating output that is easy to copy/paste into a spreadsheet
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@411 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-19 17:20:11 +00:00
DRC
3e87c8b0a4 Wordsmithing
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@410 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-19 16:42:14 +00:00
DRC
db8df01c85 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@409 632fc199-4ca6-4c93-a231-07263d6284db 2011-02-19 00:01:11 +00:00
DRC
240d82f8be Include jpgtest in Unix/Linux distribution packages
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@408 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-19 00:00:34 +00:00
DRC
8569c2f5a6 Include libjpeg run-time programs and jpgtest in installer; Move documentation in SDK distribution packages into doc\ subdirectory
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@407 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 23:49:42 +00:00
DRC
5d6f858235 Disable CXX compiler check
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@406 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 23:08:58 +00:00
DRC
f3281e8275 Oops. We still had the description left over from VirtualGL
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@403 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 22:40:34 +00:00
DRC
0d2d965364 Wordsmithed the project description
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@402 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 22:29:45 +00:00
DRC
16e761e59c Include high-quality test image in distribution
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@401 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 21:20:50 +00:00
DRC
69e15442f3 1.1.0
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@400 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 21:16:56 +00:00
DRC
da509e32c6 New C version of jpgtest needs libm
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@399 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 21:16:04 +00:00
DRC
23ce65d25d Updated (C)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@392 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 07:02:32 +00:00
DRC
f38eee0739 The API/ABI should be described as "libjpeg v8", not "libjpeg v8b", since there are multiple libjpeg releases with the same interface
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@391 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 07:00:38 +00:00
DRC
d24b276820 Re-order high-quality JPEG test per existing convention
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@390 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 05:24:50 +00:00
DRC
94a402305c Also run high-quality JPEG test when code is built without SIMD extensions
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@389 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 05:15:59 +00:00
DRC
c4ef01fc66 Add high-quality JPEG tests to CMake
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@388 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 05:06:58 +00:00
DRC
ab4db657db Various documentation tweaks
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@387 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 04:55:08 +00:00
DRC
856fd82ea3 More doc tweaks
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@386 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 04:50:45 +00:00
DRC
39f3aa0871 Various documentation tweaks
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@385 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 04:39:36 +00:00
DRC
6514105007 Include high-quality test image in distribution
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@384 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 03:55:25 +00:00
DRC
6ca69537f1 The SIMD quantization algorithm does not produce correct results with the fast forward integer DCT and JPEG qualities >= 98, so for now, use the non-SIMD quantization function under those circumstances.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@383 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 03:31:11 +00:00
DRC
f0a5ba7542 "integer forward DCT", not "forward integer DCT"
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@382 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 03:21:06 +00:00
DRC
e1716b8507 The fast integer DCT degrades for qualities > 95, so use the slow integer DCT instead to ensure that perceptually lossless performance is maintained.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@381 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 03:19:43 +00:00
DRC
7c1df0a430 Performance pitfalls
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@380 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 02:45:24 +00:00
DRC
bb4465f392 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@379 632fc199-4ca6-4c93-a231-07263d6284db 2011-02-18 02:41:03 +00:00
DRC
72abc29722 The SIMD quantization algorithm does not produce correct results with the fast forward integer DCT and JPEG qualities >= 98, so for now, use the non-SIMD quantization function under those circumstances.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@378 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-18 01:45:24 +00:00
DRC
e2f3718d39 Fix typo that was causing visual artifacts in grayscale JPEGs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@377 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-17 07:53:46 +00:00
DRC
fc1970acef Fix typo that was causing visual artifacts in grayscale JPEGs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@376 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-17 07:51:35 +00:00
DRC
dbf80031ae Not using Intel codec anymore
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@371 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-16 01:39:29 +00:00
DRC
8254df1a06 Document that pitch=0 == pitch=width*pixelsize
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@366 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-15 07:57:48 +00:00
DRC
91e86ba6cf Ensure that YUV temp buffers get properly freed if a failure occurs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@364 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-15 05:24:08 +00:00
DRC
cfef7f1bd8 Ensure that the exit status of the program indicates failure if one of the pixel value checks fails
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@362 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-15 05:17:20 +00:00
DRC
b8cc52bf1a Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@360 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-15 03:59:11 +00:00
DRC
e27124ab39 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@359 632fc199-4ca6-4c93-a231-07263d6284db 2011-02-08 07:14:33 +00:00
DRC
2e4d044cab Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@355 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-08 01:18:37 +00:00
DRC
af1ca9bcc1 Clarify that the C wrappers and headers fall under the same license as the rest of the SIMD code
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@335 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-02 05:42:37 +00:00
DRC
daae6d966a Clarify that the C wrappers and headers fall under the same license as the rest of the SIMD code
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@334 632fc199-4ca6-4c93-a231-07263d6284db
2011-02-02 05:41:15 +00:00
DRC
4a1c2d9693 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@329 632fc199-4ca6-4c93-a231-07263d6284db 2011-01-28 08:00:10 +00:00
DRC
9dcb1af2f6 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@328 632fc199-4ca6-4c93-a231-07263d6284db 2011-01-28 07:56:21 +00:00
DRC
c4bce4857e git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@327 632fc199-4ca6-4c93-a231-07263d6284db 2011-01-28 07:51:25 +00:00
DRC
a4efd4eec7 Create 1.1.x branch
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@325 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-28 06:06:34 +00:00
DRC
fa1d18385d Further protect against invalid Huffman codes
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@324 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-26 05:35:20 +00:00
DRC
79778f6588 1.0.2
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@323 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-26 05:34:01 +00:00
DRC
a432ff43a2 Create 1.0.x branch
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@322 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-26 05:23:28 +00:00
DRC
2d94e261ec The fast integer DCT degrades for qualities > 95, so use the slow integer DCT instead to ensure that perceptually lossless performance is maintained.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@320 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-25 06:52:31 +00:00
DRC
01e6909180 Clarifications
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@319 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-06 01:19:43 +00:00
DRC
57423076e6 Eliminate all of the __memalign() mess and just handle the alignment ourselves
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@317 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-05 23:35:53 +00:00
DRC
2a2e451ddc Ensure temp. buffers for YUV output are 16-byte aligned on 32-bit Windows
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@316 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-05 22:33:24 +00:00
DRC
990e28dc96 Make arithmetic coding support status messages more clear
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@315 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-04 21:40:11 +00:00
DRC
49aedf4231 Further protect against invalid Huffman codes
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@314 632fc199-4ca6-4c93-a231-07263d6284db
2011-01-04 08:09:41 +00:00
DRC
190d5495fe Include new tjDecompressHeader2() function
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@313 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-14 19:48:38 +00:00
DRC
50c657bc09 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@312 632fc199-4ca6-4c93-a231-07263d6284db 2010-12-14 01:23:16 +00:00
DRC
cad1cfe17c Added YUV decode functionality to the "decompress only" test
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@311 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-14 01:22:00 +00:00
DRC
1fe80f80f5 Added extended tjDecompressHeader() function which can determine the type of subsampling used in the JPEG image
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@310 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-14 01:21:29 +00:00
DRC
a6f4fca72c Fix various memory corruption issues in the new JPEG->YUV feature
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@309 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-11 06:01:11 +00:00
DRC
f9cf5c799d If the output width/height are not an even number of MCU's, then use an intermediate buffer to ensure that the output format is XVideo-compatible
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@308 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-10 10:58:49 +00:00
DRC
9e17f7d9bc Provide TJ_YUV option for tjDecompress() as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@307 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-10 04:59:13 +00:00
DRC
ac08ef624c Don't require quality argument when encoding to YUV
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@306 632fc199-4ca6-4c93-a231-07263d6284db
2010-12-09 10:01:57 +00:00
DRC
fbb674707e Merge the TurboJPEG planar YUV encoding feature from VirtualGL 2.2
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@305 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-24 04:02:37 +00:00
DRC
541e651e4c Hide internal SIMD symbols in libjpeg-turbo shared library
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@304 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 20:42:48 +00:00
DRC
a46830b232 Eliminate spurious global symbols
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@303 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 18:00:46 +00:00
DRC
f0b7fefbf4 Include arithmetic coding test files in dist
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@302 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 17:13:02 +00:00
DRC
245cfdf3d6 Allow arithmetic encoding/decoding to be disabled in CMake build
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@301 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 17:11:06 +00:00
DRC
e372004b4d Added configure options to disable arithmetic encoding/decoding
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@300 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 06:50:14 +00:00
DRC
66f97e6820 Support arithmetic encoding and decoding
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@299 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-23 05:49:54 +00:00
DRC
58842f9679 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@298 632fc199-4ca6-4c93-a231-07263d6284db 2010-11-23 04:46:59 +00:00
DRC
ec31193812 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@297 632fc199-4ca6-4c93-a231-07263d6284db 2010-11-22 19:51:42 +00:00
DRC
646e5a8a11 RGBA=RGBX, etc.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@296 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-18 19:55:29 +00:00
DRC
b8841f1ba2 Oops. Still need to explicitly make symlinks in this script, because prefix!=/opt/libjpeg-turbo
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@295 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-17 23:14:53 +00:00
DRC
d1c281a055 Create /opt/libjpeg-turbo/lib32 and /opt/libjpeg-turbo/lib64 symlinks when doing 'make install'
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@294 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-17 22:44:40 +00:00
DRC
61c15bdefb Fix invalid use of fpos_t
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@293 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-13 05:31:25 +00:00
DRC
e89bbaee14 Document jpgtest decompress-only feature
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@292 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-12 10:18:08 +00:00
DRC
e8ce2e0864 Add option to test decompression only + clean up error handling
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@291 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-12 10:14:11 +00:00
DRC
7a0478e1e4 Use version script for jpeg-6b emulation as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@290 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-07 19:12:30 +00:00
DRC
7ab9d7cad9 Update header description for grayscale bitmap support
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@289 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-04 22:42:18 +00:00
DRC
09854f57dc Grayscale bitmap support in TurboJPEG/OSS
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@288 632fc199-4ca6-4c93-a231-07263d6284db
2010-11-04 22:39:59 +00:00
DRC
98dbe91270 git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@287 632fc199-4ca6-4c93-a231-07263d6284db 2010-11-04 22:22:30 +00:00
DRC
0f53df8f71 Allow Mac and Solaris packages to be built with v7/v8b emulated libraries
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@286 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-21 19:47:06 +00:00
DRC
8515d3d58d Emulate the version script in libjpeg v7/v8 shared libraries
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@285 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-19 06:38:57 +00:00
DRC
c0a1cba11b Accommodate spaces in CMAKE_BINARY_DIR
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@284 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 09:46:27 +00:00
DRC
efa618ecba git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@283 632fc199-4ca6-4c93-a231-07263d6284db 2010-10-18 08:41:11 +00:00
DRC
3a606240f7 1.0.90 (1.1 beta1)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@282 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 08:27:04 +00:00
DRC
9ef93dbbdc Modify OS X universal binary creation process to give the user more control over the 32-bit fork (necessary for building universal binaries with libjpeg v7/v8b emulation, for instance)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@281 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 08:24:42 +00:00
DRC
68bf3f2846 MinGW under Cygwin needs CMAKE_SYSTEM_NAME=Windows as well, since technically, we're cross-compiling
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@280 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 07:56:14 +00:00
DRC
81543310fd Cygwin is only supported with the autotools build system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@279 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 07:23:58 +00:00
DRC
5559c900c0 Additional information/corrections involving libjpeg v7/v8b emulation
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@278 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 02:21:10 +00:00
DRC
b42a48cc44 Use built-in cmake compare_files function rather than GNU cmp (which isn't natively available on Windows)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@277 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 01:06:36 +00:00
DRC
1f80a10b4e Allow RPMs and SRPMs to be generated with v7/v8b emulation; Add CMake scripts and other missing files to source distribution
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@276 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-18 00:15:31 +00:00
DRC
e2befdef6a Install headers as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@275 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-17 07:28:08 +00:00
DRC
310f606b72 Windows packaging has been moved to the CMake build system, so remove it from autotools
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@274 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-17 06:50:35 +00:00
DRC
26658432fb Document 'make install'
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@273 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 22:04:29 +00:00
DRC
7284c9a0cd Allow installation from the build system (without needing to build an installer)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@272 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 21:55:14 +00:00
DRC
6f4ba6144a Eliminate redundant dependency statement; Notify user when SIMD is disabled
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@271 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 21:27:38 +00:00
DRC
1c73ce8eb5 Additional MinGW recipes
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@270 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 21:02:54 +00:00
DRC
b397bfd7db Remove old Windows build system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@269 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 09:23:36 +00:00
DRC
cc2437425b Document new CMake build system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@268 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 09:22:43 +00:00
DRC
b09fde7723 Oops. Forgot to check in header templates
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@267 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 08:52:55 +00:00
DRC
2c0a4e1e74 Integrate installer build into CMake build system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@266 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-16 08:51:43 +00:00
DRC
d830d36074 Fix dependencies for the color conversion routines, which build other .asm files indirectly
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@265 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 20:07:41 +00:00
DRC
378da4d61b Print error message if trying to do a native Unix build
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@264 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 19:11:11 +00:00
DRC
c869c2c811 Unix LF
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@263 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 08:43:32 +00:00
DRC
cd5f2ee23c Allow nasm path to be overridden
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@262 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 08:39:44 +00:00
DRC
a9d5b25304 Set version information for DLL's
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@261 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 06:42:45 +00:00
DRC
e328bf25f0 Export the correct symbols from the Windows DLL when built with libjpeg v7 or v8b emulation
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@260 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 05:33:21 +00:00
DRC
cdd8f123cc Use version suffix on Cygwin DLL as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@259 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 04:58:13 +00:00
DRC
eb2b9d6b96 Echo version and build
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@258 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 04:55:13 +00:00
DRC
846970366b First pass at a CMake build system
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@257 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-15 03:43:24 +00:00
DRC
efa4ddcc88 Space = Tab
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@256 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-13 19:22:50 +00:00
DRC
2edf19d601 Oops. Should be single, not double = sign
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@255 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-13 19:22:20 +00:00
DRC
77e3964ca9 Document the libjpeg v7/v8 extensions
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@254 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-12 03:02:31 +00:00
DRC
766dc5c59d Mention new v7/v8 extensions
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@253 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-12 02:50:18 +00:00
DRC
39ea562c07 Document new v7/v8 features; .doc = .txt
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@252 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-12 01:55:31 +00:00
DRC
ed16ad11ff Enable the use of separate luminance/chrominance quality scaling with libjpeg v6b code base as well
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@251 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-11 23:36:04 +00:00
DRC
12387ebc92 Add sanity check in BMP reader module to avoid cjpeg crash for empty input
image


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@250 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 07:27:26 +00:00
Guido Vollbeding
5829cb2398 The Independent JPEG Group's JPEG software v8d 2015-07-27 13:50:34 -05:00
DRC
294079cbe0 Add option for setting luminance & chrominance quality independently (currently only works if using libjpeg v7 or v8 code base)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@248 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 07:21:55 +00:00
DRC
2cdd2ae753 Display libjpeg-turbo version/copyrights in run-time programs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@247 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 06:54:21 +00:00
DRC
517e1c0525 Add -raw option to rdjpgcom for outputting non-printable characters as-is; Make rdjpgcom locale-aware.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@246 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 06:04:05 +00:00
DRC
1658c79eba Fix byte order issue with 16bit PPM/PGM files
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@245 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 06:01:00 +00:00
DRC
9a648cc90b Fix transpose feature with jpeg v6b code base
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@244 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 02:48:21 +00:00
DRC
c04bd3cc97 Implement lossless crop feature from jpeg v7 and v8
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@243 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 02:15:56 +00:00
DRC
c54275c6a7 Fix version numbers for v7/v8 shared libs
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@242 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-10 00:40:37 +00:00
DRC
49967cdb30 Improve readability and flexibility of compatibility macros
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@241 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-09 19:57:51 +00:00
DRC
10acd811d0 Remove comments describing DCT scaling feature
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@240 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-09 19:24:28 +00:00
DRC
553d868c25 Oops. Forgot to include the new macro header
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@239 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-09 19:09:41 +00:00
DRC
a5ee9df541 Bump revision to 1.1 alpha
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@238 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-08 08:07:37 +00:00
DRC
eafbe8a056 Bump revision to 1.1 alpha
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@237 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-08 08:07:10 +00:00
DRC
36a6eec932 Added optional emulation of the jpeg-7 or jpeg-8b API/ABI's
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@236 632fc199-4ca6-4c93-a231-07263d6284db
2010-10-08 08:05:44 +00:00
DRC
e5d7bc9f93 "OS/X" = "OS X"
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@235 632fc199-4ca6-4c93-a231-07263d6284db
2010-09-30 18:54:31 +00:00
113 changed files with 7803 additions and 2576 deletions

View File

@@ -1,7 +1,8 @@
******************************************************************************* *******************************************************************************
** Building on Unix Platforms, Cygwin, and MinGW ** Building on Unix Platforms (including Cygwin)
******************************************************************************* *******************************************************************************
================== ==================
Build Requirements Build Requirements
================== ==================
@@ -9,57 +10,75 @@ Build Requirements
-- autoconf 2.56 or later -- autoconf 2.56 or later
-- automake 1.7 or later -- automake 1.7 or later
-- libtool 1.4 or later -- libtool 1.4 or later
* If using MinGW, these can be obtained by installing the MSYS DTK
-- NASM -- NASM
* 0.98 or later is required for a 32-bit build * 0.98, or 2.01 or later is required for a 32-bit build
* NASM 2.05 or later is required for a 64-bit build * NASM 2.00 or later is required for a 64-bit build
* NASM 2.07 or later is required for a 64-bit build on OS/X. This can be * NASM 2.07 or later is required for a 64-bit build on OS X. This can be
obtained from MacPorts (http://www.macports.org/). obtained from MacPorts (http://www.macports.org/).
The NASM 2.05 RPMs do not work on older Linux systems, such as Enterprise The binary RPMs released by the NASM project do not work on older Linux
Linux 4. On such systems, you can easily build and install NASM 2.05 systems, such as Red Hat Enterprise Linux 4. On such systems, you can
from the source RPM by executing the following as root: easily build and install NASM from a source RPM by downloading one of the
SRPMs from
http://www.nasm.us/pub/nasm/releasebuilds
and executing the following as root:
ARCH=`uname -m` ARCH=`uname -m`
wget http://www.nasm.us/pub/nasm/releasebuilds/2.05.01/nasm-2.05.01-1.src.rpm rpmbuild --rebuild nasm-{version}.src.rpm
rpmbuild --rebuild nasm-2.05.01-1.src.rpm rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-2.05.01-1.$ARCH.rpm
NOTE: NASM build will fail if texinfo is not installed. NOTE: the NASM build will fail if texinfo is not installed.
-- GCC v4.1 or later recommended for best performance -- GCC v4.1 or later recommended for best performance
==================
Out-of-Tree Builds
==================
Binary objects, libraries, and executables are generated in the same directory
from which configure was executed (the "binary directory"), and this directory
need not necessarily be the same as the libjpeg-turbo source directory. You
can create multiple independent binary directories, in which different versions
of libjpeg-turbo can be built from the same source tree using different
compilers or settings. In the sections below, {build_directory} refers to the
binary directory, whereas {source_directory} refers to the libjpeg-turbo source
directory. For in-tree builds, these directories are the same.
====================== ======================
Building libjpeg-turbo Building libjpeg-turbo
====================== ======================
The following procedure will build libjpeg-turbo on Linux, FreeBSD, 32-bit The following procedure will build libjpeg-turbo on Linux, FreeBSD, 32-bit
OS X, and Solaris/x86 systems (on Solaris, this generates a 32-bit library. OS X, Cygwin, and Solaris/x86 systems (on Solaris, this generates a 32-bit
See below for 64-bit build instructions.) library. See below for 64-bit build instructions.)
cd libjpeg-turbo cd {source_directory}
autoreconf -fiv autoreconf -fiv
sh ./configure cd {build_directory}
sh {source_directory}/configure [additional configure flags]
make make
NOTE: Running autoreconf is only necessary if building libjpeg-turbo from the NOTE: Running autoreconf in the source directory is only necessary if building
SVN repository. libjpeg-turbo from the SVN repository.
This will generate the following files under .libs/ This will generate the following files under .libs/
libjpeg.a libjpeg.a
Static link library for libjpeg-turbo Static link library for libjpeg-turbo
libjpeg.so.62.0.0 (Linux, Solaris) libjpeg.so.{version} (Linux, Solaris)
libjpeg.62.dylib (OS X) libjpeg.{version}.dylib (OS X)
libjpeg-62.dll (MinGW) cygjpeg-{version}.dll (Cygwin)
cygjpeg-62.dll (Cygwin)
Shared library for libjpeg-turbo Shared library for libjpeg-turbo
libjpeg.so (Linux, Solaris) libjpeg.so (Linux, Solaris)
libjpeg.dylib (OS X) libjpeg.dylib (OS X)
libjpeg.dll.a (Cygwin, MinGW) libjpeg.dll.a (Cygwin)
Development stub for libjpeg-turbo shared library Development stub for libjpeg-turbo shared library
libturbojpeg.a libturbojpeg.a
@@ -69,13 +88,39 @@ This will generate the following files under .libs/
libturbojpeg.dylib (OS X) libturbojpeg.dylib (OS X)
Shared library and development stub for TurboJPEG/OSS Shared library and development stub for TurboJPEG/OSS
libturbojpeg.dll (MinGW)
cygturbojpeg.dll (Cygwin) cygturbojpeg.dll (Cygwin)
Shared library for TurboJPEG/OSS Shared library for TurboJPEG/OSS
libturbojpeg.dll.a (Cygwin, MinGW) libturbojpeg.dll.a (Cygwin)
Development stub for TurboJPEG/OSS shared library Development stub for TurboJPEG/OSS shared library
{version} is 62.0.0, 7.0.0, or 8.0.2, depending on whether libjpeg v6b
(default), v7, or v8 emulation is enabled. If using Cygwin, {version} is
62, 7, or 8.
libjpeg v7 or v8 Emulation
--------------------------
Add --with-jpeg7 to the configure command line to build a version of
libjpeg-turbo that is compatible with libjpeg v7. Add --with-jpeg8 to the
configure command to build a version of libjpeg-turbo that is compatible with
libjpeg v8. See README-turbo.txt for more information on libjpeg v7 and v8
emulation.
Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
based on the implementation in libjpeg v8, but it works when emulating libjpeg
v7 or v6b as well. The default is to enable both arithmetic encoding and
decoding, but those who have philosophical objections to arithmetic coding can
add --without-arith-enc or --without-arith-dec to the configure command line to
disable encoding or decoding (respectively.)
======================== ========================
Installing libjpeg-turbo Installing libjpeg-turbo
======================== ========================
@@ -102,21 +147,23 @@ a non-system directory and manipulate the LD_LIBRARY_PATH or create sym links
to force applications to use libjpeg-turbo instead of libjpeg. See to force applications to use libjpeg-turbo instead of libjpeg. See
README-turbo.txt for more information. README-turbo.txt for more information.
============= =============
Build Recipes Build Recipes
============= =============
32-bit Library Build on 64-bit Linux 32-bit Library Build on 64-bit Linux
------------------------------------ ------------------------------------
Add Add
--host i686-pc-linux-gnu CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32 --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
to the configure command line. to the configure command line.
64-bit Library Build on 64-bit OS/X 64-bit Library Build on 64-bit OS X
----------------------------------- -----------------------------------
Add Add
@@ -127,25 +174,23 @@ to the configure command line. NASM 2.07 or later from MacPorts must be
installed. installed.
32-bit Library Build on 64-bit OS/X 32-bit Library Build on 64-bit OS X
----------------------------------- -----------------------------------
Add Add
CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32 CFLAGS='-O3 -m32' LDFLAGS=-m32
to the configure command line. to the configure command line.
64-bit Backward-Compatible Library Build on 64-bit OS/X 64-bit Backward-Compatible Library Build on 64-bit OS X
------------------------------------------------------- -------------------------------------------------------
Add Add
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm \ --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4 -O3' \
CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4 -O3' \ -mmacosx-version-min=10.4 -O3' \
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4' -mmacosx-version-min=10.4'
@@ -154,14 +199,12 @@ to the configure command line. The OS X 10.4 SDK, and NASM 2.07 or later from
MacPorts, must be installed. MacPorts, must be installed.
32-bit Backward-Compatible Library Build on OS/X 32-bit Backward-Compatible Library Build on OS X
------------------------------------------------ ------------------------------------------------
Add Add
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4 -O3 -m32' \
CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4 -O3 -m32' \ -mmacosx-version-min=10.4 -O3 -m32' \
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-mmacosx-version-min=10.4 -m32' -mmacosx-version-min=10.4 -m32'
@@ -174,7 +217,7 @@ to the configure command line. The OS X 10.4 SDK must be installed.
Add Add
--host x86_64-pc-solaris CFLAGS='-O3 -m64' CXXFLAGS='-O3 -m64' LDFLAGS=-m64 --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
to the configure command line. to the configure command line.
@@ -184,103 +227,299 @@ to the configure command line.
Add Add
--host i386-unknown-freebsd CC='gcc -B /usr/lib32' CXX='g++ -B/usr/lib32' \ --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS='-B/usr/lib32' LDFLAGS='-B/usr/lib32'
to the configure command line. NASM 2.07 or later from FreeBSD ports must be to the configure command line. NASM 2.07 or later from FreeBSD ports must be
installed. installed.
MinGW Build on Cygwin
---------------------
Add
--host mingw32
to the configure command line. This will produce libraries which do not
depend on cygwin1.dll or other Cygwin DLL's.
Sun Studio Sun Studio
---------- ----------
Add Add
CC=cc CXX=CC CC=cc
to the configure command line. libjpeg-turbo will automatically be built with to the configure command line. libjpeg-turbo will automatically be built with
the maximum optimization level (-xO5) unless you override CFLAGS and CXXFLAGS. the maximum optimization level (-xO5) unless you override CFLAGS.
To build a 64-bit version of libjpeg-turbo using Sun Studio, add To build a 64-bit version of libjpeg-turbo using Sun Studio, add
--host x86_64-pc-solaris CC=cc CXX=CC CFLAGS='-xO5 -m64' \ --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
CXXFLAGS='-xO5 -m64' LDFLAGS=-m64
to the configure command line. to the configure command line.
MinGW Build on Cygwin
---------------------
Use CMake (see recipes below)
******************************************************************************* *******************************************************************************
** Building on Windows (Visual C++) ** Building on Windows (Visual C++ or MinGW)
******************************************************************************* *******************************************************************************
================== ==================
Build Requirements Build Requirements
================== ==================
-- GNU Make v3.7 or later -- CMake (http://www.cmake.org) v2.6 or later
* Can be found in MSYS (http://www.mingw.org/download.shtml) or
Cygwin (http://www.cygwin.com/)
-- Windows SDK for Windows Server 2008 and .NET Framework 3.5 (or a later -- Microsoft Visual C++ 2005 or later
version)
http://msdn.microsoft.com/en-us/windows/dd146047.aspx If you don't already have Visual C++, then the easiest way to get it is by
installing the Windows SDK:
* The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and http://msdn.microsoft.com/en-us/windows/bb980924.aspx
everything necessary to build libjpeg-turbo. If you do not already have
Visual C++ installed, then this is the recommended solution. Also tested The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
with Microsoft Visual C++ 2008 Express Edition (both are free downloads.) everything necessary to build libjpeg-turbo.
* Add the compiler and SDK binary directories (for instance,
c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN; * For 32-bit builds, you can also use Microsoft Visual C++ Express
c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE; Edition. Visual C++ Express Edition is a free download.
c:\Program Files\Microsoft SDKs\Windows\v6.1\bin) * If you intend to build libjpeg-turbo from the command line, then add the
to the system or user PATH environment variable prior to building appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
libjpeg-turbo. environment variables. This is generally accomplished by executing
* Add the compiler and SDK include directories (for instance, vcvars32.bat or vcvars64.bat and SetEnv.cmd. vcvars32.bat and
c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE; vcvars64.bat are part of Visual C++ and are located in the same directory
c:\Program Files\Microsoft SDKs\Windows\v6.1\include) as the compiler. SetEnv.cmd is part of the Windows SDK. You can pass
to the system or user INCLUDE environment variable prior to building optional arguments to SetEnv.cmd to specify a 32-bit or 64-bit build
libjpeg-turbo. environment.
* Add the compiler library directory (for instance,
c:\Program Files\Microsoft Visual Studio 9.0\VC\LIB; ... OR ...
c:\Program Files\Microsoft SDKs\Windows\v6.1\lib)
to the system or user LIB environment variable prior to building -- MinGW
libjpeg-turbo.
GCC v4.1 or later recommended for best performance
-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for -- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
a 64-bit build) a 64-bit build)
==================
Out-of-Tree Builds
==================
Binary objects, libraries, and executables are generated in the same directory
from which cmake was executed (the "binary directory"), and this directory need
not necessarily be the same as the libjpeg-turbo source directory. You can
create multiple independent binary directories, in which different versions of
libjpeg-turbo can be built from the same source tree using different compilers
or settings. In the sections below, {build_directory} refers to the binary
directory, whereas {source_directory} refers to the libjpeg-turbo source
directory. For in-tree builds, these directories are the same.
====================== ======================
Building libjpeg-turbo Building libjpeg-turbo
====================== ======================
cd libjpeg-turbo
make -f win/Makefile
This will generate the following files under libjpeg-turbo\windows\: Visual C++ (Command Line)
-------------------------
jpeg-static.lib Static link library for libjpeg-turbo cd {build_directory}
jpeg62.dll Shared library for libjpeg-turbo cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
jpeg.lib Development stub for libjpeg-turbo shared library nmake
turbojpeg-static.lib Static link library for TurboJPEG/OSS
turbojpeg.dll Shared library for TurboJPEG/OSS
turbojpeg.lib Development stub for TurboJPEG/OSS shared library
If a 64-bit Windows platform is detected, then the build system will attempt This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
to build a 64-bit version of libjpeg-turbo. You can override this by running on which version of cl.exe is in the PATH.
make -f win/Makefile WIN64=no The following files will be generated under {build_directory}:
jpeg-static.lib
Static link library for libjpeg-turbo
sharedlib/jpeg{version}.dll
DLL for libjpeg-turbo
sharedlib/jpeg.lib
Import library for libjpeg-turbo DLL
turbojpeg-static.lib
Static link library for TurboJPEG/OSS
turbojpeg.dll
DLL for TurboJPEG/OSS
turbojpeg.lib
Import library for TurboJPEG/OSS DLL
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
v8 emulation is enabled.
Visual C++ (IDE)
----------------
Choose the appropriate CMake generator option for your version of Visual Studio
(run "cmake" with no arguments for a list of available generators.) For
instance:
cd {build_directory}
cmake -G "Visual Studio 9 2008" {source_directory}
You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
configurations in that project ("Debug", "Release", etc.) to generate a full
build of libjpeg-turbo.
This will generate the following files under {build_directory}:
{configuration}/jpeg-static.lib
Static link library for libjpeg-turbo
sharedlib/{configuration}/jpeg{version}.dll
DLL for libjpeg-turbo
sharedlib/{configuration}/jpeg.lib
Import library for libjpeg-turbo DLL
{configuration}/turbojpeg-static.lib
Static link library for TurboJPEG/OSS
{configuration}/turbojpeg.dll
DLL for TurboJPEG/OSS
{configuration}/turbojpeg.lib
Import library for TurboJPEG/OSS DLL
{configuration} is Debug, Release, RelWithDebInfo, or MinSizeRel, depending on
the configuration you built in the IDE, and {version} is 62, 7, or 8,
depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
MinGW
-----
cd {build_directory}
cmake -G "MSYS Makefiles" {source_directory}
make
This will generate the following files under {build_directory}
libjpeg.a
Static link library for libjpeg-turbo
sharedlib/libjpeg-{version}.dll
DLL for libjpeg-turbo
sharedlib/libjpeg.dll.a
Import library for libjpeg-turbo DLL
libturbojpeg.a
Static link library for TurboJPEG/OSS
libturbojpeg.dll
DLL for TurboJPEG/OSS
libturbojpeg.dll.a
Import library for TurboJPEG/OSS DLL
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
v8 emulation is enabled.
Debug Build
-----------
Add "-DCMAKE_BUILD_TYPE=Debug" to the cmake command line. Or, if building with
NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
NMake.)
libjpeg v7 or v8 Emulation
--------------------------
Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
libjpeg-turbo that is compatible with libjpeg v7. Add "-DWITH_JPEG8=1" to the
cmake command to build a version of libjpeg-turbo that is compatible with
libjpeg v8. See README-turbo.txt for more information on libjpeg v7 and v8
emulation.
Arithmetic Coding Support
-------------------------
Since the patent on arithmetic coding has expired, this functionality has been
included in this release of libjpeg-turbo. libjpeg-turbo's implementation is
based on the implementation in libjpeg v8, but it works when emulating libjpeg
v7 or v6b as well. The default is to enable both arithmetic encoding and
decoding, but those who have philosophical objections to arithmetic coding can
add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
disable encoding or decoding (respectively.)
========================
Installing libjpeg-turbo
========================
You can use the build system to install libjpeg-turbo into a directory of your
choosing (as opposed to creating an installer.) To do this, add:
-DCMAKE_INSTALL_PREFIX={install_directory}
to the cmake command line.
For example,
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory}
nmake install
will install the header files in c:\libjpeg-turbo\include, the library files
in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the
documentation in c:\libjpeg-turbo\doc.
=============
Build Recipes
=============
64-bit MinGW Build on Cygwin
----------------------------
cd {build_directory}
CC=/usr/bin/x86_64-w64-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar \
-DCMAKE_RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib {source_directory}
make
This produces a 64-bit build of libjpeg-turbo that does not depend on
cygwin1.dll or other Cygwin DLL's. The mingw64-x86_64-gcc-core and
mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
32-bit MinGW Build on Cygwin
----------------------------
cd {build_directory}
CC=/usr/bin/i686-w64-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DDCMAKE_AR=/usr/bin/i686-w64-mingw32-ar \
-DCMAKE_RANLIB=/usr/bin/i686-w64-mingw32-ranlib {source_directory}
make
This produces a 32-bit build of libjpeg-turbo that does not depend on
cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and
mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
MinGW-w64 Build on Windows
--------------------------
This produces a 64-bit build of libjpeg-turbo using the "native" MinGW-w64
toolchain (which is faster than the Cygwin version):
cd {build_directory}
CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \
cmake -G "MSYS Makefiles" \
-DCMAKE_AR={mingw-w64_binary_path}/x86_64-w64-mingw32-ar \
-DCMAKE_RANLIB={mingw-w64_binary_path}/x86_64-w64-mingw32-ranlib \
{source_directory}
make
MinGW Build on Linux
--------------------
cd {build_directory}
CC={mingw_binary_path}/i386-mingw32-gcc \
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
-DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
{source_directory}
make
******************************************************************************* *******************************************************************************
@@ -289,14 +528,18 @@ to build a 64-bit version of libjpeg-turbo. You can override this by running
The following commands can be used to create various types of release packages: The following commands can be used to create various types of release packages:
Unix
----
make rpm make rpm
Create RedHat-style binary RPM package. Requires RPM v4 or later. Create Red Hat-style binary RPM package. Requires RPM v4 or later.
make srpm make srpm
This runs 'make dist' to create a pristine source tarball, then creates a This runs 'make dist' to create a pristine source tarball, then creates a
RedHat-style source RPM package from the tarball. Requires RPM v4 or later. Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
make deb make deb
@@ -307,22 +550,55 @@ make dmg
Create Macintosh package/disk image. This requires the PackageMaker Create Macintosh package/disk image. This requires the PackageMaker
application, which must be installed in /Developer/Applications/Utilities. application, which must be installed in /Developer/Applications/Utilities.
make udmg make udmg [BUILDDIR32={32-bit build directory}]
On 64-bit OS X systems, this creates a version of the Macintosh package and On 64-bit OS X systems, this creates a version of the Macintosh package and
disk image which contains universal i386/x86-64 binaries. The 32-bit fork of disk image which contains universal i386/x86-64 binaries. You should first
these binaries is backward compatible with OS X 10.4 and later. The 64-bit configure a 32-bit out-of-tree build of libjpeg-turbo, then configure a
fork can be made backward compatible as well by using the instructions in 64-bit out-of-tree build, then run 'make udmg' from the 64-bit build
the "Build Recipes" section. OS X 10.4 compatibility SDK required. directory. The build system will look for the 32-bit build under
{source_directory}/osxx86 by default, but you can override this by setting
the BUILDDIR32 variable on the make command line as shown above.
make nsi make sunpkg
When using MinGW, this creates a Win32 installer for the GCC version of the Build a Solaris package. This requires pkgmk, pkgtrans, and bzip2.
libjpeg-turbo SDK. This requires the Nullsoft Install System
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.
make -f win/Makefile nsi make csunpkg [BUILDDIR32={32-bit build directory}]
This creates a Win32 installer for the Visual C++ version of the On 64-bit Solaris systems, this creates a combined package which contains
libjpeg-turbo SDK. This requires the Nullsoft Install System both 32-bit and 64-bit libraries. You should first configure a 32-bit
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH. out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree
build, then run 'make csunpkg' from the 64-bit build directory. The build
system will look for the 32-bit build under {source_directory}/solx86 by
default, but you can override this by setting the BUILDDIR32 variable on the
make command line as shown above.
make cygwinpkg
Build a Cygwin binary package.
Windows
-------
If using NMake:
cd {build_directory}
nmake installer
If using MinGW:
cd {build_directory}
make installer
If using the Visual Studio IDE, build the "installer" project.
The installer package (libjpeg-turbo[-gcc][64].exe) will be located under
{build_directory}. If building using the Visual Studio IDE, then the installer
package will be located in a subdirectory with the same name as the
configuration you built (such as {build_directory}\Debug\ or
{build_directory}\Release\).
Building a Windows installer requires the Nullsoft Install System
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.

343
CMakeLists.txt Normal file
View File

@@ -0,0 +1,343 @@
#
# Setup
#
cmake_minimum_required(VERSION 2.6)
project(libjpeg-turbo C)
set(VERSION 1.1.1)
if(MINGW OR CYGWIN)
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
string(REGEX REPLACE "\n" "" BUILD ${BUILD})
elseif(WIN32)
execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
OUTPUT_VARIABLE BUILD)
string(REGEX REPLACE "\n" "" BUILD ${BUILD})
else()
message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
# This only works if building from the command line. There is currently no way
# to set a variable's value based on the build type when using the MSVC IDE.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD "${BUILD}d")
endif()
message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
option(WITH_SIMD "Include SIMD extensions" TRUE)
option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE)
option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE)
option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
if(WITH_ARITH_ENC)
set(C_ARITH_CODING_SUPPORTED 1)
message(STATUS "Arithmetic encoding support enabled")
else()
message(STATUS "Arithmetic encoding support disabled")
endif()
if(WITH_ARITH_DEC)
set(D_ARITH_CODING_SUPPORTED 1)
message(STATUS "Arithmetic decoding support enabled")
else()
message(STATUS "Arithmetic decoding support disabled")
endif()
set(JPEG_LIB_VERSION 62)
set(DLL_VERSION ${JPEG_LIB_VERSION})
set(FULLVERSION ${DLL_VERSION}.0.0)
if(WITH_JPEG8)
set(JPEG_LIB_VERSION 80)
set(DLL_VERSION 8)
set(FULLVERSION ${DLL_VERSION}.0.2)
message(STATUS "Emulating libjpeg v8 API/ABI")
elseif(WITH_JPEG7)
set(JPEG_LIB_VERSION 70)
set(DLL_VERSION 7)
set(FULLVERSION ${DLL_VERSION}.0.0)
message(STATUS "Emulating libjpeg v7 API/ABI")
endif(WITH_JPEG8)
if(MSVC)
# Use the static C library for all build types
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
endif()
endforeach()
add_definitions(-W3 -wd4996)
endif()
# Detect whether compiler is 64-bit
if(MSVC AND CMAKE_CL_64)
set(SIMD_X86_64 1)
set(64BIT 1)
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(SIMD_X86_64 1)
set(64BIT 1)
endif()
if(64BIT)
message(STATUS "64-bit build")
else()
message(STATUS "32-bit build")
endif()
configure_file(win/jconfig.h.in jconfig.h)
configure_file(win/config.h.in config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#
# Targets
#
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
endif()
if(WITH_ARITH_ENC)
set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
endif()
if(WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
endif()
if(WITH_SIMD)
add_definitions(-DWITH_SIMD)
add_subdirectory(simd)
if(SIMD_X86_64)
set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
else()
set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
endif()
# This tells CMake that the "source" files haven't been generated yet
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
else()
set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
message(STATUS "Not using SIMD acceleration")
endif()
add_subdirectory(sharedlib)
add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
if(NOT MSVC)
set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
endif()
if(WITH_SIMD)
add_dependencies(jpeg-static simd)
endif()
add_library(turbojpeg SHARED turbojpegl.c)
set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
target_link_libraries(turbojpeg jpeg-static)
set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
turbojpegl.c)
if(NOT MSVC)
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
endif()
if(WITH_SIMD)
add_dependencies(turbojpeg-static simd)
endif()
add_executable(jpegut jpegut.c)
target_link_libraries(jpegut turbojpeg)
add_executable(jpegut-static jpegut.c)
target_link_libraries(jpegut-static turbojpeg-static)
add_executable(jpgtest jpgtest.c bmp.c)
target_link_libraries(jpgtest turbojpeg)
add_executable(jpgtest-static jpgtest.c bmp.c)
target_link_libraries(jpgtest-static turbojpeg-static)
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
rdtarga.c)
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
target_link_libraries(cjpeg-static jpeg-static)
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
wrppm.c wrtarga.c)
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
target_link_libraries(djpeg-static jpeg-static)
add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
target_link_libraries(jpegtran-static jpeg-static)
add_executable(rdjpgcom rdjpgcom.c)
add_executable(wrjpgcom rdjpgcom.c)
#
# Tests
#
enable_testing()
add_test(jpegut jpegut)
add_test(jpegut-yuv jpegut -yuv)
add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
if(WITH_SIMD)
add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
else()
add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
endif()
add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
if(WITH_SIMD)
add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
else()
add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
endif()
add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
if(WITH_ARITH_ENC)
add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
endif()
if(WITH_ARITH_DEC)
add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
endif()
add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
add_test(jpegut-static jpegut-static)
add_test(jpegut-static-yuv jpegut-static -yuv)
add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
if(WITH_SIMD)
add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
else()
add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
endif()
add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
if(WITH_SIMD)
add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
else()
add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
endif()
add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
if(WITH_ARITH_ENC)
add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
endif()
if(WITH_ARITH_DEC)
add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
endif()
add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
#
# Installer
#
if(MSVC)
set(INST_PLATFORM "Visual C++")
set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
set(INST_DIR ${CMAKE_PROJECT_NAME})
elseif(MINGW)
set(INST_PLATFORM GCC)
set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
set(INST_DEFS -DGCC)
endif()
if(64BIT)
set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
set(INST_NAME ${INST_NAME}64)
set(INST_DIR ${INST_DIR}64)
set(INST_DEFS ${INST_DEFS} -DWIN64)
endif()
if(MSVC_IDE)
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
else()
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
endif()
configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
add_custom_target(installer
makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
cjpeg djpeg jpegtran jpgtest
SOURCES libjpeg-turbo.nsi)
install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
DESTINATION doc)
install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)

View File

@@ -1,5 +1,107 @@
Significant changes since 1.0.0 1.1.1
=============================== =====
[1] Fixed a 1-pixel error in row 0, column 21 of the luminance plane generated
by tjEncodeYUV().
[2] libjpeg-turbo's accelerated Huffman decoder previously ignored unexpected
markers found in the middle of the JPEG data stream during decompression. It
will now hand off decoding of a particular block to the unaccelerated Huffman
decoder if an unexpected marker is found, so that the unaccelerated Huffman
decoder can generate an appropriate warning.
[3] Older versions of MinGW64 prefixed symbol names with underscores by
default, which differed from the behavior of 64-bit Visual C++. MinGW64 1.0
has adopted the behavior of 64-bit Visual C++ as the default, so to accommodate
this, the libjpeg-turbo SIMD function names are no longer prefixed with an
underscore when building with MinGW64. This means that, when building
libjpeg-turbo with older versions of MinGW64, you will now have to add
-fno-leading-underscore to the CFLAGS.
[4] Fixed a regression bug in the NSIS script that caused the Windows installer
build to fail when using the Visual Studio IDE.
[5] Fixed a bug in jpeg_read_coefficients() whereby it would not initialize
cinfo->image_width and cinfo->image_height if libjpeg v7 or v8 emulation was
enabled. This specifically caused the jpegoptim program to fail if it was
linked against a version of libjpeg-turbo that was built with libjpeg v7 or v8
emulation.
[6] Eliminated excessive I/O overhead that occurred when reading BMP files in
cjpeg.
[7] Eliminated errors in the output of cjpeg on Windows that occurred when the
application was invoked using I/O redirection (cjpeg <inputfile >output.jpg).
1.1.0
=====
[1] The algorithm used by the SIMD quantization function cannot produce correct
results when the JPEG quality is >= 98 and the fast integer forward DCT is
used. Thus, the non-SIMD quantization function is now used for those cases,
and libjpeg-turbo should now produce identical output to libjpeg v6b in all
cases.
[2] Despite the above, the fast integer forward DCT still degrades somewhat for
JPEG qualities greater than 95, so TurboJPEG/OSS will now automatically use the
slow integer forward DCT when generating JPEG images of quality 96 or greater.
This reduces compression performance by as much as 15% for these high-quality
images but is necessary to ensure that the images are perceptually lossless.
It also ensures that the library can avoid the performance pitfall created by
[1].
[3] Ported jpgtest.cxx to pure C to avoid the need for a C++ compiler.
[4] Fixed visual artifacts in grayscale JPEG compression caused by a typo in
the RGB-to-luminance lookup tables.
[5] The Windows distribution packages now include the libjpeg run-time programs
(cjpeg, etc.)
[6] All packages now include jpgtest.
[7] The TurboJPEG dynamic library now uses versioned symbols.
[8] Added two new TurboJPEG API functions, tjEncodeYUV() and
tjDecompressToYUV(), to replace the somewhat hackish TJ_YUV flag.
1.0.90 (1.1 beta1)
==================
[1] Added emulation of the libjpeg v7 and v8 APIs and ABIs. See
README-turbo.txt for more details. This feature was sponsored by CamTrace SAS.
[2] Created a new CMake-based build system for the Visual C++ and MinGW builds.
[3] TurboJPEG/OSS can now compress from/decompress to grayscale bitmaps.
[4] jpgtest can now be used to test decompression performance with existing
JPEG images.
[5] If the default install prefix (/opt/libjpeg-turbo) is used, then
'make install' now creates /opt/libjpeg-turbo/lib32 and
/opt/libjpeg-turbo/lib64 sym links to duplicate the behavior of the binary
packages.
[6] All symbols in the libjpeg-turbo dynamic library are now versioned, even
when the library is built with libjpeg v6b emulation.
[7] Added arithmetic encoding and decoding support (can be disabled with
configure or CMake options)
[8] Added a TJ_YUV flag to TurboJPEG/OSS which causes both the compressor and
decompressor to output planar YUV images.
[9] Added an extended version of tjDecompressHeader() to TurboJPEG/OSS which
allows the caller to determine the type of subsampling used in a JPEG image.
[10] Added further protections against invalid Huffman codes.
1.0.1
=====
[1] The Huffman decoder will now handle erroneous Huffman codes (for instance, [1] The Huffman decoder will now handle erroneous Huffman codes (for instance,
from a corrupt JPEG image.) Previously, these would cause libjpeg-turbo to from a corrupt JPEG image.) Previously, these would cause libjpeg-turbo to
@@ -12,8 +114,8 @@ be used instead of 4:2:0 when decompressing JPEG images using SSE2 code.
INCOMPLETE_TYPES_BROKEN macro should be defined. INCOMPLETE_TYPES_BROKEN macro should be defined.
Significant changes since 0.0.93 1.0.0
================================ =====
[1] 2983700: Further FreeBSD build tweaks (no longer necessary to specify [1] 2983700: Further FreeBSD build tweaks (no longer necessary to specify
--host when configuring on a 64-bit system) --host when configuring on a 64-bit system)
@@ -37,18 +139,24 @@ contains just the 32-bit libjpeg-turbo libraries.
unit tests now work on those architectures. unit tests now work on those architectures.
Significant changes since 0.0.91 0.0.93
================================ ======
[1] 2982659, Fixed x86-64 build on FreeBSD systems [1] 2982659, Fixed x86-64 build on FreeBSD systems
[2] 2988188: Added support for Windows 64-bit systems [2] 2988188: Added support for Windows 64-bit systems
Significant changes since 0.0.90 0.0.91
================================ ======
[1] Added documentation to .deb packages [1] Added documentation to .deb packages
[2] 2968313: Fixed data corruption issues when decompressing large JPEG images [2] 2968313: Fixed data corruption issues when decompressing large JPEG images
and/or using buffered I/O with the libjpeg-turbo decompressor and/or using buffered I/O with the libjpeg-turbo decompressor
0.0.90
======
Initial release

View File

@@ -1,11 +1,11 @@
lib_LTLIBRARIES = libjpeg.la libturbojpeg.la lib_LTLIBRARIES = libjpeg.la libturbojpeg.la
libjpeg_la_LDFLAGS = -version-number 62:0:0 -no-undefined libjpeg_la_LDFLAGS = -version-info ${SO_MAJOR_VERSION}:${SO_MINOR_VERSION} -no-undefined
libturbojpeg_la_LDFLAGS = -avoid-version -no-undefined libturbojpeg_la_LDFLAGS = -avoid-version -no-undefined
include_HEADERS = jerror.h jmorecfg.h jpeglib.h turbojpeg.h include_HEADERS = jerror.h jmorecfg.h jpeglib.h turbojpeg.h
nodist_include_HEADERS = jconfig.h nodist_include_HEADERS = jconfig.h
HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \ HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \
jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegcomp.h
libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \ libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \
jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \ jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \
@@ -16,12 +16,31 @@ libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \
jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \
jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c
if WITH_ARITH
libjpeg_la_SOURCES += jaricom.c
endif
if WITH_ARITH_ENC
libjpeg_la_SOURCES += jcarith.c
endif
if WITH_ARITH_DEC
libjpeg_la_SOURCES += jdarith.c
endif
libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) turbojpegl.c turbojpeg.h \ libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) turbojpegl.c turbojpeg.h \
turbojpeg-mapfile turbojpeg-mapfile
if VERSION_SCRIPT if VERSION_SCRIPT
libturbojpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile libturbojpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile
libjpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)libjpeg.map
endif endif
@@ -39,12 +58,12 @@ endif
TSTHDRS = rrutil.h rrtimer.h TSTHDRS = rrutil.h rrtimer.h
bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom jpgtest
noinst_PROGRAMS = jpgtest jpegut noinst_PROGRAMS = jpegut
jpgtest_SOURCES = $(TSTHDRS) jpgtest.cxx bmp.h bmp.c jpgtest_SOURCES = $(TSTHDRS) jpgtest.c bmp.h bmp.c
jpgtest_LDADD = libturbojpeg.la jpgtest_LDADD = libturbojpeg.la -lm
jpegut_SOURCES = $(TSTHDRS) jpegut.c bmp.h bmp.c jpegut_SOURCES = $(TSTHDRS) jpegut.c bmp.h bmp.c
@@ -81,129 +100,164 @@ wrjpgcom_LDADD = libjpeg.la
dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 dist_man1_MANS = cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1
DOCS= README install.doc usage.doc wizard.doc example.c libjpeg.doc \ DOCS= README install.txt usage.txt wizard.txt example.c libjpeg.txt \
structure.doc coderules.doc filelist.doc jconfig.doc change.log \ structure.txt coderules.txt filelist.txt jconfig.txt change.log \
README-turbo.txt rdrle.c wrrle.c LICENSE.txt LGPL.txt BUILDING.txt \ README-turbo.txt rdrle.c wrrle.c LICENSE.txt LGPL.txt BUILDING.txt \
ChangeLog.txt ChangeLog.txt
TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \ TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \
testimgfst.jpg testimgint.jpg testimgp.jpg testimgflt.ppm testimgfst.ppm \ testimgfst.jpg testimgint.jpg testimgp.jpg testimgflt.ppm testimgfst.ppm \
testimgint.ppm testimgflt-nosimd.jpg testimgint.ppm testimgflt-nosimd.jpg testimgcrop.jpg testimgari.jpg \
testimgari.ppm testimgfst100.jpg
EXTRA_DIST = win release $(DOCS) $(TESTFILES) EXTRA_DIST = win release $(DOCS) $(TESTFILES) CMakeLists.txt \
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in
dist-hook: dist-hook:
rm -rf `find $(distdir) -name .svn` rm -rf `find $(distdir) -name .svn`
test: testclean all
./jpegut
./jpegut -yuv
./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgint.jpg testoutint.jpg
./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgfst.jpg testoutfst.jpg
./cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgfst100.jpg testoutfst100.jpg
./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm
if WITH_SIMD if WITH_SIMD
test: testclean all
./jpegut
./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm
./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm
./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgint.jpg testoutint.jpg
cmp $(srcdir)/testimgfst.jpg testoutfst.jpg
cmp $(srcdir)/testimgflt.jpg testoutflt.jpg cmp $(srcdir)/testimgflt.jpg testoutflt.jpg
./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg
./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg
./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg
cmp $(srcdir)/testimgint.ppm testoutint.ppm
cmp $(srcdir)/testimgfst.ppm testoutfst.ppm
cmp $(srcdir)/testimgflt.ppm testoutflt.ppm
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
cmp $(srcdir)/testimg.bmp testout.bmp
./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgp.jpg testoutp.jpg
./jpegtran -outfile testoutt.jpg testoutp.jpg
cmp $(srcdir)/testimgint.jpg testoutt.jpg
else else
test: testclean all
./jpegut
./cjpeg -dct int -outfile testoutint.jpg $(srcdir)/testorig.ppm
./cjpeg -dct fast -opt -outfile testoutfst.jpg $(srcdir)/testorig.ppm
./cjpeg -dct float -outfile testoutflt.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgint.jpg testoutint.jpg
cmp $(srcdir)/testimgfst.jpg testoutfst.jpg
cmp $(srcdir)/testimgflt-nosimd.jpg testoutflt.jpg cmp $(srcdir)/testimgflt-nosimd.jpg testoutflt.jpg
endif
./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg ./djpeg -dct int -fast -ppm -outfile testoutint.ppm $(srcdir)/testorig.jpg
./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg
./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg
cmp $(srcdir)/testimgint.ppm testoutint.ppm cmp $(srcdir)/testimgint.ppm testoutint.ppm
./djpeg -dct fast -ppm -outfile testoutfst.ppm $(srcdir)/testorig.jpg
cmp $(srcdir)/testimgfst.ppm testoutfst.ppm cmp $(srcdir)/testimgfst.ppm testoutfst.ppm
./djpeg -dct float -ppm -outfile testoutflt.ppm $(srcdir)/testorig.jpg
if WITH_SIMD
cmp $(srcdir)/testimgflt.ppm testoutflt.ppm
else
cmp $(srcdir)/testorig.ppm testoutflt.ppm cmp $(srcdir)/testorig.ppm testoutflt.ppm
endif
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
cmp $(srcdir)/testimg.bmp testout.bmp cmp $(srcdir)/testimg.bmp testout.bmp
if WITH_ARITH_ENC
./cjpeg -dct int -arithmetic -outfile testoutari.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgari.jpg testoutari.jpg
./jpegtran -arithmetic -outfile testouta.jpg $(srcdir)/testimgint.jpg
cmp $(srcdir)/testimgari.jpg testouta.jpg
endif
if WITH_ARITH_DEC
./djpeg -dct int -fast -ppm -outfile testoutari.ppm $(srcdir)/testimgari.jpg
cmp $(srcdir)/testimgari.ppm testoutari.ppm
./jpegtran -outfile testouta.jpg $(srcdir)/testimgari.jpg
cmp $(srcdir)/testimgint.jpg testouta.jpg
endif
./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm ./cjpeg -dct int -progressive -outfile testoutp.jpg $(srcdir)/testorig.ppm
cmp $(srcdir)/testimgp.jpg testoutp.jpg cmp $(srcdir)/testimgp.jpg testoutp.jpg
./jpegtran -outfile testoutt.jpg testoutp.jpg ./jpegtran -outfile testoutt.jpg testoutp.jpg
cmp $(srcdir)/testimgint.jpg testoutt.jpg cmp $(srcdir)/testimgint.jpg testoutt.jpg
./jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg $(srcdir)/testorig.jpg
cmp $(srcdir)/testimgcrop.jpg testoutcrop.jpg
endif
testclean: testclean:
rm -f testout* rm -f testout*
rm -f *_GRAYQ[0-9]*.bmp rm -f *_GRAYQ[0-9]*.bmp
rm -f *_GRAYQ[0-9]*.ppm rm -f *_GRAYQ[0-9]*.ppm
rm -f *_GRAYQ[0-9]*.jpg rm -f *_GRAYQ[0-9]*.jpg
rm -f *_GRAY.yuv
rm -f *_420Q[0-9]*.bmp rm -f *_420Q[0-9]*.bmp
rm -f *_420Q[0-9]*.ppm rm -f *_420Q[0-9]*.ppm
rm -f *_420Q[0-9]*.jpg rm -f *_420Q[0-9]*.jpg
rm -f *_420.yuv
rm -f *_422Q[0-9]*.bmp rm -f *_422Q[0-9]*.bmp
rm -f *_422Q[0-9]*.ppm rm -f *_422Q[0-9]*.ppm
rm -f *_422Q[0-9]*.jpg rm -f *_422Q[0-9]*.jpg
rm -f *_422.yuv
rm -f *_444Q[0-9]*.bmp rm -f *_444Q[0-9]*.bmp
rm -f *_444Q[0-9]*.ppm rm -f *_444Q[0-9]*.ppm
rm -f *_444Q[0-9]*.jpg rm -f *_444Q[0-9]*.jpg
rm -f *_444.yuv
if X86_64
install-exec-hook:
__PREFIX=`echo ${prefix} | sed -e 's@\/*$$@@'`; \
if [ "$$__PREFIX" = "/opt/libjpeg-turbo" ]; then \
cd $(DESTDIR)/${prefix}; \
if [ -d lib -a ! -d lib64 -a ! -h lib64 ]; then \
$(LN_S) lib lib64; \
fi \
fi
else
install-exec-hook:
__PREFIX=`echo ${prefix} | sed -e 's@\/*$$@@'`; \
if [ "$$__PREFIX" = "/opt/libjpeg-turbo" ]; then \
cd $(DESTDIR)/${prefix}; \
if [ -d lib -a ! -d lib32 -a ! -h lib32 ]; then \
$(LN_S) lib lib32; \
fi \
fi
endif
rpm: all rpm: all
sh $(srcdir)/release/makerpm ${PACKAGE_NAME} ${VERSION} ${BUILD} \ TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
${RPMARCH} ${srcdir} mkdir -p $$TMPDIR/RPMS; \
ln -fs `pwd` $$TMPDIR/BUILD; \
rm -f ${PACKAGE_NAME}-${VERSION}.${RPMARCH}.rpm; \
rpmbuild -bb --define "_blddir $$TMPDIR/buildroot" \
--define "_topdir $$TMPDIR" --define "_srcdir ${srcdir}" \
--target ${RPMARCH} pkgscripts/libjpeg-turbo.spec; \
cp $$TMPDIR/RPMS/${RPMARCH}/${PACKAGE_NAME}-${VERSION}-${BUILD}.${RPMARCH}.rpm \
${PACKAGE_NAME}-${VERSION}.${RPMARCH}.rpm; \
rm -rf $$TMPDIR
srpm: dist-gzip srpm: dist-gzip
sh $(srcdir)/release/makesrpm ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir} TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
mkdir -p $$TMPDIR/RPMS; \
mkdir -p $$TMPDIR/SRPMS; \
mkdir -p $$TMPDIR/BUILD; \
mkdir -p $$TMPDIR/SOURCES; \
mkdir -p $$TMPDIR/SPECS; \
rm -f ${PACKAGE_NAME}-${VERSION}.src.rpm; \
cp ${PACKAGE_NAME}-${VERSION}.tar.gz $$TMPDIR/SOURCES; \
cat pkgscripts/libjpeg-turbo.spec | sed s/%{_blddir}/%{_tmppath}/g \
| sed s@%{_srcdir}/@@g | sed s/#--\>//g \
> $$TMPDIR/SPECS/libjpeg-turbo.spec; \
rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/libjpeg-turbo.spec; \
cp $$TMPDIR/SRPMS/${PACKAGE_NAME}-${VERSION}-${BUILD}.src.rpm \
${PACKAGE_NAME}-${VERSION}.src.rpm; \
rm -rf $$TMPDIR
deb: all deb: all
sh $(srcdir)/release/makedpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ sh pkgscripts/makedpkg
${DEBARCH} ${srcdir}
if X86_64 if X86_64
udmg: all udmg: all
sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ sh pkgscripts/makemacpkg universal ${BUILDDIR32}
${srcdir} universal
endif endif
dmg: all dmg: all
sh $(srcdir)/release/makemacpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} ${srcdir} sh pkgscripts/makemacpkg
if X86_64 if X86_64
sunpkg: all csunpkg: all
sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \ sh pkgscripts/makesunpkg combined ${BUILDDIR32}
${DEBARCH} ${srcdir} $(CC) $(CXX) combined
nsi: all
makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc64 \
-DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. -DWIN64 \
-DPLATFORM="GCC 64-bit" -DGCC $(srcdir)/release/libjpeg-turbo.nsi
else
sunpkg: all
sh $(srcdir)/release/makesunpkg ${PACKAGE_NAME} ${VERSION} ${BUILD} \
${DEBARCH} ${srcdir} $(CC) $(CXX)
nsi: all
makensis -nocd -DVERSION=$(VERSION) -DAPPNAME=libjpeg-turbo-gcc \
-DWLIBDIR=.libs -DWSRCDIR=$(srcdir) -DWBLDDIR=. -DWHDRDIR=. \
-DPLATFORM="GCC" -DGCC $(srcdir)/release/libjpeg-turbo.nsi
endif endif
sunpkg: all
sh pkgscripts/makesunpkg
cygwinpkg: all cygwinpkg: all
sh $(srcdir)/release/makecygwinpkg ${PACKAGE_NAME} ${VERSION} ${srcdir} sh pkgscripts/makecygwinpkg

263
README
View File

@@ -1,29 +1,20 @@
libjpeg-turbo note: This is the legacy document from the original libjpeg v6b libjpeg-turbo note: This file is mostly taken from the libjpeg v8b README
release, which is included for reference. The Internet addresses given below file, and it is included only for reference. Some parts of it may not apply to
are likely non-functional. For more information about the libjpeg project, libjpeg-turbo. Please see README-turbo.txt for information specific to the
please see http://www.ijg.org. For more information about libjpeg-turbo, turbo version.
please see http://libjpeg-turbo.virtualgl.org.
The Independent JPEG Group's JPEG software The Independent JPEG Group's JPEG software
========================================== ==========================================
README for release 6b of 27-Mar-1998 This distribution contains a 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 distribution contains the sixth public release of the Independent JPEG This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
Group's free JPEG software. You are welcome to redistribute this software and Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
and other members of the Independent JPEG Group.
Serious users of this software (particularly those incorporating it into
larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to
our electronic mailing list. Mailing list members are notified of updates
and have a chance to participate in technical discussions, etc.
This software is the work of Tom Lane, Philip Gladstone, Jim Boucher,
Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
Guido Vollbeding, 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 official ISO JPEG standards committee.
@@ -37,27 +28,26 @@ OVERVIEW General description of JPEG and the IJG software.
LEGAL ISSUES Copyright, lack of warranty, terms of distribution. LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
REFERENCES Where to learn more about JPEG. REFERENCES Where to learn more about JPEG.
ARCHIVE LOCATIONS Where to find newer versions of this software. ARCHIVE LOCATIONS Where to find newer versions of this software.
RELATED SOFTWARE Other stuff you should get.
FILE FORMAT WARS Software *not* to get. FILE FORMAT WARS Software *not* to get.
TO DO Plans for future IJG releases. TO DO Plans for future IJG releases.
Other documentation files in the distribution are: Other documentation files in the distribution are:
User documentation: User documentation:
install.doc How to configure and install the IJG software. install.txt How to configure and install the IJG software.
usage.doc Usage instructions for cjpeg, djpeg, jpegtran, usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom. rdjpgcom, and wrjpgcom.
*.1 Unix-style man pages for programs (same info as usage.doc). *.1 Unix-style man pages for programs (same info as usage.txt).
wizard.doc Advanced usage instructions for JPEG wizards only. wizard.txt Advanced usage instructions for JPEG wizards only.
change.log Version-to-version change highlights. change.log Version-to-version change highlights.
Programmer and internal documentation: Programmer and internal documentation:
libjpeg.doc How to use the JPEG library in your own programs. libjpeg.txt How to use the JPEG library in your own programs.
example.c Sample code for calling the JPEG library. example.c Sample code for calling the JPEG library.
structure.doc Overview of the JPEG library's internal structure. structure.txt Overview of the JPEG library's internal structure.
filelist.doc Road map of IJG files. filelist.txt Road map of IJG files.
coderules.doc Coding style rules --- please read if you contribute code. coderules.txt Coding style rules --- please read if you contribute code.
Please read at least the files install.doc and usage.doc. Useful information Please read at least the files install.txt and usage.txt. Some information
can also be found in the JPEG FAQ (Frequently Asked Questions) article. See can also be found in the JPEG FAQ (Frequently Asked Questions) article. See
ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
@@ -69,24 +59,27 @@ the order listed) before diving into the code.
OVERVIEW OVERVIEW
======== ========
This package contains C software to implement JPEG image compression and This package contains C software to implement JPEG image encoding, decoding,
decompression. JPEG (pronounced "jay-peg") is a standardized compression and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
method for full-color and gray-scale images. JPEG is intended for compressing method for full-color and gray-scale images. JPEG's strong suit is compressing
"real-world" scenes; line drawings, cartoons and other non-realistic images photographic images or other types of images which have smooth color and
are not its strong suit. JPEG is lossy, meaning that the output image is not brightness transitions between neighboring pixels. Images with sharp lines or
exactly identical to the input image. Hence you must not use JPEG if you other abrupt features may not compress well with JPEG, and a higher JPEG
have to have identical output bits. However, on typical photographic images, quality may have to be used to avoid visible compression artifacts with such
very good compression levels can be obtained with no visible change, and images.
remarkably high compression levels are possible if you can tolerate a
low-quality image. For more details, see the references, or just experiment JPEG is lossy, meaning that the output pixels are not necessarily identical to
with various compression settings. the input pixels. However, on photographic content and other "smooth" images,
very good compression ratios can be obtained with no visible compression
artifacts, and extremely high compression ratios are possible if you are
willing to sacrifice image quality (by reducing the "quality" setting in the
compressor.)
This software implements JPEG baseline, extended-sequential, and progressive This software implements JPEG baseline, extended-sequential, and progressive
compression processes. Provision is made for supporting all variants of these compression processes. Provision is made for supporting all variants of these
processes, although some uncommon parameter settings aren't implemented yet. processes, although some uncommon parameter settings aren't implemented yet.
For legal reasons, we are not distributing code for the arithmetic-coding We have made no provision for supporting the hierarchical or lossless
variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting processes defined in the standard.
the hierarchical or lossless processes defined in the standard.
We provide a set of library routines for reading and writing JPEG image files, We provide a set of library routines for reading and writing JPEG image files,
plus two sample applications "cjpeg" and "djpeg", which use the library to plus two sample applications "cjpeg" and "djpeg", which use the library to
@@ -98,10 +91,11 @@ considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG for example, the color quantization modules are not strictly part of JPEG
decoding, but they are essential for output to colormapped file formats or decoding, but they are essential for output to colormapped file formats or
colormapped displays. These extra functions can be compiled out of the colormapped displays. These extra functions can be compiled out of the
library if not required for a particular application. We have also included library if not required for a particular application.
"jpegtran", a utility for lossless transcoding between different JPEG
processes, and "rdjpgcom" and "wrjpgcom", two simple applications for We have also included "jpegtran", a utility for lossless transcoding between
inserting and extracting textual comments in JFIF files. different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
applications for inserting and extracting textual comments in JFIF files.
The emphasis in designing this software has been on achieving portability and The emphasis in designing this software has been on achieving portability and
flexibility, while also making it fast enough to be useful. In particular, flexibility, while also making it fast enough to be useful. In particular,
@@ -134,7 +128,7 @@ with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you, 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. its user, assume the entire risk as to its quality and accuracy.
This software is copyright (C) 1991-1998, Thomas G. Lane. This software is copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below. All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this Permission is hereby granted to use, copy, modify, and distribute this
@@ -177,17 +171,8 @@ the foregoing paragraphs do.
The Unix configuration script "configure" was produced with GNU Autoconf. The Unix configuration script "configure" was produced with GNU Autoconf.
It is copyright by the Free Software Foundation but is freely distributable. It is copyright by the Free Software Foundation but is freely distributable.
The same holds for its supporting scripts (config.guess, config.sub, The same holds for its supporting scripts (config.guess, config.sub,
ltconfig, ltmain.sh). Another support script, install-sh, is copyright ltmain.sh). Another support script, install-sh, is copyright by X Consortium
by M.I.T. but is also freely distributable. but is also freely distributable.
It appears that the arithmetic coding option of the JPEG spec is covered by
patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot
legally be used without obtaining one or more licenses. For this reason,
support for arithmetic coding has been removed from the free JPEG software.
(Since arithmetic coding provides only a marginal gain over the unpatented
Huffman mode, it is unlikely that very many implementations will support it.)
So far as we are aware, there are no patent restrictions on the remaining
code.
The IJG distribution formerly included code to read and write GIF files. The IJG distribution formerly included code to read and write GIF files.
To avoid entanglement with the Unisys LZW patent, GIF reading support has To avoid entanglement with the Unisys LZW patent, GIF reading support has
@@ -205,7 +190,7 @@ We are required to state that
REFERENCES REFERENCES
========== ==========
We highly recommend reading one or more of these references before trying to We recommend reading one or more of these references before trying to
understand the innards of the JPEG software. understand the innards of the JPEG software.
The best short technical introduction to the JPEG compression algorithm is The best short technical introduction to the JPEG compression algorithm is
@@ -214,7 +199,7 @@ The best short technical introduction to the JPEG compression algorithm is
(Adjacent articles in that issue discuss MPEG motion picture compression, (Adjacent articles in that issue discuss MPEG motion picture compression,
applications of JPEG, and related topics.) If you don't have the CACM issue 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 handy, a PostScript file containing a revised version of Wallace's article is
available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually available at http://www.ijg.org/files/wallace.ps.gz. The file (actually
a preprint for an article that appeared in IEEE Trans. Consumer Electronics) a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
omits the sample images that appeared in CACM, but it includes corrections omits the sample images that appeared in CACM, but it includes corrections
and some added material. Note: the Wallace article is copyright ACM and IEEE, and some added material. Note: the Wallace article is copyright ACM and IEEE,
@@ -229,82 +214,53 @@ code but don't know much about data compression in general. The book's JPEG
sample code is far from industrial-strength, but when you are ready to look sample code is far from industrial-strength, but when you are ready to look
at a full implementation, you've got one here... at a full implementation, you've got one here...
The best full description of JPEG is the textbook "JPEG Still Image Data The best currently available description of JPEG is the textbook "JPEG Still
Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published Image Data Compression Standard" by William B. Pennebaker and Joan L.
by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
The book includes the complete text of the ISO JPEG standards (DIS 10918-1 Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
and draft DIS 10918-2). This is by far the most complete exposition of JPEG standards (DIS 10918-1 and draft DIS 10918-2).
in existence, and we highly recommend it.
The JPEG standard itself is not available electronically; you must order a The original JPEG standard is divided into two parts, Part 1 being the actual
paper copy through ISO or ITU. (Unless you feel a need to own a certified specification, while Part 2 covers compliance testing methods. Part 1 is
official copy, we recommend buying the Pennebaker and Mitchell book instead; titled "Digital Compression and Coding of Continuous-tone Still Images,
it's much cheaper and includes a great deal of useful explanatory material.)
In the USA, copies of the standard may be ordered from ANSI Sales at (212)
642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI
doesn't take credit card orders, but Global does.) It's not cheap: as of
1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%
shipping/handling. The standard is divided into two parts, Part 1 being the
actual specification, while Part 2 covers compliance testing methods. Part 1
is titled "Digital Compression and Coding of Continuous-tone Still Images,
Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS 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 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 Continuous-tone Still Images, Part 2: Compliance testing" and has document
numbers ISO/IEC IS 10918-2, ITU-T T.83. numbers ISO/IEC IS 10918-2, ITU-T T.83.
Some extensions to the original JPEG standard are defined in JPEG Part 3,
a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG
currently does not support any Part 3 extensions.
The JPEG standard does not specify all details of an interchangeable file The JPEG standard does not specify all details of an interchangeable file
format. For the omitted details we follow the "JFIF" conventions, revision format. For the omitted details we follow the "JFIF" conventions, revision
1.02. A copy of the JFIF spec is available from: 1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report
Literature Department and thus received a formal publication status. It is available as a free
C-Cube Microsystems, Inc. download in PDF format from
1778 McCarthy Blvd. http://www.ecma-international.org/publications/techreports/E-TR-098.htm.
Milpitas, CA 95035 A PostScript version of the JFIF document is available at
phone (408) 944-6300, fax (408) 944-6314 http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at
A PostScript version of this document is available by FTP at http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures.
ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text
version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing
the figures.
The TIFF 6.0 file format specification can be obtained by FTP from 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 ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or (Compression tag 7). Copies of this Note can be obtained from
from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision http://www.ijg.org/files/. It is expected that the next revision
of the TIFF spec will replace the 6.0 JPEG design with the Note's design. of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
Although IJG's own code does not support TIFF/JPEG, the free libtiff library Although IJG's own code does not support TIFF/JPEG, the free libtiff library
uses our library to implement TIFF/JPEG per the Note. libtiff is available uses our library to implement TIFF/JPEG per the Note.
from ftp://ftp.sgi.com/graphics/tiff/.
ARCHIVE LOCATIONS ARCHIVE LOCATIONS
================= =================
The "official" archive site for this software is ftp.uu.net (Internet The "official" archive site for this software is www.ijg.org.
address 192.48.96.9). The most recent released version can always be found The most recent released version can always be found there in
there in directory graphics/jpeg. This particular version will be archived directory "files". This particular version will be archived as
as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have http://www.ijg.org/files/jpegsrc.v8b.tar.gz, and in Windows-compatible
direct Internet access, UUNET's archives are also available via UUCP; contact "zip" archive format as http://www.ijg.org/files/jpegsr8b.zip.
help@uunet.uu.net for information on retrieving files that way.
Numerous Internet sites maintain copies of the UUNET files. However, only The JPEG FAQ (Frequently Asked Questions) article is a source of some
ftp.uu.net is guaranteed to have the latest official version. general information about JPEG.
You can also obtain this software in DOS-compatible "zip" archive format from
the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or
on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12
"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net
release.
The JPEG FAQ (Frequently Asked Questions) article is a useful source of
general information about JPEG. It is updated constantly and therefore is
not included in this distribution. The FAQ is posted every two weeks to
Usenet newsgroups comp.graphics.misc, news.answers, and other groups.
It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
and other news.answers archive sites, including the official news.answers and other news.answers archive sites, including the official news.answers
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
@@ -314,79 +270,20 @@ with body
send usenet/news.answers/jpeg-faq/part2 send usenet/news.answers/jpeg-faq/part2
RELATED SOFTWARE
================
Numerous viewing and image manipulation programs now support JPEG. (Quite a
few of them use this library to do so.) The JPEG FAQ described above lists
some of the more popular free and shareware viewers, and tells where to
obtain them on Internet.
If you are on a Unix machine, we highly recommend Jef Poskanzer's free
PBMPLUS software, which provides many useful operations on PPM-format image
files. In particular, it can convert PPM images to and from a wide range of
other formats, thus making cjpeg/djpeg considerably more useful. The latest
version is distributed by the NetPBM group, and is available from numerous
sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/.
Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is;
you are likely to have difficulty making it work on any non-Unix machine.
A different free JPEG implementation, written by the PVRG group at Stanford,
is available from ftp://havefun.stanford.edu/pub/jpeg/. This program
is designed for research and experimentation rather than production use;
it is slower, harder to use, and less portable than the IJG code, but it
is easier to read and modify. Also, the PVRG code supports lossless JPEG,
which we do not. (On the other hand, it doesn't do progressive JPEG.)
FILE FORMAT WARS FILE FORMAT WARS
================ ================
Some JPEG programs produce files that are not compatible with our library. The ISO JPEG standards committee actually promotes different formats like
The root of the problem is that the ISO JPEG committee failed to specify a "JPEG 2000" or "JPEG XR" which are incompatible with original DCT-based
concrete file format. Some vendors "filled in the blanks" on their own, JPEG. IJG therefore does not support these formats (see REFERENCES). Indeed,
creating proprietary formats that no one else could read. (For example, none
of the early commercial JPEG implementations for the Macintosh were able to
exchange compressed files.)
The file format we have adopted is called JFIF (see REFERENCES). This format
has been agreed to by a number of major commercial JPEG vendors, and it has
become the de facto standard. JFIF is a minimal or "low end" representation.
We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF
Technical Note #2) for "high end" applications that need to record a lot of
additional data about an image. TIFF/JPEG is fairly new and not yet widely
supported, unfortunately.
The upcoming JPEG Part 3 standard defines a file format called SPIFF.
SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should
be able to read the most common variant of SPIFF. SPIFF has some technical
advantages over JFIF, but its major claim to fame is simply that it is an
official standard rather than an informal one. At this point it is unclear
whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto
standard. IJG intends to support SPIFF once the standard is frozen, but we
have not decided whether it should become our default output format or not.
(In any case, our decoder will remain capable of reading JFIF indefinitely.)
Various proprietary file formats incorporating JPEG compression also exist.
We have little or no sympathy for the existence of these formats. Indeed,
one of the original reasons for developing this free software was to help one of the original reasons for developing this free software was to help
force convergence on common, open format standards for JPEG files. Don't force convergence on common, interoperable format standards for JPEG files.
use a proprietary file format! Don't use an incompatible file format!
(In any case, our decoder will remain capable of reading existing JPEG
image files indefinitely.)
TO DO TO DO
===== =====
The major thrust for v7 will probably be improvement of visual quality. Please send bug reports, offers of help, etc. to jpeg-info@uc.ag.
The current method for scaling the quantization tables is known not to be
very good at low Q values. We also intend to investigate block boundary
smoothing, "poor man's variable quantization", and other means of improving
quality-vs-file-size performance without sacrificing compatibility.
In future versions, we are considering supporting some of the upcoming JPEG
Part 3 extensions --- principally, variable quantization and the SPIFF file
format.
As always, speeding things up is of great interest.
Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.

View File

@@ -2,22 +2,23 @@
** Background ** Background
******************************************************************************* *******************************************************************************
libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors libjpeg-turbo is a derivative of libjpeg which uses SIMD instructions (MMX,
which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG SSE2, etc.) to accelerate baseline JPEG compression and decompression on x86
compression and decompression. libjpeg-turbo is generally 2-4x as fast and x86-64 systems. On such systems, libjpeg-turbo is generally 2-4x as fast
as the unmodified version of libjpeg, all else being equal. as the unmodified version of libjpeg, all else being equal.
libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
the TigerVNC and VirtualGL projects made numerous enhancements to the codec, the TigerVNC and VirtualGL projects made numerous enhancements to the codec in
including improved support for Mac OS X, 64-bit support, support for 32-bit 2009, including improved support for Mac OS X, 64-bit support, support for
and big endian pixel formats, accelerated Huffman encoding/decoding, and 32-bit and big endian pixel formats (RGBX, XBGR, etc.), accelerated Huffman
various bug fixes. The goal was to produce a fully open source codec that encoding/decoding, and various bug fixes. The goal was to produce a fully open
could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL source codec that could replace the partially closed source TurboJPEG/IPP codec
and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of used by VirtualGL and TurboVNC. libjpeg-turbo generally performs in the range
TurboJPEG/IPP. It is faster in some areas but slower in others. of 80-120% of TurboJPEG/IPP. It is faster in some areas but slower in others.
It was decided to split libjpeg-turbo into a separate SDK so that other In early 2010, libjpeg-turbo spun off into its own independent project, with
projects could take advantage of this technology. The libjpeg-turbo shared the goal of making high-speed JPEG compression/decompression technology
available to a broader range of users and developers. The libjpeg-turbo shared
libraries can be used as drop-in replacements for libjpeg on most systems. libraries can be used as drop-in replacements for libjpeg on most systems.
@@ -25,21 +26,21 @@ libraries can be used as drop-in replacements for libjpeg on most systems.
** License ** License
******************************************************************************* *******************************************************************************
Some of the optimizations to the Huffman encoder (jchuff.c) and decoder The TurboJPEG/OSS wrapper, as well as some of the optimizations to the Huffman
(jdhuff.c) were borrowed from VirtualGL, and thus any distribution of encoder (jchuff.c) and decoder (jdhuff.c), were borrowed from VirtualGL, and
libjpeg-turbo which includes those optimizations must, as a whole, be subject thus any distribution of libjpeg-turbo which includes those files must, as a
to the terms of the wxWindows Library Licence, Version 3.1. A copy of this whole, be subject to the terms of the wxWindows Library Licence, Version 3.1.
license can be found in this directory under LICENSE.txt. The wxWindows A copy of this license can be found in this directory under LICENSE.txt. The
Library License is based on the LGPL but includes provisions which allow the wxWindows Library License is based on the LGPL but includes provisions which
Library to be statically linked into proprietary libraries and applications allow the Library to be statically linked into proprietary libraries and
without requiring the resulting binaries to be distributed under the terms of applications without requiring the resulting binaries to be distributed under
the LGPL. the terms of the LGPL.
The rest of the source code, apart from the Huffman codec optimizations, falls The rest of the source code, apart from TurboJPEG/OSS and the Huffman codec
under a less restrictive, BSD-style license (see README.) You can choose to optimizations, falls under a less restrictive, BSD-style license (see README.)
distribute libjpeg-turbo, as a whole, under this BSD-style license by simply You can choose to distribute libjpeg-turbo, as a whole, under this BSD-style
replacing the optimized jchuff.c and jdhuff.c with their unoptimized license by simply removing TurboJPEG/OSS and replacing the optimized jchuff.c
counterparts from the libjpeg v6b source. and jdhuff.c with their unoptimized counterparts from the libjpeg v6b source.
******************************************************************************* *******************************************************************************
@@ -51,7 +52,7 @@ Replacing libjpeg at Run Time
============================= =============================
If a Unix application is dynamically linked with libjpeg, then you can replace If a Unix application is dynamically linked with libjpeg, then you can replace
libjpeg with libjpeg-turbo at run time by manipulating the LD_LIBRARY_PATH. libjpeg with libjpeg-turbo at run time by manipulating LD_LIBRARY_PATH.
For instance: For instance:
[Using libjpeg] [Using libjpeg]
@@ -75,36 +76,39 @@ links to the libjpeg dynamic library located in /opt/libjpeg-turbo/{lib}. This
will effectively accelerate every dynamically linked libjpeg application on the will effectively accelerate every dynamically linked libjpeg application on the
system. system.
The Windows distribution of the libjpeg-turbo SDK installs jpeg62.dll into The libjpeg-turbo SDK for Visual C++ installs the libjpeg-turbo DLL
c:\libjpeg-turbo\bin, and the PATH environment variable can be modified such (jpeg62.dll, jpeg7.dll, or jpeg8.dll, depending on whether libjpeg v6b, v7, or
that this directory is searched before any others that might contain v8 emulation is enabled) into c:\libjpeg-turbo[64]\bin, and the PATH
jpeg62.dll. However, if jpeg62.dll also exists in an application's install environment variable can be modified such that this directory is searched
directory, then Windows will load the application's version of it first. Thus, before any others that might contain a libjpeg DLL. However, if a libjpeg
if an application ships with jpeg62.dll, then back up the application's version DLL exists in an application's install directory, then Windows will load this
of jpeg62.dll and copy c:\libjpeg-turbo\bin\jpeg62.dll into the application's DLL first whenever the application is launched. Thus, if an application ships
install directory to accelerate it. with jpeg62.dll, jpeg7.dll, or jpeg8.dll, then back up the application's
version of this DLL and copy c:\libjpeg-turbo[64]\bin\jpeg*.dll into the
application's install directory to accelerate it.
The version of jpeg62.dll distributed in the libjpeg-turbo SDK requires the The version of the libjpeg-turbo DLL distributed in the libjpeg-turbo SDK for
Visual C++ 2008 C run time DLL (msvcr90.dll). This library ships with more Visual C++ requires the Visual C++ 2008 C run time DLL (msvcr90.dll).
recent versions of Windows, but users of older versions can obtain it from the msvcr90.dll ships with more recent versions of Windows, but users of older
Visual C++ 2008 Redistributable Package, which is available as a free download Windows releases can obtain it from the Visual C++ 2008 Redistributable
from Microsoft's web site. Package, which is available as a free download from Microsoft's web site.
NOTE: Features of libjpeg which require passing a C run time structure, such NOTE: Features of libjpeg which require passing a C run time structure, such
as a file handle, from an application to libjpeg will probably not work with as a file handle, from an application to libjpeg will probably not work with
the distributed version of jpeg62.dll unless the application is also built to the version of the libjpeg-turbo DLL distributed in the libjpeg-turbo SDK for
use the Visual C++ 2008 C run time DLL. In particular, this affects Visual C++, unless the application is also built to use the Visual C++ 2008 C
jpeg_stdio_dest() and jpeg_stdio_src(). run time DLL. In particular, this affects jpeg_stdio_dest() and
jpeg_stdio_src().
Mac applications typically embed their own copies of libjpeg.62.dylib inside Mac applications typically embed their own copies of the libjpeg dylib inside
the (hidden) application bundle, so it is not possible to globally replace the (hidden) application bundle, so it is not possible to globally replace
libjpeg on OS X systems. If an application uses a shared library version of libjpeg on OS X systems. If an application uses a shared library version of
libjpeg, then it may be possible to replace the application's version of it. libjpeg, then it may be possible to replace the application's version of it.
This would generally involve copying libjpeg.62.dylib into the appropriate This would generally involve copying libjpeg.*.dylib from libjpeg-turbo into
place in the application bundle and using install_name_tool to repoint the the appropriate place in the application bundle and using install_name_tool to
dylib to the new directory. This requires an advanced knowledge of OS X and repoint the dylib to the new directory. This requires an advanced knowledge of
would not survive an upgrade or a re-install of the application. Thus, it is OS X and would not survive an upgrade or a re-install of the application.
not recommended for most users. Thus, it is not recommended for most users.
======================= =======================
Replacing TurboJPEG/IPP Replacing TurboJPEG/IPP
@@ -115,8 +119,8 @@ VirtualGL 2.1.x and TurboVNC 0.6 (and prior.) libjpeg-turbo contains a wrapper
library (TurboJPEG/OSS) that emulates the TurboJPEG API using libjpeg-turbo library (TurboJPEG/OSS) that emulates the TurboJPEG API using libjpeg-turbo
instead of the closed source Intel Performance Primitives. You can replace the instead of the closed source Intel Performance Primitives. You can replace the
TurboJPEG/IPP package on Linux systems with the libjpeg-turbo package in order TurboJPEG/IPP package on Linux systems with the libjpeg-turbo package in order
to make existing releases of VirtualGL 2.1.x and TurboVNC use the new codec at to make existing releases of VirtualGL 2.1.x and TurboVNC 0.x use the new codec
run time. Note that the 64-bit libjpeg-turbo packages contain only 64-bit at run time. Note that the 64-bit libjpeg-turbo packages contain only 64-bit
binaries, whereas the TurboJPEG/IPP 64-bit packages contained both 64-bit and binaries, whereas the TurboJPEG/IPP 64-bit packages contained both 64-bit and
32-bit binaries. Thus, to replace a TurboJPEG/IPP 64-bit package, install 32-bit binaries. Thus, to replace a TurboJPEG/IPP 64-bit package, install
both the 64-bit and 32-bit versions of libjpeg-turbo. both the 64-bit and 32-bit versions of libjpeg-turbo.
@@ -132,8 +136,8 @@ Using libjpeg-turbo in Your Own Programs
For the most part, libjpeg-turbo should work identically to libjpeg, so in For the most part, libjpeg-turbo should work identically to libjpeg, so in
most cases, an application can be built against libjpeg and then run against most cases, an application can be built against libjpeg and then run against
libjpeg-turbo. On Unix systems, you can build against libjpeg-turbo instead libjpeg-turbo. On Unix systems (including Cygwin), you can build against
of libjpeg by setting libjpeg-turbo instead of libjpeg by setting
CPATH=/opt/libjpeg-turbo/include CPATH=/opt/libjpeg-turbo/include
and and
@@ -142,12 +146,6 @@ of libjpeg by setting
({lib} = lib32 or lib64, depending on whether you are building a 32-bit or a ({lib} = lib32 or lib64, depending on whether you are building a 32-bit or a
64-bit application.) 64-bit application.)
If using Cygwin, then set
CPATH=/cygdrive/c/libjpeg-turbo-gcc[64]/include
and
LIBRARY_PATH=/cygdrive/c/libjpeg-turbo-gcc[64]/lib
If using MinGW, then set If using MinGW, then set
CPATH=/c/libjpeg-turbo-gcc[64]/include CPATH=/c/libjpeg-turbo-gcc[64]/include
@@ -156,11 +154,11 @@ If using MinGW, then set
Building against libjpeg-turbo is useful, for instance, if you want to build an Building against libjpeg-turbo is useful, for instance, if you want to build an
application that leverages the libjpeg-turbo colorspace extensions (see below.) application that leverages the libjpeg-turbo colorspace extensions (see below.)
On Linux and Solaris systems, you would still need to manipulate the On Linux and Solaris systems, you would still need to manipulate
LD_LIBRARY_PATH or sym links appropriately to use libjpeg-turbo at run time. LD_LIBRARY_PATH or create appropriate sym links to use libjpeg-turbo at run
On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker to time. On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker
force the use of libjpeg-turbo at run time rather than libjpeg (also useful if to force the use of libjpeg-turbo at run time rather than libjpeg (also useful
you want to leverage the colorspace extensions), or you can link against the if you want to leverage the colorspace extensions), or you can link against the
libjpeg-turbo static library. libjpeg-turbo static library.
To force a Linux, Solaris, or MinGW application to link against the static To force a Linux, Solaris, or MinGW application to link against the static
@@ -172,18 +170,18 @@ On OS X, simply add /opt/libjpeg-turbo/lib/libjpeg.a to the linker command
line (this also works on Linux and Solaris.) line (this also works on Linux and Solaris.)
To build Visual C++ applications using libjpeg-turbo, add To build Visual C++ applications using libjpeg-turbo, add
c:\libjpeg-turbo[64]\include to your system or user INCLUDE environment c:\libjpeg-turbo[64]\include to the system or user INCLUDE environment
variable and c:\libjpeg-turbo[64]\lib to your system or user LIB environment variable and c:\libjpeg-turbo[64]\lib to the system or user LIB environment
variable, and then link against either jpeg.lib (to use jpeg62.dll) or variable, and then link against either jpeg.lib (to use the DLL version of
jpeg-static.lib (to use the static version of libjpeg-turbo.) libjpeg-turbo) or jpeg-static.lib (to use the static version of libjpeg-turbo.)
===================== =====================
Colorspace Extensions Colorspace Extensions
===================== =====================
libjpeg-turbo includes extensions which allow JPEG images to be compressed libjpeg-turbo includes extensions which allow JPEG images to be compressed
directly from (and decompressed directly to) buffers which use BGR, BGRA, directly from (and decompressed directly to) buffers which use BGR, BGRX,
RGBA, ABGR, and ARGB pixel ordering. This is implemented with six new RGBX, XBGR, and XRGB pixel ordering. This is implemented with six new
colorspace constants: colorspace constants:
JCS_EXT_RGB /* red/green/blue */ JCS_EXT_RGB /* red/green/blue */
@@ -205,3 +203,102 @@ time with:
At run time, attempting to use these extensions with a version of libjpeg At run time, attempting to use these extensions with a version of libjpeg
that doesn't support them will result in a "Bogus input colorspace" error. that doesn't support them will result in a "Bogus input colorspace" error.
=================================
libjpeg v7 and v8 API/ABI support
=================================
libjpeg v7 and v8 added new features to the API/ABI, and, unfortunately, the
compression and decompression structures were extended in a backward-
incompatible manner to accommodate these features. Thus, programs which are
built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
based on the libjpeg v6b code base. Although libjpeg v7 and v8 are still not
as widely used as v6b, enough programs (including a few Linux distros) have
made the switch that it was desirable to provide support for the libjpeg v7/v8
API/ABI in libjpeg-turbo.
Some of the libjpeg v7 and v8 features -- DCT scaling, to name one -- involve
deep modifications to the code which cannot be accommodated by libjpeg-turbo
without either breaking compatibility with libjpeg v6b or producing an
unsupportable mess. In order to fully support libjpeg v8 with all of its
features, we would have to essentially port the SIMD extensions to the libjpeg
v8 code base and maintain two separate code trees. We are hesitant to do this
until/unless the newer libjpeg code bases garner more community support and
involvement and until/unless we have some notion of whether future libjpeg
releases will also be backward-incompatible.
By passing an argument of --with-jpeg7 or --with-jpeg8 to configure, or an
argument of -DWITH_JPEG7=1 or -DWITH_JPEG8=1 to cmake, you can build a version
of libjpeg-turbo which emulates the libjpeg v7 or v8 API/ABI, so that programs
which are built against libjpeg v7 or v8 can be run with libjpeg-turbo. The
following section describes which libjpeg v7+ features are supported and which
aren't.
libjpeg v7 and v8 Features:
---------------------------
Fully supported:
-- cjpeg: Separate quality settings for luminance and chrominance
Note that the libpjeg v7+ API was extended to accommodate this feature only
for convenience purposes. It has always been possible to implement this
feature with libjpeg v6b (see rdswitch.c for an example.)
-- cjpeg: 32-bit BMP support
-- jpegtran: lossless cropping
-- jpegtran: -perfect option
-- rdjpgcom: -raw option
-- rdjpgcom: locale awareness
Fully supported when using libjpeg v7/v8 emulation:
-- libjpeg: In-memory source and destination managers
Not supported:
-- libjpeg: DCT scaling in compressor
cinfo.scale_num and cinfo.scale_denom are silently ignored.
-- libjpeg: IDCT scaling extensions in decompressor
libjpeg-turbo still supports IDCT scaling with scaling factors of 1/2, 1/4,
and 1/8 (same as libjpeg v6b.)
-- libjpeg: Fancy downsampling in compressor
cinfo.do_fancy_downsampling is silently ignored.
-- jpegtran: Scaling
Seems to depend on the DCT scaling feature, which isn't supported.
*******************************************************************************
** Performance pitfalls
*******************************************************************************
===============
Restart Markers
===============
The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
in a way that makes libjpeg happy, so it is necessary to use the slow Huffman
decoder when decompressing a JPEG image that has restart markers. This can
cause the decompression performance to drop by as much as 20%, but the
performance will still be much much greater than that of libjpeg v6b. Many
consumer packages, such as PhotoShop, use restart markers when generating JPEG
images, so images generated by those programs will experience this issue.
===============================================
Fast Integer Forward DCT at High Quality Levels
===============================================
The algorithm used by the SIMD-accelerated quantization function cannot produce
correct results whenever the fast integer forward DCT is used along with a JPEG
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
function in those cases. This causes performance to drop by as much as 40%.
It is therefore strongly advised that you use the slow integer forward DCT
whenever encoding images with a JPEG quality of 98 or higher.

3
bmp.h
View File

@@ -1,5 +1,6 @@
/* Copyright (C)2004 Landmark Graphics Corporation /* Copyright (C)2004 Landmark Graphics Corporation
* Copyright (C)2005 Sun Microsystems, Inc. * Copyright (C)2005 Sun Microsystems, Inc.
* Copyright (C)2011 D. R. Commander
* *
* This library is free software and may be redistributed and/or modified under * This library is free software and may be redistributed and/or modified under
* the terms of the wxWindows Library License, Version 3.1 or (at your option) * the terms of the wxWindows Library License, Version 3.1 or (at your option)
@@ -19,7 +20,7 @@
#define __BMP_H__ #define __BMP_H__
#define BMPPIXELFORMATS 6 #define BMPPIXELFORMATS 6
enum BMPPIXELFORMAT {BMP_RGB=0, BMP_RGBA, BMP_BGR, BMP_BGRA, BMP_ABGR, BMP_ARGB}; enum BMPPIXELFORMAT {BMP_RGB=0, BMP_RGBX, BMP_BGR, BMP_BGRX, BMP_XBGR, BMP_XRGB};
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -2,6 +2,7 @@
* cderror.h * cderror.h
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -45,6 +46,7 @@ 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_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") 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(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")

View File

@@ -104,6 +104,7 @@ typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
#define jinit_write_targa jIWrTarga #define jinit_write_targa jIWrTarga
#define read_quant_tables RdQTables #define read_quant_tables RdQTables
#define read_scan_script RdScnScript #define read_scan_script RdScnScript
#define set_quality_ratings SetQRates
#define set_quant_slots SetQSlots #define set_quant_slots SetQSlots
#define set_sample_factors SetSFacts #define set_sample_factors SetSFacts
#define read_color_map RdCMap #define read_color_map RdCMap
@@ -131,8 +132,10 @@ EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
/* cjpeg support routines (in rdswitch.c) */ /* cjpeg support routines (in rdswitch.c) */
EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
int scale_factor, boolean force_baseline)); boolean force_baseline));
EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg,
boolean force_baseline));
EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));

View File

@@ -1,6 +1,67 @@
CHANGE LOG for Independent JPEG Group's JPEG software CHANGE LOG for Independent JPEG Group's JPEG software
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.
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.
Version 8 10-Jan-2010
----------------------
Add sanity check in BMP reader module to avoid cjpeg crash for empty input
image (thank to Isaev Ildar of ISP RAS, Moscow, RU for reporting this error).
Add data source and destination managers for read from and write to
memory buffers. New API functions jpeg_mem_src and jpeg_mem_dest.
Thank to Roberto Boni from Italy for the suggestion.
Version 7 27-Jun-2009
----------------------
cjpeg -quality option has been extended for support of separate quality
settings for luminance and chrominance (or in general, for every provided
quantization table slot).
New API function jpeg_default_qtables() and q_scale_factor array in library.
Support arithmetic entropy encoding and decoding.
Added files jaricom.c, jcarith.c, jdarith.c.
jpegtran has a new "lossless" cropping feature.
Implement -perfect option in jpegtran, new API function
jtransform_perfect_transform() in transupp. (DP 204_perfect.dpatch)
Better error messages for jpegtran fopen failure.
(DP 203_jpegtran_errmsg.dpatch)
Fix byte order issue with 16bit PPM/PGM files in rdppm.c/wrppm.c:
according to Netpbm, the de facto standard implementation of the PNM formats,
the most significant byte is first. (DP 203_rdppm.dpatch)
Add -raw option to rdjpgcom not to mangle the output.
(DP 205_rdjpgcom_raw.dpatch)
Make rdjpgcom locale aware. (DP 201_rdjpgcom_locale.dpatch)
Add extern "C" to jpeglib.h.
This avoids the need to put extern "C" { ... } around #include "jpeglib.h"
in your C++ application. Defining the symbol DONT_USE_EXTERN_C in the
configuration prevents this. (DP 202_jpeglib.h_c++.dpatch)
Version 6b 27-Mar-1998 Version 6b 27-Mar-1998
----------------------- -----------------------

56
cjpeg.1
View File

@@ -1,4 +1,4 @@
.TH CJPEG 1 "20 March 1998" .TH CJPEG 1 "11 October 2010"
.SH NAME .SH NAME
cjpeg \- compress an image file to a JPEG file cjpeg \- compress an image file to a JPEG file
.SH SYNOPSIS .SH SYNOPSIS
@@ -36,7 +36,7 @@ though for brevity these are not mentioned below.
.PP .PP
The basic switches are: The basic switches are:
.TP .TP
.BI \-quality " N" .BI \-quality " N[,...]"
Scale quantization tables to adjust image quality. Quality is 0 (worst) to Scale quantization tables to adjust image quality. Quality is 0 (worst) to
100 (best); default is 75. (See below for more info.) 100 (best); default is 75. (See below for more info.)
.TP .TP
@@ -108,6 +108,36 @@ other JPEG programs may be unable to decode the resulting file. Use
.B \-baseline .B \-baseline
if you need to ensure compatibility at low quality values.) if you need to ensure compatibility at low quality values.)
.PP .PP
The \fB-quality\fR option has been extended in this version of \fBcjpeg\fR to
support separate quality settings for luminance and chrominance (or, in
general, separate settings for every quantization table slot.) The principle
is the same as chrominance subsampling: since the human eye is more sensitive
to spatial changes in brightness than spatial changes in color, the chrominance
components can be quantized more than the luminance components without
incurring any visible image quality loss. However, unlike subsampling, this
feature reduces data in the frequency domain instead of the spatial domain,
which allows for more fine-grained control. This option is useful in
quality-sensitive applications, for which the artifacts generated by
subsampling may be unacceptable.
.PP
The \fB-quality\fR option accepts a comma-separated list of parameters, which
respectively refer to the quality levels which should be assigned to the
quantization table slots. If there are more q-table slots than parameters,
then the last parameter is replicated. Thus, if only one quality parameter is
given, this is used for both luminance and chrominance (slots 0 and 1,
respectively), preserving the legacy behavior of cjpeg v6b and prior.
More (or customized) quantization tables can be set with the \fB-qtables\fR
option and assigned to components with the \fB-qslots\fR option (see the
"wizard" switches below.)
.PP
JPEG files generated with separate luminance and chrominance quality are fully
compliant with standard JPEG decoders.
.PP
.BR CAUTION:
For this setting to be useful, be sure to pass an argument of \fB-sample 1x1\fR
to \fBcjpeg\fR to disable chrominance subsampling. Otherwise, the default
subsampling level (2x2, AKA "4:2:0") will be used.
.PP
The The
.B \-progressive .B \-progressive
switch creates a "progressive JPEG" file. In this type of JPEG file, the data switch creates a "progressive JPEG" file. In this type of JPEG file, the data
@@ -117,9 +147,6 @@ scan to display a low-quality image very quickly, and can then improve the
display with each subsequent scan. The final image is exactly equivalent to a display with each subsequent scan. The final image is exactly equivalent to a
standard JPEG file of the same quality setting, and the total file size is standard JPEG file of the same quality setting, and the total file size is
about the same --- often a little smaller. about the same --- often a little smaller.
.B Caution:
progressive JPEG is not yet widely implemented, so many decoders will be
unable to view a progressive JPEG file at all.
.PP .PP
Switches for advanced users: Switches for advanced users:
.TP .TP
@@ -187,6 +214,12 @@ visibly blur the image, however.
.PP .PP
Switches for wizards: Switches for wizards:
.TP .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 .B \-baseline
Force baseline-compatible quantization tables to be generated. This clamps Force baseline-compatible quantization tables to be generated. This clamps
quantization values to 8 bits even at low quality settings. (This switch is quantization values to 8 bits even at low quality settings. (This switch is
@@ -211,7 +244,7 @@ Use the scan script given in the specified text file.
.PP .PP
The "wizard" switches are intended for experimentation with JPEG. If you The "wizard" switches are intended for experimentation with JPEG. If you
don't know what you are doing, \fBdon't use them\fR. These switches are don't know what you are doing, \fBdon't use them\fR. These switches are
documented further in the file wizard.doc. documented further in the file wizard.txt.
.SH EXAMPLES .SH EXAMPLES
.LP .LP
This example compresses the PPM file foo.ppm with a quality factor of This example compresses the PPM file foo.ppm with a quality factor of
@@ -276,11 +309,10 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
.SH AUTHOR .SH AUTHOR
Independent JPEG Group Independent JPEG Group
.SH BUGS .SH BUGS
Arithmetic coding is not supported for legal reasons. Support for GIF input files was removed in cjpeg v6b due to concerns over
.PP the Unisys LZW patent. Although this patent expired in 2006, cjpeg still
GIF input files are no longer supported, to avoid the Unisys LZW patent. lacks GIF support, for these historical reasons. (Conversion of GIF files to
Use a Unisys-licensed program if you need to read a GIF file. (Conversion JPEG is usually a bad idea anyway.)
of GIF files to JPEG is usually a bad idea anyway.)
.PP .PP
Not all variants of BMP and Targa file formats are supported. Not all variants of BMP and Targa file formats are supported.
.PP .PP
@@ -288,5 +320,3 @@ The
.B \-targa .B \-targa
switch is not a bug, it's a feature. (It would be a bug if the Targa format switch is not a bug, it's a feature. (It would be a bug if the Targa format
designers had not been clueless.) designers had not been clueless.)
.PP
Still not as fast as we'd like.

35
cjpeg.c
View File

@@ -2,6 +2,8 @@
* cjpeg.c * cjpeg.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2008 by Guido Vollbeding.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -25,6 +27,7 @@
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "config.h"
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */
#ifdef __MWERKS__ #ifdef __MWERKS__
@@ -149,7 +152,7 @@ usage (void)
#endif #endif
fprintf(stderr, "Switches (names may be abbreviated):\n"); fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\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, " -grayscale Create monochrome JPEG file\n");
#ifdef ENTROPY_OPT_SUPPORTED #ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
@@ -209,21 +212,16 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
{ {
int argn; int argn;
char * arg; char * arg;
int quality; /* -quality parameter */
int q_scale_factor; /* scaling percentage for -qtables */
boolean force_baseline; boolean force_baseline;
boolean simple_progressive; boolean simple_progressive;
char * qualityarg = NULL; /* saves -quality parm if any */
char * qtablefile = NULL; /* saves -qtables filename if any */ char * qtablefile = NULL; /* saves -qtables filename if any */
char * qslotsarg = NULL; /* saves -qslots parm if any */ char * qslotsarg = NULL; /* saves -qslots parm if any */
char * samplearg = NULL; /* saves -sample parm if any */ char * samplearg = NULL; /* saves -sample parm if any */
char * scansarg = NULL; /* saves -scans parm if any */ char * scansarg = NULL; /* saves -scans parm if any */
/* Set up default JPEG parameters. */ /* Set up default JPEG parameters. */
/* Note that default -quality level need not, and does not,
* match the default scaling for an explicit -qtables argument.
*/
quality = 75; /* default -quality value */
q_scale_factor = 100; /* default to no scaling for -qtables */
force_baseline = FALSE; /* by default, allow 16-bit quantizers */ force_baseline = FALSE; /* by default, allow 16-bit quantizers */
simple_progressive = FALSE; simple_progressive = FALSE;
is_targa = FALSE; is_targa = FALSE;
@@ -277,7 +275,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
static boolean printed_version = FALSE; static boolean printed_version = FALSE;
if (! printed_version) { if (! printed_version) {
fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
fprintf(stderr, "%s\n\n", LJTCOPYRIGHT);
fprintf(stderr, "Based on Independent JPEG Group's libjpeg, version %s\n%s\n\n",
JVERSION, JCOPYRIGHT); JVERSION, JCOPYRIGHT);
printed_version = TRUE; printed_version = TRUE;
} }
@@ -328,13 +329,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
#endif #endif
} else if (keymatch(arg, "quality", 1)) { } else if (keymatch(arg, "quality", 1)) {
/* Quality factor (quantization table scaling factor). */ /* Quality ratings (quantization table scaling factors). */
if (++argn >= argc) /* advance to next argument */ if (++argn >= argc) /* advance to next argument */
usage(); usage();
if (sscanf(argv[argn], "%d", &quality) != 1) qualityarg = argv[argn];
usage();
/* Change scale factor in case -qtables is present. */
q_scale_factor = jpeg_quality_scaling(quality);
} else if (keymatch(arg, "qslots", 2)) { } else if (keymatch(arg, "qslots", 2)) {
/* Quantization table slot numbers. */ /* Quantization table slot numbers. */
@@ -382,7 +380,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
* default sampling factors. * default sampling factors.
*/ */
} else if (keymatch(arg, "scans", 2)) { } else if (keymatch(arg, "scans", 4)) {
/* Set scan script. */ /* Set scan script. */
#ifdef C_MULTISCAN_FILES_SUPPORTED #ifdef C_MULTISCAN_FILES_SUPPORTED
if (++argn >= argc) /* advance to next argument */ if (++argn >= argc) /* advance to next argument */
@@ -422,11 +420,12 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
/* Set quantization tables for selected quality. */ /* Set quantization tables for selected quality. */
/* Some or all may be overridden if -qtables is present. */ /* Some or all may be overridden if -qtables is present. */
jpeg_set_quality(cinfo, quality, force_baseline); if (qualityarg != NULL) /* process -quality if it was present */
if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
usage();
if (qtablefile != NULL) /* process -qtables if it was present */ if (qtablefile != NULL) /* process -qtables if it was present */
if (! read_quant_tables(cinfo, qtablefile, if (! read_quant_tables(cinfo, qtablefile, force_baseline))
q_scale_factor, force_baseline))
usage(); usage();
if (qslotsarg != NULL) /* process -qslots if it was present */ if (qslotsarg != NULL) /* process -qslots if it was present */

3
cmakescripts/getdate.bat Normal file
View File

@@ -0,0 +1,3 @@
@echo off
for /f "tokens=1-4 eol=/ DELIMS=/ " %%i in ('date /t') do set BUILD=%%l%%j%%k
echo %BUILD%

View File

@@ -103,7 +103,7 @@ should be in the common data structures.
4. Don't use static variables except for read-only constant tables. Variables 4. Don't use static variables except for read-only constant tables. Variables
that should be private to a module can be placed into private structures (see that should be private to a module can be placed into private structures (see
the system architecture document, structure.doc). the system architecture document, structure.txt).
5. Source file names should begin with "j" for files that are part of the 5. Source file names should begin with "j" for files that are part of the
library proper; source files that are not part of the library, such as cjpeg.c library proper; source files that are not part of the library, such as cjpeg.c

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.56]) AC_PREREQ([2.56])
AC_INIT([libjpeg-turbo], [1.0.1]) AC_INIT([libjpeg-turbo], [1.1.1])
BUILD=`date +%Y%m%d` BUILD=`date +%Y%m%d`
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2]) AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
@@ -13,10 +13,9 @@ AC_DEFINE([HAVE_PROTOTYPES], 1, [Define if your compiler supports prototypes])
# Checks for programs. # Checks for programs.
SAVED_CFLAGS=${CFLAGS} SAVED_CFLAGS=${CFLAGS}
SAVED_CXXFLAGS=${CXXFLAGS} SAVED_CPPFLAGS=${CPPFLAGS}
AC_PROG_CPP AC_PROG_CPP
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_PROG_LN_S AC_PROG_LN_S
@@ -28,33 +27,12 @@ AC_MSG_RESULT(yes),
[AC_MSG_RESULT(no) [AC_MSG_RESULT(no)
AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])]) AC_DEFINE([INCOMPLETE_TYPES_BROKEN],[1],[Compiler does not support pointers to undefined structures.])])
AC_MSG_CHECKING([whether the linker supports version scripts])
VERSION_SCRIPT=no
LDVER=`$LD --help </dev/null 2>&1 | grep "\-\-version-script"`
if test "$LDVER"; then
VERSION_SCRIPT=yes
VERSION_SCRIPT_FLAG=-Wl,--version-script,
AC_MSG_RESULT(yes)
else
LDVER=`$LD --help </dev/null 2>&1 | grep "\-M"`
if test "$LDVER"; then
VERSION_SCRIPT=yes
VERSION_SCRIPT_FLAG=-Wl,-M,
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
AC_SUBST(VERSION_SCRIPT_FLAG)
if test "x${GCC}" = "xyes"; then if test "x${GCC}" = "xyes"; then
if test "x${SAVED_CFLAGS}" = "x"; then if test "x${SAVED_CFLAGS}" = "x"; then
CFLAGS=-O3 CFLAGS=-O3
fi fi
if test "x${SAVED_CXXFLAGS}" = "x"; then if test "x${SAVED_CPPFLAGS}" = "x"; then
CXXFLAGS=-O3 CPPFLAGS=-Wall
fi fi
fi fi
@@ -63,9 +41,6 @@ if test "x${SUNCC}" = "xyes"; then
if test "x${SAVED_CFLAGS}" = "x"; then if test "x${SAVED_CFLAGS}" = "x"; then
CFLAGS=-xO5 CFLAGS=-xO5
fi fi
if test "x${SAVED_CXXFLAGS}" = "x"; then
CXXFLAGS=-xO5
fi
fi fi
# Checks for libraries. # Checks for libraries.
@@ -123,17 +98,107 @@ AC_CHECK_FUNCS([memset memcpy], [],
[AC_DEFINE([NEED_BSD_STRINGS], 1, [AC_DEFINE([NEED_BSD_STRINGS], 1,
[Define if you have BSD-like bzero and bcopy])]) [Define if you have BSD-like bzero and bcopy])])
# Set flags to indicate platform AC_MSG_CHECKING([libjpeg API version])
case "$host_os" in AC_ARG_VAR(JPEG_LIB_VERSION, [libjpeg API version (62, 70, or 80)])
cygwin* | mingw* | pw32* | interix*) if test "x$JPEG_LIB_VERSION" = "x"; then
is_win32=1 AC_ARG_WITH([jpeg7],
;; AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
esac AC_ARG_WITH([jpeg8],
AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "x1"]) AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
if test "x${with_jpeg8}" = "xyes"; then
JPEG_LIB_VERSION=80
else
if test "x${with_jpeg7}" = "xyes"; then
JPEG_LIB_VERSION=70
else
JPEG_LIB_VERSION=62
fi
fi
fi
JPEG_LIB_VERSION_DECIMAL=`expr $JPEG_LIB_VERSION / 10`.`expr $JPEG_LIB_VERSION % 10`
AC_SUBST(JPEG_LIB_VERSION_DECIMAL)
AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL])
AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version])
AC_MSG_CHECKING([libjpeg shared library version])
AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)])
AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)])
if test "x$SO_MAJOR_VERSION" = "x"; then
case "$JPEG_LIB_VERSION" in
62) SO_MAJOR_VERSION=$JPEG_LIB_VERSION ;;
*) SO_MAJOR_VERSION=`expr $JPEG_LIB_VERSION / 10` ;;
esac
fi
if test "x$SO_MINOR_VERSION" = "x"; then
case "$JPEG_LIB_VERSION" in
80) SO_MINOR_VERSION=2 ;;
*) SO_MINOR_VERSION=0 ;;
esac
fi
AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION])
AC_SUBST(SO_MAJOR_VERSION)
AC_SUBST(SO_MINOR_VERSION)
VERSION_SCRIPT=yes
AC_ARG_ENABLE([ld-version-script],
AS_HELP_STRING([--disable-ld-version-script],
[Disable linker version script for libjpeg-turbo (default is to use linker version script if the linker supports it)]),
[VERSION_SCRIPT=$enableval], [])
AC_MSG_CHECKING([whether the linker supports version scripts])
SAVED_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.map"
cat > conftest.map <<EOF
VERS_1 {
global: *;
};
EOF
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
[VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
if test "x$VERSION_SCRIPT_FLAG" = "x"; then
LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
[VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
fi
if test "x$VERSION_SCRIPT_FLAG" = "x"; then
VERSION_SCRIPT=no
AC_MSG_RESULT(no)
fi
LDFLAGS="$SAVED_LDFLAGS"
AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
AC_MSG_RESULT($VERSION_SCRIPT)
AM_CONDITIONAL(VERSION_SCRIPT, test "x$VERSION_SCRIPT" = "xyes")
AC_SUBST(VERSION_SCRIPT_FLAG)
AC_MSG_CHECKING([whether to include arithmetic encoding support])
AC_ARG_WITH([arith-enc],
AC_HELP_STRING([--without-arith-enc], [Omit arithmetic encoding support]))
if test "x$with_arith_enc" = "xno"; then
AC_MSG_RESULT(no)
else
AC_DEFINE([C_ARITH_CODING_SUPPORTED], [1], [Support arithmetic encoding])
AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL([WITH_ARITH_ENC], [test "x$with_arith_enc" != "xno"])
AC_MSG_CHECKING([whether to include arithmetic decoding support])
AC_ARG_WITH([arith-dec],
AC_HELP_STRING([--without-arith-dec], [Omit arithmetic decoding support]))
if test "x$with_arith_dec" = "xno"; then
AC_MSG_RESULT(no)
else
AC_DEFINE([D_ARITH_CODING_SUPPORTED], [1], [Support arithmetic decoding])
AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL([WITH_ARITH_DEC], [test "x$with_arith_dec" != "xno"])
AM_CONDITIONAL([WITH_ARITH], [test "x$with_arith_dec" != "xno" -o "x$with_arith_enc" != "xno"])
# SIMD is optional # SIMD is optional
AC_ARG_WITH([simd], AC_ARG_WITH([simd],
AC_HELP_STRING([--without-simd],[Omit accelerated SIMD routines.])) AC_HELP_STRING([--without-simd],[Omit SIMD extensions.]))
if test "x${with_simd}" != "xno"; then if test "x${with_simd}" != "xno"; then
# Check if we're on a supported CPU # Check if we're on a supported CPU
AC_MSG_CHECKING([if we have SIMD optimisations for cpu type]) AC_MSG_CHECKING([if we have SIMD optimisations for cpu type])
@@ -179,6 +244,7 @@ esac
AC_SUBST(RPMARCH) AC_SUBST(RPMARCH)
AC_SUBST(DEBARCH) AC_SUBST(DEBARCH)
AC_SUBST(BUILD) AC_SUBST(BUILD)
AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
# jconfig.h is the file we use, but we have another before that to # jconfig.h is the file we use, but we have another before that to
# fool autoheader. the reason is that we include this header in our # fool autoheader. the reason is that we include this header in our
@@ -186,5 +252,16 @@ AC_SUBST(BUILD)
# jconfig.h is a minimal version that allows this package to be built # jconfig.h is a minimal version that allows this package to be built
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([jconfig.h]) AC_CONFIG_HEADERS([jconfig.h])
AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
AC_CONFIG_FILES([pkgscripts/makecygwinpkg:release/makecygwinpkg.in])
AC_CONFIG_FILES([pkgscripts/makedpkg:release/makedpkg.in])
AC_CONFIG_FILES([pkgscripts/deb-control:release/deb-control.in])
AC_CONFIG_FILES([pkgscripts/makemacpkg:release/makemacpkg.in])
AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
AC_CONFIG_FILES([pkgscripts/uninstall:release/uninstall.in])
AC_CONFIG_FILES([pkgscripts/makesunpkg:release/makesunpkg.in])
AC_CONFIG_FILES([pkgscripts/pkginfo:release/pkginfo.in])
AC_CONFIG_FILES([libjpeg.map])
AC_CONFIG_FILES([Makefile simd/Makefile]) AC_CONFIG_FILES([Makefile simd/Makefile])
AC_OUTPUT AC_OUTPUT

View File

@@ -1,4 +1,4 @@
.TH DJPEG 1 "22 August 1997" .TH DJPEG 1 "11 October 2010"
.SH NAME .SH NAME
djpeg \- decompress a JPEG file to an image file djpeg \- decompress a JPEG file to an image file
.SH SYNOPSIS .SH SYNOPSIS
@@ -243,11 +243,7 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
.SH AUTHOR .SH AUTHOR
Independent JPEG Group Independent JPEG Group
.SH BUGS .SH BUGS
Arithmetic coding is not supported for legal reasons.
.PP
To avoid the Unisys LZW patent, To avoid the Unisys LZW patent,
.B djpeg .B djpeg
produces uncompressed GIF files. These are larger than they should be, but produces uncompressed GIF files. These are larger than they should be, but
are readable by standard GIF decoders. are readable by standard GIF decoders.
.PP
Still not as fast as we'd like.

View File

@@ -2,6 +2,7 @@
* djpeg.c * djpeg.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -25,6 +26,7 @@
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "config.h"
#include <ctype.h> /* to declare isprint() */ #include <ctype.h> /* to declare isprint() */
@@ -240,7 +242,10 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
static boolean printed_version = FALSE; static boolean printed_version = FALSE;
if (! printed_version) { if (! printed_version) {
fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
fprintf(stderr, "%s\n\n", LJTCOPYRIGHT);
fprintf(stderr, "Based on Independent JPEG Group's libjpeg, version %s\n%s\n\n",
JVERSION, JCOPYRIGHT); JVERSION, JCOPYRIGHT);
printed_version = TRUE; printed_version = TRUE;
} }
@@ -455,7 +460,7 @@ main (int argc, char **argv)
* APP12 is used by some digital camera makers for textual info, * APP12 is used by some digital camera makers for textual info,
* so we provide the ability to display it as text. * so we provide the ability to display it as text.
* If you like, additional APPn marker types can be selected for display, * 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_COM, print_text_marker);
jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);

View File

@@ -3,7 +3,7 @@
* *
* This file illustrates how to use the IJG code as a subroutine library * This file illustrates how to use the IJG code as a subroutine library
* to read or write JPEG image files. You should look at this code in * to read or write JPEG image files. You should look at this code in
* conjunction with the documentation file libjpeg.doc. * conjunction with the documentation file libjpeg.txt.
* *
* This code will not do anything useful as-is, but it may be helpful as a * This code will not do anything useful as-is, but it may be helpful as a
* skeleton for constructing routines that call the JPEG library. * skeleton for constructing routines that call the JPEG library.
@@ -196,7 +196,7 @@ write_JPEG_file (char * filename, int quality)
* files for anything that doesn't fit within the maximum-memory setting. * files for anything that doesn't fit within the maximum-memory setting.
* (Note that temp files are NOT needed if you use the default parameters.) * (Note that temp files are NOT needed if you use the default parameters.)
* On some systems you may need to set up a signal handler to ensure that * On some systems you may need to set up a signal handler to ensure that
* temporary files are deleted if the program is interrupted. See libjpeg.doc. * temporary files are deleted if the program is interrupted. See libjpeg.txt.
* *
* Scanlines MUST be supplied in top-to-bottom order if you want your JPEG * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG
* files to be compatible with everyone else's. If you cannot readily read * files to be compatible with everyone else's. If you cannot readily read
@@ -335,7 +335,7 @@ read_JPEG_file (char * filename)
/* We can ignore the return value from jpeg_read_header since /* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and * (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error. * (b) we passed TRUE to reject a tables-only JPEG file as an error.
* See libjpeg.doc for more info. * See libjpeg.txt for more info.
*/ */
/* Step 4: set parameters for decompression */ /* Step 4: set parameters for decompression */
@@ -413,14 +413,14 @@ read_JPEG_file (char * filename)
* In the above code, we ignored the return value of jpeg_read_scanlines, * In the above code, we ignored the return value of jpeg_read_scanlines,
* which is the number of scanlines actually read. We could get away with * which is the number of scanlines actually read. We could get away with
* this because we asked for only one line at a time and we weren't using * this because we asked for only one line at a time and we weren't using
* a suspending data source. See libjpeg.doc for more info. * a suspending data source. See libjpeg.txt for more info.
* *
* We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress();
* we should have done it beforehand to ensure that the space would be * we should have done it beforehand to ensure that the space would be
* counted against the JPEG max_memory setting. In some systems the above * counted against the JPEG max_memory setting. In some systems the above
* code would risk an out-of-memory error. However, in general we don't * code would risk an out-of-memory error. However, in general we don't
* know the output image dimensions before jpeg_start_decompress(), unless we * know the output image dimensions before jpeg_start_decompress(), unless we
* call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. * call jpeg_calc_output_dimensions(). See libjpeg.txt for more about this.
* *
* Scanlines are returned in the same order as they appear in the JPEG file, * Scanlines are returned in the same order as they appear in the JPEG file,
* which is standardly top-to-bottom. If you must emit data bottom-to-top, * which is standardly top-to-bottom. If you must emit data bottom-to-top,
@@ -429,5 +429,5 @@ read_JPEG_file (char * filename)
* *
* As with compression, some operating modes may require temporary files. * As with compression, some operating modes may require temporary files.
* On some systems you may need to set up a signal handler to ensure that * On some systems you may need to set up a signal handler to ensure that
* temporary files are deleted if the program is interrupted. See libjpeg.doc. * temporary files are deleted if the program is interrupted. See libjpeg.txt.
*/ */

View File

@@ -1,6 +1,6 @@
IJG JPEG LIBRARY: FILE LIST IJG JPEG LIBRARY: FILE LIST
Copyright (C) 1994-1998, Thomas G. Lane. Copyright (C) 1994-2010, Thomas G. Lane, Guido Vollbeding, D. R. Commander.
This file is part of the Independent JPEG Group's software. This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file. For conditions of distribution and use, see the accompanying README file.
@@ -74,8 +74,9 @@ jfdctfst.c Forward DCT using faster, less accurate integer method.
jfdctflt.c Forward DCT using floating-point arithmetic. jfdctflt.c Forward DCT using floating-point arithmetic.
jchuff.c Huffman entropy coding for sequential JPEG. jchuff.c Huffman entropy coding for sequential JPEG.
jcphuff.c Huffman entropy coding for progressive JPEG. jcphuff.c Huffman entropy coding for progressive JPEG.
jcarith.c Arithmetic entropy coding.
jcmarker.c JPEG marker writing. jcmarker.c JPEG marker writing.
jdatadst.c Data destination manager for stdio output. jdatadst.c Data destination managers for memory and stdio output.
Decompression side of the library: Decompression side of the library:
@@ -87,6 +88,7 @@ jdpostct.c Postprocessor buffer controller.
jdmarker.c JPEG marker reading. jdmarker.c JPEG marker reading.
jdhuff.c Huffman entropy decoding for sequential JPEG. jdhuff.c Huffman entropy decoding for sequential JPEG.
jdphuff.c Huffman entropy decoding for progressive JPEG. jdphuff.c Huffman entropy decoding for progressive JPEG.
jdarith.c Arithmetic entropy decoding.
jddctmgr.c IDCT manager (IDCT implementation selection & control). jddctmgr.c IDCT manager (IDCT implementation selection & control).
jidctint.c Inverse DCT using slow-but-accurate integer method. jidctint.c Inverse DCT using slow-but-accurate integer method.
jidctfst.c Inverse DCT using faster, less accurate integer method. jidctfst.c Inverse DCT using faster, less accurate integer method.
@@ -98,10 +100,12 @@ jdmerge.c Merged upsampling/color conversion (faster, lower quality).
jquant1.c One-pass color quantization using a fixed-spacing colormap. jquant1.c One-pass color quantization using a fixed-spacing colormap.
jquant2.c Two-pass color quantization using a custom-generated colormap. jquant2.c Two-pass color quantization using a custom-generated colormap.
Also handles one-pass quantization to an externally given map. Also handles one-pass quantization to an externally given map.
jdatasrc.c Data source manager for stdio input. jdatasrc.c Data source managers for memory and stdio input.
Support files for both compression and decompression: Support files for both compression and decompression:
jaricom.c Tables for common use in arithmetic entropy encoding and
decoding routines.
jerror.c Standard error handling routines (application replaceable). jerror.c Standard error handling routines (application replaceable).
jmemmgr.c System-independent (more or less) memory management code. jmemmgr.c System-independent (more or less) memory management code.
jutils.c Miscellaneous utility routines. jutils.c Miscellaneous utility routines.
@@ -118,7 +122,7 @@ jmemdos.c Custom implementation for MS-DOS (16-bit environment only):
jmemmac.c Custom implementation for Apple Macintosh. jmemmac.c Custom implementation for Apple Macintosh.
Exactly one of the system-dependent modules should be configured into an Exactly one of the system-dependent modules should be configured into an
installed JPEG library (see install.doc for hints about which one to use). installed JPEG library (see install.txt for hints about which one to use).
On unusual systems you may find it worthwhile to make a special On unusual systems you may find it worthwhile to make a special
system-dependent memory manager. system-dependent memory manager.
@@ -184,27 +188,27 @@ ADDITIONAL FILES
Documentation (see README for a guide to the documentation files): Documentation (see README for a guide to the documentation files):
README Master documentation file. README Master documentation file.
*.doc Other documentation files. *.txt Other documentation files.
*.1 Documentation in Unix man page format. *.1 Documentation in Unix man page format.
change.log Version-to-version change highlights. change.log Version-to-version change highlights.
example.c Sample code for calling JPEG library. example.c Sample code for calling JPEG library.
Configuration/installation files and programs (see install.doc for more info): Configuration/installation files and programs (see install.txt for more info):
configure Unix shell script to perform automatic configuration. configure Unix shell script to perform automatic configuration.
ltconfig Support scripts for configure (from GNU libtool). configure.ac Source file for use with Autoconf to generate configure.
ltmain.sh ltmain.sh Support scripts for configure (from GNU libtool).
config.guess config.guess
config.sub config.sub
depcomp
missing
install-sh Install shell script for those Unix systems lacking one. install-sh Install shell script for those Unix systems lacking one.
ckconfig.c Program to generate jconfig.h on non-Unix systems. Makefile.in Makefile input for configure.
jconfig.doc Template for making jconfig.h by hand. Makefile.am Source file for use with Automake to generate Makefile.in.
makefile.* Sample makefiles for particular systems. jconfig.txt Template for making jconfig.h by hand.
jconfig.* Sample jconfig.h for particular systems. 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.doc for test procedure): Test files (see install.txt for test procedure):
test*.* Source and comparison files for confidence test. test*.* Source and comparison files for confidence test.
These are binary image files, NOT text files. These are binary image files, NOT text files.

View File

@@ -1,6 +1,6 @@
INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software
Copyright (C) 1991-1998, Thomas G. Lane. Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
This file is part of the Independent JPEG Group's software. This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file. For conditions of distribution and use, see the accompanying README file.
@@ -94,18 +94,13 @@ Configure was created with GNU Autoconf and it follows the usual conventions
for GNU configure scripts. It makes a few assumptions that you may want to for GNU configure scripts. It makes a few assumptions that you may want to
override. You can do this by providing optional switches to configure: override. You can do this by providing optional switches to configure:
* If you want to build libjpeg as a shared library, say * Configure will build both static and shared libraries, if possible.
./configure --enable-shared If you want to build libjpeg only as a static library, say
To get both shared and static libraries, say ./configure --disable-shared
./configure --enable-shared --enable-static If you want to build libjpeg only as a shared library, say
Note that these switches invoke GNU libtool to take care of system-dependent ./configure --disable-static
shared library building methods. If things don't work this way, please try Configure uses GNU libtool to take care of system-dependent shared library
running configure without either switch; that should build a static library building methods.
without using libtool. If that works, your problem is probably with libtool
not with the IJG code. libtool is fairly new and doesn't support all flavors
of Unix yet. (You might be able to find a newer version of libtool than the
one included with libjpeg; see ftp.gnu.org. Report libtool problems to
bug-libtool@gnu.org.)
* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. * Configure will use gcc (GNU C compiler) if it's available, otherwise cc.
To force a particular compiler to be selected, use the CC option, for example To force a particular compiler to be selected, use the CC option, for example
@@ -115,10 +110,10 @@ For example, on HP-UX you probably want to say
./configure CC='cc -Aa' ./configure CC='cc -Aa'
to get HP's compiler to run in ANSI mode. to get HP's compiler to run in ANSI mode.
* The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc. * The default CFLAGS setting is "-g" for non-gcc compilers, "-g -O2" for gcc.
You can override this by saying, for example, You can override this by saying, for example,
./configure CFLAGS='-g' ./configure CFLAGS='-O2'
if you want to compile with debugging support. if you want to compile without debugging support.
* Configure will set up the makefile so that "make install" will install files * Configure will set up the makefile so that "make install" will install files
into /usr/local/bin, /usr/local/man, etc. You can specify an installation into /usr/local/bin, /usr/local/man, etc. You can specify an installation
@@ -153,7 +148,8 @@ 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.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only)
makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C
makefile.vc jconfig.vc Windows NT/95, MS Visual C++ makefile.vc jconfig.vc Windows NT/95, MS Visual C++
make*.ds jconfig.vc Windows NT/95, MS Developer Studio make*.vc6 jconfig.vc Windows NT/95, MS Visual C++ 6
make*.v10 jconfig.vc Windows NT/95, MS Visual C++ 2010 (v10)
makefile.mms jconfig.vms Digital VMS, with MMS software makefile.mms jconfig.vms Digital VMS, with MMS software
makefile.vms jconfig.vms Digital VMS, without MMS software makefile.vms jconfig.vms Digital VMS, without MMS software
@@ -166,8 +162,8 @@ Configuring the software by hand
-------------------------------- --------------------------------
First, generate a jconfig.h file. If you are moderately familiar with C, First, generate a jconfig.h file. If you are moderately familiar with C,
the comments in jconfig.doc should be enough information to do this; just the comments in jconfig.txt should be enough information to do this; just
copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may copy jconfig.txt to jconfig.h and edit it appropriately. Otherwise, you may
prefer to use the ckconfig.c program. You will need to compile and execute prefer to use the ckconfig.c program. You will need to compile and execute
ckconfig.c by hand --- we hope you know at least enough to do that. ckconfig.c by hand --- we hope you know at least enough to do that.
ckconfig.c may not compile the first try (in fact, the whole idea is for it ckconfig.c may not compile the first try (in fact, the whole idea is for it
@@ -447,8 +443,8 @@ on our to-do list.)
The PPM reader (rdppm.c) can read 12-bit data from either text-format or 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 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, LSB first maxval greater than 255 are assumed to use 2 bytes per sample, MSB first
(little-endian order). As of early 1995, 2-byte binary format is not (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 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 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 read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming
@@ -521,7 +517,7 @@ that float DCT results may vary slightly across machines.) To do that, add
"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change "#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change
the default, you should redefine JDCT_FASTEST, which is the method selected the default, you should redefine JDCT_FASTEST, which is the method selected
by djpeg's -fast switch. Don't forget to update the documentation files by djpeg's -fast switch. Don't forget to update the documentation files
(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. (usage.txt and/or cjpeg.1, djpeg.1) to agree with what you've done.
If access to "short" arrays is slow on your machine, it may be a win to If access to "short" arrays is slow on your machine, it may be a win to
define type JCOEF as int rather than short. This will cost a good deal of define type JCOEF as int rather than short. This will cost a good deal of
@@ -538,17 +534,17 @@ In general, it's worth trying the maximum optimization level of your compiler,
and experimenting with any optional optimizations such as loop unrolling. and experimenting with any optional optimizations such as loop unrolling.
(Unfortunately, far too many compilers have optimizer bugs ... be prepared to (Unfortunately, far too many compilers have optimizer bugs ... be prepared to
back off if the code fails self-test.) If you do any experimentation along back off if the code fails self-test.) If you do any experimentation along
these lines, please report the optimal settings to jpeg-info@uunet.uu.net so these lines, please report the optimal settings to jpeg-info@uc.ag so we
we can mention them in future releases. Be sure to specify your machine and can mention them in future releases. Be sure to specify your machine
compiler version. and compiler version.
HINTS FOR SPECIFIC SYSTEMS HINTS FOR SPECIFIC SYSTEMS
========================== ==========================
We welcome reports on changes needed for systems not mentioned here. Submit We welcome reports on changes needed for systems not mentioned here. Submit
'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong 'em to jpeg-info@uc.ag. Also, if configure or ckconfig.c is wrong about how
about how to configure the JPEG software for your system, please let us know. to configure the JPEG software for your system, please let us know.
Acorn RISC OS: Acorn RISC OS:
@@ -568,7 +564,7 @@ Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the
lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h'
dependency section. dependency section.
Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE Copy jconfig.txt to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE
and CHAR_IS_UNSIGNED. and CHAR_IS_UNSIGNED.
Run the makefile using !AMU not !Make. If you want to use the 'clean' and Run the makefile using !AMU not !Make. If you want to use the 'clean' and
@@ -587,7 +583,7 @@ manager, with temporary files being created on the device named by
Atari ST/STE/TT: Atari ST/STE/TT:
Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st
to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The
project files should work as-is with Pure C. For Turbo C, change library project files should work as-is with Pure C. For Turbo C, change library
@@ -610,7 +606,8 @@ or jpegtran.ttp. You'll have to perform the self-test by hand.
We haven't bothered to include project files for rdjpgcom and wrjpgcom. We haven't bothered to include project files for rdjpgcom and wrjpgcom.
Those source files should just be compiled by themselves; they don't Those source files should just be compiled by themselves; they don't
depend on the JPEG library. depend on the JPEG library. You can use the default.prj project file
of the Pure C distribution to make the programs.
There is a bug in some older versions of the Turbo C library which causes the There is a bug in some older versions of the Turbo C library which causes the
space used by temporary files created with "tmpfile()" not to be freed after space used by temporary files created with "tmpfile()" not to be freed after
@@ -872,6 +869,7 @@ Since jmorecfg.h tries to define FAR as empty, you may get a compiler
warning if you include both jpeglib.h and windef.h (which windows.h warning if you include both jpeglib.h and windef.h (which windows.h
includes). To suppress the warning, you can put "#ifndef FAR"/"#endif" includes). To suppress the warning, you can put "#ifndef FAR"/"#endif"
around the line "#define FAR" in jmorecfg.h. around the line "#define FAR" in jmorecfg.h.
(Something like this is already in jmorecfg.h, by the way.)
When using the library in a Windows application, you will almost certainly When using the library in a Windows application, you will almost certainly
want to modify or replace the error handler module jerror.c, since our want to modify or replace the error handler module jerror.c, since our
@@ -890,7 +888,7 @@ jconfig.h to enable it.)
The proper solution for problem 2 is to return control to your calling The proper solution for problem 2 is to return control to your calling
application after a library error. This can be done with the setjmp/longjmp application after a library error. This can be done with the setjmp/longjmp
technique discussed in libjpeg.doc and illustrated in example.c. (NOTE: technique discussed in libjpeg.txt and illustrated in example.c. (NOTE:
some older Windows C compilers provide versions of setjmp/longjmp that some older Windows C compilers provide versions of setjmp/longjmp that
don't actually work under Windows. You may need to use the Windows system don't actually work under Windows. You may need to use the Windows system
functions Catch and Throw instead.) functions Catch and Throw instead.)
@@ -1000,32 +998,67 @@ model. makefile.vc is intended for command-line use. (If you are using
the Developer Studio environment, you may prefer the DevStudio project the Developer Studio environment, you may prefer the DevStudio project
files; see below.) files; see below.)
Some users feel that it's easier to call the library from C++ code if you IJG JPEG 7 adds extern "C" to jpeglib.h. This avoids the need to put
force VC++ to treat the library as C++ code, which you can do by renaming extern "C" { ... } around #include "jpeglib.h" in your C++ application.
all the *.c files to *.cpp (and adjusting the makefile to match). This You can also force VC++ to treat the library as C++ code by renaming
avoids the need to put extern "C" { ... } around #include "jpeglib.h" in all the *.c files to *.cpp (and adjusting the makefile to match).
your C++ application. In this case you also need to define the symbol DONT_USE_EXTERN_C in
the configuration to prevent jpeglib.h from using extern "C".
Microsoft Windows, Microsoft Developer Studio: Microsoft Windows, Microsoft Visual C++ 6 Developer Studio:
We include makefiles that should work as project files in DevStudio 4.2 or 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 later. There is a library makefile that builds the IJG library as a static
Win32 library, and an application makefile that builds the sample applications Win32 library, and application makefiles that build the sample applications
as Win32 console applications. (Even if you only want the library, we as Win32 console applications. (Even if you only want the library, we
recommend building the applications so that you can run the self-test.) recommend building the applications so that you can run the self-test.)
To use: To use:
1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and 1. Open the command prompt, change to the main directory and execute the
makeapps.ds to apps.mak. (Note that the renaming is critical!) command line
2. Click on the .mak files to construct project workspaces. NMAKE /f makefile.vc setup-vc6
(If you are using DevStudio more recent than 4.2, you'll probably This will move jconfig.vc to jconfig.h and makefiles to project files.
get a message saying that the makefiles are being updated.) (Note that the renaming is critical!)
3. Build the library project, then the applications project. 2. Open the workspace file jpeg.dsw, build the library project.
4. Move the application .exe files from `app`\Release to an (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. Open the workspace file apps.dsw, build the application projects.
4. To perform the self-test, execute the command line
NMAKE /f makefile.vc test-build
5. Move the application .exe files from `app`\Release to an
appropriate location on your path. 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++ 2010 Developer Studio (v10):
We include makefiles that should work as project files in Visual Studio
2010 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. Open the command prompt, change to the main directory and execute the
command line
NMAKE /f makefile.vc setup-v10
This will move jconfig.vc to jconfig.h and makefiles to project files.
(Note that the renaming is critical!)
2. Open the solution file jpeg.sln, build the library project.
(If you are using Visual Studio more recent than 2010 (v10), you'll
probably get a message saying that the project files are being updated.)
3. Open the solution file apps.sln, build the application projects.
4. To perform the self-test, execute the command line
NMAKE /f makefile.vc test-build
5. Move the application .exe files from `app`\Release to an
appropriate location on your path.
Note:
There seems to be an optimization bug in the compiler which causes the
self-test to fail with the color quantization option.
We have disabled optimization for the file jquant2.c in the library
project file which causes the self-test to pass properly.
OS/2, Borland C++: OS/2, Borland C++:

153
jaricom.c Normal file
View File

@@ -0,0 +1,153 @@
/*
* jaricom.c
*
* Developed 1997-2009 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).
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* The following #define specifies the packing of the four components
* into the compact INT32 representation.
* Note that this formula must match the actual arithmetic encoder
* and decoder implementation. The implementation has to be changed
* if this formula is changed.
* The current organization is leaned on Markus Kuhn's JBIG
* implementation (jbig_tab.c).
*/
#define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b)
const INT32 jpeg_aritab[113+1] = {
/*
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
*/
V( 0, 0x5a1d, 1, 1, 1 ),
V( 1, 0x2586, 14, 2, 0 ),
V( 2, 0x1114, 16, 3, 0 ),
V( 3, 0x080b, 18, 4, 0 ),
V( 4, 0x03d8, 20, 5, 0 ),
V( 5, 0x01da, 23, 6, 0 ),
V( 6, 0x00e5, 25, 7, 0 ),
V( 7, 0x006f, 28, 8, 0 ),
V( 8, 0x0036, 30, 9, 0 ),
V( 9, 0x001a, 33, 10, 0 ),
V( 10, 0x000d, 35, 11, 0 ),
V( 11, 0x0006, 9, 12, 0 ),
V( 12, 0x0003, 10, 13, 0 ),
V( 13, 0x0001, 12, 13, 0 ),
V( 14, 0x5a7f, 15, 15, 1 ),
V( 15, 0x3f25, 36, 16, 0 ),
V( 16, 0x2cf2, 38, 17, 0 ),
V( 17, 0x207c, 39, 18, 0 ),
V( 18, 0x17b9, 40, 19, 0 ),
V( 19, 0x1182, 42, 20, 0 ),
V( 20, 0x0cef, 43, 21, 0 ),
V( 21, 0x09a1, 45, 22, 0 ),
V( 22, 0x072f, 46, 23, 0 ),
V( 23, 0x055c, 48, 24, 0 ),
V( 24, 0x0406, 49, 25, 0 ),
V( 25, 0x0303, 51, 26, 0 ),
V( 26, 0x0240, 52, 27, 0 ),
V( 27, 0x01b1, 54, 28, 0 ),
V( 28, 0x0144, 56, 29, 0 ),
V( 29, 0x00f5, 57, 30, 0 ),
V( 30, 0x00b7, 59, 31, 0 ),
V( 31, 0x008a, 60, 32, 0 ),
V( 32, 0x0068, 62, 33, 0 ),
V( 33, 0x004e, 63, 34, 0 ),
V( 34, 0x003b, 32, 35, 0 ),
V( 35, 0x002c, 33, 9, 0 ),
V( 36, 0x5ae1, 37, 37, 1 ),
V( 37, 0x484c, 64, 38, 0 ),
V( 38, 0x3a0d, 65, 39, 0 ),
V( 39, 0x2ef1, 67, 40, 0 ),
V( 40, 0x261f, 68, 41, 0 ),
V( 41, 0x1f33, 69, 42, 0 ),
V( 42, 0x19a8, 70, 43, 0 ),
V( 43, 0x1518, 72, 44, 0 ),
V( 44, 0x1177, 73, 45, 0 ),
V( 45, 0x0e74, 74, 46, 0 ),
V( 46, 0x0bfb, 75, 47, 0 ),
V( 47, 0x09f8, 77, 48, 0 ),
V( 48, 0x0861, 78, 49, 0 ),
V( 49, 0x0706, 79, 50, 0 ),
V( 50, 0x05cd, 48, 51, 0 ),
V( 51, 0x04de, 50, 52, 0 ),
V( 52, 0x040f, 50, 53, 0 ),
V( 53, 0x0363, 51, 54, 0 ),
V( 54, 0x02d4, 52, 55, 0 ),
V( 55, 0x025c, 53, 56, 0 ),
V( 56, 0x01f8, 54, 57, 0 ),
V( 57, 0x01a4, 55, 58, 0 ),
V( 58, 0x0160, 56, 59, 0 ),
V( 59, 0x0125, 57, 60, 0 ),
V( 60, 0x00f6, 58, 61, 0 ),
V( 61, 0x00cb, 59, 62, 0 ),
V( 62, 0x00ab, 61, 63, 0 ),
V( 63, 0x008f, 61, 32, 0 ),
V( 64, 0x5b12, 65, 65, 1 ),
V( 65, 0x4d04, 80, 66, 0 ),
V( 66, 0x412c, 81, 67, 0 ),
V( 67, 0x37d8, 82, 68, 0 ),
V( 68, 0x2fe8, 83, 69, 0 ),
V( 69, 0x293c, 84, 70, 0 ),
V( 70, 0x2379, 86, 71, 0 ),
V( 71, 0x1edf, 87, 72, 0 ),
V( 72, 0x1aa9, 87, 73, 0 ),
V( 73, 0x174e, 72, 74, 0 ),
V( 74, 0x1424, 72, 75, 0 ),
V( 75, 0x119c, 74, 76, 0 ),
V( 76, 0x0f6b, 74, 77, 0 ),
V( 77, 0x0d51, 75, 78, 0 ),
V( 78, 0x0bb6, 77, 79, 0 ),
V( 79, 0x0a40, 77, 48, 0 ),
V( 80, 0x5832, 80, 81, 1 ),
V( 81, 0x4d1c, 88, 82, 0 ),
V( 82, 0x438e, 89, 83, 0 ),
V( 83, 0x3bdd, 90, 84, 0 ),
V( 84, 0x34ee, 91, 85, 0 ),
V( 85, 0x2eae, 92, 86, 0 ),
V( 86, 0x299a, 93, 87, 0 ),
V( 87, 0x2516, 86, 71, 0 ),
V( 88, 0x5570, 88, 89, 1 ),
V( 89, 0x4ca9, 95, 90, 0 ),
V( 90, 0x44d9, 96, 91, 0 ),
V( 91, 0x3e22, 97, 92, 0 ),
V( 92, 0x3824, 99, 93, 0 ),
V( 93, 0x32b4, 99, 94, 0 ),
V( 94, 0x2e17, 93, 86, 0 ),
V( 95, 0x56a8, 95, 96, 1 ),
V( 96, 0x4f46, 101, 97, 0 ),
V( 97, 0x47e5, 102, 98, 0 ),
V( 98, 0x41cf, 103, 99, 0 ),
V( 99, 0x3c3d, 104, 100, 0 ),
V( 100, 0x375e, 99, 93, 0 ),
V( 101, 0x5231, 105, 102, 0 ),
V( 102, 0x4c0f, 106, 103, 0 ),
V( 103, 0x4639, 107, 104, 0 ),
V( 104, 0x415e, 103, 99, 0 ),
V( 105, 0x5627, 105, 106, 1 ),
V( 106, 0x50e7, 108, 107, 0 ),
V( 107, 0x4b85, 109, 103, 0 ),
V( 108, 0x5597, 110, 109, 0 ),
V( 109, 0x504f, 111, 107, 0 ),
V( 110, 0x5a10, 110, 111, 1 ),
V( 111, 0x5522, 112, 109, 0 ),
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.
*/
V( 113, 0x5a1d, 113, 113, 0 )
};

View File

@@ -2,6 +2,7 @@
* jcapimin.c * jcapimin.c
* *
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -63,14 +64,25 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
cinfo->comp_info = NULL; cinfo->comp_info = NULL;
for (i = 0; i < NUM_QUANT_TBLS; i++) for (i = 0; i < NUM_QUANT_TBLS; i++) {
cinfo->quant_tbl_ptrs[i] = NULL; cinfo->quant_tbl_ptrs[i] = NULL;
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[i] = 100;
#endif
}
for (i = 0; i < NUM_HUFF_TBLS; i++) { for (i = 0; i < NUM_HUFF_TBLS; i++) {
cinfo->dc_huff_tbl_ptrs[i] = NULL; cinfo->dc_huff_tbl_ptrs[i] = NULL;
cinfo->ac_huff_tbl_ptrs[i] = NULL; cinfo->ac_huff_tbl_ptrs[i] = NULL;
} }
#if JPEG_LIB_VERSION >= 80
/* 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;
#endif
cinfo->script_space = NULL; cinfo->script_space = NULL;
cinfo->input_gamma = 1.0; /* in case application forgets */ cinfo->input_gamma = 1.0; /* in case application forgets */

925
jcarith.c Normal file
View File

@@ -0,0 +1,925 @@
/*
* jcarith.c
*
* Developed 1997-2009 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 portable arithmetic entropy encoding routines for JPEG
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
*
* Both sequential and progressive modes are supported in this single module.
*
* Suspension is not currently supported in this module.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* Expanded entropy encoder object for arithmetic encoding. */
typedef struct {
struct jpeg_entropy_encoder pub; /* public fields */
INT32 c; /* C register, base of coding interval, layout as in sec. D.1.3 */
INT32 a; /* A register, normalized size of coding interval */
INT32 sc; /* counter for stacked 0xFF values which might overflow */
INT32 zc; /* counter for pending 0x00 output values which might *
* be discarded at the end ("Pacman" termination) */
int ct; /* bit shift counter, determines when next byte will be written */
int buffer; /* buffer for most recent output byte != 0xFF */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
int next_restart_num; /* next restart number to write (0-7) */
/* Pointers to statistics areas (these workspaces have image lifespan) */
unsigned char * dc_stats[NUM_ARITH_TBLS];
unsigned char * ac_stats[NUM_ARITH_TBLS];
/* Statistics bin for coding with fixed probability 0.5 */
unsigned char fixed_bin[4];
} arith_entropy_encoder;
typedef arith_entropy_encoder * arith_entropy_ptr;
/* The following two definitions specify the allocation chunk size
* for the statistics area.
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
*
* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
/* NOTE: Uncomment the following #define if you want to use the
* given formula for calculating the AC conditioning parameter Kx
* for spectral selection progressive coding in section G.1.3.2
* of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4).
* Although the spec and P&M authors claim that this "has proven
* to give good results for 8 bit precision samples", I'm not
* convinced yet that this is really beneficial.
* Early tests gave only very marginal compression enhancements
* (a few - around 5 or so - bytes even for very large files),
* which would turn out rather negative if we'd suppress the
* DAC (Define Arithmetic Conditioning) marker segments for
* the default parameters in the future.
* Note that currently the marker writing module emits 12-byte
* DAC segments for a full-component scan in a color image.
* This is not worth worrying about IMHO. However, since the
* spec defines the default values to be used if the tables
* are omitted (unlike Huffman tables, which are required
* anyway), one might optimize this behaviour in the future,
* and then it would be disadvantageous to use custom tables if
* they don't provide sufficient gain to exceed the DAC size.
*
* On the other hand, I'd consider it as a reasonable result
* that the conditioning has no significant influence on the
* compression performance. This means that the basic
* statistical model is already rather stable.
*
* Thus, at the moment, we use the default conditioning values
* anyway, and do not use the custom formula.
*
#define CALCULATE_SPECTRAL_CONDITIONING
*/
/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
* We assume that int right shift is unsigned if INT32 right shift is,
* which should be safe.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS int ishift_temp;
#define IRIGHT_SHIFT(x,shft) \
((ishift_temp = (x)) < 0 ? \
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
(ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
LOCAL(void)
emit_byte (int val, j_compress_ptr cinfo)
/* Write next output byte; we do not support suspension in this module. */
{
struct jpeg_destination_mgr * dest = cinfo->dest;
*dest->next_output_byte++ = (JOCTET) val;
if (--dest->free_in_buffer == 0)
if (! (*dest->empty_output_buffer) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
}
/*
* Finish up at the end of an arithmetic-compressed scan.
*/
METHODDEF(void)
finish_pass (j_compress_ptr cinfo)
{
arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
INT32 temp;
/* Section D.1.8: Termination of encoding */
/* Find the e->c in the coding interval with the largest
* number of trailing zero bits */
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c)
e->c = temp + 0x8000L;
else
e->c = temp;
/* Send remaining bytes to output */
e->c <<= e->ct;
if (e->c & 0xF8000000L) {
/* One final overflow has to be handled */
if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer + 1, cinfo);
if (e->buffer + 1 == 0xFF)
emit_byte(0x00, cinfo);
}
e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
e->sc = 0;
} else {
if (e->buffer == 0)
++e->zc;
else if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer, cinfo);
}
if (e->sc) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
do {
emit_byte(0xFF, cinfo);
emit_byte(0x00, cinfo);
} while (--e->sc);
}
}
/* Output final bytes only if they are not 0x00 */
if (e->c & 0x7FFF800L) {
if (e->zc) /* output final pending zero bytes */
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte((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);
if (((e->c >> 11) & 0xFF) == 0xFF)
emit_byte(0x00, cinfo);
}
}
}
/*
* The core arithmetic encoding routine (common in JPEG and JBIG).
* This needs to go as fast as possible.
* Machine-dependent optimization facilities
* are not utilized in this portable implementation.
* However, this code should be fairly efficient and
* may be a good base for further optimizations anyway.
*
* Parameter 'val' to be encoded may be 0 or 1 (binary decision).
*
* Note: I've added full "Pacman" termination support to the
* byte output routines, which is equivalent to the optional
* Discard_final_zeros procedure (Figure D.15) in the spec.
* Thus, we always produce the shortest possible output
* stream compliant to the spec (no trailing zero bytes,
* except for FF stuffing).
*
* I've also introduced a new scheme for accessing
* the probability estimation state machine table,
* derived from Markus Kuhn's JBIG implementation.
*/
LOCAL(void)
arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
{
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
register unsigned char nl, nm;
register INT32 qe, temp;
register int sv;
/* Fetch values from our compact representation of Table D.2:
* Qe values and probability estimation state machine
*/
sv = *st;
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
/* Encode & estimation procedures per sections D.1.4 & D.1.5 */
e->a -= qe;
if (val != (sv >> 7)) {
/* Encode the less probable symbol */
if (e->a >= qe) {
/* If the interval size (qe) for the less probable symbol (LPS)
* is larger than the interval size for the MPS, then exchange
* the two symbols for coding efficiency, otherwise code the LPS
* as usual: */
e->c += e->a;
e->a = qe;
}
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
} else {
/* Encode the more probable symbol */
if (e->a >= 0x8000L)
return; /* A >= 0x8000 -> ready, no renormalization required */
if (e->a < qe) {
/* If the interval size (qe) for the less probable symbol (LPS)
* is larger than the interval size for the MPS, then exchange
* the two symbols for coding efficiency: */
e->c += e->a;
e->a = qe;
}
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
}
/* Renormalization & data output per section D.1.6 */
do {
e->a <<= 1;
e->c <<= 1;
if (--e->ct == 0) {
/* Another byte is ready for output */
temp = e->c >> 19;
if (temp > 0xFF) {
/* Handle overflow over all stacked 0xFF bytes */
if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer + 1, cinfo);
if (e->buffer + 1 == 0xFF)
emit_byte(0x00, cinfo);
}
e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
e->sc = 0;
/* 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 */
} else if (temp == 0xFF) {
++e->sc; /* stack 0xFF byte (which might overflow later) */
} else {
/* Output all stacked 0xFF bytes, they will not overflow any more */
if (e->buffer == 0)
++e->zc;
else if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer, cinfo);
}
if (e->sc) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
do {
emit_byte(0xFF, cinfo);
emit_byte(0x00, cinfo);
} while (--e->sc);
}
e->buffer = temp & 0xFF; /* new output byte (can still overflow) */
}
e->c &= 0x7FFFFL;
e->ct += 8;
}
} while (e->a < 0x8000L);
}
/*
* Emit a restart marker & resynchronize predictions.
*/
LOCAL(void)
emit_restart (j_compress_ptr cinfo, int restart_num)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci;
jpeg_component_info * compptr;
finish_pass(cinfo);
emit_byte(0xFF, cinfo);
emit_byte(JPEG_RST0 + restart_num, cinfo);
/* Re-initialize statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */
if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS);
/* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
/* AC needs no table when not present */
if (cinfo->progressive_mode == 0 || cinfo->Se) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS);
}
}
/* Reset arithmetic encoding variables */
entropy->c = 0;
entropy->a = 0x10000L;
entropy->sc = 0;
entropy->zc = 0;
entropy->ct = 11;
entropy->buffer = -1; /* empty */
}
/*
* MCU encoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
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;
ISHIFT_TEMPS
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
/* 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);
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.4: Encode_DC_DIFF */
if ((v = m - entropy->last_dc_val[ci]) == 0) {
arith_encode(cinfo, st, 0);
entropy->dc_context[ci] = 0; /* zero diff category */
} else {
entropy->last_dc_val[ci] = m;
arith_encode(cinfo, st, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
st += 2; /* Table F.4: SP = S0 + 2 */
entropy->dc_context[ci] = 4; /* small positive diff category */
} else {
v = -v;
arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
st += 3; /* Table F.4: SN = S0 + 3 */
entropy->dc_context[ci] = 8; /* small negative diff category */
}
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
arith_encode(cinfo, st, 0);
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] += 8; /* large diff category */
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
}
return TRUE;
}
/*
* MCU encoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int tbl, k, ke;
int v, v2, m;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
/* Encode the MCU data block */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* 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--)
/* 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.
*/
if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
if (v >>= cinfo->Al) break;
} else {
v = -v;
if (v >>= cinfo->Al) break;
}
/* Figure F.5: Encode_AC_Coefficients */
for (k = cinfo->Ss; k <= ke; k++) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
arith_encode(cinfo, st, 0); /* EOB decision */
for (;;) {
if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
if (v >>= cinfo->Al) {
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 0);
break;
}
} else {
v = -v;
if (v >>= cinfo->Al) {
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 1);
break;
}
}
arith_encode(cinfo, st + 1, 0); st += 3; k++;
}
st += 2;
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
if (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
}
arith_encode(cinfo, st, 0);
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
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);
arith_encode(cinfo, st, 1);
}
return TRUE;
}
/*
* MCU encoding for DC successive approximation refinement scan.
*/
METHODDEF(boolean)
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
unsigned char *st;
int Al, blkn;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
st = entropy->fixed_bin; /* use fixed probability estimation */
Al = cinfo->Al;
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
/* We simply emit the Al'th bit of the DC coefficient value. */
arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
}
return TRUE;
}
/*
* MCU encoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int tbl, k, ke, kex;
int v;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
/* Encode the MCU data block */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* Section G.1.3.3: Encoding of AC coefficients */
/* Establish EOB (end-of-block) index */
for (ke = cinfo->Se; ke > 0; ke--)
/* 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.
*/
if ((v = (*block)[jpeg_natural_order[ke]]) >= 0) {
if (v >>= cinfo->Al) break;
} else {
v = -v;
if (v >>= cinfo->Al) break;
}
/* Establish EOBx (previous stage end-of-block) index */
for (kex = ke; kex > 0; kex--)
if ((v = (*block)[jpeg_natural_order[kex]]) >= 0) {
if (v >>= cinfo->Ah) break;
} else {
v = -v;
if (v >>= cinfo->Ah) break;
}
/* 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)
arith_encode(cinfo, st, 0); /* EOB decision */
for (;;) {
if ((v = (*block)[jpeg_natural_order[k]]) >= 0) {
if (v >>= cinfo->Al) {
if (v >> 1) /* previously nonzero coef */
arith_encode(cinfo, st + 2, (v & 1));
else { /* newly nonzero coef */
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 0);
}
break;
}
} else {
v = -v;
if (v >>= cinfo->Al) {
if (v >> 1) /* previously nonzero coef */
arith_encode(cinfo, st + 2, (v & 1));
else { /* newly nonzero coef */
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 1);
}
break;
}
}
arith_encode(cinfo, st + 1, 0); st += 3; k++;
}
}
/* Encode EOB decision only if k <= cinfo->Se */
if (k <= cinfo->Se) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
arith_encode(cinfo, st, 1);
}
return TRUE;
}
/*
* Encode and output one MCU's worth of arithmetic-compressed coefficients.
*/
METHODDEF(boolean)
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
jpeg_component_info * compptr;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, k, ke;
int v, v2, m;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
/* 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];
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
tbl = compptr->dc_tbl_no;
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.4: Encode_DC_DIFF */
if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
arith_encode(cinfo, st, 0);
entropy->dc_context[ci] = 0; /* zero diff category */
} else {
entropy->last_dc_val[ci] = (*block)[0];
arith_encode(cinfo, st, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
st += 2; /* Table F.4: SP = S0 + 2 */
entropy->dc_context[ci] = 4; /* small positive diff category */
} else {
v = -v;
arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
st += 3; /* Table F.4: SN = S0 + 3 */
entropy->dc_context[ci] = 8; /* small negative diff category */
}
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
arith_encode(cinfo, st, 0);
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] += 8; /* large diff category */
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
/* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
tbl = compptr->ac_tbl_no;
/* Establish EOB (end-of-block) index */
for (ke = DCTSIZE2 - 1; ke > 0; ke--)
if ((*block)[jpeg_natural_order[ke]]) break;
/* Figure F.5: Encode_AC_Coefficients */
for (k = 1; k <= ke; k++) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
arith_encode(cinfo, st, 0); /* EOB decision */
while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
arith_encode(cinfo, st + 1, 0); st += 3; k++;
}
arith_encode(cinfo, st + 1, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, entropy->fixed_bin, 0);
} else {
v = -v;
arith_encode(cinfo, entropy->fixed_bin, 1);
}
st += 2;
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
if (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
}
arith_encode(cinfo, st, 0);
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
/* Encode EOB decision only if k <= DCTSIZE2 - 1 */
if (k <= DCTSIZE2 - 1) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
arith_encode(cinfo, st, 1);
}
}
return TRUE;
}
/*
* Initialize for an arithmetic-compressed scan.
*/
METHODDEF(void)
start_pass (j_compress_ptr cinfo, boolean gather_statistics)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info * compptr;
if (gather_statistics)
/* Make sure to avoid that in the master control logic!
* We are fully adaptive here and need no extra
* statistics gathering pass!
*/
ERREXIT(cinfo, JERR_NOT_COMPILED);
/* We assume jcmaster.c already validated the progressive scan parameters. */
/* Select execution routines */
if (cinfo->progressive_mode) {
if (cinfo->Ah == 0) {
if (cinfo->Ss == 0)
entropy->pub.encode_mcu = encode_mcu_DC_first;
else
entropy->pub.encode_mcu = encode_mcu_AC_first;
} else {
if (cinfo->Ss == 0)
entropy->pub.encode_mcu = encode_mcu_DC_refine;
else
entropy->pub.encode_mcu = encode_mcu_AC_refine;
}
} else
entropy->pub.encode_mcu = encode_mcu;
/* Allocate & initialize requested statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */
if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
tbl = compptr->dc_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
/* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
/* AC needs no table when not present */
if (cinfo->progressive_mode == 0 || cinfo->Se) {
tbl = compptr->ac_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
#ifdef CALCULATE_SPECTRAL_CONDITIONING
if (cinfo->progressive_mode)
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4);
#endif
}
}
/* Initialize arithmetic encoding variables */
entropy->c = 0;
entropy->a = 0x10000L;
entropy->sc = 0;
entropy->zc = 0;
entropy->ct = 11;
entropy->buffer = -1; /* empty */
/* Initialize restart stuff */
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num = 0;
}
/*
* Module initialization routine for arithmetic entropy encoding.
*/
GLOBAL(void)
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->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass;
/* Mark tables unallocated */
for (i = 0; i < NUM_ARITH_TBLS; i++) {
entropy->dc_stats[i] = NULL;
entropy->ac_stats[i] = NULL;
}
/* Initialize index for fixed probability estimation */
entropy->fixed_bin[0] = 113;
}

View File

@@ -3,7 +3,7 @@
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright 2009 D. R. Commander * Copyright 2009-2011 D. R. Commander
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -83,7 +83,7 @@ typedef my_color_converter * my_cconvert_ptr;
#if BITS_IN_JSAMPLE == 8 #if BITS_IN_JSAMPLE == 8
const unsigned char red_lut[256] = { static const unsigned char red_lut[256] = {
0 , 0 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 0 , 0 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 ,
5 , 5 , 5 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 8 , 8 , 8 , 9 , 9 , 9 , 5 , 5 , 5 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 8 , 8 , 8 , 9 , 9 , 9 ,
10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14,
@@ -102,7 +102,7 @@ const unsigned char red_lut[256] = {
72, 72, 72, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76 72, 72, 72, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76
}; };
const unsigned char green_lut[256] = { static const unsigned char green_lut[256] = {
0 , 1 , 1 , 2 , 2 , 3 , 4 , 4 , 5 , 5 , 6 , 6 , 0 , 1 , 1 , 2 , 2 , 3 , 4 , 4 , 5 , 5 , 6 , 6 ,
7 , 8 , 8 , 9 , 9 , 10 , 11 , 11 , 12 , 12 , 13 , 14 , 7 , 8 , 8 , 9 , 9 , 10 , 11 , 11 , 12 , 12 , 13 , 14 ,
14 , 15 , 15 , 16 , 16 , 17 , 18 , 18 , 19 , 19 , 20 , 21 , 14 , 15 , 15 , 16 , 16 , 17 , 18 , 18 , 19 , 19 , 20 , 21 ,
@@ -122,12 +122,12 @@ const unsigned char green_lut[256] = {
113, 113, 114, 114, 115, 116, 116, 117, 117, 118, 119, 119, 113, 113, 114, 114, 115, 116, 116, 117, 117, 118, 119, 119,
120, 120, 121, 122, 122, 123, 123, 124, 124, 125, 126, 126, 120, 120, 121, 122, 122, 123, 123, 124, 124, 125, 126, 126,
127, 127, 128, 129, 129, 130, 130, 131, 131, 132, 133, 133, 127, 127, 128, 129, 129, 130, 130, 131, 131, 132, 133, 133,
34, 134, 135, 136, 136, 137, 137, 138, 139, 139, 140, 140, 134, 134, 135, 136, 136, 137, 137, 138, 139, 139, 140, 140,
141, 141, 142, 143, 143, 144, 144, 145, 146, 146, 147, 147, 141, 141, 142, 143, 143, 144, 144, 145, 146, 146, 147, 147,
148, 149, 149, 150 148, 149, 149, 150
}; };
const unsigned char blue_lut[256] = { static const unsigned char blue_lut[256] = {
0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 ,
2 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 4 ,
4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ,
@@ -258,14 +258,13 @@ rgb_gray_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
#if BITS_IN_JSAMPLE != 8 #if BITS_IN_JSAMPLE != 8
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 * ctab = cconvert->rgb_ycc_tab; register INT32 * ctab = cconvert->rgb_ycc_tab;
#endif #endif
register JSAMPROW inptr; register JSAMPROW inptr;
register JSAMPROW outptr; register JSAMPROW outptr;
JSAMPLE *maxoutptr; JSAMPLE *maxoutptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
int rindex = rgb_red[cinfo->in_color_space]; int rindex = rgb_red[cinfo->in_color_space];
int gindex = rgb_green[cinfo->in_color_space]; int gindex = rgb_green[cinfo->in_color_space];

View File

@@ -4,6 +4,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011 D. R. Commander
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -39,6 +40,8 @@ typedef JMETHOD(void, float_quantize_method_ptr,
(JCOEFPTR coef_block, FAST_FLOAT * divisors, (JCOEFPTR coef_block, FAST_FLOAT * divisors,
FAST_FLOAT * workspace)); FAST_FLOAT * workspace));
METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
typedef struct { typedef struct {
struct jpeg_forward_dct pub; /* public fields */ struct jpeg_forward_dct pub; /* public fields */
@@ -160,7 +163,7 @@ flss (UINT16 val)
* of in a consecutive manner, yet again in order to allow SIMD * of in a consecutive manner, yet again in order to allow SIMD
* routines. * routines.
*/ */
LOCAL(void) LOCAL(int)
compute_reciprocal (UINT16 divisor, DCTELEM * dtbl) compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
{ {
UDCTELEM2 fq, fr; UDCTELEM2 fq, fr;
@@ -189,6 +192,9 @@ compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */ dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */
dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */ dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
if(r <= 16) return 0;
else return 1;
} }
/* /*
@@ -232,7 +238,9 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
} }
dtbl = fdct->divisors[qtblno]; dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]); if(!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i])
&& fdct->quantize == jsimd_quantize)
fdct->quantize = quantize;
} }
break; break;
#endif #endif
@@ -266,10 +274,12 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
} }
dtbl = fdct->divisors[qtblno]; dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
compute_reciprocal( if(!compute_reciprocal(
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
(INT32) aanscales[i]), (INT32) aanscales[i]),
CONST_BITS-3), &dtbl[i]); CONST_BITS-3), &dtbl[i])
&& fdct->quantize == jsimd_quantize)
fdct->quantize = quantize;
} }
} }
break; break;

View File

@@ -36,7 +36,7 @@
#include <limits.h> #include <limits.h>
static unsigned char jpeg_first_bit_table[65536]; static unsigned char jpeg_first_bit_table[65536];
int jpeg_first_bit_table_init=0; static int jpeg_first_bit_table_init=0;
#ifndef min #ifndef min
#define min(a,b) ((a)<(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b))
@@ -423,8 +423,6 @@ dump_buffer (working_state * state)
CHECKBUF15() \ CHECKBUF15() \
} }
int _max=0;
#if __WORDSIZE==64 || defined(_WIN64) #if __WORDSIZE==64 || defined(_WIN64)
#define DUMP_VALUE(ht, codevalue, t, nbits) { \ #define DUMP_VALUE(ht, codevalue, t, nbits) { \

View File

@@ -42,7 +42,11 @@ jinit_compress_master (j_compress_ptr cinfo)
jinit_forward_dct(cinfo); jinit_forward_dct(cinfo);
/* Entropy encoding: either Huffman or arithmetic coding. */ /* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code) {
#ifdef C_ARITH_CODING_SUPPORTED
jinit_arith_encoder(cinfo);
#else
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
#endif
} else { } else {
if (cinfo->progressive_mode) { if (cinfo->progressive_mode) {
#ifdef C_PROGRESSIVE_SUPPORTED #ifdef C_PROGRESSIVE_SUPPORTED

View File

@@ -2,6 +2,7 @@
* jcmarker.c * jcmarker.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -11,6 +12,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
typedef enum { /* JPEG marker codes */ typedef enum { /* JPEG marker codes */
@@ -285,13 +287,13 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
/* Make sure image isn't bigger than SOF field can handle */ /* Make sure image isn't bigger than SOF field can handle */
if ((long) cinfo->image_height > 65535L || if ((long) cinfo->_jpeg_height > 65535L ||
(long) cinfo->image_width > 65535L) (long) cinfo->_jpeg_width > 65535L)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
emit_byte(cinfo, cinfo->data_precision); emit_byte(cinfo, cinfo->data_precision);
emit_2bytes(cinfo, (int) cinfo->image_height); emit_2bytes(cinfo, (int) cinfo->_jpeg_height);
emit_2bytes(cinfo, (int) cinfo->image_width); emit_2bytes(cinfo, (int) cinfo->_jpeg_width);
emit_byte(cinfo, cinfo->num_components); emit_byte(cinfo, cinfo->num_components);

View File

@@ -2,6 +2,8 @@
* jcmaster.c * jcmaster.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -14,6 +16,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* Private state */ /* Private state */
@@ -42,8 +45,28 @@ typedef my_comp_master * my_master_ptr;
* Support routines that do various essential calculations. * Support routines that do various essential calculations.
*/ */
#if JPEG_LIB_VERSION >= 70
/*
* 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 */
{
/* 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
LOCAL(void) LOCAL(void)
initial_setup (j_compress_ptr cinfo) initial_setup (j_compress_ptr cinfo, boolean transcode_only)
/* Do computations that are needed before master selection phase */ /* Do computations that are needed before master selection phase */
{ {
int ci; int ci;
@@ -51,14 +74,21 @@ initial_setup (j_compress_ptr cinfo)
long samplesperrow; long samplesperrow;
JDIMENSION jd_samplesperrow; JDIMENSION jd_samplesperrow;
#if JPEG_LIB_VERSION >= 70
#if JPEG_LIB_VERSION >= 80
if (!transcode_only)
#endif
jpeg_calc_jpeg_dimensions(cinfo);
#endif
/* Sanity check on image dimensions */ /* Sanity check on image dimensions */
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0
|| cinfo->num_components <= 0 || cinfo->input_components <= 0) || cinfo->num_components <= 0 || cinfo->input_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE); ERREXIT(cinfo, JERR_EMPTY_IMAGE);
/* Make sure image isn't bigger than I can handle */ /* Make sure image isn't bigger than I can handle */
if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) (long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
/* Width of an input scanline must be representable as JDIMENSION. */ /* Width of an input scanline must be representable as JDIMENSION. */
@@ -96,20 +126,24 @@ initial_setup (j_compress_ptr cinfo)
/* Fill in the correct component_index value; don't rely on application */ /* Fill in the correct component_index value; don't rely on application */
compptr->component_index = ci; compptr->component_index = ci;
/* For compression, we never do DCT scaling. */ /* For compression, we never do DCT scaling. */
#if JPEG_LIB_VERSION >= 70
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
#else
compptr->DCT_scaled_size = DCTSIZE; compptr->DCT_scaled_size = DCTSIZE;
#endif
/* Size in DCT blocks */ /* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION) compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
(long) (cinfo->max_h_samp_factor * DCTSIZE)); (long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->height_in_blocks = (JDIMENSION) compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
(long) (cinfo->max_v_samp_factor * DCTSIZE)); (long) (cinfo->max_v_samp_factor * DCTSIZE));
/* Size in samples */ /* Size in samples */
compptr->downsampled_width = (JDIMENSION) compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
(long) cinfo->max_h_samp_factor); (long) cinfo->max_h_samp_factor);
compptr->downsampled_height = (JDIMENSION) compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
(long) cinfo->max_v_samp_factor); (long) cinfo->max_v_samp_factor);
/* Mark component needed (this flag isn't actually used for compression) */ /* Mark component needed (this flag isn't actually used for compression) */
compptr->component_needed = TRUE; compptr->component_needed = TRUE;
@@ -119,7 +153,7 @@ initial_setup (j_compress_ptr cinfo)
* main controller will call coefficient controller). * main controller will call coefficient controller).
*/ */
cinfo->total_iMCU_rows = (JDIMENSION) cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, jdiv_round_up((long) cinfo->_jpeg_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE)); (long) (cinfo->max_v_samp_factor*DCTSIZE));
} }
@@ -347,10 +381,10 @@ per_scan_setup (j_compress_ptr cinfo)
/* Overall image size in MCUs */ /* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION) cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, jdiv_round_up((long) cinfo->_jpeg_width,
(long) (cinfo->max_h_samp_factor*DCTSIZE)); (long) (cinfo->max_h_samp_factor*DCTSIZE));
cinfo->MCU_rows_in_scan = (JDIMENSION) cinfo->MCU_rows_in_scan = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, jdiv_round_up((long) cinfo->_jpeg_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE)); (long) (cinfo->max_v_samp_factor*DCTSIZE));
cinfo->blocks_in_MCU = 0; cinfo->blocks_in_MCU = 0;
@@ -554,7 +588,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
master->pub.is_last_pass = FALSE; master->pub.is_last_pass = FALSE;
/* Validate parameters, determine derived values */ /* Validate parameters, determine derived values */
initial_setup(cinfo); initial_setup(cinfo, transcode_only);
if (cinfo->scan_info != NULL) { if (cinfo->scan_info != NULL) {
#ifdef C_MULTISCAN_FILES_SUPPORTED #ifdef C_MULTISCAN_FILES_SUPPORTED

View File

@@ -1,3 +1,14 @@
/* Version ID for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
*/
#define JPEG_LIB_VERSION 62 /* Version 6b */
/* Support arithmetic encoding */
#undef C_ARITH_CODING_SUPPORTED
/* Support arithmetic decoding */
#undef D_ARITH_CODING_SUPPORTED
/* Define if your compiler supports prototypes */ /* Define if your compiler supports prototypes */
#undef HAVE_PROTOTYPES #undef HAVE_PROTOTYPES

View File

@@ -1,5 +1,5 @@
/* /*
* jconfig.doc * jconfig.txt
* *
* Copyright (C) 1991-1994, Thomas G. Lane. * Copyright (C) 1991-1994, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
@@ -24,7 +24,7 @@
*/ */
/* Does your compiler support function prototypes? /* Does your compiler support function prototypes?
* (If not, you also need to use ansi2knr, see install.doc) * (If not, you also need to use ansi2knr, see install.txt)
*/ */
#define HAVE_PROTOTYPES #define HAVE_PROTOTYPES
@@ -91,6 +91,15 @@
*/ */
#undef INCOMPLETE_TYPES_BROKEN #undef INCOMPLETE_TYPES_BROKEN
/* Define "boolean" as unsigned char, not int, on Windows systems.
*/
#ifdef _WIN32
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif
/* /*
* The following options affect code selection within the JPEG library, * The following options affect code selection within the JPEG library,

View File

@@ -2,7 +2,8 @@
* jcparam.c * jcparam.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Copyright (C) 2009, D. R. Commander. * Modified 2003-2008 by Guido Vollbeding.
* Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -61,6 +62,49 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
} }
/* These are the sample quantization tables given in JPEG spec section K.1.
* The spec says that the values given produce "good" quality, and
* when divided by 2, "very good" quality.
*/
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
#if JPEG_LIB_VERSION >= 70
GLOBAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables
* and straight percentage-scaling quality scales.
* This entry point allows different scalings for luminance and chrominance.
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
cinfo->q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
#endif
GLOBAL(void) GLOBAL(void)
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
boolean force_baseline) boolean force_baseline)
@@ -70,31 +114,6 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
* applications that insist on a linear percentage scaling. * applications that insist on a linear percentage scaling.
*/ */
{ {
/* These are the sample quantization tables given in JPEG spec section K.1.
* The spec says that the values given produce "good" quality, and
* when divided by 2, "very good" quality.
*/
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
/* Set up two quantization tables using the specified scaling */ /* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline); scale_factor, force_baseline);
@@ -285,6 +304,10 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* Initialize everything not dependent on the color space */ /* Initialize everything not dependent on the color space */
#if JPEG_LIB_VERSION >= 70
cinfo->scale_num = 1; /* 1:1 scaling */
cinfo->scale_denom = 1;
#endif
cinfo->data_precision = BITS_IN_JSAMPLE; cinfo->data_precision = BITS_IN_JSAMPLE;
/* Set up two quantization tables using default quality of 75 */ /* Set up two quantization tables using default quality of 75 */
jpeg_set_quality(cinfo, 75, TRUE); jpeg_set_quality(cinfo, 75, TRUE);
@@ -321,6 +344,11 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* By default, use the simpler non-cosited sampling alignment */ /* By default, use the simpler non-cosited sampling alignment */
cinfo->CCIR601_sampling = FALSE; cinfo->CCIR601_sampling = FALSE;
#if JPEG_LIB_VERSION >= 70
/* By default, apply fancy downsampling */
cinfo->do_fancy_downsampling = TRUE;
#endif
/* No input smoothing */ /* No input smoothing */
cinfo->smoothing_factor = 0; cinfo->smoothing_factor = 0;

View File

@@ -2,6 +2,7 @@
* jctrans.c * jctrans.c
* *
* Copyright (C) 1995-1998, Thomas G. Lane. * Copyright (C) 1995-1998, Thomas G. Lane.
* Modified 2000-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -76,6 +77,12 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
dstinfo->image_height = srcinfo->image_height; dstinfo->image_height = srcinfo->image_height;
dstinfo->input_components = srcinfo->num_components; dstinfo->input_components = srcinfo->num_components;
dstinfo->in_color_space = srcinfo->jpeg_color_space; dstinfo->in_color_space = srcinfo->jpeg_color_space;
#if JPEG_LIB_VERSION >= 70
dstinfo->jpeg_width = srcinfo->output_width;
dstinfo->jpeg_height = srcinfo->output_height;
dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size;
dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size;
#endif
/* Initialize all parameters to default values */ /* Initialize all parameters to default values */
jpeg_set_defaults(dstinfo); jpeg_set_defaults(dstinfo);
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
@@ -167,7 +174,11 @@ transencode_master_selection (j_compress_ptr cinfo,
/* Entropy encoding: either Huffman or arithmetic coding. */ /* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code) {
#ifdef C_ARITH_CODING_SUPPORTED
jinit_arith_encoder(cinfo);
#else
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
#endif
} else { } else {
if (cinfo->progressive_mode) { if (cinfo->progressive_mode) {
#ifdef C_PROGRESSIVE_SUPPORTED #ifdef C_PROGRESSIVE_SUPPORTED

View File

@@ -2,6 +2,7 @@
* jdapistd.c * jdapistd.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -17,6 +18,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* Forward declarations */ /* Forward declarations */
@@ -202,7 +204,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
} }
/* Verify that at least one iMCU row can be returned. */ /* Verify that at least one iMCU row can be returned. */
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size;
if (max_lines < lines_per_iMCU_row) if (max_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE); ERREXIT(cinfo, JERR_BUFFER_SIZE);

761
jdarith.c Normal file
View File

@@ -0,0 +1,761 @@
/*
* jdarith.c
*
* Developed 1997-2009 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 portable arithmetic entropy decoding routines for JPEG
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
*
* Both sequential and progressive modes are supported in this single module.
*
* Suspension is not currently supported in this module.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* Expanded entropy decoder object for arithmetic decoding. */
typedef struct {
struct jpeg_entropy_decoder pub; /* public fields */
INT32 c; /* C register, base of coding interval + input bit buffer */
INT32 a; /* A register, normalized size of coding interval */
int ct; /* bit shift counter, # of bits left in bit buffer part of C */
/* init: ct = -16 */
/* run: ct = 0..7 */
/* error: ct = -1 */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
/* Pointers to statistics areas (these workspaces have image lifespan) */
unsigned char * dc_stats[NUM_ARITH_TBLS];
unsigned char * ac_stats[NUM_ARITH_TBLS];
/* Statistics bin for coding with fixed probability 0.5 */
unsigned char fixed_bin[4];
} arith_entropy_decoder;
typedef arith_entropy_decoder * arith_entropy_ptr;
/* The following two definitions specify the allocation chunk size
* for the statistics area.
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
*
* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
LOCAL(int)
get_byte (j_decompress_ptr cinfo)
/* Read next input byte; we do not support suspension in this module. */
{
struct jpeg_source_mgr * src = cinfo->src;
if (src->bytes_in_buffer == 0)
if (! (*src->fill_input_buffer) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
src->bytes_in_buffer--;
return GETJOCTET(*src->next_input_byte++);
}
/*
* The core arithmetic decoding routine (common in JPEG and JBIG).
* This needs to go as fast as possible.
* Machine-dependent optimization facilities
* are not utilized in this portable implementation.
* However, this code should be fairly efficient and
* may be a good base for further optimizations anyway.
*
* Return value is 0 or 1 (binary decision).
*
* Note: I've changed the handling of the code base & bit
* buffer register C compared to other implementations
* based on the standards layout & procedures.
* While it also contains both the actual base of the
* coding interval (16 bits) and the next-bits buffer,
* the cut-point between these two parts is floating
* (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
* of C (except for new data insertion, of course).
*
* I've also introduced a new scheme for accessing
* the probability estimation state machine table,
* derived from Markus Kuhn's JBIG implementation.
*/
LOCAL(int)
arith_decode (j_decompress_ptr cinfo, unsigned char *st)
{
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
register unsigned char nl, nm;
register INT32 qe, temp;
register int sv, data;
/* Renormalization & data input per section D.2.6 */
while (e->a < 0x8000L) {
if (--e->ct < 0) {
/* Need to fetch next data byte */
if (cinfo->unread_marker)
data = 0; /* stuff zero data */
else {
data = get_byte(cinfo); /* read next input byte */
if (data == 0xFF) { /* zero stuff or marker code */
do data = get_byte(cinfo);
while (data == 0xFF); /* swallow extra 0xFF bytes */
if (data == 0)
data = 0xFF; /* discard stuffed zero byte */
else {
/* Note: Different from the Huffman decoder, hitting
* a marker while processing the compressed data
* segment is legal in arithmetic coding.
* The convention is to supply zero data
* then until decoding is complete.
*/
cinfo->unread_marker = data;
data = 0;
}
}
}
e->c = (e->c << 8) | data; /* insert data into C register */
if ((e->ct += 8) < 0) /* update bit shift counter */
/* Need more initial bytes */
if (++e->ct == 0)
/* Got 2 initial bytes -> re-init A and exit loop */
e->a = 0x8000L; /* => e->a = 0x10000L after loop exit */
}
e->a <<= 1;
}
/* Fetch values from our compact representation of Table D.2:
* Qe values and probability estimation state machine
*/
sv = *st;
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
/* Decode & estimation procedures per sections D.2.4 & D.2.5 */
temp = e->a - qe;
e->a = temp;
temp <<= e->ct;
if (e->c >= temp) {
e->c -= temp;
/* Conditional LPS (less probable symbol) exchange */
if (e->a < qe) {
e->a = qe;
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
} else {
e->a = qe;
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
sv ^= 0x80; /* Exchange LPS/MPS */
}
} else if (e->a < 0x8000L) {
/* Conditional MPS (more probable symbol) exchange */
if (e->a < qe) {
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
sv ^= 0x80; /* Exchange LPS/MPS */
} else {
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
}
}
return sv >> 7;
}
/*
* Check for a restart marker & resynchronize decoder.
*/
LOCAL(void)
process_restart (j_decompress_ptr cinfo)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci;
jpeg_component_info * compptr;
/* Advance past the RSTn marker */
if (! (*cinfo->marker->read_restart_marker) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
/* Re-initialize statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS);
/* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
if (! cinfo->progressive_mode || cinfo->Ss) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS);
}
}
/* Reset arithmetic decoding variables */
entropy->c = 0;
entropy->a = 0;
entropy->ct = -16; /* force reading 2 initial bytes to fill C */
/* Reset restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
}
/*
* Arithmetic MCU decoding.
* Each of these routines decodes and returns one MCU's worth of
* arithmetic-compressed coefficients.
* The coefficients are reordered from zigzag order into natural array order,
* but are not dequantized.
*
* The i'th block of the MCU is stored into the block pointed to by
* MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
*/
/*
* MCU decoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, sign;
int v, m;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
/* Outer loop handles each block in the MCU */
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;
/* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.19: Decode_DC_DIFF */
if (arith_decode(cinfo, st) == 0)
entropy->dc_context[ci] = 0;
else {
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, st + 1);
st += 2; st += sign;
/* Figure F.23: Decoding the magnitude category of v */
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) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
else
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v;
}
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
(*block)[0] = (JCOEF) (entropy->last_dc_val[ci] << cinfo->Al);
}
return TRUE;
}
/*
* MCU decoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int tbl, sign, k;
int v, m;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
/* There is always only one block per MCU */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* 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);
if (arith_decode(cinfo, st)) break; /* EOB flag */
while (arith_decode(cinfo, st + 1) == 0) {
st += 3; k++;
if (k > cinfo->Se) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, entropy->fixed_bin);
st += 2;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
if (arith_decode(cinfo, st)) {
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
}
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
/* Scale and output coefficient in natural (dezigzagged) order */
(*block)[jpeg_natural_order[k]] = (JCOEF) (v << cinfo->Al);
}
return TRUE;
}
/*
* MCU decoding for DC successive approximation refinement scan.
*/
METHODDEF(boolean)
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;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
st = entropy->fixed_bin; /* use fixed probability estimation */
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++) {
/* Encoded data is simply the next bit of the two's-complement DC value */
if (arith_decode(cinfo, st))
MCU_data[blkn][0][0] |= p1;
}
return TRUE;
}
/*
* MCU decoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
JCOEFPTR thiscoef;
unsigned char *st;
int tbl, k, kex;
int p1, m1;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
/* There is always only one block per MCU */
block = MCU_data[0];
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 */
/* Establish EOBx (previous stage end-of-block) index */
for (kex = cinfo->Se; kex > 0; kex--)
if ((*block)[jpeg_natural_order[kex]]) break;
for (k = cinfo->Ss; k <= cinfo->Se; k++) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
if (k > kex)
if (arith_decode(cinfo, st)) break; /* EOB flag */
for (;;) {
thiscoef = *block + jpeg_natural_order[k];
if (*thiscoef) { /* previously nonzero coef */
if (arith_decode(cinfo, st + 2)) {
if (*thiscoef < 0)
*thiscoef += m1;
else
*thiscoef += p1;
}
break;
}
if (arith_decode(cinfo, st + 1)) { /* newly nonzero coef */
if (arith_decode(cinfo, entropy->fixed_bin))
*thiscoef = m1;
else
*thiscoef = p1;
break;
}
st += 3; k++;
if (k > cinfo->Se) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
}
return TRUE;
}
/*
* Decode one MCU's worth of arithmetic-compressed coefficients.
*/
METHODDEF(boolean)
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
jpeg_component_info * compptr;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, sign, k;
int v, m;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
/* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
tbl = compptr->dc_tbl_no;
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.19: Decode_DC_DIFF */
if (arith_decode(cinfo, st) == 0)
entropy->dc_context[ci] = 0;
else {
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, st + 1);
st += 2; st += sign;
/* Figure F.23: Decoding the magnitude category of v */
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) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
else
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v;
}
(*block)[0] = (JCOEF) entropy->last_dc_val[ci];
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
tbl = compptr->ac_tbl_no;
/* Figure F.20: Decode_AC_coefficients */
for (k = 1; k <= DCTSIZE2 - 1; k++) {
st = entropy->ac_stats[tbl] + 3 * (k - 1);
if (arith_decode(cinfo, st)) break; /* EOB flag */
while (arith_decode(cinfo, st + 1) == 0) {
st += 3; k++;
if (k > DCTSIZE2 - 1) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, entropy->fixed_bin);
st += 2;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
if (arith_decode(cinfo, st)) {
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == 0x8000) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
}
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
(*block)[jpeg_natural_order[k]] = (JCOEF) v;
}
}
return TRUE;
}
/*
* Initialize for an arithmetic-compressed scan.
*/
METHODDEF(void)
start_pass (j_decompress_ptr cinfo)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info * compptr;
if (cinfo->progressive_mode) {
/* Validate progressive scan parameters */
if (cinfo->Ss == 0) {
if (cinfo->Se != 0)
goto bad;
} else {
/* need not check Ss/Se < 0 since they came from unsigned bytes */
if (cinfo->Se < cinfo->Ss || cinfo->Se > DCTSIZE2 - 1)
goto bad;
/* AC scans may have only one component */
if (cinfo->comps_in_scan != 1)
goto bad;
}
if (cinfo->Ah != 0) {
/* Successive approximation refinement scan: must have Al = Ah-1. */
if (cinfo->Ah-1 != cinfo->Al)
goto bad;
}
if (cinfo->Al > 13) { /* need not check for < 0 */
bad:
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
}
/* Update progression status, and verify that scan order is legal.
* Note that inter-scan inconsistencies are treated as warnings
* not fatal errors ... not clear if this is right way to behave.
*/
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
if (cinfo->Ah != expected)
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
coef_bit_ptr[coefi] = cinfo->Al;
}
}
/* Select MCU decoding routine */
if (cinfo->Ah == 0) {
if (cinfo->Ss == 0)
entropy->pub.decode_mcu = decode_mcu_DC_first;
else
entropy->pub.decode_mcu = decode_mcu_AC_first;
} else {
if (cinfo->Ss == 0)
entropy->pub.decode_mcu = decode_mcu_DC_refine;
else
entropy->pub.decode_mcu = decode_mcu_AC_refine;
}
} else {
/* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
* This ought to be an error condition, but we make it a warning.
*/
if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 ||
(cinfo->Se < DCTSIZE2 && cinfo->Se != DCTSIZE2 - 1))
WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
/* Select MCU decoding routine */
entropy->pub.decode_mcu = decode_mcu;
}
/* Allocate & initialize requested statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
tbl = compptr->dc_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
/* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
if (! cinfo->progressive_mode || cinfo->Ss) {
tbl = compptr->ac_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
}
}
/* Initialize arithmetic decoding variables */
entropy->c = 0;
entropy->a = 0;
entropy->ct = -16; /* force reading 2 initial bytes to fill C */
/* Initialize restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
}
/*
* Module initialization routine for arithmetic entropy decoding.
*/
GLOBAL(void)
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->pub.start_pass = start_pass;
/* Mark tables unallocated */
for (i = 0; i < NUM_ARITH_TBLS; i++) {
entropy->dc_stats[i] = NULL;
entropy->ac_stats[i] = NULL;
}
/* Initialize index for fixed probability estimation */
entropy->fixed_bin[0] = 113;
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));
coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)
*coef_bit_ptr++ = -1;
}
}

View File

@@ -2,13 +2,14 @@
* jdatadst.c * jdatadst.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains compression data destination routines for the case of * This file contains compression data destination routines for the case of
* emitting JPEG data to a file (or any stdio stream). While these routines * emitting JPEG data to memory or to a file (or any stdio stream).
* are sufficient for most applications, some will want to use a different * While these routines are sufficient for most applications,
* destination manager. * some will want to use a different destination manager.
* IMPORTANT: we assume that fwrite() will correctly transcribe an array of * IMPORTANT: we assume that fwrite() will correctly transcribe an array of
* JOCTETs into 8-bit-wide elements on external storage. If char is wider * JOCTETs into 8-bit-wide elements on external storage. If char is wider
* than 8 bits on your machine, you may need to do some tweaking. * than 8 bits on your machine, you may need to do some tweaking.
@@ -19,6 +20,11 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.h" #include "jerror.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void * malloc JPP((size_t size));
extern void free JPP((void *ptr));
#endif
/* Expanded data destination object for stdio output */ /* Expanded data destination object for stdio output */
@@ -34,6 +40,23 @@ typedef my_destination_mgr * my_dest_ptr;
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ #define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
#if JPEG_LIB_VERSION >= 80
/* Expanded data destination object for memory output */
typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
unsigned char ** outbuffer; /* target buffer */
unsigned long * outsize;
unsigned char * newbuffer; /* newly allocated buffer */
JOCTET * buffer; /* start of buffer */
size_t bufsize;
} my_mem_destination_mgr;
typedef my_mem_destination_mgr * my_mem_dest_ptr;
#endif
/* /*
* Initialize destination --- called by jpeg_start_compress * Initialize destination --- called by jpeg_start_compress
* before any data is actually written. * before any data is actually written.
@@ -53,6 +76,14 @@ init_destination (j_compress_ptr cinfo)
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
} }
#if JPEG_LIB_VERSION >= 80
METHODDEF(void)
init_mem_destination (j_compress_ptr cinfo)
{
/* no work necessary here */
}
#endif
/* /*
* Empty the output buffer --- called whenever buffer fills up. * Empty the output buffer --- called whenever buffer fills up.
@@ -92,6 +123,38 @@ empty_output_buffer (j_compress_ptr cinfo)
return TRUE; return TRUE;
} }
#if JPEG_LIB_VERSION >= 80
METHODDEF(boolean)
empty_mem_output_buffer (j_compress_ptr cinfo)
{
size_t nextsize;
JOCTET * nextbuffer;
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
/* Try to allocate new buffer with double size */
nextsize = dest->bufsize * 2;
nextbuffer = malloc(nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
if (dest->newbuffer != NULL)
free(dest->newbuffer);
dest->newbuffer = nextbuffer;
dest->pub.next_output_byte = nextbuffer + dest->bufsize;
dest->pub.free_in_buffer = dest->bufsize;
dest->buffer = nextbuffer;
dest->bufsize = nextsize;
return TRUE;
}
#endif
/* /*
* Terminate destination --- called by jpeg_finish_compress * Terminate destination --- called by jpeg_finish_compress
@@ -119,6 +182,17 @@ term_destination (j_compress_ptr cinfo)
ERREXIT(cinfo, JERR_FILE_WRITE); ERREXIT(cinfo, JERR_FILE_WRITE);
} }
#if JPEG_LIB_VERSION >= 80
METHODDEF(void)
term_mem_destination (j_compress_ptr cinfo)
{
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
*dest->outbuffer = dest->buffer;
*dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
}
#endif
/* /*
* Prepare for output to a stdio stream. * Prepare for output to a stdio stream.
@@ -149,3 +223,55 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
dest->pub.term_destination = term_destination; dest->pub.term_destination = term_destination;
dest->outfile = outfile; dest->outfile = outfile;
} }
#if JPEG_LIB_VERSION >= 80
/*
* Prepare for output to a memory buffer.
* The caller may supply an own initial buffer with appropriate size.
* Otherwise, or when the actual data output exceeds the given size,
* the library adapts the buffer size as necessary.
* The standard library functions malloc/free are used for allocating
* larger memory, so the buffer is available to the application after
* finishing compression, and then the application is responsible for
* freeing the requested memory.
*/
GLOBAL(void)
jpeg_mem_dest (j_compress_ptr cinfo,
unsigned char ** outbuffer, unsigned long * outsize)
{
my_mem_dest_ptr dest;
if (outbuffer == NULL || outsize == NULL) /* sanity check */
ERREXIT(cinfo, JERR_BUFFER_SIZE);
/* The destination object is made permanent so that multiple JPEG images
* 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));
}
dest = (my_mem_dest_ptr) cinfo->dest;
dest->pub.init_destination = init_mem_destination;
dest->pub.empty_output_buffer = empty_mem_output_buffer;
dest->pub.term_destination = term_mem_destination;
dest->outbuffer = outbuffer;
dest->outsize = outsize;
dest->newbuffer = NULL;
if (*outbuffer == NULL || *outsize == 0) {
/* Allocate initial buffer */
dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE);
if (dest->newbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
*outsize = OUTPUT_BUF_SIZE;
}
dest->pub.next_output_byte = dest->buffer = *outbuffer;
dest->pub.free_in_buffer = dest->bufsize = *outsize;
}
#endif

View File

@@ -2,13 +2,14 @@
* jdatasrc.c * jdatasrc.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2010 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains decompression data source routines for the case of * This file contains decompression data source routines for the case of
* reading JPEG data from a file (or any stdio stream). While these routines * reading JPEG data from memory or from a file (or any stdio stream).
* are sufficient for most applications, some will want to use a different * While these routines are sufficient for most applications,
* source manager. * some will want to use a different source manager.
* IMPORTANT: we assume that fread() will correctly transcribe an array of * IMPORTANT: we assume that fread() will correctly transcribe an array of
* JOCTETs from 8-bit-wide elements on external storage. If char is wider * JOCTETs from 8-bit-wide elements on external storage. If char is wider
* than 8 bits on your machine, you may need to do some tweaking. * than 8 bits on your machine, you may need to do some tweaking.
@@ -52,6 +53,14 @@ init_source (j_decompress_ptr cinfo)
src->start_of_file = TRUE; src->start_of_file = TRUE;
} }
#if JPEG_LIB_VERSION >= 80
METHODDEF(void)
init_mem_source (j_decompress_ptr cinfo)
{
/* no work necessary here */
}
#endif
/* /*
* Fill the input buffer --- called whenever buffer is emptied. * Fill the input buffer --- called whenever buffer is emptied.
@@ -111,6 +120,28 @@ fill_input_buffer (j_decompress_ptr cinfo)
return TRUE; return TRUE;
} }
#if JPEG_LIB_VERSION >= 80
METHODDEF(boolean)
fill_mem_input_buffer (j_decompress_ptr cinfo)
{
static JOCTET mybuffer[4];
/* 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;
return TRUE;
}
#endif
/* /*
* Skip data --- used to skip over a potentially large amount of * Skip data --- used to skip over a potentially large amount of
@@ -127,22 +158,22 @@ fill_input_buffer (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
skip_input_data (j_decompress_ptr cinfo, long num_bytes) skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{ {
my_src_ptr src = (my_src_ptr) cinfo->src; struct jpeg_source_mgr * src = cinfo->src;
/* Just a dumb implementation for now. Could use fseek() except /* Just a dumb implementation for now. Could use fseek() except
* it doesn't work on pipes. Not clear that being smart is worth * it doesn't work on pipes. Not clear that being smart is worth
* any trouble anyway --- large skips are infrequent. * any trouble anyway --- large skips are infrequent.
*/ */
if (num_bytes > 0) { if (num_bytes > 0) {
while (num_bytes > (long) src->pub.bytes_in_buffer) { while (num_bytes > (long) src->bytes_in_buffer) {
num_bytes -= (long) src->pub.bytes_in_buffer; num_bytes -= (long) src->bytes_in_buffer;
(void) fill_input_buffer(cinfo); (void) (*src->fill_input_buffer) (cinfo);
/* note we assume that fill_input_buffer will never return FALSE, /* note we assume that fill_input_buffer will never return FALSE,
* so suspension need not be handled. * so suspension need not be handled.
*/ */
} }
src->pub.next_input_byte += (size_t) num_bytes; src->next_input_byte += (size_t) num_bytes;
src->pub.bytes_in_buffer -= (size_t) num_bytes; src->bytes_in_buffer -= (size_t) num_bytes;
} }
} }
@@ -210,3 +241,40 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
src->pub.next_input_byte = NULL; /* until buffer loaded */ src->pub.next_input_byte = NULL; /* until buffer loaded */
} }
#if JPEG_LIB_VERSION >= 80
/*
* Prepare for input from a supplied memory buffer.
* The buffer must contain the whole JPEG data.
*/
GLOBAL(void)
jpeg_mem_src (j_decompress_ptr cinfo,
unsigned char * inbuffer, unsigned long insize)
{
struct jpeg_source_mgr * src;
if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
ERREXIT(cinfo, JERR_INPUT_EMPTY);
/* The source object is made permanent so that a series of JPEG images
* can be read from the same buffer by calling jpeg_mem_src only before
* 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));
}
src = cinfo->src;
src->init_source = init_mem_source;
src->fill_input_buffer = fill_mem_input_buffer;
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;
}
#endif

View File

@@ -2,6 +2,7 @@
* jdcoefct.c * jdcoefct.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -17,6 +18,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* Block smoothing is only applicable for progressive JPEG, so: */ /* Block smoothing is only applicable for progressive JPEG, so: */
#ifndef D_PROGRESSIVE_SUPPORTED #ifndef D_PROGRESSIVE_SUPPORTED
@@ -190,7 +192,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width; : compptr->last_col_width;
output_ptr = output_buf[compptr->component_index] + output_ptr = output_buf[compptr->component_index] +
yoffset * compptr->DCT_scaled_size; yoffset * compptr->_DCT_scaled_size;
start_col = MCU_col_num * compptr->MCU_sample_width; start_col = MCU_col_num * compptr->MCU_sample_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (cinfo->input_iMCU_row < last_iMCU_row || if (cinfo->input_iMCU_row < last_iMCU_row ||
@@ -200,11 +202,11 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(*inverse_DCT) (cinfo, compptr, (*inverse_DCT) (cinfo, compptr,
(JCOEFPTR) coef->MCU_buffer[blkn+xindex], (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
output_ptr, output_col); output_ptr, output_col);
output_col += compptr->DCT_scaled_size; output_col += compptr->_DCT_scaled_size;
} }
} }
blkn += compptr->MCU_width; blkn += compptr->MCU_width;
output_ptr += compptr->DCT_scaled_size; output_ptr += compptr->_DCT_scaled_size;
} }
} }
} }
@@ -365,9 +367,9 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
output_ptr, output_col); output_ptr, output_col);
buffer_ptr++; buffer_ptr++;
output_col += compptr->DCT_scaled_size; output_col += compptr->_DCT_scaled_size;
} }
output_ptr += compptr->DCT_scaled_size; output_ptr += compptr->_DCT_scaled_size;
} }
} }
@@ -660,9 +662,9 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
DC4 = DC5; DC5 = DC6; DC4 = DC5; DC5 = DC6;
DC7 = DC8; DC8 = DC9; DC7 = DC8; DC8 = DC9;
buffer_ptr++, prev_block_row++, next_block_row++; buffer_ptr++, prev_block_row++, next_block_row++;
output_col += compptr->DCT_scaled_size; output_col += compptr->_DCT_scaled_size;
} }
output_ptr += compptr->DCT_scaled_size; output_ptr += compptr->_DCT_scaled_size;
} }
} }

View File

@@ -223,7 +223,6 @@ gray_rgb_convert (j_decompress_ptr cinfo,
{ {
register JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
JSAMPLE *maxinptr; JSAMPLE *maxinptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width; JDIMENSION num_cols = cinfo->output_width;
int rindex = rgb_red[cinfo->out_color_space]; int rindex = rgb_red[cinfo->out_color_space];
int gindex = rgb_green[cinfo->out_color_space]; int gindex = rgb_green[cinfo->out_color_space];

View File

@@ -3,6 +3,7 @@
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -21,6 +22,7 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jdct.h" /* Private declarations for DCT subsystem */ #include "jdct.h" /* Private declarations for DCT subsystem */
#include "jsimddct.h" #include "jsimddct.h"
#include "jpegcomp.h"
/* /*
@@ -100,7 +102,7 @@ start_pass (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
/* Select the proper IDCT routine for this component's scaling */ /* Select the proper IDCT routine for this component's scaling */
switch (compptr->DCT_scaled_size) { switch (compptr->_DCT_scaled_size) {
#ifdef IDCT_SCALING_SUPPORTED #ifdef IDCT_SCALING_SUPPORTED
case 1: case 1:
method_ptr = jpeg_idct_1x1; method_ptr = jpeg_idct_1x1;
@@ -156,7 +158,7 @@ start_pass (j_decompress_ptr cinfo)
} }
break; break;
default: default:
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
break; break;
} }
idct->pub.inverse_DCT[ci] = method_ptr; idct->pub.inverse_DCT[ci] = method_ptr;

View File

@@ -2,6 +2,7 @@
* jdhuff.c * jdhuff.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -14,7 +15,7 @@
* storage only upon successful completion of an MCU. * storage only upon successful completion of an MCU.
*/ */
/* Modifications: /* Performance enhancements:
* Copyright (C)2007 Sun Microsystems, Inc. * Copyright (C)2007 Sun Microsystems, Inc.
* Copyright (C)2009-2010 D. R. Commander * Copyright (C)2009-2010 D. R. Commander
* *
@@ -33,6 +34,7 @@
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jdhuff.h" /* Declarations shared with jdphuff.c */ #include "jdhuff.h" /* Declarations shared with jdphuff.c */
#include "jpegcomp.h"
/* /*
@@ -137,7 +139,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
if (compptr->component_needed) { if (compptr->component_needed) {
entropy->dc_needed[blkn] = TRUE; entropy->dc_needed[blkn] = TRUE;
/* we don't need the ACs if producing a 1/8th-size image */ /* we don't need the ACs if producing a 1/8th-size image */
entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); entropy->ac_needed[blkn] = (compptr->_DCT_scaled_size > 1);
} else { } else {
entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
} }
@@ -621,6 +623,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (val0 == 0xFF) { \ if (val0 == 0xFF) { \
buffer++; \ buffer++; \
if (val1 != 0) { \ if (val1 != 0) { \
cinfo->unread_marker = val1; \
buffer -= 2; \ buffer -= 2; \
get_buffer &= ~0xFF; \ get_buffer &= ~0xFF; \
} \ } \
@@ -658,7 +661,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
symbol |= GET_BITS(1); \ symbol |= GET_BITS(1); \
size++; \ size++; \
} \ } \
symbol = htbl->pub->huffval[ (int) (symbol + htbl->valoffset[size]) ]; \ symbol = htbl->pub->huffval[ (int) (symbol + htbl->valoffset[size]) & 0xFF ]; \
} \ } \
} }
@@ -737,6 +740,11 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
} }
} }
if (cinfo->unread_marker != 0) {
cinfo->unread_marker = 0;
return FALSE;
}
br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte); br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
br_state.next_input_byte = buffer; br_state.next_input_byte = buffer;
BITREAD_SAVE_STATE(cinfo,entropy->bitstate); BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
@@ -776,7 +784,8 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
usefast = 0; usefast = 0;
} }
if (cinfo->src->bytes_in_buffer < BUFSIZE * cinfo->blocks_in_MCU) if (cinfo->src->bytes_in_buffer < BUFSIZE * cinfo->blocks_in_MCU
|| cinfo->unread_marker != 0)
usefast = 0; usefast = 0;
/* If we've run out of data, just leave the MCU set to zeroes. /* If we've run out of data, just leave the MCU set to zeroes.
@@ -785,9 +794,10 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (! entropy->pub.insufficient_data) { if (! entropy->pub.insufficient_data) {
if (usefast) { if (usefast) {
if (!decode_mcu_fast(cinfo, MCU_data)) return FALSE; if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
} }
else { else {
use_slow:
if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE; if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
} }

View File

@@ -2,6 +2,8 @@
* jdinput.c * jdinput.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2002-2009 by Guido Vollbeding.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -14,6 +16,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* Private state */ /* Private state */
@@ -35,6 +38,79 @@ METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo));
* Routines to calculate various quantities related to the size of the image. * Routines to calculate various quantities related to the size of the image.
*/ */
#if JPEG_LIB_VERSION >= 80
/*
* Compute output 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_core_output_dimensions (j_decompress_ptr cinfo)
/* Do computations that are needed before master selection phase.
* This function is used for transcoding and full decompression.
*/
{
#ifdef IDCT_SCALING_SUPPORTED
int ci;
jpeg_component_info *compptr;
/* Compute actual output image dimensions and DCT scaling choices. */
if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) {
/* Provide 1/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 1;
cinfo->min_DCT_v_scaled_size = 1;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) {
/* Provide 2/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 2;
cinfo->min_DCT_v_scaled_size = 2;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) {
/* Provide 4/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 4;
cinfo->min_DCT_v_scaled_size = 4;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) {
/* Provide 8/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 8;
cinfo->min_DCT_v_scaled_size = 8;
}
/* Recompute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size;
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size;
}
#else /* !IDCT_SCALING_SUPPORTED */
/* 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,
* and has computed unscaled downsampled_width and downsampled_height.
*/
#endif /* IDCT_SCALING_SUPPORTED */
}
#endif
LOCAL(void) LOCAL(void)
initial_setup (j_decompress_ptr cinfo) initial_setup (j_decompress_ptr cinfo)
/* Called once, when first SOS marker is reached */ /* Called once, when first SOS marker is reached */
@@ -70,16 +146,30 @@ initial_setup (j_decompress_ptr cinfo)
compptr->v_samp_factor); compptr->v_samp_factor);
} }
#if JPEG_LIB_VERSION >=80
cinfo->block_size = DCTSIZE;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
#endif
/* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
* In the full decompressor, this will be overridden by jdmaster.c; * In the full decompressor, this will be overridden by jdmaster.c;
* but in the transcoder, jdmaster.c is not used, so we must do it here. * but in the transcoder, jdmaster.c is not used, so we must do it here.
*/ */
#if JPEG_LIB_VERSION >= 70
cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
#else
cinfo->min_DCT_scaled_size = DCTSIZE; cinfo->min_DCT_scaled_size = DCTSIZE;
#endif
/* Compute dimensions of components */ /* Compute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
#if JPEG_LIB_VERSION >= 70
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
#else
compptr->DCT_scaled_size = DCTSIZE; compptr->DCT_scaled_size = DCTSIZE;
#endif
/* Size in DCT blocks */ /* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION) compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
@@ -138,7 +228,7 @@ per_scan_setup (j_decompress_ptr cinfo)
compptr->MCU_width = 1; compptr->MCU_width = 1;
compptr->MCU_height = 1; compptr->MCU_height = 1;
compptr->MCU_blocks = 1; compptr->MCU_blocks = 1;
compptr->MCU_sample_width = compptr->DCT_scaled_size; compptr->MCU_sample_width = compptr->_DCT_scaled_size;
compptr->last_col_width = 1; compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height /* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row. * as the number of block rows present in the last iMCU row.
@@ -174,7 +264,7 @@ per_scan_setup (j_decompress_ptr cinfo)
compptr->MCU_width = compptr->h_samp_factor; compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor; compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; compptr->MCU_sample_width = compptr->MCU_width * compptr->_DCT_scaled_size;
/* Figure number of non-dummy blocks in last MCU column & row */ /* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width; if (tmp == 0) tmp = compptr->MCU_width;

View File

@@ -2,6 +2,7 @@
* jdmainct.c * jdmainct.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -16,6 +17,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* /*
@@ -161,7 +163,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
{ {
my_main_ptr main = (my_main_ptr) cinfo->main; my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, rgroup; int ci, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY xbuf; JSAMPARRAY xbuf;
@@ -175,8 +177,8 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; /* height of a row group of component */ cinfo->_min_DCT_scaled_size; /* height of a row group of component */
/* Get space for pointer lists --- M+4 row groups in each list. /* Get space for pointer lists --- M+4 row groups in each list.
* We alloc both pointer lists with one call to save a few cycles. * We alloc both pointer lists with one call to save a few cycles.
*/ */
@@ -202,14 +204,14 @@ make_funny_pointers (j_decompress_ptr cinfo)
{ {
my_main_ptr main = (my_main_ptr) cinfo->main; my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup; int ci, i, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY buf, xbuf0, xbuf1; JSAMPARRAY buf, xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; /* height of a row group of component */ cinfo->_min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci]; xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci]; xbuf1 = main->xbuffer[1][ci];
/* First copy the workspace pointers as-is */ /* First copy the workspace pointers as-is */
@@ -242,14 +244,14 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
{ {
my_main_ptr main = (my_main_ptr) cinfo->main; my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup; int ci, i, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY xbuf0, xbuf1; JSAMPARRAY xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; /* height of a row group of component */ cinfo->_min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci]; xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci]; xbuf1 = main->xbuffer[1][ci];
for (i = 0; i < rgroup; i++) { for (i = 0; i < rgroup; i++) {
@@ -277,8 +279,8 @@ set_bottom_pointers (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
/* Count sample rows in one iMCU row and in one row group */ /* Count sample rows in one iMCU row and in one row group */
iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; iMCUheight = compptr->v_samp_factor * compptr->_DCT_scaled_size;
rgroup = iMCUheight / cinfo->min_DCT_scaled_size; rgroup = iMCUheight / cinfo->_min_DCT_scaled_size;
/* Count nondummy sample rows remaining for this component */ /* Count nondummy sample rows remaining for this component */
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
if (rows_left == 0) rows_left = iMCUheight; if (rows_left == 0) rows_left = iMCUheight;
@@ -357,7 +359,7 @@ process_data_simple_main (j_decompress_ptr cinfo,
} }
/* There are always min_DCT_scaled_size row groups in an iMCU row. */ /* There are always min_DCT_scaled_size row groups in an iMCU row. */
rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size;
/* Note: at the bottom of the image, we may pass extra garbage row groups /* Note: at the bottom of the image, we may pass extra garbage row groups
* to the postprocessor. The postprocessor has to check for bottom * to the postprocessor. The postprocessor has to check for bottom
* of image anyway (at row resolution), so no point in us doing it too. * of image anyway (at row resolution), so no point in us doing it too.
@@ -417,7 +419,7 @@ process_data_context_main (j_decompress_ptr cinfo,
case CTX_PREPARE_FOR_IMCU: case CTX_PREPARE_FOR_IMCU:
/* Prepare to process first M-1 row groups of this iMCU row */ /* Prepare to process first M-1 row groups of this iMCU row */
main->rowgroup_ctr = 0; main->rowgroup_ctr = 0;
main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); main->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1);
/* Check for bottom of image: if so, tweak pointers to "duplicate" /* Check for bottom of image: if so, tweak pointers to "duplicate"
* the last sample row, and adjust rowgroups_avail to ignore padding rows. * the last sample row, and adjust rowgroups_avail to ignore padding rows.
*/ */
@@ -440,8 +442,8 @@ process_data_context_main (j_decompress_ptr cinfo,
main->buffer_full = FALSE; main->buffer_full = FALSE;
/* Still need to process last row group of this iMCU row, */ /* Still need to process last row group of this iMCU row, */
/* which is saved at index M+1 of the other xbuffer */ /* which is saved at index M+1 of the other xbuffer */
main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); main->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1);
main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); main->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2);
main->context_state = CTX_POSTPONED_ROW; main->context_state = CTX_POSTPONED_ROW;
} }
} }
@@ -492,21 +494,21 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
* ngroups is the number of row groups we need. * ngroups is the number of row groups we need.
*/ */
if (cinfo->upsample->need_context_rows) { if (cinfo->upsample->need_context_rows) {
if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
ERREXIT(cinfo, JERR_NOTIMPL); ERREXIT(cinfo, JERR_NOTIMPL);
alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
ngroups = cinfo->min_DCT_scaled_size + 2; ngroups = cinfo->_min_DCT_scaled_size + 2;
} else { } else {
ngroups = cinfo->min_DCT_scaled_size; ngroups = cinfo->_min_DCT_scaled_size;
} }
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; /* height of a row group of component */ cinfo->_min_DCT_scaled_size; /* height of a row group of component */
main->buffer[ci] = (*cinfo->mem->alloc_sarray) main->buffer[ci] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
compptr->width_in_blocks * compptr->DCT_scaled_size, compptr->width_in_blocks * compptr->_DCT_scaled_size,
(JDIMENSION) (rgroup * ngroups)); (JDIMENSION) (rgroup * ngroups));
} }
} }

View File

@@ -2,7 +2,7 @@
* jdmaster.c * jdmaster.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Copyright (C) 2009, D. R. Commander. * Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -15,6 +15,7 @@
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jpegcomp.h"
/* Private state */ /* Private state */
@@ -68,9 +69,9 @@ use_merged_upsample (j_decompress_ptr cinfo)
cinfo->comp_info[2].v_samp_factor != 1) cinfo->comp_info[2].v_samp_factor != 1)
return FALSE; return FALSE;
/* furthermore, it doesn't work if we've scaled the IDCTs differently */ /* furthermore, it doesn't work if we've scaled the IDCTs differently */
if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
return FALSE; return FALSE;
/* ??? also need to test for upsample-time rescaling, when & if supported */ /* ??? also need to test for upsample-time rescaling, when & if supported */
return TRUE; /* by golly, it'll work... */ return TRUE; /* by golly, it'll work... */
@@ -109,26 +110,42 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
jdiv_round_up((long) cinfo->image_width, 8L); jdiv_round_up((long) cinfo->image_width, 8L);
cinfo->output_height = (JDIMENSION) cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 8L); jdiv_round_up((long) cinfo->image_height, 8L);
#if JPEG_LIB_VERSION >= 70
cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 1;
#else
cinfo->min_DCT_scaled_size = 1; cinfo->min_DCT_scaled_size = 1;
#endif
} else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
/* Provide 1/4 scaling */ /* Provide 1/4 scaling */
cinfo->output_width = (JDIMENSION) cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, 4L); jdiv_round_up((long) cinfo->image_width, 4L);
cinfo->output_height = (JDIMENSION) cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 4L); jdiv_round_up((long) cinfo->image_height, 4L);
#if JPEG_LIB_VERSION >= 70
cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 2;
#else
cinfo->min_DCT_scaled_size = 2; cinfo->min_DCT_scaled_size = 2;
#endif
} else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
/* Provide 1/2 scaling */ /* Provide 1/2 scaling */
cinfo->output_width = (JDIMENSION) cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, 2L); jdiv_round_up((long) cinfo->image_width, 2L);
cinfo->output_height = (JDIMENSION) cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 2L); jdiv_round_up((long) cinfo->image_height, 2L);
#if JPEG_LIB_VERSION >= 70
cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 4;
#else
cinfo->min_DCT_scaled_size = 4; cinfo->min_DCT_scaled_size = 4;
#endif
} else { } else {
/* Provide 1/1 scaling */ /* Provide 1/1 scaling */
cinfo->output_width = cinfo->image_width; cinfo->output_width = cinfo->image_width;
cinfo->output_height = cinfo->image_height; cinfo->output_height = cinfo->image_height;
#if JPEG_LIB_VERSION >= 70
cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
#else
cinfo->min_DCT_scaled_size = DCTSIZE; cinfo->min_DCT_scaled_size = DCTSIZE;
#endif
} }
/* In selecting the actual DCT scaling for each component, we try to /* In selecting the actual DCT scaling for each component, we try to
* scale up the chroma components via IDCT scaling rather than upsampling. * scale up the chroma components via IDCT scaling rather than upsampling.
@@ -137,15 +154,19 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
*/ */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
int ssize = cinfo->min_DCT_scaled_size; int ssize = cinfo->_min_DCT_scaled_size;
while (ssize < DCTSIZE && while (ssize < DCTSIZE &&
(compptr->h_samp_factor * ssize * 2 <= (compptr->h_samp_factor * ssize * 2 <=
cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) &&
(compptr->v_samp_factor * ssize * 2 <= (compptr->v_samp_factor * ssize * 2 <=
cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size)) {
ssize = ssize * 2; ssize = ssize * 2;
} }
#if JPEG_LIB_VERSION >= 70
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
#else
compptr->DCT_scaled_size = ssize; compptr->DCT_scaled_size = ssize;
#endif
} }
/* Recompute downsampled dimensions of components; /* Recompute downsampled dimensions of components;
@@ -156,11 +177,11 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
/* Size in samples, after IDCT scaling */ /* Size in samples, after IDCT scaling */
compptr->downsampled_width = (JDIMENSION) compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * jdiv_round_up((long) cinfo->image_width *
(long) (compptr->h_samp_factor * compptr->DCT_scaled_size), (long) (compptr->h_samp_factor * compptr->_DCT_scaled_size),
(long) (cinfo->max_h_samp_factor * DCTSIZE)); (long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->downsampled_height = (JDIMENSION) compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * jdiv_round_up((long) cinfo->image_height *
(long) (compptr->v_samp_factor * compptr->DCT_scaled_size), (long) (compptr->v_samp_factor * compptr->_DCT_scaled_size),
(long) (cinfo->max_v_samp_factor * DCTSIZE)); (long) (cinfo->max_v_samp_factor * DCTSIZE));
} }
@@ -384,7 +405,11 @@ master_selection (j_decompress_ptr cinfo)
jinit_inverse_dct(cinfo); jinit_inverse_dct(cinfo);
/* Entropy decoding: either Huffman or arithmetic coding. */ /* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code) {
#ifdef D_ARITH_CODING_SUPPORTED
jinit_arith_decoder(cinfo);
#else
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
#endif
} else { } else {
if (cinfo->progressive_mode) { if (cinfo->progressive_mode) {
#ifdef D_PROGRESSIVE_SUPPORTED #ifdef D_PROGRESSIVE_SUPPORTED

View File

@@ -3,6 +3,7 @@
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -23,6 +24,7 @@
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jsimd.h" #include "jsimd.h"
#include "jpegcomp.h"
/* Pointer to routine to upsample a single component */ /* Pointer to routine to upsample a single component */
@@ -420,7 +422,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
/* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
* so don't ask for it. * so don't ask for it.
*/ */
do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;
/* Verify we can handle the sampling factors, select per-component methods, /* Verify we can handle the sampling factors, select per-component methods,
* and create storage as needed. * and create storage as needed.
@@ -430,10 +432,10 @@ jinit_upsampler (j_decompress_ptr cinfo)
/* Compute size of an "input group" after IDCT scaling. This many samples /* Compute size of an "input group" after IDCT scaling. This many samples
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels. * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
*/ */
h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; cinfo->_min_DCT_scaled_size;
v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->min_DCT_scaled_size; cinfo->_min_DCT_scaled_size;
h_out_group = cinfo->max_h_samp_factor; h_out_group = cinfo->max_h_samp_factor;
v_out_group = cinfo->max_v_samp_factor; v_out_group = cinfo->max_v_samp_factor;
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ upsample->rowgroup_height[ci] = v_in_group; /* save for use later */

View File

@@ -99,9 +99,18 @@ transdecode_master_selection (j_decompress_ptr cinfo)
/* This is effectively a buffered-image operation. */ /* This is effectively a buffered-image operation. */
cinfo->buffered_image = TRUE; cinfo->buffered_image = TRUE;
#if JPEG_LIB_VERSION >= 80
/* Compute output image dimensions and related values. */
jpeg_core_output_dimensions(cinfo);
#endif
/* Entropy decoding: either Huffman or arithmetic coding. */ /* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code) {
#ifdef D_ARITH_CODING_SUPPORTED
jinit_arith_decoder(cinfo);
#else
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
#endif
} else { } else {
if (cinfo->progressive_mode) { if (cinfo->progressive_mode) {
#ifdef D_PROGRESSIVE_SUPPORTED #ifdef D_PROGRESSIVE_SUPPORTED

View File

@@ -2,6 +2,7 @@
* jerror.h * jerror.h
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -40,11 +41,12 @@ JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
/* For maintenance convenience, list is alphabetical by message code name */ /* For maintenance convenience, list is alphabetical by message code name */
JMESSAGE(JERR_ARITH_NOTIMPL, JMESSAGE(JERR_ARITH_NOTIMPL,
"Sorry, there are legal restrictions on arithmetic coding") "Sorry, arithmetic coding is not implemented")
JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
@@ -93,6 +95,7 @@ JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
JMESSAGE(JERR_NOTIMPL, "Not implemented yet") JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
@@ -170,6 +173,7 @@ JMESSAGE(JTRC_UNKNOWN_IDS,
JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
JMESSAGE(JWRN_BOGUS_PROGRESSION, JMESSAGE(JWRN_BOGUS_PROGRESSION,
"Inconsistent progression sequence for component %d coefficient %d") "Inconsistent progression sequence for component %d coefficient %d")
JMESSAGE(JWRN_EXTRANEOUS_DATA, JMESSAGE(JWRN_EXTRANEOUS_DATA,

View File

@@ -37,6 +37,15 @@ extern char * getenv JPP((const char * name));
#endif #endif
LOCAL(size_t)
round_up_pow2 (size_t a, size_t b)
/* a rounded up to the next multiple of b, i.e. ceil(a/b)*b */
/* Assumes a >= 0, b > 0, and b is a power of 2 */
{
return ((a + b - 1) & (~(b - 1)));
}
/* /*
* Some important notes: * Some important notes:
* The allocation routines provided here must never return NULL. * The allocation routines provided here must never return NULL.
@@ -265,7 +274,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
* and so that algorithms can straddle outside the proper area up * and so that algorithms can straddle outside the proper area up
* to the next alignment. * to the next alignment.
*/ */
sizeofobject = jround_up(sizeofobject, ALIGN_SIZE); sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
@@ -354,7 +363,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
* algorithms can straddle outside the proper area up to the next * algorithms can straddle outside the proper area up to the next
* alignment. * alignment.
*/ */
sizeofobject = jround_up(sizeofobject, ALIGN_SIZE); sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
@@ -420,7 +429,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
/* Make sure each row is properly aligned */ /* Make sure each row is properly aligned */
if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0) if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0)
out_of_memory(cinfo, 5); /* safety check */ out_of_memory(cinfo, 5); /* safety check */
samplesperrow = (JDIMENSION)jround_up(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE)); samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE));
/* Calculate max # of rows allowed in one allocation chunk */ /* 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)) /

View File

@@ -257,8 +257,6 @@ typedef int boolean;
* (You may HAVE to do that if your compiler doesn't like null source files.) * (You may HAVE to do that if your compiler doesn't like null source files.)
*/ */
/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
/* Capability options common to encoder and decoder: */ /* Capability options common to encoder and decoder: */
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
@@ -267,7 +265,6 @@ typedef int boolean;
/* Encoder capability options: */ /* Encoder capability options: */
#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
@@ -283,7 +280,6 @@ typedef int boolean;
/* Decoder capability options: */ /* Decoder capability options: */
#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */

26
jpegcomp.h Normal file
View File

@@ -0,0 +1,26 @@
/*
* jpegcomp.h
*
* Copyright (C) 2010, D. R. Commander
* For conditions of distribution and use, see the accompanying README file.
*
* JPEG compatibility macros
* These declarations are considered internal to the JPEG library; most
* applications using the library shouldn't need to include this file.
*/
#if JPEG_LIB_VERSION >= 70
#define _DCT_scaled_size DCT_h_scaled_size
#define _min_DCT_scaled_size min_DCT_h_scaled_size
#define _min_DCT_h_scaled_size min_DCT_h_scaled_size
#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
#define _jpeg_width jpeg_width
#define _jpeg_height jpeg_height
#else
#define _DCT_scaled_size DCT_scaled_size
#define _min_DCT_scaled_size min_DCT_scaled_size
#define _min_DCT_h_scaled_size min_DCT_scaled_size
#define _min_DCT_v_scaled_size min_DCT_scaled_size
#define _jpeg_width image_width
#define _jpeg_height image_height
#endif

View File

@@ -2,6 +2,7 @@
* jpegint.h * jpegint.h
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -304,6 +305,7 @@ struct jpeg_color_quantizer {
#define jinit_forward_dct jIFDCT #define jinit_forward_dct jIFDCT
#define jinit_huff_encoder jIHEncoder #define jinit_huff_encoder jIHEncoder
#define jinit_phuff_encoder jIPHEncoder #define jinit_phuff_encoder jIPHEncoder
#define jinit_arith_encoder jIAEncoder
#define jinit_marker_writer jIMWriter #define jinit_marker_writer jIMWriter
#define jinit_master_decompress jIDMaster #define jinit_master_decompress jIDMaster
#define jinit_d_main_controller jIDMainC #define jinit_d_main_controller jIDMainC
@@ -313,6 +315,7 @@ struct jpeg_color_quantizer {
#define jinit_marker_reader jIMReader #define jinit_marker_reader jIMReader
#define jinit_huff_decoder jIHDecoder #define jinit_huff_decoder jIHDecoder
#define jinit_phuff_decoder jIPHDecoder #define jinit_phuff_decoder jIPHDecoder
#define jinit_arith_decoder jIADecoder
#define jinit_inverse_dct jIIDCT #define jinit_inverse_dct jIIDCT
#define jinit_upsampler jIUpsampler #define jinit_upsampler jIUpsampler
#define jinit_color_deconverter jIDColor #define jinit_color_deconverter jIDColor
@@ -327,6 +330,7 @@ struct jpeg_color_quantizer {
#define jzero_far jZeroFar #define jzero_far jZeroFar
#define jpeg_zigzag_order jZIGTable #define jpeg_zigzag_order jZIGTable
#define jpeg_natural_order jZAGTable #define jpeg_natural_order jZAGTable
#define jpeg_aritab jAriTab
#endif /* NEED_SHORT_EXTERNAL_NAMES */ #endif /* NEED_SHORT_EXTERNAL_NAMES */
@@ -345,6 +349,7 @@ EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
/* Decompression module initialization routines */ /* Decompression module initialization routines */
EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
@@ -358,6 +363,7 @@ EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
@@ -369,7 +375,7 @@ EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
/* Utility routines in jutils.c */ /* Utility routines in jutils.c */
EXTERN(long) jdiv_round_up JPP((long a, long b)); EXTERN(long) jdiv_round_up JPP((long a, long b));
EXTERN(size_t) jround_up JPP((size_t a, size_t b)); EXTERN(long) jround_up JPP((long a, long b));
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
JSAMPARRAY output_array, int dest_row, JSAMPARRAY output_array, int dest_row,
int num_rows, JDIMENSION num_cols)); int num_rows, JDIMENSION num_cols));
@@ -382,6 +388,9 @@ extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
#endif #endif
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
/* Arithmetic coding probability estimation tables in jaricom.c */
extern const INT32 jpeg_aritab[];
/* Suppress undefined-structure complaints if necessary. */ /* Suppress undefined-structure complaints if necessary. */
#ifdef INCOMPLETE_TYPES_BROKEN #ifdef INCOMPLETE_TYPES_BROKEN

123
jpeglib.h
View File

@@ -2,7 +2,8 @@
* jpeglib.h * jpeglib.h
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Copyright (C) 2009, D. R. Commander. * Modified 2002-2009 by Guido Vollbeding.
* Copyright (C) 2009-2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -14,10 +15,6 @@
#ifndef JPEGLIB_H #ifndef JPEGLIB_H
#define JPEGLIB_H #define JPEGLIB_H
#ifdef __cplusplus
extern "C" {
#endif
/* /*
* First we include the configuration files that record how this * First we include the configuration files that record how this
* installation of the JPEG library is set up. jconfig.h can be * installation of the JPEG library is set up. jconfig.h can be
@@ -31,11 +28,11 @@ extern "C" {
#include "jmorecfg.h" /* seldom changed options */ #include "jmorecfg.h" /* seldom changed options */
/* Version ID for the JPEG library. #ifdef __cplusplus
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". #ifndef DONT_USE_EXTERN_C
*/ extern "C" {
#endif
#define JPEG_LIB_VERSION 62 /* Version 6b */ #endif
/* Various constants determining the sizes of things. /* Various constants determining the sizes of things.
@@ -149,12 +146,17 @@ typedef struct {
* Values of 1,2,4,8 are likely to be supported. Note that different * Values of 1,2,4,8 are likely to be supported. Note that different
* components may receive different IDCT scalings. * components may receive different IDCT scalings.
*/ */
#if JPEG_LIB_VERSION >= 70
int DCT_h_scaled_size;
int DCT_v_scaled_size;
#else
int DCT_scaled_size; int DCT_scaled_size;
#endif
/* The downsampled dimensions are the component's actual, unpadded number /* The downsampled dimensions are the component's actual, unpadded number
* of samples at the main buffer (preprocessing/compression interface), thus * of samples at the main buffer (preprocessing/compression interface), thus
* downsampled_width = ceil(image_width * Hi/Hmax) * downsampled_width = ceil(image_width * Hi/Hmax)
* and similarly for height. For decompression, IDCT scaling is included, so * and similarly for height. For decompression, IDCT scaling is included, so
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) * downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
*/ */
JDIMENSION downsampled_width; /* actual width in samples */ JDIMENSION downsampled_width; /* actual width in samples */
JDIMENSION downsampled_height; /* actual height in samples */ JDIMENSION downsampled_height; /* actual height in samples */
@@ -169,7 +171,7 @@ typedef struct {
int MCU_width; /* number of blocks per MCU, horizontally */ int MCU_width; /* number of blocks per MCU, horizontally */
int MCU_height; /* number of blocks per MCU, vertically */ int MCU_height; /* number of blocks per MCU, vertically */
int MCU_blocks; /* MCU_width * MCU_height */ int MCU_blocks; /* MCU_width * MCU_height */
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
int last_col_width; /* # of non-dummy blocks across in last MCU */ int last_col_width; /* # of non-dummy blocks across in last MCU */
int last_row_height; /* # of non-dummy blocks down in last MCU */ int last_row_height; /* # of non-dummy blocks down in last MCU */
@@ -305,6 +307,19 @@ struct jpeg_compress_struct {
* helper routines to simplify changing parameters. * helper routines to simplify changing parameters.
*/ */
#if JPEG_LIB_VERSION >= 70
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
JDIMENSION jpeg_width; /* scaled JPEG image width */
JDIMENSION jpeg_height; /* scaled JPEG image height */
/* Dimensions of actual JPEG image that will be written to file,
* derived from input dimensions by scaling factors above.
* These fields are computed by jpeg_start_compress().
* You can also use jpeg_calc_jpeg_dimensions() to determine these values
* in advance of calling jpeg_start_compress().
*/
#endif
int data_precision; /* bits of precision in image data */ int data_precision; /* bits of precision in image data */
int num_components; /* # of color components in JPEG image */ int num_components; /* # of color components in JPEG image */
@@ -312,14 +327,19 @@ struct jpeg_compress_struct {
jpeg_component_info * comp_info; jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */ /* comp_info[i] describes component that appears i'th in SOF */
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
/* ptrs to coefficient quantization tables, or NULL if not defined */ #if JPEG_LIB_VERSION >= 70
int q_scale_factor[NUM_QUANT_TBLS];
#endif
/* ptrs to coefficient quantization tables, or NULL if not defined,
* and corresponding scale factors (percentage, initialized 100).
*/
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
/* ptrs to Huffman coding tables, or NULL if not defined */ /* ptrs to Huffman coding tables, or NULL if not defined */
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
@@ -335,6 +355,9 @@ struct jpeg_compress_struct {
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
#if JPEG_LIB_VERSION >= 70
boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
#endif
int smoothing_factor; /* 1..100, or 0 for no input smoothing */ int smoothing_factor; /* 1..100, or 0 for no input smoothing */
J_DCT_METHOD dct_method; /* DCT algorithm selector */ J_DCT_METHOD dct_method; /* DCT algorithm selector */
@@ -378,6 +401,11 @@ struct jpeg_compress_struct {
int max_h_samp_factor; /* largest h_samp_factor */ int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */ int max_v_samp_factor; /* largest v_samp_factor */
#if JPEG_LIB_VERSION >= 70
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
#endif
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ 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 /* The coefficient controller receives data in units of MCU rows as defined
* for fully interleaved scans (whether the JPEG file is interleaved or not). * for fully interleaved scans (whether the JPEG file is interleaved or not).
@@ -403,6 +431,12 @@ struct jpeg_compress_struct {
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
#if JPEG_LIB_VERSION >= 80
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array */
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
#endif
/* /*
* Links to compression subobjects (methods and private variables of modules) * Links to compression subobjects (methods and private variables of modules)
*/ */
@@ -549,6 +583,9 @@ struct jpeg_decompress_struct {
jpeg_component_info * comp_info; jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */ /* comp_info[i] describes component that appears i'th in SOF */
#if JPEG_LIB_VERSION >= 80
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
#endif
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
@@ -589,7 +626,12 @@ struct jpeg_decompress_struct {
int max_h_samp_factor; /* largest h_samp_factor */ int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */ int max_v_samp_factor; /* largest v_samp_factor */
#if JPEG_LIB_VERSION >= 70
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
#else
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
#endif
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
/* The coefficient controller's input and output progress is measured in /* The coefficient controller's input and output progress is measured in
@@ -597,7 +639,7 @@ struct jpeg_decompress_struct {
* in fully interleaved JPEG scans, but are used whether the scan is * 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 * interleaved or not. We define an iMCU row as v_samp_factor DCT block
* rows of each component. Therefore, the IDCT output contains * rows of each component. Therefore, the IDCT output contains
* v_samp_factor*DCT_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 */ JSAMPLE * sample_range_limit; /* table for fast range-limiting */
@@ -621,6 +663,14 @@ struct jpeg_decompress_struct {
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
#if JPEG_LIB_VERSION >= 80
/* These fields are derived from Se of first SOS marker.
*/
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array for entropy decode */
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
#endif
/* This field is shared between entropy decoder and marker parser. /* This field is shared between entropy decoder and marker parser.
* It is either zero or the code of a JPEG marker that has been * It is either zero or the code of a JPEG marker that has been
* read from the data source, but has not yet been processed. * read from the data source, but has not yet been processed.
@@ -850,11 +900,18 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_destroy_decompress jDestDecompress #define jpeg_destroy_decompress jDestDecompress
#define jpeg_stdio_dest jStdDest #define jpeg_stdio_dest jStdDest
#define jpeg_stdio_src jStdSrc #define jpeg_stdio_src jStdSrc
#if JPEG_LIB_VERSION >= 80
#define jpeg_mem_dest jMemDest
#define jpeg_mem_src jMemSrc
#endif
#define jpeg_set_defaults jSetDefaults #define jpeg_set_defaults jSetDefaults
#define jpeg_set_colorspace jSetColorspace #define jpeg_set_colorspace jSetColorspace
#define jpeg_default_colorspace jDefColorspace #define jpeg_default_colorspace jDefColorspace
#define jpeg_set_quality jSetQuality #define jpeg_set_quality jSetQuality
#define jpeg_set_linear_quality jSetLQuality #define jpeg_set_linear_quality jSetLQuality
#if JPEG_LIB_VERSION >= 70
#define jpeg_default_qtables jDefQTables
#endif
#define jpeg_add_quant_table jAddQuantTable #define jpeg_add_quant_table jAddQuantTable
#define jpeg_quality_scaling jQualityScaling #define jpeg_quality_scaling jQualityScaling
#define jpeg_simple_progression jSimProgress #define jpeg_simple_progression jSimProgress
@@ -864,6 +921,9 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_start_compress jStrtCompress #define jpeg_start_compress jStrtCompress
#define jpeg_write_scanlines jWrtScanlines #define jpeg_write_scanlines jWrtScanlines
#define jpeg_finish_compress jFinCompress #define jpeg_finish_compress jFinCompress
#if JPEG_LIB_VERSION >= 70
#define jpeg_calc_jpeg_dimensions jCjpegDimensions
#endif
#define jpeg_write_raw_data jWrtRawData #define jpeg_write_raw_data jWrtRawData
#define jpeg_write_marker jWrtMarker #define jpeg_write_marker jWrtMarker
#define jpeg_write_m_header jWrtMHeader #define jpeg_write_m_header jWrtMHeader
@@ -880,6 +940,9 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_input_complete jInComplete #define jpeg_input_complete jInComplete
#define jpeg_new_colormap jNewCMap #define jpeg_new_colormap jNewCMap
#define jpeg_consume_input jConsumeInput #define jpeg_consume_input jConsumeInput
#if JPEG_LIB_VERSION >= 80
#define jpeg_core_output_dimensions jCoreDimensions
#endif
#define jpeg_calc_output_dimensions jCalcDimensions #define jpeg_calc_output_dimensions jCalcDimensions
#define jpeg_save_markers jSaveMarkers #define jpeg_save_markers jSaveMarkers
#define jpeg_set_marker_processor jSetMarker #define jpeg_set_marker_processor jSetMarker
@@ -924,6 +987,16 @@ EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
#if JPEG_LIB_VERSION >= 80
/* Data source and destination managers: memory buffers. */
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
unsigned char ** outbuffer,
unsigned long * outsize));
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
unsigned char * inbuffer,
unsigned long insize));
#endif
/* Default parameter setup for compression */ /* Default parameter setup for compression */
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
/* Compression parameter setup aids */ /* Compression parameter setup aids */
@@ -935,6 +1008,10 @@ EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
int scale_factor, int scale_factor,
boolean force_baseline)); boolean force_baseline));
#if JPEG_LIB_VERSION >= 70
EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
boolean force_baseline));
#endif
EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table, const unsigned int *basic_table,
int scale_factor, int scale_factor,
@@ -954,12 +1031,17 @@ EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
JDIMENSION num_lines)); JDIMENSION num_lines));
EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
#if JPEG_LIB_VERSION >= 70
/* Precalculate JPEG dimensions for current compression parameters. */
EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo));
#endif
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ /* Replaces jpeg_write_scanlines when writing raw downsampled data. */
EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
JSAMPIMAGE data, JSAMPIMAGE data,
JDIMENSION num_lines)); JDIMENSION num_lines));
/* Write a special marker. See libjpeg.doc concerning safe usage. */ /* Write a special marker. See libjpeg.txt concerning safe usage. */
EXTERN(void) jpeg_write_marker EXTERN(void) jpeg_write_marker
JPP((j_compress_ptr cinfo, int marker, JPP((j_compress_ptr cinfo, int marker,
const JOCTET * dataptr, unsigned int datalen)); const JOCTET * dataptr, unsigned int datalen));
@@ -1013,6 +1095,9 @@ EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ #define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* Precalculate output dimensions for current decompression parameters. */ /* Precalculate output dimensions for current decompression parameters. */
#if JPEG_LIB_VERSION >= 80
EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
#endif
EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
/* Control saving of COM and APPn markers into marker_list. */ /* Control saving of COM and APPn markers into marker_list. */
@@ -1108,7 +1193,9 @@ struct jpeg_color_quantizer { long dummy; };
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
#ifndef DONT_USE_EXTERN_C
} }
#endif #endif
#endif
#endif /* JPEGLIB_H */ #endif /* JPEGLIB_H */

View File

@@ -1,4 +1,4 @@
.TH JPEGTRAN 1 "3 August 1997" .TH JPEGTRAN 1 "11 October 2010"
.SH NAME .SH NAME
jpegtran \- lossless transformation of JPEG files jpegtran \- lossless transformation of JPEG files
.SH SYNOPSIS .SH SYNOPSIS
@@ -60,6 +60,9 @@ Create progressive JPEG file.
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
attached to the number. attached to the number.
.TP .TP
.B \-arithmetic
Use arithmetic coding.
.TP
.BI \-scans " file" .BI \-scans " file"
Use the scan script given in the specified text file. Use the scan script given in the specified text file.
.PP .PP
@@ -117,7 +120,7 @@ switch:
.TP .TP
.B \-trim .B \-trim
Drop non-transformable edge blocks. Drop non-transformable edge blocks.
.PP .IP
Obviously, a transformation with Obviously, a transformation with
.B \-trim .B \-trim
is not reversible, so strictly speaking is not reversible, so strictly speaking
@@ -130,12 +133,38 @@ trims only the bottom edge, but
followed by followed by
.B \-rot 180 -trim .B \-rot 180 -trim
trims both edges. trims both edges.
.TP
.B \-perfect
If you are only interested in perfect transformations, add the
.B \-perfect
switch. This causes
.B jpegtran
to fail with an error if the transformation is not perfect.
.IP
For example, you may want to do
.IP
.B (jpegtran \-rot 90 -perfect
.I foo.jpg
.B || djpeg
.I foo.jpg
.B | pnmflip \-r90 | cjpeg)
.IP
to do a perfect rotation, if available, or an approximated one if not.
.TP
.B \-crop WxH+X+Y
Crop the image to a rectangular region of width W and height H, starting at
point X,Y. The lossless crop feature discards data outside of a given 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 it
doesn't, then it is silently moved up and/or left to the nearest iMCU boundary
(the lower right corner is unchanged.)
.PP .PP
Another not-strictly-lossless transformation switch is: Other not-strictly-lossless transformation switches are:
.TP .TP
.B \-grayscale .B \-grayscale
Force grayscale output. Force grayscale output.
.PP .IP
This option discards the chrominance channels if the input image is YCbCr This option discards the chrominance channels if the input image is YCbCr
(ie, a standard color JPEG), resulting in a grayscale JPEG file. The (ie, a standard color JPEG), resulting in a grayscale JPEG file. The
luminance channel is preserved exactly, so this is a better method of reducing luminance channel is preserved exactly, so this is a better method of reducing
@@ -154,20 +183,16 @@ Copy no extra markers from source file. This setting suppresses all
comments and other excess baggage present in the source file. comments and other excess baggage present in the source file.
.TP .TP
.B \-copy comments .B \-copy comments
Copy only comment markers. This setting copies comments from the source file, Copy only comment markers. This setting copies comments from the source file
but discards any other inessential data. but discards any other data which is inessential for image display.
.TP .TP
.B \-copy all .B \-copy all
Copy all extra markers. This setting preserves miscellaneous markers Copy all extra markers. This setting preserves miscellaneous markers
found in the source file, such as JFIF thumbnails and Photoshop settings. found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
In some files these extra markers can be sizable. settings. In some files, these extra markers can be sizable.
.PP .PP
The default behavior is The default behavior is \fB-copy comments\fR. (Note: in IJG releases v6 and
.BR "\-copy comments" . v6a, \fBjpegtran\fR always did the equivalent of \fB-copy none\fR.)
(Note: in IJG releases v6 and v6a,
.B jpegtran
always did the equivalent of
.BR "\-copy none" .)
.PP .PP
Additional switches recognized by jpegtran are: Additional switches recognized by jpegtran are:
.TP .TP
@@ -227,11 +252,11 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
.SH AUTHOR .SH AUTHOR
Independent JPEG Group Independent JPEG Group
.SH BUGS .SH BUGS
Arithmetic coding is not supported for legal reasons.
.PP
The transform options can't transform odd-size images perfectly. Use The transform options can't transform odd-size images perfectly. Use
.B \-trim .B \-trim
if you don't like the results without it. or
.B \-perfect
if you don't like the results.
.PP .PP
The entire image is read into memory and then written out again, even in The entire image is read into memory and then written out again, even in
cases where this isn't really necessary. Expect swapping on large images, cases where this isn't really necessary. Expect swapping on large images,

View File

@@ -1,19 +1,21 @@
/* /*
* jpegtran.c * jpegtran.c
* *
* Copyright (C) 1995-1997, Thomas G. Lane. * Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains a command-line user interface for JPEG transcoding. * This file contains a command-line user interface for JPEG transcoding.
* It is very similar to cjpeg.c, but provides lossless transcoding between * It is very similar to cjpeg.c, and partly to djpeg.c, but provides
* different JPEG file formats. It also provides some lossless and sort-of- * lossless transcoding between different JPEG file formats. It also
* lossless transformations of JPEG data. * provides some lossless and sort-of-lossless transformations of JPEG data.
*/ */
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "transupp.h" /* Support routines for jpegtran */ #include "transupp.h" /* Support routines for jpegtran */
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "config.h"
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */
#ifdef __MWERKS__ #ifdef __MWERKS__
@@ -62,15 +64,19 @@ usage (void)
#ifdef C_PROGRESSIVE_SUPPORTED #ifdef C_PROGRESSIVE_SUPPORTED
fprintf(stderr, " -progressive Create progressive JPEG file\n"); fprintf(stderr, " -progressive Create progressive JPEG file\n");
#endif #endif
#if TRANSFORMS_SUPPORTED
fprintf(stderr, "Switches for modifying the image:\n"); 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, " -grayscale Reduce to grayscale (omit color data)\n");
fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n");
fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n");
#endif
#if TRANSFORMS_SUPPORTED
fprintf(stderr, " -transpose Transpose image\n"); fprintf(stderr, " -transpose Transpose image\n");
fprintf(stderr, " -transverse Transverse transpose image\n"); fprintf(stderr, " -transverse Transverse transpose image\n");
fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
#endif /* TRANSFORMS_SUPPORTED */ #endif
fprintf(stderr, "Switches for advanced users:\n"); fprintf(stderr, "Switches for advanced users:\n");
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); 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, " -maxmemory N Maximum memory to use (in kbytes)\n");
@@ -132,8 +138,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
outfilename = NULL; outfilename = NULL;
copyoption = JCOPYOPT_DEFAULT; copyoption = JCOPYOPT_DEFAULT;
transformoption.transform = JXFORM_NONE; transformoption.transform = JXFORM_NONE;
transformoption.perfect = FALSE;
transformoption.trim = FALSE; transformoption.trim = FALSE;
transformoption.force_grayscale = FALSE; transformoption.force_grayscale = FALSE;
transformoption.crop = FALSE;
cinfo->err->trace_level = 0; cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */ /* Scan command line options, adjust parameters */
@@ -160,7 +168,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
#endif #endif
} else if (keymatch(arg, "copy", 1)) { } else if (keymatch(arg, "copy", 2)) {
/* Select which extra markers to copy. */ /* Select which extra markers to copy. */
if (++argn >= argc) /* advance to next argument */ if (++argn >= argc) /* advance to next argument */
usage(); usage();
@@ -173,13 +181,30 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
} else } else
usage(); usage();
} else if (keymatch(arg, "crop", 2)) {
/* Perform lossless cropping. */
#if TRANSFORMS_SUPPORTED
if (++argn >= argc) /* advance to next argument */
usage();
if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
fprintf(stderr, "%s: bogus -crop argument '%s'\n",
progname, argv[argn]);
exit(EXIT_FAILURE);
}
#else
select_transform(JXFORM_NONE); /* force an error */
#endif
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
/* Enable debug printouts. */ /* Enable debug printouts. */
/* On first -d, print version identification */ /* On first -d, print version identification */
static boolean printed_version = FALSE; static boolean printed_version = FALSE;
if (! printed_version) { if (! printed_version) {
fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
fprintf(stderr, "%s\n\n", LJTCOPYRIGHT);
fprintf(stderr, "Based on Independent JPEG Group's libjpeg, version %s\n%s\n\n",
JVERSION, JCOPYRIGHT); JVERSION, JCOPYRIGHT);
printed_version = TRUE; printed_version = TRUE;
} }
@@ -233,7 +258,12 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
usage(); usage();
outfilename = argv[argn]; /* save it away for later use */ outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "progressive", 1)) { } else if (keymatch(arg, "perfect", 2)) {
/* Fail if there is any partial edge MCUs that the transform can't
* handle. */
transformoption.perfect = TRUE;
} else if (keymatch(arg, "progressive", 2)) {
/* Select simple progressive mode. */ /* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED #ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE; simple_progressive = TRUE;
@@ -342,8 +372,10 @@ main (int argc, char **argv)
jvirt_barray_ptr * src_coef_arrays; jvirt_barray_ptr * src_coef_arrays;
jvirt_barray_ptr * dst_coef_arrays; jvirt_barray_ptr * dst_coef_arrays;
int file_index; int file_index;
FILE * input_file; /* We assume all-in-memory processing and can therefore use only a
FILE * output_file; * single file pointer for sequential input and output operation.
*/
FILE * fp;
/* On Mac, fetch a command line. */ /* On Mac, fetch a command line. */
#ifdef USE_CCOMMAND #ifdef USE_CCOMMAND
@@ -406,24 +438,13 @@ main (int argc, char **argv)
/* Open the input file. */ /* Open the input file. */
if (file_index < argc) { if (file_index < argc) {
if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else { } else {
/* default input file is stdin */ /* default input file is stdin */
input_file = read_stdin(); fp = read_stdin();
}
/* Open the output file. */
if (outfilename != NULL) {
if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
output_file = write_stdout();
} }
#ifdef PROGRESS_REPORT #ifdef PROGRESS_REPORT
@@ -431,7 +452,7 @@ main (int argc, char **argv)
#endif #endif
/* Specify data source for decompression */ /* Specify data source for decompression */
jpeg_stdio_src(&srcinfo, input_file); jpeg_stdio_src(&srcinfo, fp);
/* Enable saving of extra markers that we want to copy */ /* Enable saving of extra markers that we want to copy */
jcopy_markers_setup(&srcinfo, copyoption); jcopy_markers_setup(&srcinfo, copyoption);
@@ -443,7 +464,12 @@ main (int argc, char **argv)
* jpeg_read_coefficients so that memory allocation will be done right. * jpeg_read_coefficients so that memory allocation will be done right.
*/ */
#if TRANSFORMS_SUPPORTED #if TRANSFORMS_SUPPORTED
jtransform_request_workspace(&srcinfo, &transformoption); /* Fail right away if -perfect is given and transformation is not perfect.
*/
if (!jtransform_request_workspace(&srcinfo, &transformoption)) {
fprintf(stderr, "%s: transformation is not perfect\n", progname);
exit(EXIT_FAILURE);
}
#endif #endif
/* Read source file as DCT coefficients */ /* Read source file as DCT coefficients */
@@ -463,11 +489,32 @@ main (int argc, char **argv)
dst_coef_arrays = src_coef_arrays; dst_coef_arrays = src_coef_arrays;
#endif #endif
/* Close input file, if we opened it.
* Note: we assume that jpeg_read_coefficients consumed all input
* until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
* only consume more while (! cinfo->inputctl->eoi_reached).
* We cannot call jpeg_finish_decompress here since we still need the
* virtual arrays allocated from the source object for processing.
*/
if (fp != stdin)
fclose(fp);
/* Open the output file. */
if (outfilename != NULL) {
if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
fp = write_stdout();
}
/* Adjust default compression parameters by re-parsing the options */ /* Adjust default compression parameters by re-parsing the options */
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
/* Specify data destination for compression */ /* Specify data destination for compression */
jpeg_stdio_dest(&dstinfo, output_file); jpeg_stdio_dest(&dstinfo, fp);
/* Start compressor (note no image data is actually written here) */ /* Start compressor (note no image data is actually written here) */
jpeg_write_coefficients(&dstinfo, dst_coef_arrays); jpeg_write_coefficients(&dstinfo, dst_coef_arrays);
@@ -488,11 +535,9 @@ main (int argc, char **argv)
(void) jpeg_finish_decompress(&srcinfo); (void) jpeg_finish_decompress(&srcinfo);
jpeg_destroy_decompress(&srcinfo); jpeg_destroy_decompress(&srcinfo);
/* Close files, if we opened them */ /* Close output file, if we opened it */
if (input_file != stdin) if (fp != stdout)
fclose(input_file); fclose(fp);
if (output_file != stdout)
fclose(output_file);
#ifdef PROGRESS_REPORT #ifdef PROGRESS_REPORT
end_progress_monitor((j_common_ptr) &dstinfo); end_progress_monitor((j_common_ptr) &dstinfo);

308
jpegut.c
View File

@@ -1,6 +1,6 @@
/* Copyright (C)2004 Landmark Graphics Corporation /* Copyright (C)2004 Landmark Graphics Corporation
* Copyright (C)2005 Sun Microsystems, Inc. * Copyright (C)2005 Sun Microsystems, Inc.
* Copyright (C)2009 D. R. Commander * Copyright (C)2009-2011 D. R. Commander
* *
* This library is free software and may be redistributed and/or modified under * This library is free software and may be redistributed and/or modified under
* the terms of the wxWindows Library License, Version 3.1 or (at your option) * the terms of the wxWindows Library License, Version 3.1 or (at your option)
@@ -18,11 +18,19 @@
#include <string.h> #include <string.h>
#include "./rrtimer.h" #include "./rrtimer.h"
#include "./turbojpeg.h" #include "./turbojpeg.h"
#ifndef _WIN32
#define stricmp strcasecmp
#endif
#define _catch(f) {if((f)==-1) {printf("TJPEG: %s\n", tjGetErrorStr()); bailout();}} #define _catch(f) {if((f)==-1) {printf("TJPEG: %s\n", tjGetErrorStr()); bailout();}}
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"}; const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"};
const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"}; const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"};
const int _hsf[NUMSUBOPT]={1, 2, 2, 1};
const int _vsf[NUMSUBOPT]={1, 1, 2, 1};
enum {YUVENCODE=1, YUVDECODE};
int yuv=0;
int exitstatus=0; int exitstatus=0;
#define bailout() {exitstatus=-1; goto finally;} #define bailout() {exitstatus=-1; goto finally;}
@@ -46,6 +54,28 @@ void initbuf(unsigned char *buf, int w, int h, int ps, int flags)
_i, j; _i, j;
if(flags&TJ_ALPHAFIRST) {roffset++; goffset++; boffset++;} if(flags&TJ_ALPHAFIRST) {roffset++; goffset++; boffset++;}
memset(buf, 0, w*h*ps); memset(buf, 0, w*h*ps);
if(ps==1)
{
for(_i=0; _i<16; _i++)
{
if(flags&TJ_BOTTOMUP) i=h-_i-1; else i=_i;
for(j=0; j<w; j++)
{
if(((_i/8)+(j/8))%2==0) buf[w*i+j]=255;
else buf[w*i+j]=76;
}
}
for(_i=16; _i<h; _i++)
{
if(flags&TJ_BOTTOMUP) i=h-_i-1; else i=_i;
for(j=0; j<w; j++)
{
if(((_i/8)+(j/8))%2==0) buf[w*i+j]=0;
else buf[w*i+j]=226;
}
}
return;
}
for(_i=0; _i<16; _i++) for(_i=0; _i<16; _i++)
{ {
if(flags&TJ_BOTTOMUP) i=h-_i-1; else i=_i; if(flags&TJ_BOTTOMUP) i=h-_i-1; else i=_i;
@@ -77,12 +107,13 @@ void dumpbuf(unsigned char *buf, int w, int h, int ps, int flags)
{ {
int roffset=(flags&TJ_BGR)?2:0, goffset=1, boffset=(flags&TJ_BGR)?0:2, i, int roffset=(flags&TJ_BGR)?2:0, goffset=1, boffset=(flags&TJ_BGR)?0:2, i,
j; j;
printf("\n");
for(i=0; i<h; i++) for(i=0; i<h; i++)
{ {
for(j=0; j<w; j++) for(j=0; j<w; j++)
{ {
printf("%.3d/%.3d/%.3d ", buf[(w*i+j)*ps+roffset], printf("%.3d/%.3d/%.3d ", buf[(w*i+j)*ps+roffset],
buf[(w*i+j)*ps+roffset], buf[(w*i+j)*ps+roffset]); buf[(w*i+j)*ps+goffset], buf[(w*i+j)*ps+boffset]);
} }
printf("\n"); printf("\n");
} }
@@ -93,6 +124,7 @@ int checkbuf(unsigned char *buf, int w, int h, int ps, int subsamp, int flags)
int roffset=(flags&TJ_BGR)?2:0, goffset=1, boffset=(flags&TJ_BGR)?0:2, i, int roffset=(flags&TJ_BGR)?2:0, goffset=1, boffset=(flags&TJ_BGR)?0:2, i,
_i, j; _i, j;
if(flags&TJ_ALPHAFIRST) {roffset++; goffset++; boffset++;} if(flags&TJ_ALPHAFIRST) {roffset++; goffset++; boffset++;}
if(ps==1) roffset=goffset=boffset=0;
if(subsamp==TJ_GRAYSCALE) if(subsamp==TJ_GRAYSCALE)
{ {
for(_i=0; _i<16; _i++) for(_i=0; _i<16; _i++)
@@ -174,6 +206,118 @@ int checkbuf(unsigned char *buf, int w, int h, int ps, int subsamp, int flags)
return 1; return 1;
} }
#define checkval(v, cv) { \
if(v<cv-1 || v>cv+1) { \
printf("\nComp. %s at %d,%d should be %d, not %d\n", #v, i, j, cv, v); \
retval=0; goto bailout; \
}}
#define checkval0(v) { \
if(v>1) { \
printf("\nComp. %s at %d,%d should be 0, not %d\n", #v, i, j, v); \
retval=0; goto bailout; \
}}
#define checkval255(v) { \
if(v<254) { \
printf("\nComp. %s at %d,%d should be 255, not %d\n", #v, i, j, v); \
retval=0; goto bailout; \
}}
#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
int checkbufyuv(unsigned char *buf, int w, int h, int subsamp)
{
int i, j;
int hsf=_hsf[subsamp], vsf=_vsf[subsamp];
int pw=PAD(w, hsf), ph=PAD(h, vsf);
int cw=pw/hsf, ch=ph/vsf;
int ypitch=PAD(pw, 4), uvpitch=PAD(cw, 4);
int retval=1;
for(i=0; i<16; i++)
{
for(j=0; j<pw; j++)
{
unsigned char y=buf[ypitch*i+j];
if(((i/8)+(j/8))%2==0) checkval255(y)
else checkval(y, 76)
}
}
for(i=16; i<ph; i++)
{
for(j=0; j<pw; j++)
{
unsigned char y=buf[ypitch*i+j];
if(((i/8)+(j/8))%2==0) checkval0(y)
else checkval(y, 226)
}
}
if(subsamp!=TJ_GRAYSCALE)
{
for(i=0; i<16/vsf; i++)
{
for(j=0; j<cw; j++)
{
unsigned char u=buf[ypitch*ph + (uvpitch*i+j)],
v=buf[ypitch*ph + uvpitch*ch + (uvpitch*i+j)];
if(((i*vsf/8)+(j*hsf/8))%2==0)
{
checkval(u, 128); checkval(v, 128);
}
else
{
checkval(u, 85); checkval255(v);
}
}
}
for(i=16/vsf; i<ch; i++)
{
for(j=0; j<cw; j++)
{
unsigned char u=buf[ypitch*ph + (uvpitch*i+j)],
v=buf[ypitch*ph + uvpitch*ch + (uvpitch*i+j)];
if(((i*vsf/8)+(j*hsf/8))%2==0)
{
checkval(u, 128); checkval(v, 128);
}
else
{
checkval0(u); checkval(v, 149);
}
}
}
}
bailout:
if(retval==0)
{
for(i=0; i<ph; i++)
{
for(j=0; j<pw; j++)
printf("%.3d ", buf[ypitch*i+j]);
printf("\n");
}
printf("\n");
for(i=0; i<ch; i++)
{
for(j=0; j<cw; j++)
printf("%.3d ", buf[ypitch*ph + (uvpitch*i+j)]);
printf("\n");
}
printf("\n");
for(i=0; i<ch; i++)
{
for(j=0; j<cw; j++)
printf("%.3d ", buf[ypitch*ph + uvpitch*ch + (uvpitch*i+j)]);
printf("\n");
}
printf("\n");
}
return retval;
}
void writejpeg(unsigned char *jpegbuf, unsigned long jpgbufsize, char *filename) void writejpeg(unsigned char *jpegbuf, unsigned long jpgbufsize, char *filename)
{ {
FILE *outfile=NULL; FILE *outfile=NULL;
@@ -201,53 +345,86 @@ void gentestjpeg(tjhandle hnd, unsigned char *jpegbuf, unsigned long *size,
if(flags&TJ_BGR) if(flags&TJ_BGR)
{ {
if(ps==3) pixformat="BGR"; if(ps==3) pixformat="BGR";
else {if(flags&TJ_ALPHAFIRST) pixformat="ABGR"; else pixformat="BGRA";} else {if(flags&TJ_ALPHAFIRST) pixformat="XBGR"; else pixformat="BGRX";}
} }
else else
{ {
if(ps==3) pixformat="RGB"; if(ps==3) pixformat="RGB";
else {if(flags&TJ_ALPHAFIRST) pixformat="ARGB"; else pixformat="RGBA";} else {if(flags&TJ_ALPHAFIRST) pixformat="XRGB"; else pixformat="RGBX";}
} }
printf("%s %s -> %s Q%d ... ", pixformat, if(ps==1) pixformat="Grayscale";
(flags&TJ_BOTTOMUP)?"Bottom-Up":"Top-Down ", _subnamel[subsamp], qual); if(yuv==YUVENCODE)
printf("%s %s -> %s YUV ... ", pixformat,
(flags&TJ_BOTTOMUP)?"Bottom-Up":"Top-Down ", _subnamel[subsamp]);
else
printf("%s %s -> %s Q%d ... ", pixformat,
(flags&TJ_BOTTOMUP)?"Bottom-Up":"Top-Down ", _subnamel[subsamp], qual);
if((bmpbuf=(unsigned char *)malloc(w*h*ps+1))==NULL) if((bmpbuf=(unsigned char *)malloc(w*h*ps+1))==NULL)
{ {
printf("ERROR: Could not allocate buffer\n"); bailout(); printf("ERROR: Could not allocate buffer\n"); bailout();
} }
initbuf(bmpbuf, w, h, ps, flags); initbuf(bmpbuf, w, h, ps, flags);
memset(jpegbuf, 0, TJBUFSIZE(w, h)); memset(jpegbuf, 0,
yuv==YUVENCODE? TJBUFSIZEYUV(w, h, subsamp):TJBUFSIZE(w, h));
t=rrtime(); t=rrtime();
_catch(tjCompress(hnd, bmpbuf, w, 0, h, ps, jpegbuf, size, subsamp, qual, flags)); if(yuv==YUVENCODE)
{
_catch(tjEncodeYUV(hnd, bmpbuf, w, 0, h, ps, jpegbuf, subsamp, flags));
*size=TJBUFSIZEYUV(w, h, subsamp);
}
else
{
_catch(tjCompress(hnd, bmpbuf, w, 0, h, ps, jpegbuf, size, subsamp, qual,
flags));
}
t=rrtime()-t; t=rrtime()-t;
sprintf(tempstr, "%s_enc_%s_%s_%sQ%d.jpg", basefilename, pixformat, if(yuv==YUVENCODE)
(flags&TJ_BOTTOMUP)? "BU":"TD", _subnames[subsamp], qual); sprintf(tempstr, "%s_enc_%s_%s_%s.yuv", basefilename, pixformat,
(flags&TJ_BOTTOMUP)? "BU":"TD", _subnames[subsamp]);
else
sprintf(tempstr, "%s_enc_%s_%s_%sQ%d.jpg", basefilename, pixformat,
(flags&TJ_BOTTOMUP)? "BU":"TD", _subnames[subsamp], qual);
writejpeg(jpegbuf, *size, tempstr); writejpeg(jpegbuf, *size, tempstr);
printf("Done. %f ms\n Result in %s\n", t*1000., tempstr); if(yuv==YUVENCODE)
{
if(checkbufyuv(jpegbuf, w, h, subsamp)) printf("Passed.");
else {printf("FAILED!"); exitstatus=-1;}
}
else printf("Done.");
printf(" %f ms\n Result in %s\n", t*1000., tempstr);
finally: finally:
if(bmpbuf) free(bmpbuf); if(bmpbuf) free(bmpbuf);
} }
void gentestbmp(tjhandle hnd, unsigned char *jpegbuf, unsigned long jpegsize, void gentestbmp(tjhandle hnd, unsigned char *jpegbuf, unsigned long jpegsize,
int w, int h, int ps, char *basefilename, int subsamp, int qual, int flags) int w, int h, int ps, char *basefilename, int subsamp, int flags)
{ {
unsigned char *bmpbuf=NULL; unsigned char *bmpbuf=NULL;
const char *pixformat; int _w=0, _h=0; double t; const char *pixformat; int _w=0, _h=0; double t;
unsigned long size=0;
if(yuv==YUVENCODE) return;
if(flags&TJ_BGR) if(flags&TJ_BGR)
{ {
if(ps==3) pixformat="BGR"; if(ps==3) pixformat="BGR";
else {if(flags&TJ_ALPHAFIRST) pixformat="ABGR"; else pixformat="BGRA";} else {if(flags&TJ_ALPHAFIRST) pixformat="XBGR"; else pixformat="BGRX";}
} }
else else
{ {
if(ps==3) pixformat="RGB"; if(ps==3) pixformat="RGB";
else {if(flags&TJ_ALPHAFIRST) pixformat="ARGB"; else pixformat="RGBA";} else {if(flags&TJ_ALPHAFIRST) pixformat="XRGB"; else pixformat="RGBX";}
} }
printf("JPEG -> %s %s ... ", pixformat, (flags&TJ_BOTTOMUP)?"Bottom-Up":"Top-Down "); if(ps==1) pixformat="Grayscale";
if(yuv==YUVDECODE)
printf("JPEG -> YUV %s ... ", _subnames[subsamp]);
else
printf("JPEG -> %s %s ... ", pixformat,
(flags&TJ_BOTTOMUP)?"Bottom-Up":"Top-Down ");
_catch(tjDecompressHeader(hnd, jpegbuf, jpegsize, &_w, &_h)); _catch(tjDecompressHeader(hnd, jpegbuf, jpegsize, &_w, &_h));
if(_w!=w || _h!=h) if(_w!=w || _h!=h)
@@ -255,19 +432,40 @@ void gentestbmp(tjhandle hnd, unsigned char *jpegbuf, unsigned long jpegsize,
printf("Incorrect JPEG header\n"); bailout(); printf("Incorrect JPEG header\n"); bailout();
} }
if((bmpbuf=(unsigned char *)malloc(w*h*ps+1))==NULL) if(yuv==YUVDECODE) size=TJBUFSIZEYUV(w, h, subsamp);
else size=w*h*ps+1;
if((bmpbuf=(unsigned char *)malloc(size))==NULL)
{ {
printf("ERROR: Could not allocate buffer\n"); bailout(); printf("ERROR: Could not allocate buffer\n"); bailout();
} }
memset(bmpbuf, 0, w*ps*h); memset(bmpbuf, 0, size);
t=rrtime(); t=rrtime();
_catch(tjDecompress(hnd, jpegbuf, jpegsize, bmpbuf, w, w*ps, h, ps, flags)); if(yuv==YUVDECODE)
{
_catch(tjDecompressToYUV(hnd, jpegbuf, jpegsize, bmpbuf, flags));
}
else
{
_catch(tjDecompress(hnd, jpegbuf, jpegsize, bmpbuf, w, w*ps, h, ps,
flags));
}
t=rrtime()-t; t=rrtime()-t;
if(checkbuf(bmpbuf, w, h, ps, subsamp, flags)) printf("Passed."); if(yuv==YUVDECODE)
else {printf("FAILED!"); dumpbuf(bmpbuf, w, h, ps, flags);} {
if(checkbufyuv(bmpbuf, w, h, subsamp)) printf("Passed.");
else {printf("FAILED!"); exitstatus=-1;}
}
else
{
if(checkbuf(bmpbuf, w, h, ps, subsamp, flags)) printf("Passed.");
else
{
printf("FAILED!"); exitstatus=-1;
dumpbuf(bmpbuf, w, h, ps, flags);
}
}
printf(" %f ms\n\n", t*1000.); printf(" %f ms\n\n", t*1000.);
finally: finally:
@@ -279,7 +477,8 @@ void dotest(int w, int h, int ps, int subsamp, char *basefilename)
tjhandle hnd=NULL, dhnd=NULL; unsigned char *jpegbuf=NULL; tjhandle hnd=NULL, dhnd=NULL; unsigned char *jpegbuf=NULL;
unsigned long size; unsigned long size;
if((jpegbuf=(unsigned char *)malloc(TJBUFSIZE(w, h))) == NULL) size=(yuv==YUVENCODE? TJBUFSIZEYUV(w, h, subsamp):TJBUFSIZE(w, h));
if((jpegbuf=(unsigned char *)malloc(size)) == NULL)
{ {
puts("ERROR: Could not allocate buffer."); bailout(); puts("ERROR: Could not allocate buffer."); bailout();
} }
@@ -290,30 +489,32 @@ void dotest(int w, int h, int ps, int subsamp, char *basefilename)
{printf("Error in tjInitDecompress():\n%s\n", tjGetErrorStr()); bailout();} {printf("Error in tjInitDecompress():\n%s\n", tjGetErrorStr()); bailout();}
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, 0); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, 0);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, 0); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 0);
if(ps==1 || yuv==YUVDECODE) goto finally;
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BGR); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BGR);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_BGR); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_BGR);
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BOTTOMUP); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BOTTOMUP);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_BOTTOMUP); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_BOTTOMUP);
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BGR|TJ_BOTTOMUP); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_BGR|TJ_BOTTOMUP);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_BGR|TJ_BOTTOMUP); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_BGR|TJ_BOTTOMUP);
if(ps==4) if(ps==4)
{ {
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_ALPHAFIRST);
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_ALPHAFIRST|TJ_BGR);
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BOTTOMUP); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BOTTOMUP);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BOTTOMUP); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_ALPHAFIRST|TJ_BOTTOMUP);
gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR|TJ_BOTTOMUP); gentestjpeg(hnd, jpegbuf, &size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR|TJ_BOTTOMUP);
gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, 100, TJ_ALPHAFIRST|TJ_BGR|TJ_BOTTOMUP); gentestbmp(dhnd, jpegbuf, size, w, h, ps, basefilename, subsamp, TJ_ALPHAFIRST|TJ_BGR|TJ_BOTTOMUP);
} }
finally: finally:
@@ -347,9 +548,9 @@ void dotest1(void)
{ {
bmpbuf[i2*4]=pixels[i2%9][2]; bmpbuf[i2*4]=pixels[i2%9][2];
bmpbuf[i2*4+1]=pixels[i2%9][1]; bmpbuf[i2*4+1]=pixels[i2%9][1];
bmpbuf[i2*2+2]=pixels[i2%9][0]; bmpbuf[i2*4+2]=pixels[i2%9][0];
} }
_catch(tjCompress(hnd, bmpbuf, i, i*4, j, 4, _catch(tjCompress(hnd, bmpbuf, i, 0, j, 4,
jpgbuf, &size, TJ_444, 100, TJ_BGR)); jpgbuf, &size, TJ_444, 100, TJ_BGR));
free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL; free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL;
@@ -358,12 +559,12 @@ void dotest1(void)
{ {
printf("Memory allocation failure\n"); bailout(); printf("Memory allocation failure\n"); bailout();
} }
for(i2=0; i2<j*i*4; i2++) for(i2=0; i2<j*i; i2++)
{ {
if(i2%2==0) bmpbuf[i2]=0xFF; if(i2%2==0) bmpbuf[i2*4]=bmpbuf[i2*4+1]=bmpbuf[i2*4+2]=0xFF;
else bmpbuf[i2]=0; else bmpbuf[i2*4]=bmpbuf[i2*4+1]=bmpbuf[i2*4+2]=0;
} }
_catch(tjCompress(hnd, bmpbuf, j, j*4, i, 4, _catch(tjCompress(hnd, bmpbuf, j, 0, i, 4,
jpgbuf, &size, TJ_444, 100, TJ_BGR)); jpgbuf, &size, TJ_444, 100, TJ_BGR));
free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL; free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL;
} }
@@ -377,11 +578,36 @@ void dotest1(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
dotest(35, 41, 3, TJ_444, "test"); int doyuv=0;
dotest(35, 41, 4, TJ_444, "test"); if(argc>1 && !stricmp(argv[1], "-yuv")) doyuv=1;
dotest(35, 41, 3, TJ_GRAYSCALE, "test"); if(doyuv) yuv=YUVENCODE;
dotest(35, 41, 4, TJ_GRAYSCALE, "test"); dotest(35, 39, 3, TJ_444, "test");
dotest1(); dotest(39, 41, 4, TJ_444, "test");
if(doyuv)
{
dotest(41, 35, 3, TJ_422, "test");
dotest(35, 39, 4, TJ_422, "test");
dotest(39, 41, 3, TJ_420, "test");
dotest(41, 35, 4, TJ_420, "test");
}
dotest(35, 39, 1, TJ_GRAYSCALE, "test");
dotest(39, 41, 3, TJ_GRAYSCALE, "test");
dotest(41, 35, 4, TJ_GRAYSCALE, "test");
if(!doyuv) dotest1();
if(doyuv)
{
yuv=YUVDECODE;
dotest(48, 48, 3, TJ_444, "test");
dotest(35, 39, 3, TJ_444, "test");
dotest(48, 48, 3, TJ_422, "test");
dotest(39, 41, 3, TJ_422, "test");
dotest(48, 48, 3, TJ_420, "test");
dotest(41, 35, 3, TJ_420, "test");
dotest(48, 48, 3, TJ_GRAYSCALE, "test");
dotest(35, 39, 3, TJ_GRAYSCALE, "test");
dotest(48, 48, 1, TJ_GRAYSCALE, "test");
dotest(39, 41, 1, TJ_GRAYSCALE, "test");
}
return exitstatus; return exitstatus;
} }

610
jpgtest.c Normal file
View File

@@ -0,0 +1,610 @@
/* Copyright (C)2004 Landmark Graphics Corporation
* Copyright (C)2005, 2006 Sun Microsystems, Inc.
* Copyright (C)2009-2011 D. R. Commander
*
* This library is free software and may be redistributed and/or modified under
* the terms of the wxWindows Library License, Version 3.1 or (at your option)
* any later version. The full license is in the LICENSE.txt file included
* with this distribution.
*
* This library 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
* wxWindows Library License for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include "./bmp.h"
#include "./rrutil.h"
#include "./rrtimer.h"
#include "./turbojpeg.h"
#define _throw(op, err) { \
printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); goto bailout;}
#define _throwunix(m) _throw(m, strerror(errno))
#define _throwtj(m) _throw(m, tjGetErrorStr())
#define _throwbmp(m) _throw(m, bmpgeterr())
#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
enum {YUVENCODE=1, YUVDECODE};
int forcemmx=0, forcesse=0, forcesse2=0, forcesse3=0, fastupsample=0,
decomponly=0, yuv=0;
const int _ps[BMPPIXELFORMATS]={3, 4, 3, 4, 4, 4};
const int _flags[BMPPIXELFORMATS]={0, 0, TJ_BGR, TJ_BGR,
TJ_BGR|TJ_ALPHAFIRST, TJ_ALPHAFIRST};
const int _rindex[BMPPIXELFORMATS]={0, 0, 2, 2, 3, 1};
const int _gindex[BMPPIXELFORMATS]={1, 1, 1, 1, 2, 2};
const int _bindex[BMPPIXELFORMATS]={2, 2, 0, 0, 1, 3};
const char *_pfname[]={"RGB", "RGBX", "BGR", "BGRX", "XBGR", "XRGB"};
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"};
const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"};
void printsigfig(double val, int figs)
{
char format[80];
double _l=log10(val); int l;
if(_l<0.)
{
l=(int)fabs(_l);
sprintf(format, "%%%d.%df", figs+l+2, figs+l);
}
else
{
l=(int)_l+1;
if(figs<=l) sprintf(format, "%%.0f");
else sprintf(format, "%%%d.%df", figs+1, figs-l);
}
printf(format, val);
}
void dotest(unsigned char *srcbuf, int w, int h, int pf, int bu,
int jpegsub, int qual, char *filename, int dotile, int useppm, int quiet)
{
char tempstr[1024];
FILE *outfile=NULL; tjhandle hnd=NULL;
unsigned char **jpegbuf=NULL, *rgbbuf=NULL;
double start, elapsed;
int jpgbufsize=0, i, j, tilesizex=w, tilesizey=h, numtilesx=1, numtilesy=1,
ITER;
unsigned long *comptilesize=NULL;
int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
|(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0)
|(fastupsample?TJ_FASTUPSAMPLE:0);
int ps=_ps[pf], tilen;
int pitch=w*ps, yuvsize=0;
flags |= _flags[pf];
if(bu) flags |= TJ_BOTTOMUP;
if(yuv==YUVENCODE) yuvsize=TJBUFSIZEYUV(w, h, jpegsub);
if((rgbbuf=(unsigned char *)malloc(max(yuvsize, pitch*h+1))) == NULL)
_throwunix("allocating image buffer");
if(!quiet)
{
if(yuv==YUVENCODE)
printf(">>>>> %s (%s) <--> YUV %s <<<<<\n", _pfname[pf],
bu?"Bottom-up":"Top-down", _subnamel[jpegsub]);
else
printf(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", _pfname[pf],
bu?"Bottom-up":"Top-down", _subnamel[jpegsub], qual);
}
if(yuv) dotile=0;
if(dotile) {tilesizex=tilesizey=4;} else {tilesizex=w; tilesizey=h;}
do
{
tilesizex*=2; if(tilesizex>w) tilesizex=w;
tilesizey*=2; if(tilesizey>h) tilesizey=h;
numtilesx=(w+tilesizex-1)/tilesizex;
numtilesy=(h+tilesizey-1)/tilesizey;
if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long)*numtilesx*numtilesy)) == NULL
|| (jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)*numtilesx*numtilesy)) == NULL)
_throwunix("allocating image buffers");
memset(jpegbuf, 0, sizeof(unsigned char *)*numtilesx*numtilesy);
for(i=0; i<numtilesx*numtilesy; i++)
{
if((jpegbuf[i]=(unsigned char *)malloc(
yuv==YUVENCODE? TJBUFSIZEYUV(tilesizex, tilesizey, jpegsub)
: TJBUFSIZE(tilesizex, tilesizey))) == NULL)
_throwunix("allocating image buffers");
}
// Compression test
if(quiet==1) printf("%s\t%s\t%s\t%d\t", _pfname[pf], bu?"BU":"TD",
_subnamel[jpegsub], qual);
for(i=0; i<h; i++) memcpy(&rgbbuf[pitch*i], &srcbuf[w*ps*i], w*ps);
if((hnd=tjInitCompress())==NULL)
_throwtj("executing tjInitCompress()");
if(yuv==YUVENCODE)
{
if(tjEncodeYUV(hnd, rgbbuf, tilesizex, pitch, tilesizey, ps,
jpegbuf[0], jpegsub, flags)==-1)
_throwtj("executing tjEncodeYUV()");
comptilesize[0]=TJBUFSIZEYUV(tilesizex, tilesizey, jpegsub);
}
else if(tjCompress(hnd, rgbbuf, tilesizex, pitch, tilesizey, ps,
jpegbuf[0], &comptilesize[0], jpegsub, qual, flags)==-1)
_throwtj("executing tjCompress()");
ITER=0;
start=rrtime();
do
{
jpgbufsize=0; tilen=0;
for(i=0; i<h; i+=tilesizey)
{
for(j=0; j<w; j+=tilesizex)
{
int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
if(yuv==YUVENCODE)
{
if(tjEncodeYUV(hnd, &rgbbuf[pitch*i+j*ps], tempw, pitch,
temph, ps, jpegbuf[tilen], jpegsub, flags)==-1)
_throwtj("executing tjEncodeYUV()");
comptilesize[tilen]=TJBUFSIZEYUV(tempw, temph, jpegsub);
}
else if(tjCompress(hnd, &rgbbuf[pitch*i+j*ps], tempw, pitch,
temph, ps, jpegbuf[tilen], &comptilesize[tilen], jpegsub, qual,
flags)==-1)
_throwtj("executing tjCompress()");
jpgbufsize+=comptilesize[tilen];
tilen++;
}
}
ITER++;
} while((elapsed=rrtime()-start)<5.);
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
hnd=NULL;
if(quiet==1)
{
if(tilesizex==w && tilesizey==h) printf("Full \t");
else printf("%-4d %-4d\t", tilesizex, tilesizey);
}
if(quiet)
{
printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4);
printf("%c", quiet==2? '\n':'\t');
printsigfig((double)(w*h*ps)/(double)jpgbufsize, 4);
printf("%c", quiet==2? '\n':'\t');
}
else
{
if(tilesizex==w && tilesizey==h) printf("\nFull image\n");
else printf("\nTile size: %d x %d\n", tilesizex, tilesizey);
printf("C--> Frame rate: %f fps\n", (double)ITER/elapsed);
printf(" Output image size: %d bytes\n", jpgbufsize);
printf(" Compression ratio: %f:1\n",
(double)(w*h*ps)/(double)jpgbufsize);
printf(" Source throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)ITER/elapsed);
printf(" Output bit stream: %f Megabits/sec\n",
(double)jpgbufsize*8./1000000.*(double)ITER/elapsed);
}
if(tilesizex==w && tilesizey==h)
{
if(yuv==YUVENCODE)
sprintf(tempstr, "%s_%s.yuv", filename, _subnames[jpegsub]);
else
sprintf(tempstr, "%s_%sQ%d.jpg", filename, _subnames[jpegsub], qual);
if((outfile=fopen(tempstr, "wb"))==NULL)
_throwunix("opening reference image");
if(fwrite(jpegbuf[0], jpgbufsize, 1, outfile)!=1)
_throwunix("writing reference image");
fclose(outfile); outfile=NULL;
if(!quiet) printf("Reference image written to %s\n", tempstr);
}
if(yuv==YUVENCODE)
{
if(quiet==1) printf("\n"); goto bailout;
}
// Decompression test
memset(rgbbuf, 127, max(yuvsize, pitch*h)); // Grey image means decompressor did nothing
if((hnd=tjInitDecompress())==NULL)
_throwtj("executing tjInitDecompress()");
if(yuv==YUVDECODE)
{
if(tjDecompressToYUV(hnd, jpegbuf[0], jpgbufsize, rgbbuf, flags)==-1)
_throwtj("executing tjDecompressToYUV()");
}
else if(tjDecompress(hnd, jpegbuf[0], jpgbufsize, rgbbuf, tilesizex, pitch,
tilesizey, ps, flags)==-1)
_throwtj("executing tjDecompress()");
ITER=0;
start=rrtime();
do
{
int tilen=0;
for(i=0; i<h; i+=tilesizey)
{
for(j=0; j<w; j+=tilesizex)
{
int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
if(yuv==YUVDECODE)
{
if(tjDecompressToYUV(hnd, jpegbuf[tilen], comptilesize[tilen],
&rgbbuf[pitch*i+ps*j], flags)==-1)
_throwtj("executing tjDecompressToYUV()");
}
else if(tjDecompress(hnd, jpegbuf[tilen], comptilesize[tilen],
&rgbbuf[pitch*i+ps*j], tempw, pitch, temph, ps, flags)==-1)
_throwtj("executing tjDecompress()");
tilen++;
}
}
ITER++;
} while((elapsed=rrtime()-start)<5.);
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
hnd=NULL;
if(quiet)
{
printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4);
printf("\n");
}
else
{
printf("D--> Frame rate: %f fps\n", (double)ITER/elapsed);
printf(" Dest. throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)ITER/elapsed);
}
if(yuv==YUVDECODE)
{
sprintf(tempstr, "%s_%sQ%d.yuv", filename, _subnames[jpegsub], qual);
if((outfile=fopen(tempstr, "wb"))==NULL)
_throwunix("opening YUV image for output");
if(fwrite(rgbbuf, yuvsize, 1, outfile)!=1)
_throwunix("writing YUV image");
fclose(outfile); outfile=NULL;
}
else
{
if(tilesizex==w && tilesizey==h)
sprintf(tempstr, "%s_%sQ%d_full.%s", filename, _subnames[jpegsub], qual,
useppm?"ppm":"bmp");
else sprintf(tempstr, "%s_%sQ%d_%dx%d.%s", filename, _subnames[jpegsub],
qual, tilesizex, tilesizey, useppm?"ppm":"bmp");
if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
_throwbmp("saving bitmap");
sprintf(strrchr(tempstr, '.'), "-err.%s", useppm?"ppm":"bmp");
if(!quiet)
printf("Computing compression error and saving to %s.\n", tempstr);
if(jpegsub==TJ_GRAYSCALE)
{
for(j=0; j<h; j++)
{
for(i=0; i<w*ps; i+=ps)
{
int y=(int)((double)srcbuf[w*ps*j+i+_rindex[pf]]*0.299
+ (double)srcbuf[w*ps*j+i+_gindex[pf]]*0.587
+ (double)srcbuf[w*ps*j+i+_bindex[pf]]*0.114 + 0.5);
if(y>255) y=255; if(y<0) y=0;
rgbbuf[pitch*j+i+_rindex[pf]]=abs(rgbbuf[pitch*j+i+_rindex[pf]]-y);
rgbbuf[pitch*j+i+_gindex[pf]]=abs(rgbbuf[pitch*j+i+_gindex[pf]]-y);
rgbbuf[pitch*j+i+_bindex[pf]]=abs(rgbbuf[pitch*j+i+_bindex[pf]]-y);
}
}
}
else
{
for(j=0; j<h; j++) for(i=0; i<w*ps; i++)
rgbbuf[pitch*j+i]=abs(rgbbuf[pitch*j+i]-srcbuf[w*ps*j+i]);
}
if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
_throwbmp("saving bitmap");
}
// Cleanup
if(outfile) {fclose(outfile); outfile=NULL;}
if(jpegbuf)
{
for(i=0; i<numtilesx*numtilesy; i++)
{if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;}
free(jpegbuf); jpegbuf=NULL;
}
if(comptilesize) {free(comptilesize); comptilesize=NULL;}
} while(tilesizex<w || tilesizey<h);
if(rgbbuf) {free(rgbbuf); rgbbuf=NULL;}
return;
bailout:
if(outfile) {fclose(outfile); outfile=NULL;}
if(jpegbuf)
{
for(i=0; i<numtilesx*numtilesy; i++)
{if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;}
free(jpegbuf); jpegbuf=NULL;
}
if(comptilesize) {free(comptilesize); comptilesize=NULL;}
if(rgbbuf) {free(rgbbuf); rgbbuf=NULL;}
if(hnd) {tjDestroy(hnd); hnd=NULL;}
return;
}
void dodecomptest(char *filename, int pf, int bu, int useppm,
int quiet)
{
char tempstr[1024];
FILE *file=NULL; tjhandle hnd=NULL;
unsigned char *jpegbuf=NULL, *rgbbuf=NULL;
double start, elapsed;
int w, h, ITER;
unsigned long jpgbufsize=0;
int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
|(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0)
|(fastupsample?TJ_FASTUPSAMPLE:0);
int ps=_ps[pf], pitch, jpegsub=-1;
char *temp=NULL;
int yuvsize, bufsize;
flags |= _flags[pf];
if(bu) flags |= TJ_BOTTOMUP;
if((file=fopen(filename, "rb"))==NULL)
_throwunix("opening file");
if(fseek(file, 0, SEEK_END)<0 || (jpgbufsize=ftell(file))<0)
_throwunix("determining file size");
if((jpegbuf=(unsigned char *)malloc(jpgbufsize))==NULL)
_throwunix("allocating memory");
if(fseek(file, 0, SEEK_SET)<0)
_throwunix("setting file position");
if(fread(jpegbuf, jpgbufsize, 1, file)<1)
_throwunix("reading JPEG data");
fclose(file); file=NULL;
temp=strrchr(filename, '.');
if(temp!=NULL) *temp='\0';
if((hnd=tjInitDecompress())==NULL) _throwtj("executing tjInitDecompress()");
if(tjDecompressHeader2(hnd, jpegbuf, jpgbufsize, &w, &h, &jpegsub)==-1)
_throwtj("executing tjDecompressHeader2()");
yuvsize=TJBUFSIZEYUV(w, h, jpegsub);
pitch=w*ps;
if(quiet==1)
{
printf("All performance values in Mpixels/sec\n\n");
printf("Bitmap\tBitmap\tImage Size\tDecomp\n"),
printf("Format\tOrder\t X Y \tPerf\n\n");
printf("%s\t%s\t%-4d %-4d\t", _pfname[pf], bu?"BU":"TD", w, h);
}
bufsize=(yuv==YUVDECODE? yuvsize:pitch*h);
if((rgbbuf=(unsigned char *)malloc(bufsize))==NULL)
_throwunix("allocating image buffer");
if(!quiet)
{
if(yuv==YUVDECODE)
printf(">>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]);
else
printf(">>>>> JPEG --> %s (%s) <<<<<\n", _pfname[pf],
bu?"Bottom-up":"Top-down");
printf("\nImage size: %d x %d\n", w, h);
}
memset(rgbbuf, 127, bufsize); // Grey image means decompressor did nothing
if(yuv==YUVDECODE)
{
if(tjDecompressToYUV(hnd, jpegbuf, jpgbufsize, rgbbuf, flags)==-1)
_throwtj("executing tjDecompressToYUV()");
}
else if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps,
flags)==-1)
_throwtj("executing tjDecompress()");
ITER=0;
start=rrtime();
do
{
if(yuv==YUVDECODE)
{
if(tjDecompressToYUV(hnd, jpegbuf, jpgbufsize, rgbbuf, flags)==-1)
_throwtj("executing tjDecompressToYUV()");
}
else if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps,
flags)==-1)
_throwtj("executing tjDecompress()");
ITER++;
} while((elapsed=rrtime()-start)<5.);
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
hnd=NULL;
if(quiet)
{
printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4);
printf("\n");
}
else
{
printf("D--> Frame rate: %f fps\n", (double)ITER/elapsed);
printf(" Dest. throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)ITER/elapsed);
}
sprintf(tempstr, "%s_full.%s", filename, useppm?"ppm":"bmp");
if(yuv==YUVDECODE)
{
sprintf(tempstr, "%s_%s.yuv", filename, _subnames[jpegsub]);
if((file=fopen(tempstr, "wb"))==NULL)
_throwunix("opening YUV image for output");
if(fwrite(rgbbuf, yuvsize, 1, file)!=1)
_throwunix("writing YUV image");
fclose(file); file=NULL;
}
else
{
if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
_throwbmp("saving bitmap");
}
bailout:
if(file) {fclose(file); file=NULL;}
if(jpegbuf) {free(jpegbuf); jpegbuf=NULL;}
if(rgbbuf) {free(rgbbuf); rgbbuf=NULL;}
if(hnd) {tjDestroy(hnd); hnd=NULL;}
return;
}
void usage(char *progname)
{
printf("USAGE: %s <Inputfile (BMP|PPM))> <%% Quality>\n", progname);
printf(" %s <Inputfile (JPG))>\n\n", progname);
printf(" [-tile]\n");
printf(" Test performance of the codec when the image is encoded\n");
printf(" as separate tiles of varying sizes.\n\n");
printf(" [-forcemmx] [-forcesse] [-forcesse2] [-forcesse3]\n");
printf(" Force MMX, SSE, SSE2, or SSE3 code paths in the underlying codec\n\n");
printf(" [-rgb | -bgr | -rgbx | -bgrx | -xbgr | -xrgb]\n");
printf(" Test the specified color conversion path in the codec (default: BGR)\n\n");
printf(" [-fastupsample]\n");
printf(" Use fast, inaccurate upsampling code to perform 4:2:2 and 4:2:0\n");
printf(" YUV decoding in libjpeg decompressor\n\n");
printf(" [-quiet]\n");
printf(" Output in tabular rather than verbose format\n\n");
printf(" [-yuvencode]\n");
printf(" Encode RGB input as planar YUV rather than compressing as JPEG\n\n");
printf(" [-yuvdecode]\n");
printf(" Decode JPEG image to planar YUV rather than RGB\n\n");
printf(" NOTE: If the quality is specified as a range, i.e. 90-100, a separate\n");
printf(" test will be performed for all quality values in the range.\n");
exit(1);
}
int main(int argc, char *argv[])
{
unsigned char *bmpbuf=NULL; int w, h, i, useppm=0;
int qual=-1, dotile=0, quiet=0, hiqual=-1; char *temp;
int pf=BMP_BGR;
int bu=0, minarg=2;
if(argc<minarg) usage(argv[0]);
temp=strrchr(argv[1], '.');
if(temp!=NULL)
{
if(!stricmp(temp, ".ppm")) useppm=1;
if(!stricmp(temp, ".jpg") || !stricmp(temp, ".jpeg")) decomponly=1;
}
printf("\n");
if(argc>minarg)
{
for(i=minarg; i<argc; i++)
{
if(!stricmp(argv[i], "-yuvencode"))
{
printf("Testing YUV planar encoding\n\n");
yuv=YUVENCODE; hiqual=qual=100;
}
if(!stricmp(argv[i], "-yuvdecode"))
{
printf("Testing YUV planar decoding\n\n");
yuv=YUVDECODE;
}
}
}
if(!decomponly && yuv!=YUVENCODE)
{
minarg=3;
if(argc<minarg) usage(argv[0]);
if((qual=atoi(argv[2]))<1 || qual>100)
{
puts("ERROR: Quality must be between 1 and 100.");
exit(1);
}
if((temp=strchr(argv[2], '-'))!=NULL && strlen(temp)>1
&& sscanf(&temp[1], "%d", &hiqual)==1 && hiqual>qual && hiqual>=1
&& hiqual<=100) {}
else hiqual=qual;
}
if(argc>minarg)
{
for(i=minarg; i<argc; i++)
{
if(!stricmp(argv[i], "-tile")) dotile=1;
if(!stricmp(argv[i], "-forcesse3"))
{
printf("Using SSE3 code\n\n");
forcesse3=1;
}
if(!stricmp(argv[i], "-forcesse2"))
{
printf("Using SSE2 code\n\n");
forcesse2=1;
}
if(!stricmp(argv[i], "-forcesse"))
{
printf("Using SSE code\n\n");
forcesse=1;
}
if(!stricmp(argv[i], "-forcemmx"))
{
printf("Using MMX code\n\n");
forcemmx=1;
}
if(!stricmp(argv[i], "-fastupsample"))
{
printf("Using fast upsampling code\n\n");
fastupsample=1;
}
if(!stricmp(argv[i], "-rgb")) pf=BMP_RGB;
if(!stricmp(argv[i], "-rgbx")) pf=BMP_RGBX;
if(!stricmp(argv[i], "-bgr")) pf=BMP_BGR;
if(!stricmp(argv[i], "-bgrx")) pf=BMP_BGRX;
if(!stricmp(argv[i], "-xbgr")) pf=BMP_XBGR;
if(!stricmp(argv[i], "-xrgb")) pf=BMP_XRGB;
if(!stricmp(argv[i], "-bottomup")) bu=1;
if(!stricmp(argv[i], "-quiet")) quiet=1;
if(!stricmp(argv[i], "-qq")) quiet=2;
}
}
if(!decomponly)
{
if(loadbmp(argv[1], &bmpbuf, &w, &h, pf, 1, bu)==-1)
_throwbmp("loading bitmap");
temp=strrchr(argv[1], '.');
if(temp!=NULL) *temp='\0';
}
if(quiet==1 && !decomponly)
{
printf("All performance values in Mpixels/sec\n\n");
printf("Bitmap\tBitmap\tJPEG\tJPEG\tTile Size\tCompr\tCompr\tDecomp\n");
printf("Format\tOrder\tFormat\tQual\t X Y \tPerf \tRatio\tPerf\n\n");
}
if(decomponly)
{
dodecomptest(argv[1], pf, bu, 1, quiet);
printf("\n");
goto bailout;
}
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_GRAYSCALE, i, argv[1], dotile, useppm, quiet);
printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_420, i, argv[1], dotile, useppm, quiet);
printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_422, i, argv[1], dotile, useppm, quiet);
printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_444, i, argv[1], dotile, useppm, quiet);
printf("\n");
bailout:
if(bmpbuf) free(bmpbuf);
return 0;
}

View File

@@ -1,392 +0,0 @@
/* Copyright (C)2004 Landmark Graphics Corporation
* Copyright (C)2005, 2006 Sun Microsystems, Inc.
* Copyright (C)2009 D. R. Commander
*
* This library is free software and may be redistributed and/or modified under
* the terms of the wxWindows Library License, Version 3.1 or (at your option)
* any later version. The full license is in the LICENSE.txt file included
* with this distribution.
*
* This library 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
* wxWindows Library License for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "./bmp.h"
#include "./rrutil.h"
#include "./rrtimer.h"
#include "./turbojpeg.h"
#define _catch(f) {if((f)==-1) {printf("Error in %s:\n%s\n", #f, tjGetErrorStr()); goto bailout;}}
int forcemmx=0, forcesse=0, forcesse2=0, forcesse3=0, fastupsample=0;
const int _ps[BMPPIXELFORMATS]={3, 4, 3, 4, 4, 4};
const int _flags[BMPPIXELFORMATS]={0, 0, TJ_BGR, TJ_BGR,
TJ_BGR|TJ_ALPHAFIRST, TJ_ALPHAFIRST};
const int _rindex[BMPPIXELFORMATS]={0, 0, 2, 2, 3, 1};
const int _gindex[BMPPIXELFORMATS]={1, 1, 1, 1, 2, 2};
const int _bindex[BMPPIXELFORMATS]={2, 2, 0, 0, 1, 3};
const char *_pfname[]={"RGB", "RGBA", "BGR", "BGRA", "ABGR", "ARGB"};
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"};
const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"};
void printsigfig(double val, int figs)
{
char format[80];
double _l=log10(val); int l;
if(_l<0.)
{
l=(int)fabs(_l);
sprintf(format, "%%%d.%df", figs+l+2, figs+l);
}
else
{
l=(int)_l+1;
if(figs<=l) sprintf(format, "%%.0f");
else sprintf(format, "%%%d.%df", figs+1, figs-l);
}
printf(format, val);
}
void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
int jpegsub, int qual, char *filename, int dotile, int useppm, int quiet)
{
char tempstr[1024];
FILE *outfile; tjhandle hnd;
unsigned char **jpegbuf=NULL, *rgbbuf=NULL;
rrtimer timer; double elapsed;
int jpgbufsize=0, i, j, tilesizex, tilesizey, numtilesx, numtilesy, ITER;
unsigned long *comptilesize=NULL;
int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
|(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0)
|(fastupsample?TJ_FASTUPSAMPLE:0);
int ps=_ps[pf];
int pitch=w*ps;
flags |= _flags[pf];
if(bu) flags |= TJ_BOTTOMUP;
if((rgbbuf=(unsigned char *)malloc(pitch*h)) == NULL)
{
puts("ERROR: Could not allocate image buffer.");
exit(1);
}
if(!quiet) printf("\n>>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", _pfname[pf],
bu?"Bottom-up":"Top-down", _subnamel[jpegsub], qual);
if(dotile) {tilesizex=tilesizey=4;} else {tilesizex=w; tilesizey=h;}
do
{
tilesizex*=2; if(tilesizex>w) tilesizex=w;
tilesizey*=2; if(tilesizey>h) tilesizey=h;
numtilesx=(w+tilesizex-1)/tilesizex;
numtilesy=(h+tilesizey-1)/tilesizey;
if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long)*numtilesx*numtilesy)) == NULL
|| (jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)*numtilesx*numtilesy)) == NULL)
{
puts("ERROR: Could not allocate image buffers.");
goto bailout;
}
memset(jpegbuf, 0, sizeof(unsigned char *)*numtilesx*numtilesy);
for(i=0; i<numtilesx*numtilesy; i++)
{
if((jpegbuf[i]=(unsigned char *)malloc(TJBUFSIZE(tilesizex, tilesizey))) == NULL)
{
puts("ERROR: Could not allocate image buffers.");
goto bailout;
}
}
// Compression test
if(quiet) printf("%s\t%s\t%s\t%d\t", _pfname[pf], bu?"BU":"TD",
_subnamel[jpegsub], qual);
for(i=0; i<h; i++) memcpy(&rgbbuf[pitch*i], &srcbuf[w*ps*i], w*ps);
if((hnd=tjInitCompress())==NULL)
{
printf("Error in tjInitCompress():\n%s\n", tjGetErrorStr());
goto bailout;
}
_catch(tjCompress(hnd, rgbbuf, tilesizex, pitch, tilesizey, ps,
jpegbuf[0], &comptilesize[0], jpegsub, qual, flags));
ITER=0;
timer.start();
do
{
jpgbufsize=0; int tilen=0;
for(i=0; i<h; i+=tilesizey)
{
for(j=0; j<w; j+=tilesizex)
{
int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
_catch(tjCompress(hnd, &rgbbuf[pitch*i+j*ps], tempw, pitch,
temph, ps, jpegbuf[tilen], &comptilesize[tilen], jpegsub, qual,
flags));
jpgbufsize+=comptilesize[tilen];
tilen++;
}
}
ITER++;
} while((elapsed=timer.elapsed())<5.);
_catch(tjDestroy(hnd));
if(quiet)
{
if(tilesizex==w && tilesizey==h) printf("Full \t");
else printf("%-4d %-4d\t", tilesizex, tilesizey);
printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4);
printf("\t");
printsigfig((double)(w*h*ps)/(double)jpgbufsize, 4);
printf("\t");
}
else
{
if(tilesizex==w && tilesizey==h) printf("\nFull image\n");
else printf("\nTile size: %d x %d\n", tilesizex, tilesizey);
printf("C--> Frame rate: %f fps\n", (double)ITER/elapsed);
printf(" Output image size: %d bytes\n", jpgbufsize);
printf(" Compression ratio: %f:1\n",
(double)(w*h*ps)/(double)jpgbufsize);
printf(" Source throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)ITER/elapsed);
printf(" Output bit stream: %f Megabits/sec\n",
(double)jpgbufsize*8./1000000.*(double)ITER/elapsed);
}
if(tilesizex==w && tilesizey==h)
{
sprintf(tempstr, "%s_%sQ%d.jpg", filename, _subnames[jpegsub], qual);
if((outfile=fopen(tempstr, "wb"))==NULL)
{
puts("ERROR: Could not open reference image");
exit(1);
}
if(fwrite(jpegbuf[0], jpgbufsize, 1, outfile)!=1)
{
puts("ERROR: Could not write reference image");
exit(1);
}
fclose(outfile);
if(!quiet) printf("Reference image written to %s\n", tempstr);
}
// Decompression test
memset(rgbbuf, 127, pitch*h); // Grey image means decompressor did nothing
if((hnd=tjInitDecompress())==NULL)
{
printf("Error in tjInitDecompress():\n%s\n", tjGetErrorStr());
goto bailout;
}
_catch(tjDecompress(hnd, jpegbuf[0], jpgbufsize, rgbbuf, tilesizex, pitch,
tilesizey, ps, flags));
ITER=0;
timer.start();
do
{
int tilen=0;
for(i=0; i<h; i+=tilesizey)
{
for(j=0; j<w; j+=tilesizex)
{
int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
_catch(tjDecompress(hnd, jpegbuf[tilen], comptilesize[tilen],
&rgbbuf[pitch*i+ps*j], tempw, pitch, temph, ps, flags));
tilen++;
}
}
ITER++;
} while((elapsed=timer.elapsed())<5.);
_catch(tjDestroy(hnd));
if(quiet)
{
printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4);
printf("\n");
}
else
{
printf("D--> Frame rate: %f fps\n", (double)ITER/elapsed);
printf(" Dest. throughput: %f Megapixels/sec\n",
(double)(w*h)/1000000.*(double)ITER/elapsed);
}
if(tilesizex==w && tilesizey==h)
sprintf(tempstr, "%s_%sQ%d_full.%s", filename, _subnames[jpegsub], qual,
useppm?"ppm":"bmp");
else sprintf(tempstr, "%s_%sQ%d_%dx%d.%s", filename, _subnames[jpegsub],
qual, tilesizex, tilesizey, useppm?"ppm":"bmp");
if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
{
printf("ERROR saving bitmap: %s\n", bmpgeterr());
goto bailout;
}
sprintf(strrchr(tempstr, '.'), "-err.%s", useppm?"ppm":"bmp");
if(!quiet)
printf("Computing compression error and saving to %s.\n", tempstr);
if(jpegsub==TJ_GRAYSCALE)
{
for(j=0; j<h; j++)
{
for(i=0; i<w*ps; i+=ps)
{
int y=(int)((double)srcbuf[w*ps*j+i+_rindex[pf]]*0.299
+ (double)srcbuf[w*ps*j+i+_gindex[pf]]*0.587
+ (double)srcbuf[w*ps*j+i+_bindex[pf]]*0.114 + 0.5);
if(y>255) y=255; if(y<0) y=0;
rgbbuf[pitch*j+i+_rindex[pf]]=abs(rgbbuf[pitch*j+i+_rindex[pf]]-y);
rgbbuf[pitch*j+i+_gindex[pf]]=abs(rgbbuf[pitch*j+i+_gindex[pf]]-y);
rgbbuf[pitch*j+i+_bindex[pf]]=abs(rgbbuf[pitch*j+i+_bindex[pf]]-y);
}
}
}
else
{
for(j=0; j<h; j++) for(i=0; i<w*ps; i++)
rgbbuf[pitch*j+i]=abs(rgbbuf[pitch*j+i]-srcbuf[w*ps*j+i]);
}
if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
{
printf("ERROR saving bitmap: %s\n", bmpgeterr());
goto bailout;
}
// Cleanup
if(jpegbuf)
{
for(i=0; i<numtilesx*numtilesy; i++)
{if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;}
free(jpegbuf); jpegbuf=NULL;
}
if(comptilesize) {free(comptilesize); comptilesize=NULL;}
} while(tilesizex<w || tilesizey<h);
if(rgbbuf) {free(rgbbuf); rgbbuf=NULL;}
return;
bailout:
if(jpegbuf)
{
for(i=0; i<numtilesx*numtilesy; i++)
{if(jpegbuf[i]) free(jpegbuf[i]); jpegbuf[i]=NULL;}
free(jpegbuf); jpegbuf=NULL;
}
if(comptilesize) {free(comptilesize); comptilesize=NULL;}
if(rgbbuf) {free(rgbbuf); rgbbuf=NULL;}
return;
}
int main(int argc, char *argv[])
{
unsigned char *bmpbuf=NULL; int w, h, i, useppm=0;
int qual, dotile=0, quiet=0, hiqual=-1; char *temp;
BMPPIXELFORMAT pf=BMP_BGR;
int bu=0;
printf("\n");
if(argc<3)
{
printf("USAGE: %s <Inputfile (BMP|PPM)> <%% Quality>\n\n", argv[0]);
printf(" [-tile]\n");
printf(" Test performance of the codec when the image is encoded\n");
printf(" as separate tiles of varying sizes.\n\n");
printf(" [-forcemmx] [-forcesse] [-forcesse2] [-forcesse3]\n");
printf(" Force MMX, SSE, or SSE2 code paths in Intel codec\n\n");
printf(" [-rgb | -bgr | -rgba | -bgra | -abgr | -argb]\n");
printf(" Test the specified color conversion path in the codec (default: BGR)\n\n");
printf(" [-fastupsample]\n");
printf(" Use fast, inaccurate upsampling code to perform 4:2:2 and 4:2:0\n");
printf(" YUV decoding in libjpeg decompressor\n\n");
printf(" [-quiet]\n");
printf(" Output in tabular rather than verbose format\n\n");
printf(" NOTE: If the quality is specified as a range, i.e. 90-100, a separate\n");
printf(" test will be performed for all quality values in the range.\n");
exit(1);
}
if((qual=atoi(argv[2]))<1 || qual>100)
{
puts("ERROR: Quality must be between 1 and 100.");
exit(1);
}
if((temp=strchr(argv[2], '-'))!=NULL && strlen(temp)>1
&& sscanf(&temp[1], "%d", &hiqual)==1 && hiqual>qual && hiqual>=1
&& hiqual<=100) {}
else hiqual=qual;
if(argc>3)
{
for(i=3; i<argc; i++)
{
if(!stricmp(argv[i], "-tile")) dotile=1;
if(!stricmp(argv[i], "-forcesse3"))
{
printf("Using SSE3 code\n");
forcesse3=1;
}
if(!stricmp(argv[i], "-forcesse2"))
{
printf("Using SSE2 code\n");
forcesse2=1;
}
if(!stricmp(argv[i], "-forcesse"))
{
printf("Using SSE code\n");
forcesse=1;
}
if(!stricmp(argv[i], "-forcemmx"))
{
printf("Using MMX code\n");
forcemmx=1;
}
if(!stricmp(argv[i], "-fastupsample"))
{
printf("Using fast upsampling code\n");
fastupsample=1;
}
if(!stricmp(argv[i], "-rgb")) pf=BMP_RGB;
if(!stricmp(argv[i], "-rgba")) pf=BMP_RGBA;
if(!stricmp(argv[i], "-bgr")) pf=BMP_BGR;
if(!stricmp(argv[i], "-bgra")) pf=BMP_BGRA;
if(!stricmp(argv[i], "-abgr")) pf=BMP_ABGR;
if(!stricmp(argv[i], "-argb")) pf=BMP_ARGB;
if(!stricmp(argv[i], "-bottomup")) bu=1;
if(!stricmp(argv[i], "-quiet")) quiet=1;
}
}
if(loadbmp(argv[1], &bmpbuf, &w, &h, pf, 1, bu)==-1)
{
printf("ERROR loading bitmap: %s\n", bmpgeterr()); exit(1);
}
temp=strrchr(argv[1], '.');
if(temp!=NULL)
{
if(!stricmp(temp, ".ppm")) useppm=1;
*temp='\0';
}
if(quiet)
{
printf("All performance values in Mpixels/sec\n\n");
printf("Bitmap\tBitmap\tJPEG\tJPEG\tTile Size\tCompr\tCompr\tDecomp\n");
printf("Format\tOrder\tFormat\tQual\t X Y \tPerf \tRatio\tPerf\n\n");
}
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_GRAYSCALE, i, argv[1], dotile, useppm, quiet);
if(quiet) printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_420, i, argv[1], dotile, useppm, quiet);
if(quiet) printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_422, i, argv[1], dotile, useppm, quiet);
if(quiet) printf("\n");
for(i=hiqual; i>=qual; i--)
dotest(bmpbuf, w, h, pf, bu, TJ_444, i, argv[1], dotile, useppm, quiet);
if(bmpbuf) free(bmpbuf);
return 0;
}

View File

@@ -5,6 +5,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
*/ */

View File

@@ -6,6 +6,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
* This file contains stubs for when there is no SIMD support available. * This file contains stubs for when there is no SIMD support available.
*/ */

View File

@@ -5,6 +5,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
*/ */

View File

@@ -77,8 +77,8 @@ jdiv_round_up (long a, long b)
} }
GLOBAL(size_t) GLOBAL(long)
jround_up (size_t a, size_t b) jround_up (long a, long b)
/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ /* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
/* Assumes a >= 0, b > 0 */ /* Assumes a >= 0, b > 0 */
{ {

View File

@@ -1,7 +1,8 @@
/* /*
* jversion.h * jversion.h
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -9,6 +10,28 @@
*/ */
#if JPEG_LIB_VERSION >= 80
#define JVERSION "8b 16-May-2010"
#define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding"
#elif JPEG_LIB_VERSION >= 70
#define JVERSION "7 27-Jun-2009"
#define JCOPYRIGHT "Copyright (C) 2009, Thomas G. Lane, Guido Vollbeding"
#else
#define JVERSION "6b 27-Mar-1998" #define JVERSION "6b 27-Mar-1998"
#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane"
#endif
#define LJTCOPYRIGHT "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
"Copyright (C) 2004 Landmark Graphics Corporation\n" \
"Copyright (C) 2005-2007 Sun Microsystems, Inc.\n" \
"Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \
"Copyright (C) 2009-2011 D. R. Commander"

10
libjpeg.map.in Normal file
View File

@@ -0,0 +1,10 @@
LIBJPEGTURBO_@JPEG_LIB_VERSION_DECIMAL@ {
local:
jsimd_*;
jconst_*;
};
LIBJPEG_@JPEG_LIB_VERSION_DECIMAL@ {
global:
*;
};

View File

@@ -1,6 +1,6 @@
USING THE IJG JPEG LIBRARY USING THE IJG JPEG LIBRARY
Copyright (C) 1994-1998, Thomas G. Lane. Copyright (C) 1994-2010, Thomas G. Lane, Guido Vollbeding, D. R. Commander.
This file is part of the Independent JPEG Group's software. This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file. For conditions of distribution and use, see the accompanying README file.
@@ -93,7 +93,6 @@ JPEG processes are supported. (Our subset includes all features now in common
use.) Unsupported ISO options include: use.) Unsupported ISO options include:
* Hierarchical storage * Hierarchical storage
* Lossless JPEG * Lossless JPEG
* Arithmetic entropy coding (unsupported for legal reasons)
* DNL marker * DNL marker
* Nonintegral subsampling ratios * Nonintegral subsampling ratios
We support both 8- and 12-bit data precision, but this is a compile-time We support both 8- and 12-bit data precision, but this is a compile-time
@@ -750,7 +749,7 @@ is to prepare a library file ("libjpeg.a", or a corresponding name on non-Unix
machines) and reference it at your link step. If you use only half of the machines) and reference it at your link step. If you use only half of the
library (only compression or only decompression), only that much code will be library (only compression or only decompression), only that much code will be
included from the library, unless your linker is hopelessly brain-damaged. included from the library, unless your linker is hopelessly brain-damaged.
The supplied makefiles build libjpeg.a automatically (see install.doc). The supplied makefiles build libjpeg.a automatically (see install.txt).
While you can build the JPEG library as a shared library if the whim strikes While you can build the JPEG library as a shared library if the whim strikes
you, we don't really recommend it. The trouble with shared libraries is that you, we don't really recommend it. The trouble with shared libraries is that
@@ -850,6 +849,10 @@ int jpeg_quality_scaling (int quality)
can't be expressed as a simple scalar multiplier, in which case the can't be expressed as a simple scalar multiplier, in which case the
premise of this routine collapses. Caveat user. premise of this routine collapses. Caveat user.
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
[libjpeg v7/v8 only] Set default quantization tables with linear
q_scale_factor[] values (see below).
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table, const unsigned int *basic_table,
int scale_factor, boolean force_baseline) int scale_factor, boolean force_baseline)
@@ -972,6 +975,32 @@ JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
routines will set up table slot 0 for luminance quality and table routines will set up table slot 0 for luminance quality and table
slot 1 for chrominance. slot 1 for chrominance.
int q_scale_factor[NUM_QUANT_TBLS]
[libjpeg v7+ only] Linear quantization scaling factors (0-100, default
100) for use with jpeg_default_qtables().
See rdswitch.c and cjpeg.c for an example of usage.
Note that the q_scale_factor[] values use "linear" scales, so JPEG
quality levels chosen by the user must be converted to these scales
using jpeg_quality_scaling(). Here is an example which corresponds to
cjpeg -quality 90,70:
jpeg_set_defaults(cinfo);
/* Set luminance quality 90. */
cinfo->q_scale_factor[0] = jpeg_quality_scaling(90);
/* Set chrominance quality 70. */
cinfo->q_scale_factor[1] = jpeg_quality_scaling(70);
jpeg_default_qtables(cinfo, force_baseline);
CAUTION: Setting separate quality levels for chrominance and luminance
is mainly only useful if chrominance subsampling is disabled. 2x2
chrominance subsampling (AKA "4:2:0") is the default, but you can
explicitly disable subsampling as follows:
cinfo->comp_info[0].v_samp_factor = 1;
cinfo->comp_info[0].h_samp_factor = 1;
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS] JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS] JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
Pointers to Huffman coding tables, one per table slot, or NULL if Pointers to Huffman coding tables, one per table slot, or NULL if
@@ -982,9 +1011,15 @@ JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
by setting optimize_coding, as discussed above; there's seldom by setting optimize_coding, as discussed above; there's seldom
any need to mess with providing your own Huffman tables. any need to mess with providing your own Huffman tables.
There are some additional cinfo fields which are not documented here
because you currently can't change them; for example, you can't set [libjpeg v7+ only] The actual dimensions of the JPEG image that will be written
arith_code TRUE because arithmetic coding is unsupported. to the file are given by the following fields. These are computed from the
input image dimensions and the compression parameters by jpeg_start_compress().
You can also call jpeg_calc_jpeg_dimensions() to obtain the values that will
result from the current parameter settings.
JDIMENSION jpeg_width Actual dimensions of output image.
JDIMENSION jpeg_height
Per-component parameters are stored in the struct cinfo.comp_info[i] for Per-component parameters are stored in the struct cinfo.comp_info[i] for
@@ -1374,21 +1409,22 @@ Compressed data handling (source and destination managers)
The JPEG compression library sends its compressed data to a "destination The JPEG compression library sends its compressed data to a "destination
manager" module. The default destination manager just writes the data to a manager" module. The default destination manager just writes the data to a
stdio stream, but you can provide your own manager to do something else. memory buffer or to a stdio stream, but you can provide your own manager to
Similarly, the decompression library calls a "source manager" to obtain the do something else. Similarly, the decompression library calls a "source
compressed data; you can provide your own source manager if you want the data manager" to obtain the compressed data; you can provide your own source
to come from somewhere other than a stdio stream. manager if you want the data to come from somewhere other than a memory
buffer or a stdio stream.
In both cases, compressed data is processed a bufferload at a time: the In both cases, compressed data is processed a bufferload at a time: the
destination or source manager provides a work buffer, and the library invokes destination or source manager provides a work buffer, and the library invokes
the manager only when the buffer is filled or emptied. (You could define a the manager only when the buffer is filled or emptied. (You could define a
one-character buffer to force the manager to be invoked for each byte, but one-character buffer to force the manager to be invoked for each byte, but
that would be rather inefficient.) The buffer's size and location are that would be rather inefficient.) The buffer's size and location are
controlled by the manager, not by the library. For example, if you desired to controlled by the manager, not by the library. For example, the memory
decompress a JPEG datastream that was all in memory, you could just make the source manager just makes the buffer pointer and length point to the original
buffer pointer and length point to the original data in memory. Then the data in memory. In this case the buffer-reload procedure will be invoked
buffer-reload procedure would be invoked only if the decompressor ran off the only if the decompressor ran off the end of the datastream, which would
end of the datastream, which would indicate an erroneous datastream. indicate an erroneous datastream.
The work buffer is defined as an array of datatype JOCTET, which is generally The work buffer is defined as an array of datatype JOCTET, which is generally
"char" or "unsigned char". On a machine where char is not exactly 8 bits "char" or "unsigned char". On a machine where char is not exactly 8 bits
@@ -1440,7 +1476,8 @@ You will also need code to create a jpeg_destination_mgr struct, fill in its
method pointers, and insert a pointer to the struct into the "dest" field of method pointers, and insert a pointer to the struct into the "dest" field of
the JPEG compression object. This can be done in-line in your setup code if the JPEG compression object. This can be done in-line in your setup code if
you like, but it's probably cleaner to provide a separate routine similar to you like, but it's probably cleaner to provide a separate routine similar to
the jpeg_stdio_dest() routine of the supplied destination manager. the jpeg_stdio_dest() or jpeg_mem_dest() routines of the supplied destination
managers.
Decompression source managers follow a parallel design, but with some Decompression source managers follow a parallel design, but with some
additional frammishes. The source manager struct contains a pointer and count additional frammishes. The source manager struct contains a pointer and count
@@ -1516,10 +1553,10 @@ You will also need code to create a jpeg_source_mgr struct, fill in its method
pointers, and insert a pointer to the struct into the "src" field of the JPEG pointers, and insert a pointer to the struct into the "src" field of the JPEG
decompression object. This can be done in-line in your setup code if you decompression object. This can be done in-line in your setup code if you
like, but it's probably cleaner to provide a separate routine similar to the like, but it's probably cleaner to provide a separate routine similar to the
jpeg_stdio_src() routine of the supplied source manager. jpeg_stdio_src() or jpeg_mem_src() routines of the supplied source managers.
For more information, consult the stdio source and destination managers For more information, consult the memory and stdio source and destination
in jdatasrc.c and jdatadst.c. managers in jdatasrc.c and jdatadst.c.
I/O suspension I/O suspension
@@ -2608,7 +2645,7 @@ entire image into a set of virtual coefficient-block arrays, one array per
component. The return value is a pointer to an array of virtual-array component. The return value is a pointer to an array of virtual-array
descriptors. Each virtual array can be accessed directly using the JPEG descriptors. Each virtual array can be accessed directly using the JPEG
memory manager's access_virt_barray method (see Memory management, below, memory manager's access_virt_barray method (see Memory management, below,
and also read structure.doc's discussion of virtual array handling). Or, and also read structure.txt's discussion of virtual array handling). Or,
for simple transcoding to a different JPEG file format, the array list can for simple transcoding to a different JPEG file format, the array list can
just be handed directly to jpeg_write_coefficients(). just be handed directly to jpeg_write_coefficients().
@@ -2752,7 +2789,7 @@ Memory management
----------------- -----------------
This section covers some key facts about the JPEG library's built-in memory This section covers some key facts about the JPEG library's built-in memory
manager. For more info, please read structure.doc's section about the memory manager. For more info, please read structure.txt's section about the memory
manager, and consult the source code if necessary. manager, and consult the source code if necessary.
All memory and temporary file allocation within the library is done via the All memory and temporary file allocation within the library is done via the
@@ -2867,7 +2904,7 @@ 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. 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 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 and GIF file formats; you must disable the other file formats to compile a
12-bit cjpeg or djpeg. (install.doc has more information about that.) 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 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 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 application, you could probably do it by defining NEED_SHORT_EXTERNAL_NAMES
@@ -2920,7 +2957,7 @@ about them.)
The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of The code works fine on ANSI C, C++, and pre-ANSI C compilers, using any of
the popular system include file setups, and some not-so-popular ones too. the popular system include file setups, and some not-so-popular ones too.
See install.doc for configuration procedures. See install.txt for configuration procedures.
The code is not dependent on the exact sizes of the C data types. As The code is not dependent on the exact sizes of the C data types. As
distributed, we make the assumptions that distributed, we make the assumptions that
@@ -2959,7 +2996,7 @@ The code generally assumes that C names must be unique in the first 15
characters. However, global function names can be made unique in the characters. However, global function names can be made unique in the
first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES. first 6 characters by defining NEED_SHORT_EXTERNAL_NAMES.
More info about porting the code may be gleaned by reading jconfig.doc, More info about porting the code may be gleaned by reading jconfig.txt,
jmorecfg.h, and jinclude.h. jmorecfg.h, and jinclude.h.

71
rdbmp.c
View File

@@ -2,6 +2,8 @@
* rdbmp.c * rdbmp.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2010 by Guido Vollbeding.
* Modified 2011 by Siarhei Siamashka.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -177,10 +179,41 @@ get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
} }
METHODDEF(JDIMENSION)
get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading 32-bit pixels */
{
bmp_source_ptr source = (bmp_source_ptr) sinfo;
JSAMPARRAY image_ptr;
register JSAMPROW inptr, outptr;
register JDIMENSION col;
/* Fetch next row from virtual array */
source->source_row--;
image_ptr = (*cinfo->mem->access_virt_sarray)
((j_common_ptr) cinfo, source->whole_image,
source->source_row, (JDIMENSION) 1, FALSE);
/* Transfer data. Note source values are in BGR order
* (even though Microsoft's own documents say the opposite).
*/
inptr = image_ptr[0];
outptr = source->pub.buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */
outptr[1] = *inptr++;
outptr[0] = *inptr++;
inptr++; /* skip the 4th byte (Alpha channel) */
outptr += 3;
}
return 1;
}
/* /*
* This method loads the image into whole_image during the first call on * This method loads the image into whole_image during the first call on
* get_pixel_rows. The get_pixel_rows pointer is then adjusted to call * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
* get_8bit_row or get_24bit_row on subsequent calls. * get_8bit_row, get_24bit_row, or get_32bit_row on subsequent calls.
*/ */
METHODDEF(JDIMENSION) METHODDEF(JDIMENSION)
@@ -188,10 +221,9 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{ {
bmp_source_ptr source = (bmp_source_ptr) sinfo; bmp_source_ptr source = (bmp_source_ptr) sinfo;
register FILE *infile = source->pub.input_file; register FILE *infile = source->pub.input_file;
register int c;
register JSAMPROW out_ptr; register JSAMPROW out_ptr;
JSAMPARRAY image_ptr; JSAMPARRAY image_ptr;
JDIMENSION row, col; JDIMENSION row;
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
/* Read the data into a virtual array in input-file row order. */ /* Read the data into a virtual array in input-file row order. */
@@ -205,11 +237,11 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
((j_common_ptr) cinfo, source->whole_image, ((j_common_ptr) cinfo, source->whole_image,
row, (JDIMENSION) 1, TRUE); row, (JDIMENSION) 1, TRUE);
out_ptr = image_ptr[0]; out_ptr = image_ptr[0];
for (col = source->row_width; col > 0; col--) { if (fread(out_ptr, 1, source->row_width, infile) != source->row_width) {
/* inline copy of read_byte() for speed */ if (feof(infile))
if ((c = getc(infile)) == EOF) ERREXIT(cinfo, JERR_INPUT_EOF);
ERREXIT(cinfo, JERR_INPUT_EOF); else
*out_ptr++ = (JSAMPLE) c; ERREXIT(cinfo, JERR_FILE_READ);
} }
} }
if (progress != NULL) if (progress != NULL)
@@ -223,6 +255,9 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case 24: case 24:
source->pub.get_pixel_rows = get_24bit_row; source->pub.get_pixel_rows = get_24bit_row;
break; break;
case 32:
source->pub.get_pixel_rows = get_32bit_row;
break;
default: default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH); ERREXIT(cinfo, JERR_BMP_BADDEPTH);
} }
@@ -251,8 +286,8 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
(((INT32) UCH(array[offset+3])) << 24)) (((INT32) UCH(array[offset+3])) << 24))
INT32 bfOffBits; INT32 bfOffBits;
INT32 headerSize; INT32 headerSize;
INT32 biWidth = 0; /* initialize to avoid compiler warning */ INT32 biWidth;
INT32 biHeight = 0; INT32 biHeight;
unsigned int biPlanes; unsigned int biPlanes;
INT32 biCompression; INT32 biCompression;
INT32 biXPelsPerMeter,biYPelsPerMeter; INT32 biXPelsPerMeter,biYPelsPerMeter;
@@ -300,8 +335,6 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
ERREXIT(cinfo, JERR_BMP_BADDEPTH); ERREXIT(cinfo, JERR_BMP_BADDEPTH);
break; break;
} }
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);
break; break;
case 40: case 40:
case 64: case 64:
@@ -325,12 +358,13 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case 24: /* RGB image */ case 24: /* RGB image */
TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
break; break;
case 32: /* RGB image + Alpha channel */
TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
break;
default: default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH); ERREXIT(cinfo, JERR_BMP_BADDEPTH);
break; break;
} }
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);
if (biCompression != 0) if (biCompression != 0)
ERREXIT(cinfo, JERR_BMP_COMPRESSED); ERREXIT(cinfo, JERR_BMP_COMPRESSED);
@@ -343,9 +377,14 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
break; break;
default: default:
ERREXIT(cinfo, JERR_BMP_BADHEADER); ERREXIT(cinfo, JERR_BMP_BADHEADER);
break; return;
} }
if (biWidth <= 0 || biHeight <= 0)
ERREXIT(cinfo, JERR_BMP_EMPTY);
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);
/* Compute distance to bitmap data --- will adjust for colormap below */ /* Compute distance to bitmap data --- will adjust for colormap below */
bPad = bfOffBits - (headerSize + 14); bPad = bfOffBits - (headerSize + 14);
@@ -375,6 +414,8 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Compute row width in file, including padding to 4-byte boundary */ /* Compute row width in file, including padding to 4-byte boundary */
if (source->bits_per_pixel == 24) if (source->bits_per_pixel == 24)
row_width = (JDIMENSION) (biWidth * 3); row_width = (JDIMENSION) (biWidth * 3);
else if (source->bits_per_pixel == 32)
row_width = (JDIMENSION) (biWidth * 4);
else else
row_width = (JDIMENSION) biWidth; row_width = (JDIMENSION) biWidth;
while ((row_width & 3) != 0) row_width++; while ((row_width & 3) != 0) row_width++;

View File

@@ -1,9 +1,12 @@
.TH RDJPGCOM 1 "11 October 1997" .TH RDJPGCOM 1 "02 April 2009"
.SH NAME .SH NAME
rdjpgcom \- display text comments from a JPEG file rdjpgcom \- display text comments from a JPEG file
.SH SYNOPSIS .SH SYNOPSIS
.B rdjpgcom .B rdjpgcom
[ [
.B \-raw
]
[
.B \-verbose .B \-verbose
] ]
[ [
@@ -25,6 +28,12 @@ file. The maximum size of a COM block is 64K, but you can have as many of
them as you like in one JPEG file. them as you like in one JPEG file.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B \-raw
Normally
.B rdjpgcom
escapes non-printable characters in comments, for security reasons.
This option avoids that.
.PP
.B \-verbose .B \-verbose
Causes Causes
.B rdjpgcom .B rdjpgcom

View File

@@ -2,6 +2,7 @@
* rdjpgcom.c * rdjpgcom.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009 by Bill Allombert, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -14,6 +15,9 @@
#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ #define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */
#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ #include "jinclude.h" /* get auto-config symbols, <stdio.h> */
#ifdef HAVE_LOCALE_H
#include <locale.h> /* Bill Allombert: use locale for isprint */
#endif
#include <ctype.h> /* to declare isupper(), tolower() */ #include <ctype.h> /* to declare isupper(), tolower() */
#ifdef USE_SETMODE #ifdef USE_SETMODE
#include <fcntl.h> /* to declare setmode()'s parameter macros */ #include <fcntl.h> /* to declare setmode()'s parameter macros */
@@ -218,12 +222,17 @@ skip_variable (void)
*/ */
static void static void
process_COM (void) process_COM (int raw)
{ {
unsigned int length; unsigned int length;
int ch; int ch;
int lastch = 0; int lastch = 0;
/* Bill Allombert: set locale properly for isprint */
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "");
#endif
/* Get the marker parameter length count */ /* Get the marker parameter length count */
length = read_2_bytes(); length = read_2_bytes();
/* Length includes itself, so must be at least 2 */ /* Length includes itself, so must be at least 2 */
@@ -233,12 +242,14 @@ process_COM (void)
while (length > 0) { while (length > 0) {
ch = read_1_byte(); ch = read_1_byte();
if (raw) {
putc(ch, stdout);
/* Emit the character in a readable form. /* Emit the character in a readable form.
* Nonprintables are converted to \nnn form, * Nonprintables are converted to \nnn form,
* while \ is converted to \\. * while \ is converted to \\.
* Newlines in CR, CR/LF, or LF form will be printed as one newline. * Newlines in CR, CR/LF, or LF form will be printed as one newline.
*/ */
if (ch == '\r') { } else if (ch == '\r') {
printf("\n"); printf("\n");
} else if (ch == '\n') { } else if (ch == '\n') {
if (lastch != '\r') if (lastch != '\r')
@@ -254,6 +265,11 @@ process_COM (void)
length--; length--;
} }
printf("\n"); printf("\n");
/* Bill Allombert: revert to C locale */
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "C");
#endif
} }
@@ -321,7 +337,7 @@ process_SOFn (int marker)
*/ */
static int static int
scan_JPEG_header (int verbose) scan_JPEG_header (int verbose, int raw)
{ {
int marker; int marker;
@@ -362,7 +378,7 @@ scan_JPEG_header (int verbose)
return marker; return marker;
case M_COM: case M_COM:
process_COM(); process_COM(raw);
break; break;
case M_APP12: case M_APP12:
@@ -371,7 +387,7 @@ scan_JPEG_header (int verbose)
*/ */
if (verbose) { if (verbose) {
printf("APP12 contains:\n"); printf("APP12 contains:\n");
process_COM(); process_COM(raw);
} else } else
skip_variable(); skip_variable();
break; break;
@@ -398,6 +414,7 @@ usage (void)
fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname);
fprintf(stderr, "Switches (names may be abbreviated):\n"); fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -raw Display non-printable characters in comments (unsafe)\n");
fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); fprintf(stderr, " -verbose Also display dimensions of JPEG image\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -438,7 +455,7 @@ main (int argc, char **argv)
{ {
int argn; int argn;
char * arg; char * arg;
int verbose = 0; int verbose = 0, raw = 0;
/* On Mac, fetch a command line. */ /* On Mac, fetch a command line. */
#ifdef USE_CCOMMAND #ifdef USE_CCOMMAND
@@ -457,6 +474,8 @@ main (int argc, char **argv)
arg++; /* advance over '-' */ arg++; /* advance over '-' */
if (keymatch(arg, "verbose", 1)) { if (keymatch(arg, "verbose", 1)) {
verbose++; verbose++;
} else if (keymatch(arg, "raw", 1)) {
raw = 1;
} else } else
usage(); usage();
} }
@@ -488,7 +507,7 @@ main (int argc, char **argv)
} }
/* Scan the JPEG headers. */ /* Scan the JPEG headers. */
(void) scan_JPEG_header(verbose); (void) scan_JPEG_header(verbose, raw);
/* All done. */ /* All done. */
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);

17
rdppm.c
View File

@@ -2,6 +2,7 @@
* rdppm.c * rdppm.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2009 by Bill Allombert, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -250,8 +251,8 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
bufferptr = source->iobuffer; bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) { for (col = cinfo->image_width; col > 0; col--) {
register int temp; register int temp;
temp = UCH(*bufferptr++); temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp]; *ptr++ = rescale[temp];
} }
return 1; return 1;
@@ -274,14 +275,14 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
bufferptr = source->iobuffer; bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) { for (col = cinfo->image_width; col > 0; col--) {
register int temp; register int temp;
temp = UCH(*bufferptr++); temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp]; *ptr++ = rescale[temp];
temp = UCH(*bufferptr++); temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp]; *ptr++ = rescale[temp];
temp = UCH(*bufferptr++); temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++) << 8; temp |= UCH(*bufferptr++);
*ptr++ = rescale[temp]; *ptr++ = rescale[temp];
} }
return 1; return 1;

View File

@@ -2,6 +2,7 @@
* rdswitch.c * rdswitch.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Copyright (C) 2010, D. R. Commander.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -9,6 +10,7 @@
* command-line switches. Switches processed here are: * command-line switches. Switches processed here are:
* -qtables file Read quantization tables from text file * -qtables file Read quantization tables from text file
* -scans file Read scan script from text file * -scans file Read scan script from text file
* -quality N[,N,...] Set quality ratings
* -qslots N[,N,...] Set component quantization table selectors * -qslots N[,N,...] Set component quantization table selectors
* -sample HxV[,HxV,...] Set component sampling factors * -sample HxV[,HxV,...] Set component sampling factors
*/ */
@@ -69,9 +71,12 @@ read_text_integer (FILE * file, long * result, int * termchar)
} }
#if JPEG_LIB_VERSION < 70
static int q_scale_factor[NUM_QUANT_TBLS] = {100, 100, 100, 100};
#endif
GLOBAL(boolean) GLOBAL(boolean)
read_quant_tables (j_compress_ptr cinfo, char * filename, read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline)
int scale_factor, boolean force_baseline)
/* Read a set of quantization tables from the specified file. /* Read a set of quantization tables from the specified file.
* The file is plain ASCII text: decimal numbers with whitespace between. * The file is plain ASCII text: decimal numbers with whitespace between.
* Comments preceded by '#' may be included in the file. * Comments preceded by '#' may be included in the file.
@@ -108,7 +113,13 @@ read_quant_tables (j_compress_ptr cinfo, char * filename,
} }
table[i] = (unsigned int) val; table[i] = (unsigned int) val;
} }
jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); #if JPEG_LIB_VERSION >= 70
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
force_baseline);
#else
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
force_baseline);
#endif
tblno++; tblno++;
} }
@@ -262,6 +273,84 @@ bogus:
#endif /* C_MULTISCAN_FILES_SUPPORTED */ #endif /* C_MULTISCAN_FILES_SUPPORTED */
#if JPEG_LIB_VERSION < 70
/* These are the sample quantization tables given in JPEG spec section K.1.
* The spec says that the values given produce "good" quality, and
* when divided by 2, "very good" quality.
*/
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
LOCAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
{
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
q_scale_factor[1], force_baseline);
}
#endif
GLOBAL(boolean)
set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
/* Process a quality-ratings parameter string, of the form
* N[,N,...]
* If there are more q-table slots than parameters, the last value is replicated.
*/
{
int val = 75; /* default value */
int tblno;
char ch;
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
if (*arg) {
ch = ','; /* if not set by sscanf, will be ',' */
if (sscanf(arg, "%d%c", &val, &ch) < 1)
return FALSE;
if (ch != ',') /* syntax check */
return FALSE;
/* Convert user 0-100 rating to percentage scaling */
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
#else
q_scale_factor[tblno] = jpeg_quality_scaling(val);
#endif
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
;
} else {
/* reached end of parameter, set remaining factors to last value */
#if JPEG_LIB_VERSION >= 70
cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val);
#else
q_scale_factor[tblno] = jpeg_quality_scaling(val);
#endif
}
}
jpeg_default_qtables(cinfo, force_baseline);
return TRUE;
}
GLOBAL(boolean) GLOBAL(boolean)
set_quant_slots (j_compress_ptr cinfo, char *arg) set_quant_slots (j_compress_ptr cinfo, char *arg)
/* Process a quantization-table-selectors parameter string, of the form /* Process a quantization-table-selectors parameter string, of the form

View File

@@ -5,8 +5,8 @@
<key>IFPkgDescriptionDescription</key> <key>IFPkgDescriptionDescription</key>
<string>A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs</string> <string>A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs</string>
<key>IFPkgDescriptionTitle</key> <key>IFPkgDescriptionTitle</key>
<string>{__APPNAME}</string> <string>@PACKAGE_NAME@</string>
<key>IFPkgDescriptionVersion</key> <key>IFPkgDescriptionVersion</key>
<string>{__VERSION}</string> <string>@VERSION@</string>
</dict> </dict>
</plist> </plist>

View File

@@ -3,15 +3,15 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>{__VERSION}, The libjpeg-turbo Project</string> <string>@VERSION@, The libjpeg-turbo Project</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.libjpeg-turbo.libjpeg-turbo</string> <string>com.libjpeg-turbo.libjpeg-turbo</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>{__VERSION}</string> <string>@VERSION@</string>
<key>IFMajorVersion</key> <key>IFMajorVersion</key>
<integer>1</integer> <integer>1</integer>
<key>IFMinorVersion</key> <key>IFMinorVersion</key>
<integer>{__BUILD}</integer> <integer>@BUILD@</integer>
<key>IFPkgFlagAllowBackRev</key> <key>IFPkgFlagAllowBackRev</key>
<false/> <false/>
<key>IFPkgFlagAuthorizationAction</key> <key>IFPkgFlagAuthorizationAction</key>

View File

@@ -1,11 +1,13 @@
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250 {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;} {\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww15200\viewh9600\viewkind0 \margl1440\margr1440\vieww15200\viewh9600\viewkind0
\deftab720 \deftab720
\pard\pardeftab720\ql\qnatural \pard\pardeftab720\ql\qnatural
\f0\fs24 \cf0 libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression and decompression. libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal. libjpeg-turbo also includes a wrapper library for the TurboJPEG API used by VirtualGL and TurboVNC.\ \f0\fs24 \cf0 libjpeg-turbo is a derivative of libjpeg which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression and decompression on x86 and x86-64 systems. On such systems, libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal. libjpeg-turbo also includes a wrapper library which implements the TurboJPEG API used by VirtualGL and TurboVNC.\
\ \
libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but the TigerVNC and VirtualGL projects made numerous enhancements to the codec, including improved support for Mac OS X, 64-bit support, support for 32-bit and big endian pixel formats, accelerated Huffman encoding/decoding, and various bug fixes. The goal was to produce a fully open source codec that could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of TurboJPEG/IPP. It is faster in some areas but slower in others.\ libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but the TigerVNC and VirtualGL projects made numerous enhancements to the codec in 2009, including improved support for Mac OS X, 64-bit support, support for 32-bit and big endian pixel formats (RGBX, XBGR, etc.), accelerated Huffman encoding/decoding, and various bug fixes. The goal was to produce a fully open source codec that could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of TurboJPEG/IPP. It is faster in some areas but slower in others.\
\
In early 2010, libjpeg-turbo spun off into its own independent project, with the goal of making high-speed JPEG compression/decompression technology available to a broader range of users and developers.\
} }

28
release/deb-control.in Normal file
View File

@@ -0,0 +1,28 @@
Package: @PACKAGE_NAME@
Version: @VERSION@-@BUILD@
Section: misc
Priority: optional
Architecture: @DEBARCH@
Essential: no
Maintainer: The libjpeg-turbo Project [http://www.libjpeg-turbo.org]
Description: A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs
libjpeg-turbo is a derivative of libjpeg which uses SIMD instructions (MMX,
SSE2, etc.) to accelerate baseline JPEG compression and decompression on x86
and x86-64 systems. On such systems, libjpeg-turbo is generally 2-4x as fast
as the unmodified version of libjpeg, all else being equal. libjpeg-turbo
also includes a wrapper library which implements the TurboJPEG API used by
VirtualGL and TurboVNC.
.
libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
the TigerVNC and VirtualGL projects made numerous enhancements to the codec
in 2009, including improved support for Mac OS X, 64-bit support, support
for 32-bit and big endian pixel formats (RGBX, XBGR, etc.), accelerated
Huffman encoding/decoding, and various bug fixes. The goal was to produce a
fully open source codec that could replace the partially closed source
TurboJPEG/IPP codec used by VirtualGL and TurboVNC. libjpeg-turbo generally
performs in the range of 80-120% of TurboJPEG/IPP. It is faster in some
areas but slower in others.
.
In early 2010, libjpeg-turbo spun off into its own independent project, with
the goal of making high-speed JPEG compression/decompression technology
available to a broader range of users and developers.

View File

@@ -1,23 +0,0 @@
Package: {__PKGNAME}
Version: {__VERSION}-{__BUILD}
Section: misc
Priority: optional
Architecture: {__ARCH}
Essential: no
Maintainer: The libjpeg-turbo Project [http://libjpeg-turbo.VirtualGL.org]
Description: A toolkit for displaying OpenGL applications to thin clients
libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors
which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG
compression and decompression. libjpeg-turbo is generally 2-4x as fast
as the unmodified version of libjpeg, all else being equal. libjpeg-turbo
also includes a wrapper library for the TurboJPEG API used by VirtualGL and
TurboVNC.
.
libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
the TigerVNC and VirtualGL projects made numerous enhancements to the codec,
including improved support for Mac OS X, 64-bit support, support for 32-bit
and big endian pixel formats, accelerated Huffman encoding/decoding, and
various bug fixes. The goal was to produce a fully open source codec that
could replace the partially closed source TurboJPEG/IPP codec used by
VirtualGL and TurboVNC. libjpeg-turbo generally performs in the range of
80-120% of TurboJPEG/IPP. It is faster in some areas but slower in others.

View File

@@ -1,126 +0,0 @@
!include x64.nsh
Name "libjpeg-turbo SDK for ${PLATFORM}"
OutFile ${WBLDDIR}\${APPNAME}.exe
InstallDir c:\${APPNAME}
SetCompressor bzip2
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
Section "libjpeg-turbo SDK for ${PLATFORM} (required)"
!ifdef WIN64
${If} ${RunningX64}
${DisableX64FSRedirection}
${Endif}
!endif
SectionIn RO
!ifdef GCC
IfFileExists $SYSDIR/libturbojpeg.dll exists 0
!else
IfFileExists $SYSDIR/turbojpeg.dll exists 0
!endif
goto notexists
exists:
!ifdef GCC
MessageBox MB_OK "An existing version of the libjpeg-turbo SDK for ${PLATFORM} is already installed. Please uninstall it first."
!else
MessageBox MB_OK "An existing version of the libjpeg-turbo SDK for ${PLATFORM} or the TurboJPEG SDK is already installed. Please uninstall it first."
!endif
quit
notexists:
SetOutPath $SYSDIR
!ifdef GCC
File "${WLIBDIR}\libturbojpeg.dll"
!else
File "${WLIBDIR}\turbojpeg.dll"
!endif
SetOutPath $INSTDIR\bin
!ifdef GCC
File "/oname=libjpeg-62.dll" "${WLIBDIR}\libjpeg-*.dll"
!else
File "${WLIBDIR}\jpeg62.dll"
!endif
SetOutPath $INSTDIR\lib
!ifdef GCC
File "${WLIBDIR}\libturbojpeg.dll.a"
File "${WLIBDIR}\libturbojpeg.a"
File "${WLIBDIR}\libjpeg.dll.a"
File "${WLIBDIR}\libjpeg.a"
!else
File "${WLIBDIR}\turbojpeg.lib"
File "${WLIBDIR}\turbojpeg-static.lib"
File "${WLIBDIR}\jpeg.lib"
File "${WLIBDIR}\jpeg-static.lib"
!endif
SetOutPath $INSTDIR\include
File "${WHDRDIR}\jconfig.h"
File "${WSRCDIR}\jerror.h"
File "${WSRCDIR}\jmorecfg.h"
File "${WSRCDIR}\jpeglib.h"
File "${WSRCDIR}\turbojpeg.h"
SetOutPath $INSTDIR
File "${WSRCDIR}\README"
File "${WSRCDIR}\README-turbo.txt"
File "${WSRCDIR}\libjpeg.doc"
File "${WSRCDIR}\LGPL.txt"
File "${WSRCDIR}\LICENSE.txt"
WriteRegStr HKLM "SOFTWARE\${APPNAME} ${VERSION}" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${VERSION}" "DisplayName" "libjpeg-turbo SDK v${VERSION} for ${PLATFORM}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${VERSION}" "UninstallString" '"$INSTDIR\uninstall_${VERSION}.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${VERSION}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${VERSION}" "NoRepair" 1
WriteUninstaller "uninstall_${VERSION}.exe"
SectionEnd
Section "Uninstall"
!ifdef WIN64
${If} ${RunningX64}
${DisableX64FSRedirection}
${Endif}
!endif
SetShellVarContext all
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${VERSION}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME} ${VERSION}"
!ifdef GCC
Delete $INSTDIR\bin\libjpeg-62.dll
Delete $SYSDIR\libturbojpeg.dll
Delete $INSTDIR\lib\libturbojpeg.dll.a"
Delete $INSTDIR\lib\libturbojpeg.a"
Delete $INSTDIR\lib\libjpeg.dll.a"
Delete $INSTDIR\lib\libjpeg.a"
!else
Delete $INSTDIR\bin\jpeg62.dll
Delete $SYSDIR\turbojpeg.dll
Delete $INSTDIR\lib\jpeg.lib
Delete $INSTDIR\lib\jpeg-static.lib
Delete $INSTDIR\lib\turbojpeg.lib
Delete $INSTDIR\lib\turbojpeg-static.lib
!endif
Delete $INSTDIR\include\jconfig.h"
Delete $INSTDIR\include\jerror.h"
Delete $INSTDIR\include\jmorecfg.h"
Delete $INSTDIR\include\jpeglib.h"
Delete $INSTDIR\include\turbojpeg.h"
Delete $INSTDIR\uninstall_${VERSION}.exe
Delete $INSTDIR\README
Delete $INSTDIR\README-turbo.txt
Delete $INSTDIR\libjpeg.doc
Delete $INSTDIR\LGPL.txt
Delete $INSTDIR\LICENSE.txt
RMDir "$INSTDIR\include"
RMDir "$INSTDIR\lib"
RMDir "$INSTDIR\bin"
RMDir "$INSTDIR"
SectionEnd

141
release/libjpeg-turbo.nsi.in Executable file
View File

@@ -0,0 +1,141 @@
!include x64.nsh
Name "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@"
OutFile "@CMAKE_BINARY_DIR@\${BUILDDIR}@INST_NAME@.exe"
InstallDir c:\@INST_DIR@
SetCompressor bzip2
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
!ifdef WIN64
${If} ${RunningX64}
${DisableX64FSRedirection}
${Endif}
!endif
SectionIn RO
!ifdef GCC
IfFileExists $SYSDIR/libturbojpeg.dll exists 0
!else
IfFileExists $SYSDIR/turbojpeg.dll exists 0
!endif
goto notexists
exists:
!ifdef GCC
MessageBox MB_OK "An existing version of the @CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ is already installed. Please uninstall it first."
!else
MessageBox MB_OK "An existing version of the @CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ or the TurboJPEG SDK is already installed. Please uninstall it first."
!endif
quit
notexists:
SetOutPath $SYSDIR
!ifdef GCC
File "@CMAKE_BINARY_DIR@\libturbojpeg.dll"
!else
File "@CMAKE_BINARY_DIR@\${BUILDDIR}turbojpeg.dll"
!endif
SetOutPath $INSTDIR\bin
!ifdef GCC
File "/oname=libjpeg-@DLL_VERSION@.dll" "@CMAKE_BINARY_DIR@\sharedlib\libjpeg-*.dll"
!else
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpeg@DLL_VERSION@.dll"
!endif
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}cjpeg.exe"
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}djpeg.exe"
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpegtran.exe"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}jpgtest.exe"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}rdjpgcom.exe"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}wrjpgcom.exe"
SetOutPath $INSTDIR\lib
!ifdef GCC
File "@CMAKE_BINARY_DIR@\libturbojpeg.dll.a"
File "@CMAKE_BINARY_DIR@\libturbojpeg.a"
File "@CMAKE_BINARY_DIR@\sharedlib\libjpeg.dll.a"
File "@CMAKE_BINARY_DIR@\libjpeg.a"
!else
File "@CMAKE_BINARY_DIR@\${BUILDDIR}turbojpeg.lib"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}turbojpeg-static.lib"
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpeg.lib"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}jpeg-static.lib"
!endif
SetOutPath $INSTDIR\include
File "@CMAKE_BINARY_DIR@\jconfig.h"
File "@CMAKE_SOURCE_DIR@\jerror.h"
File "@CMAKE_SOURCE_DIR@\jmorecfg.h"
File "@CMAKE_SOURCE_DIR@\jpeglib.h"
File "@CMAKE_SOURCE_DIR@\turbojpeg.h"
SetOutPath $INSTDIR\doc
File "@CMAKE_SOURCE_DIR@\README"
File "@CMAKE_SOURCE_DIR@\README-turbo.txt"
File "@CMAKE_SOURCE_DIR@\libjpeg.txt"
File "@CMAKE_SOURCE_DIR@\LGPL.txt"
File "@CMAKE_SOURCE_DIR@\LICENSE.txt"
File "@CMAKE_SOURCE_DIR@\usage.txt"
WriteRegStr HKLM "SOFTWARE\@INST_DIR@ @VERSION@" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@INST_DIR@ @VERSION@" "DisplayName" "@CMAKE_PROJECT_NAME@ SDK v@VERSION@ for @INST_PLATFORM@"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@INST_DIR@ @VERSION@" "UninstallString" '"$INSTDIR\uninstall_@VERSION@.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@INST_DIR@ @VERSION@" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@INST_DIR@ @VERSION@" "NoRepair" 1
WriteUninstaller "uninstall_@VERSION@.exe"
SectionEnd
Section "Uninstall"
!ifdef WIN64
${If} ${RunningX64}
${DisableX64FSRedirection}
${Endif}
!endif
SetShellVarContext all
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@INST_DIR@ @VERSION@"
DeleteRegKey HKLM "SOFTWARE\@INST_DIR@ @VERSION@"
!ifdef GCC
Delete $INSTDIR\bin\libjpeg-@DLL_VERSION@.dll
Delete $SYSDIR\libturbojpeg.dll
Delete $INSTDIR\lib\libturbojpeg.dll.a"
Delete $INSTDIR\lib\libturbojpeg.a"
Delete $INSTDIR\lib\libjpeg.dll.a"
Delete $INSTDIR\lib\libjpeg.a"
!else
Delete $INSTDIR\bin\jpeg@DLL_VERSION@.dll
Delete $SYSDIR\turbojpeg.dll
Delete $INSTDIR\lib\jpeg.lib
Delete $INSTDIR\lib\jpeg-static.lib
Delete $INSTDIR\lib\turbojpeg.lib
Delete $INSTDIR\lib\turbojpeg-static.lib
!endif
Delete $INSTDIR\bin\cjpeg.exe
Delete $INSTDIR\bin\djpeg.exe
Delete $INSTDIR\bin\jpegtran.exe
Delete $INSTDIR\bin\jpgtest.exe
Delete $INSTDIR\bin\rdjpgcom.exe
Delete $INSTDIR\bin\wrjpgcom.exe
Delete $INSTDIR\include\jconfig.h"
Delete $INSTDIR\include\jerror.h"
Delete $INSTDIR\include\jmorecfg.h"
Delete $INSTDIR\include\jpeglib.h"
Delete $INSTDIR\include\turbojpeg.h"
Delete $INSTDIR\uninstall_@VERSION@.exe
Delete $INSTDIR\doc\README
Delete $INSTDIR\doc\README-turbo.txt
Delete $INSTDIR\doc\libjpeg.txt
Delete $INSTDIR\doc\LGPL.txt
Delete $INSTDIR\doc\LICENSE.txt
Delete $INSTDIR\doc\usage.txt
RMDir "$INSTDIR\include"
RMDir "$INSTDIR\lib"
RMDir "$INSTDIR\doc"
RMDir "$INSTDIR\bin"
RMDir "$INSTDIR"
SectionEnd

View File

@@ -5,13 +5,13 @@
%endif %endif
Summary: A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs Summary: A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs
Name: %{_name} Name: @PACKAGE_NAME@
Version: %{_version} Version: @VERSION@
Vendor: The libjpeg-turbo Project Vendor: The libjpeg-turbo Project
URL: http://libjpeg-turbo.virtualgl.org URL: http://www.libjpeg-turbo.org
Group: System Environment/Libraries Group: System Environment/Libraries
#-->Source0: http://prdownloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-%{version}.tar.gz #-->Source0: http://prdownloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-%{version}.tar.gz
Release: %{_build} Release: @BUILD@
License: wxWindows Library License, v3.1 License: wxWindows Library License, v3.1
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release} BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
Prereq: /sbin/ldconfig Prereq: /sbin/ldconfig
@@ -19,27 +19,31 @@ Provides: %{name} = %{version}-%{release}, turbojpeg = 2.00
Obsoletes: turbojpeg Obsoletes: turbojpeg
%description %description
libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors libjpeg-turbo is a derivative of libjpeg which uses SIMD instructions (MMX,
which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG SSE2, etc.) to accelerate baseline JPEG compression and decompression on x86
compression and decompression. libjpeg-turbo is generally 2-4x as fast and x86-64 systems. On such systems, libjpeg-turbo is generally 2-4x as fast
as the unmodified version of libjpeg, all else being equal. libjpeg-turbo also as the unmodified version of libjpeg, all else being equal. libjpeg-turbo also
includes a wrapper library for the TurboJPEG API used by VirtualGL and includes a wrapper library which implements the TurboJPEG API used by VirtualGL
TurboVNC. and TurboVNC.
libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
the TigerVNC and VirtualGL projects made numerous enhancements to the codec, the TigerVNC and VirtualGL projects made numerous enhancements to the codec in
including improved support for Mac OS X, 64-bit support, support for 32-bit 2009, including improved support for Mac OS X, 64-bit support, support for
and big endian pixel formats, accelerated Huffman encoding/decoding, and 32-bit and big endian pixel formats (RGBX, XBGR, etc.), accelerated Huffman
various bug fixes. The goal was to produce a fully open source codec that encoding/decoding, and various bug fixes. The goal was to produce a fully open
could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL source codec that could replace the partially closed source TurboJPEG/IPP codec
and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of used by VirtualGL and TurboVNC. libjpeg-turbo generally performs in the range
TurboJPEG/IPP. It is faster in some areas but slower in others. of 80-120% of TurboJPEG/IPP. It is faster in some areas but slower in others.
In early 2010, libjpeg-turbo spun off into its own independent project, with
the goal of making high-speed JPEG compression/decompression technology
available to a broader range of users and developers.
#-->%prep #-->%prep
#-->%setup -q #-->%setup -q
#-->%build #-->%build
#-->configure libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man --with-pic #-->./configure libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man JPEG_LIB_VERSION=@JPEG_LIB_VERSION@ SO_MAJOR_VERSION=@SO_MAJOR_VERSION@ SO_MINOR_VERSION=@SO_MINOR_VERSION@ --with-pic
#-->make DESTDIR=$RPM_BUILD_ROOT libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man #-->make DESTDIR=$RPM_BUILD_ROOT libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man
%install %install
@@ -55,10 +59,6 @@ mkdir -p $RPM_BUILD_ROOT/usr/include
mv $RPM_BUILD_ROOT/opt/%{name}/include/turbojpeg.h $RPM_BUILD_ROOT/usr/include mv $RPM_BUILD_ROOT/opt/%{name}/include/turbojpeg.h $RPM_BUILD_ROOT/usr/include
ln -fs /usr/include/turbojpeg.h $RPM_BUILD_ROOT/opt/%{name}/include/ ln -fs /usr/include/turbojpeg.h $RPM_BUILD_ROOT/opt/%{name}/include/
ln -fs /usr/%{__lib}/libturbojpeg.a $RPM_BUILD_ROOT/opt/%{name}/%{__lib}/ ln -fs /usr/%{__lib}/libturbojpeg.a $RPM_BUILD_ROOT/opt/%{name}/%{__lib}/
%ifarch x86_64
%else
ln -fs %{__lib} $RPM_BUILD_ROOT/opt/%{name}/lib32
%endif
%post -p /sbin/ldconfig %post -p /sbin/ldconfig
@@ -69,12 +69,13 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc %{_srcdir}/README-turbo.txt %{_srcdir}/README %{_srcdir}/libjpeg.doc %{_srcdir}/usage.doc %{_srcdir}/LICENSE.txt %{_srcdir}/LGPL.txt %doc %{_srcdir}/README-turbo.txt %{_srcdir}/README %{_srcdir}/libjpeg.txt %{_srcdir}/usage.txt %{_srcdir}/LICENSE.txt %{_srcdir}/LGPL.txt
%dir /opt/%{name} %dir /opt/%{name}
%dir /opt/%{name}/bin %dir /opt/%{name}/bin
/opt/%{name}/bin/cjpeg /opt/%{name}/bin/cjpeg
/opt/%{name}/bin/djpeg /opt/%{name}/bin/djpeg
/opt/%{name}/bin/jpegtran /opt/%{name}/bin/jpegtran
/opt/%{name}/bin/jpgtest
/opt/%{name}/bin/rdjpgcom /opt/%{name}/bin/rdjpgcom
/opt/%{name}/bin/wrjpgcom /opt/%{name}/bin/wrjpgcom
%dir /opt/%{name}/%{__lib} %dir /opt/%{name}/%{__lib}
@@ -82,8 +83,8 @@ rm -rf $RPM_BUILD_ROOT
%else %else
/opt/%{name}/lib32 /opt/%{name}/lib32
%endif %endif
/opt/%{name}/%{__lib}/libjpeg.so.62.0.0 /opt/%{name}/%{__lib}/libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@
/opt/%{name}/%{__lib}/libjpeg.so.62 /opt/%{name}/%{__lib}/libjpeg.so.@SO_MAJOR_VERSION@
/opt/%{name}/%{__lib}/libjpeg.so /opt/%{name}/%{__lib}/libjpeg.so
/opt/%{name}/%{__lib}/libjpeg.a /opt/%{name}/%{__lib}/libjpeg.a
/opt/%{name}/%{__lib}/libturbojpeg.a /opt/%{name}/%{__lib}/libturbojpeg.a

View File

@@ -15,16 +15,9 @@ onexit()
fi fi
} }
usage() PACKAGE_NAME=@PACKAGE_NAME@
{ VERSION=@VERSION@
echo "$0 <package name> <version> <source dir.>" SRCDIR=@abs_top_srcdir@
exit 1
}
if [ $# -lt 3 ]; then usage $0; fi
PACKAGE_NAME=$1
VERSION=$2
SRCDIR=$3
umask 022 umask 022
rm -f $PACKAGE_NAME-$VERSION-cygwin.tar.bz2 rm -f $PACKAGE_NAME-$VERSION-cygwin.tar.bz2
@@ -36,8 +29,8 @@ DOCDIR=$TMPDIR/pkg/usr/share/doc/$PACKAGE_NAME-$VERSION
mkdir -p $DOCDIR mkdir -p $DOCDIR
install -m 644 $SRCDIR/README-turbo.txt $DOCDIR install -m 644 $SRCDIR/README-turbo.txt $DOCDIR
install -m 644 $SRCDIR/README $DOCDIR install -m 644 $SRCDIR/README $DOCDIR
install -m 644 $SRCDIR/libjpeg.doc $DOCDIR install -m 644 $SRCDIR/libjpeg.txt $DOCDIR
install -m 644 $SRCDIR/usage.doc $DOCDIR install -m 644 $SRCDIR/usage.txt $DOCDIR
install -m 644 $SRCDIR/LICENSE.txt $DOCDIR install -m 644 $SRCDIR/LICENSE.txt $DOCDIR
install -m 644 $SRCDIR/LGPL.txt $DOCDIR install -m 644 $SRCDIR/LGPL.txt $DOCDIR
ln -fs lib $TMPDIR/pkg/opt/$PACKAGE_NAME/lib32 ln -fs lib $TMPDIR/pkg/opt/$PACKAGE_NAME/lib32

View File

@@ -15,12 +15,6 @@ onexit()
fi fi
} }
usage()
{
echo "$0 <package name> <version> <build> <DEB architecture> <source dir.>"
exit 1
}
makedeb() makedeb()
{ {
SUPPLEMENT=$1 SUPPLEMENT=$1
@@ -35,12 +29,10 @@ makedeb()
fi fi
umask 022 umask 022
rm -f $PACKAGE_NAME\_$DEBARCH.deb rm -f $PACKAGE_NAME\_$VERSION\_$DEBARCH.deb
TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX` TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
mkdir $TMPDIR/DEBIAN mkdir $TMPDIR/DEBIAN
(cat $SRCDIR/release/deb-control.tmpl | sed s/{__PKGNAME}/$PACKAGE_NAME/g \ cp pkgscripts/deb-control $TMPDIR/DEBIAN/control
| sed s/{__VERSION}/$VERSION/g | sed s/{__BUILD}/$BUILD/g \
| sed s/{__ARCH}/$DEBARCH/g > $TMPDIR/DEBIAN/control)
make install prefix=$TMPDIR/opt/$DIRNAME libdir=$TMPDIR/opt/$DIRNAME/$__LIB mandir=$TMPDIR/opt/$DIRNAME/man make install prefix=$TMPDIR/opt/$DIRNAME libdir=$TMPDIR/opt/$DIRNAME/$__LIB mandir=$TMPDIR/opt/$DIRNAME/man
rm -f $TMPDIR/opt/$DIRNAME/$__LIB/*.la rm -f $TMPDIR/opt/$DIRNAME/$__LIB/*.la
@@ -73,20 +65,19 @@ makedeb()
install -m 644 $SRCDIR/LGPL.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION install -m 644 $SRCDIR/LGPL.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION
install -m 644 $SRCDIR/README-turbo.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION install -m 644 $SRCDIR/README-turbo.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION
install -m 644 $SRCDIR/README $TMPDIR/usr/share/doc/$DIRNAME-$VERSION install -m 644 $SRCDIR/README $TMPDIR/usr/share/doc/$DIRNAME-$VERSION
install -m 644 $SRCDIR/libjpeg.doc $TMPDIR/usr/share/doc/$DIRNAME-$VERSION install -m 644 $SRCDIR/libjpeg.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION
install -m 644 $SRCDIR/usage.doc $TMPDIR/usr/share/doc/$DIRNAME-$VERSION install -m 644 $SRCDIR/usage.txt $TMPDIR/usr/share/doc/$DIRNAME-$VERSION
fi fi
sudo chown -Rh root:root $TMPDIR/* sudo chown -Rh root:root $TMPDIR/*
dpkg -b $TMPDIR $PACKAGE_NAME\_$DEBARCH.deb dpkg -b $TMPDIR $PACKAGE_NAME\_$VERSION\_$DEBARCH.deb
} }
if [ $# -lt 5 ]; then usage $0; fi PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_NAME=$1 VERSION=@VERSION@
VERSION=$2 BUILD=@BUILD@
BUILD=$3 DEBARCH=@DEBARCH@
DEBARCH=$4 SRCDIR=@abs_top_srcdir@
SRCDIR=$5
makedeb 0 makedeb 0
if [ "$DEBARCH" = "i386" ]; then makedeb 1; fi if [ "$DEBARCH" = "i386" ]; then makedeb 1; fi

View File

@@ -17,24 +17,27 @@ onexit()
usage() usage()
{ {
echo "$0 <package name> <version> <build> <source dir.> [universal]" echo "$0 [universal [32-bit build dir]]"
exit 1 exit 1
} }
UNIVERSAL=0 UNIVERSAL=0
if [ $# -lt 4 ]; then usage $0; fi PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_NAME=$1 VERSION=@VERSION@
VERSION=$2 BUILD=@BUILD@
BUILD=$3 SRCDIR=@abs_top_srcdir@
SRCDIR=$4 BUILDDIR32=@abs_top_srcdir@/osxx86
if [ $# -gt 4 ]; then if [ $# -gt 0 ]; then
if [ "$5" = "universal" ]; then UNIVERSAL=1; fi if [ "$1" = "universal" ]; then
UNIVERSAL=1
if [ $# -gt 1 ]; then BUILDDIR32=$2; fi
fi
fi fi
PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
if [ -f $PACKAGE_NAME.dmg ]; then if [ -f $PACKAGE_NAME-$VERSION.dmg ]; then
rm -f $PACKAGE_NAME.dmg rm -f $PACKAGE_NAME-$VERSION.dmg
fi fi
umask 022 umask 022
@@ -50,29 +53,30 @@ mkdir -p $PKGROOT/usr/include
mv $PKGROOT/opt/$PACKAGE_NAME/include/turbojpeg.h $PKGROOT/usr/include mv $PKGROOT/opt/$PACKAGE_NAME/include/turbojpeg.h $PKGROOT/usr/include
if [ $UNIVERSAL = 1 ]; then if [ $UNIVERSAL = 1 ]; then
if [ ! -d $SRCDIR/osxx86 ]; then if [ ! -d $BUILDDIR32 ]; then
mkdir -p $SRCDIR/osxx86 echo ERROR: 32-bit build directory $BUILDDIR32 does not exist
exit 1
fi
if [ ! -f $BUILDDIR32/Makefile ]; then
echo ERROR: 32-bit build directory $BUILDDIR32 is not configured
exit 1
fi fi
mkdir -p $TMPDIR/dist.x86 mkdir -p $TMPDIR/dist.x86
pushd $SRCDIR/osxx86 pushd $BUILDDIR32
sh $SRCDIR/configure --with-pic \
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -O3 -m32' \
CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -O3 -m32' \
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -m32'
make install DESTDIR=$TMPDIR/dist.x86 make install DESTDIR=$TMPDIR/dist.x86
popd popd
if [ ! -h $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib -a \ if [ ! -h $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib -a \
! -h $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib ]; then ! -h $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib ]; then
lipo -create \ lipo -create \
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib \ -arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib \
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib \ -arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib \
-output $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib -output $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib
elif [ ! -h $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.62.0.0.dylib -a \ elif [ ! -h $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@.dylib -a \
! -h $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.0.0.dylib ]; then ! -h $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@.dylib ]; then
lipo -create \ lipo -create \
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.62.0.0.dylib \ -arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@.dylib \
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.0.0.dylib \ -arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@.dylib \
-output $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.0.0.dylib -output $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@.dylib
fi fi
lipo -create \ lipo -create \
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.a \ -arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/lib/libjpeg.a \
@@ -98,6 +102,10 @@ if [ $UNIVERSAL = 1 ]; then
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/jpegtran \ -arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/jpegtran \
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/jpegtran \ -arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/jpegtran \
-output $PKGROOT/opt/$PACKAGE_NAME/bin/jpegtran -output $PKGROOT/opt/$PACKAGE_NAME/bin/jpegtran
lipo -create \
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/jpgtest \
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/jpgtest \
-output $PKGROOT/opt/$PACKAGE_NAME/bin/jpgtest
lipo -create \ lipo -create \
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/rdjpgcom \ -arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/rdjpgcom \
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/rdjpgcom \ -arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/rdjpgcom \
@@ -109,35 +117,33 @@ if [ $UNIVERSAL = 1 ]; then
fi fi
install_name_tool -id /opt/$PACKAGE_NAME/lib/libjpeg.62.dylib $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.62.dylib install_name_tool -id /opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib
install_name_tool -id libturbojpeg.dylib $PKGROOT/usr/lib/libturbojpeg.dylib install_name_tool -id libturbojpeg.dylib $PKGROOT/usr/lib/libturbojpeg.dylib
ln -fs /usr/include/turbojpeg.h $PKGROOT/opt/$PACKAGE_NAME/include/ ln -fs /usr/include/turbojpeg.h $PKGROOT/opt/$PACKAGE_NAME/include/
ln -fs /usr/lib/libturbojpeg.a $PKGROOT/opt/$PACKAGE_NAME/lib/ ln -fs /usr/lib/libturbojpeg.a $PKGROOT/opt/$PACKAGE_NAME/lib/
ln -fs lib $PKGROOT/opt/$PACKAGE_NAME/lib32 if [ ! -h $PKGROOT/opt/$PACKAGE_NAME/lib32 ]; then
ln -fs lib $PKGROOT/opt/$PACKAGE_NAME/lib64 ln -fs lib $PKGROOT/opt/$PACKAGE_NAME/lib32
fi
if [ ! -h $PKGROOT/opt/$PACKAGE_NAME/lib64 ]; then
ln -fs lib $PKGROOT/opt/$PACKAGE_NAME/lib64
fi
mkdir -p $PKGROOT/Library/Documentation/$PACKAGE_NAME mkdir -p $PKGROOT/Library/Documentation/$PACKAGE_NAME
chmod 1775 $PKGROOT/Library chmod 1775 $PKGROOT/Library
chmod 775 $PKGROOT/Library/Documentation chmod 775 $PKGROOT/Library/Documentation
mkdir -p $TMPDIR/pkg/Resources mkdir -p $TMPDIR/pkg/Resources
(cat $SRCDIR/release/Description.plist.tmpl | sed s/{__VERSION}/$VERSION/g \ cp pkgscripts/Description.plist $TMPDIR/pkg/
| sed s/{__APPNAME}/$PACKAGE_NAME/g \ cp pkgscripts/Info.plist $TMPDIR/pkg/
> $TMPDIR/pkg/Description.plist) install -m 755 pkgscripts/uninstall $PKGROOT/opt/$PACKAGE_NAME/bin/
(cat $SRCDIR/release/Info.plist.tmpl | sed s/{__VERSION}/$VERSION/g \
| sed s/{__BUILD}/$BUILD/g > $TMPDIR/pkg/Info.plist)
(cat $SRCDIR/release/uninstall.sh.tmpl \
| sed s/{__APPNAME}/$PACKAGE_NAME/g \
> $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall)
chmod 755 $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall
install -m 644 $SRCDIR/LICENSE.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/LICENSE.txt install -m 644 $SRCDIR/LICENSE.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/LICENSE.txt
install -m 644 $SRCDIR/LGPL.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/LGPL.txt install -m 644 $SRCDIR/LGPL.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/LGPL.txt
install -m 644 $SRCDIR/README-turbo.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/README-turbo.txt install -m 644 $SRCDIR/README-turbo.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/README-turbo.txt
install -m 644 $SRCDIR/README $PKGROOT/Library/Documentation/$PACKAGE_NAME/README install -m 644 $SRCDIR/README $PKGROOT/Library/Documentation/$PACKAGE_NAME/README
install -m 644 $SRCDIR/libjpeg.doc $PKGROOT/Library/Documentation/$PACKAGE_NAME/libjpeg.doc install -m 644 $SRCDIR/libjpeg.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/libjpeg.txt
install -m 644 $SRCDIR/usage.doc $PKGROOT/Library/Documentation/$PACKAGE_NAME/usage.doc install -m 644 $SRCDIR/usage.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/usage.txt
sudo chown -R root:admin $PKGROOT sudo chown -R root:admin $PKGROOT
sudo chown -R root:0 $PKGROOT/usr sudo chown -R root:0 $PKGROOT/usr
@@ -151,8 +157,7 @@ install -m 644 $SRCDIR/release/uninstall.applescript $TMPDIR
sudo osacompile -t APPL -o "$TMPDIR/dmg/Uninstall $PACKAGE_NAME.app" $TMPDIR/uninstall.applescript sudo osacompile -t APPL -o "$TMPDIR/dmg/Uninstall $PACKAGE_NAME.app" $TMPDIR/uninstall.applescript
sudo chown -R $USER "$TMPDIR/dmg/Uninstall $PACKAGE_NAME.app" sudo chown -R $USER "$TMPDIR/dmg/Uninstall $PACKAGE_NAME.app"
hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \ hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \
-srcfolder "$TMPDIR/dmg" \ -srcfolder "$TMPDIR/dmg" $TMPDIR/$PACKAGE_NAME-$VERSION.dmg
$TMPDIR/$PACKAGE_NAME.dmg cp $TMPDIR/$PACKAGE_NAME-$VERSION.dmg .
cp $TMPDIR/$PACKAGE_NAME.dmg .
exit exit

View File

@@ -1,42 +0,0 @@
#!/bin/sh
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPDIR=
onexit()
{
if [ ! "$TMPDIR" = "" ]; then
rm -rf $TMPDIR
fi
}
usage()
{
echo "$0 <package name> <version> <build> <RPM architecture> <source dir.>"
exit 1
}
if [ $# -lt 5 ]; then usage $0; fi
PACKAGE_NAME=$1
VERSION=$2
BUILD=$3
RPMARCH=$4
SRCDIR=$5
TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
mkdir -p $TMPDIR/RPMS
ln -fs `pwd` $TMPDIR/BUILD
rm -f $PACKAGE_NAME.$RPMARCH.rpm
rpmbuild -bb --define "_name $PACKAGE_NAME" \
--define "_blddir $TMPDIR/buildroot" --define "_topdir $TMPDIR" \
--define "_version $VERSION" --define "_build $BUILD" \
--define "_srcdir $SRCDIR" --target $RPMARCH \
$SRCDIR/release/libjpeg-turbo.spec
cp $TMPDIR/RPMS/$RPMARCH/$PACKAGE_NAME-$VERSION-$BUILD.$RPMARCH.rpm $PACKAGE_NAME.$RPMARCH.rpm
exit

View File

@@ -1,51 +0,0 @@
#!/bin/sh
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPDIR=
onexit()
{
if [ ! "$TMPDIR" = "" ]; then
rm -rf $TMPDIR
fi
}
usage()
{
echo "$0 <package name> <version> <build> <RPM architecture> <source dir.>"
exit 1
}
if [ $# -lt 4 ]; then usage $0; fi
PACKAGE_NAME=$1
VERSION=$2
BUILD=$3
SRCDIR=$4
TARBALL=$PACKAGE_NAME-$VERSION.tar.gz
if [ ! -f ./$TARBALL ]; then
echo ./$TARBALL does not exist. Run make dist-gzip first.
exit -1
fi
TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
mkdir -p $TMPDIR/RPMS
mkdir -p $TMPDIR/SRPMS
mkdir -p $TMPDIR/BUILD
mkdir -p $TMPDIR/SOURCES
mkdir -p $TMPDIR/SPECS
rm -f $PACKAGE_NAME.src.rpm
cp $TARBALL $TMPDIR/SOURCES
cat $SRCDIR/release/libjpeg-turbo.spec | sed s/%{_name}/$PACKAGE_NAME/g \
| sed s/%{_version}/$VERSION/g | sed s/%{_build}/$BUILD/g \
| sed s/%{_blddir}/%{_tmppath}/g | sed s@%{_srcdir}/@@g \
| sed s/#--\>//g >$TMPDIR/SPECS/libjpeg-turbo.spec
rpmbuild -bs --define "_topdir $TMPDIR" $TMPDIR/SPECS/libjpeg-turbo.spec
cp $TMPDIR/SRPMS/$PACKAGE_NAME-$VERSION-$BUILD.src.rpm $PACKAGE_NAME.src.rpm
exit

View File

@@ -17,22 +17,23 @@ onexit()
usage() usage()
{ {
echo "$0 <package name> <version> <build> <package architecture> <source dir.> [combined]" echo "$0 [combined [32-bit build dir.]]"
exit 1 exit 1
} }
COMBINED=0 COMBINED=0
if [ $# -lt 4 ]; then usage $0; fi PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_NAME=$1 VERSION=@VERSION@
VERSION=$2 BUILD=@BUILD@
BUILD=$3 PKGARCH=@DEBARCH@
PKGARCH=$4 SRCDIR=@abs_top_srcdir@
SRCDIR=$5 BUILDDIR32=@abs_top_srcdir@/solx86
CC=$6 if [ $# -gt 0 ]; then
CXX=$7 if [ "$1" = "combined" ]; then
if [ $# -gt 7 ]; then COMBINED=1
if [ "$8" = "combined" ]; then COMBINED=1; fi if [ $# -gt 1 ]; then BUILDDIR32=$2; fi
fi
fi fi
umask 022 umask 022
@@ -40,9 +41,7 @@ TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
rm -f $PACKAGE_NAME.pkg.bz2 rm -f $PACKAGE_NAME.pkg.bz2
cp $SRCDIR/release/copyright $TMPDIR cp $SRCDIR/release/copyright $TMPDIR
touch $TMPDIR/depend touch $TMPDIR/depend
cat $SRCDIR/release/pkginfo.tmpl | sed s/{__VERSION}/$VERSION/g \ cp pkgscripts/pkginfo $TMPDIR/pkginfo
| sed s/{__BUILD}/$BUILD/g | sed s/{__APPNAME}/$PACKAGE_NAME/g \
| sed s/{__PKGNAME}/$PACKAGE_NAME/g > $TMPDIR/pkginfo
if [ "$PKGARCH" = "i386" ]; then if [ "$PKGARCH" = "i386" ]; then
__LIB=lib __LIB=lib
@@ -50,21 +49,25 @@ else
__LIB=lib/$PKGARCH __LIB=lib/$PKGARCH
fi fi
# This mess is to work around a bug in /usr/ccs/bin/make
if [ $COMBINED = 1 ]; then if [ $COMBINED = 1 ]; then
if [ ! -d $SRCDIR/solx86 ]; then if [ ! -d $BUILDDIR32 ]; then
mkdir -p $SRCDIR/solx86 echo ERROR: 32-bit build directory $BUILDDIR32 does not exist
exit 1
fi
if [ ! -f $BUILDDIR32/Makefile ]; then
echo ERROR: 32-bit build directory $BUILDDIR32 is not configured
exit 1
fi fi
PWD=`pwd` PWD=`pwd`
cd $SRCDIR/solx86 cd $BUILDDIR32
sh $SRCDIR/configure --with-pic CC=$CC CXX=$CXX CFLAGS= CXXFLAGS= LDFLAGS= host_alias=
make install DESTDIR=$TMPDIR mandir=/opt/$PACKAGE_NAME/man AM_MAKEFLAGS="mandir=/opt/$PACKAGE_NAME/man" make install DESTDIR=$TMPDIR mandir=/opt/$PACKAGE_NAME/man AM_MAKEFLAGS="mandir=/opt/$PACKAGE_NAME/man"
cd $PWD cd $PWD
fi fi
# This mess is to work around a bug in /usr/ccs/bin/make
make install DESTDIR=$TMPDIR libdir=/opt/$PACKAGE_NAME/$__LIB mandir=/opt/$PACKAGE_NAME/man AM_MAKEFLAGS="libdir=/opt/$PACKAGE_NAME/$__LIB mandir=/opt/$PACKAGE_NAME/man" make install DESTDIR=$TMPDIR libdir=/opt/$PACKAGE_NAME/$__LIB mandir=/opt/$PACKAGE_NAME/man AM_MAKEFLAGS="libdir=/opt/$PACKAGE_NAME/$__LIB mandir=/opt/$PACKAGE_NAME/man"
rm -f $TMPDIR/opt/$PACKAGE_NAME/$__LIB/*.la rm -f $TMPDIR/opt/$PACKAGE_NAME/$__LIB/*.la
mkdir -p $TMPDIR/opt/$PACKAGE_NAME/doc mkdir -p $TMPDIR/opt/$PACKAGE_NAME/doc
cp $SRCDIR/LICENSE.txt $SRCDIR/LGPL.txt $SRCDIR/README-turbo.txt $SRCDIR/README $SRCDIR/libjpeg.doc $SRCDIR/usage.doc $TMPDIR/opt/$PACKAGE_NAME/doc cp $SRCDIR/LICENSE.txt $SRCDIR/LGPL.txt $SRCDIR/README-turbo.txt $SRCDIR/README $SRCDIR/libjpeg.txt $SRCDIR/usage.txt $TMPDIR/opt/$PACKAGE_NAME/doc
chmod 644 $TMPDIR/opt/$PACKAGE_NAME/doc/* chmod 644 $TMPDIR/opt/$PACKAGE_NAME/doc/*
cat >$TMPDIR/proto <<EOF cat >$TMPDIR/proto <<EOF
@@ -76,15 +79,16 @@ d none $PACKAGE_NAME/bin 0755 root bin
f none $PACKAGE_NAME/bin/cjpeg 0755 root bin f none $PACKAGE_NAME/bin/cjpeg 0755 root bin
f none $PACKAGE_NAME/bin/djpeg 0755 root bin f none $PACKAGE_NAME/bin/djpeg 0755 root bin
f none $PACKAGE_NAME/bin/jpegtran 0755 root bin f none $PACKAGE_NAME/bin/jpegtran 0755 root bin
f none $PACKAGE_NAME/bin/jpgtest 0755 root bin
f none $PACKAGE_NAME/bin/rdjpgcom 0755 root bin f none $PACKAGE_NAME/bin/rdjpgcom 0755 root bin
f none $PACKAGE_NAME/bin/wrjpgcom 0755 root bin f none $PACKAGE_NAME/bin/wrjpgcom 0755 root bin
d none $PACKAGE_NAME/lib 0755 root bin d none $PACKAGE_NAME/lib 0755 root bin
EOF EOF
if [ $COMBINED = 1 ]; then if [ $COMBINED = 1 ]; then
cat >>$TMPDIR/proto <<EOF cat >>$TMPDIR/proto <<EOF
f none $PACKAGE_NAME/lib/libjpeg.so.62.0.0 0755 root bin f none $PACKAGE_NAME/lib/libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@ 0755 root bin
s none $PACKAGE_NAME/lib/libjpeg.so.62=libjpeg.so.62.0.0 s none $PACKAGE_NAME/lib/libjpeg.so.@SO_MAJOR_VERSION@=libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@
s none $PACKAGE_NAME/lib/libjpeg.so=libjpeg.so.62.0.0 s none $PACKAGE_NAME/lib/libjpeg.so=libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@
f none $PACKAGE_NAME/lib/libjpeg.a 0644 root bin f none $PACKAGE_NAME/lib/libjpeg.a 0644 root bin
f none $PACKAGE_NAME/lib/libturbojpeg.so 0755 root bin f none $PACKAGE_NAME/lib/libturbojpeg.so 0755 root bin
f none $PACKAGE_NAME/lib/libturbojpeg.a 0644 root bin f none $PACKAGE_NAME/lib/libturbojpeg.a 0644 root bin
@@ -96,9 +100,9 @@ echo s none $PACKAGE_NAME/lib64=${__LIB} >>$TMPDIR/proto
echo s none $PACKAGE_NAME/lib/64=$PKGARCH >>$TMPDIR/proto echo s none $PACKAGE_NAME/lib/64=$PKGARCH >>$TMPDIR/proto
fi fi
cat >>$TMPDIR/proto <<EOF cat >>$TMPDIR/proto <<EOF
f none $PACKAGE_NAME/${__LIB}/libjpeg.so.62.0.0 0755 root bin f none $PACKAGE_NAME/${__LIB}/libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@ 0755 root bin
s none $PACKAGE_NAME/${__LIB}/libjpeg.so.62=libjpeg.so.62.0.0 s none $PACKAGE_NAME/${__LIB}/libjpeg.so.@SO_MAJOR_VERSION@=libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@
s none $PACKAGE_NAME/${__LIB}/libjpeg.so=libjpeg.so.62.0.0 s none $PACKAGE_NAME/${__LIB}/libjpeg.so=libjpeg.so.@SO_MAJOR_VERSION@.0.@SO_MINOR_VERSION@
f none $PACKAGE_NAME/${__LIB}/libjpeg.a 0644 root bin f none $PACKAGE_NAME/${__LIB}/libjpeg.a 0644 root bin
f none $PACKAGE_NAME/${__LIB}/libturbojpeg.so 0755 root bin f none $PACKAGE_NAME/${__LIB}/libturbojpeg.so 0755 root bin
f none $PACKAGE_NAME/${__LIB}/libturbojpeg.a 0644 root bin f none $PACKAGE_NAME/${__LIB}/libturbojpeg.a 0644 root bin
@@ -118,16 +122,16 @@ f none $PACKAGE_NAME/include/jpeglib.h 0644 root bin
f none $PACKAGE_NAME/include/turbojpeg.h 0644 root bin f none $PACKAGE_NAME/include/turbojpeg.h 0644 root bin
d none $PACKAGE_NAME/doc 0755 root bin d none $PACKAGE_NAME/doc 0755 root bin
f none $PACKAGE_NAME/doc/LGPL.txt 0644 root bin f none $PACKAGE_NAME/doc/LGPL.txt 0644 root bin
f none $PACKAGE_NAME/doc/libjpeg.doc 0644 root bin f none $PACKAGE_NAME/doc/libjpeg.txt 0644 root bin
f none $PACKAGE_NAME/doc/LICENSE.txt 0644 root bin f none $PACKAGE_NAME/doc/LICENSE.txt 0644 root bin
f none $PACKAGE_NAME/doc/README 0644 root bin f none $PACKAGE_NAME/doc/README 0644 root bin
f none $PACKAGE_NAME/doc/README-turbo.txt 0644 root bin f none $PACKAGE_NAME/doc/README-turbo.txt 0644 root bin
f none $PACKAGE_NAME/doc/usage.doc 0644 root bin f none $PACKAGE_NAME/doc/usage.txt 0644 root bin
EOF EOF
pkgmk -o -r $TMPDIR/opt -d $TMPDIR -a i386 -f $TMPDIR/proto pkgmk -o -r $TMPDIR/opt -d $TMPDIR -a i386 -f $TMPDIR/proto
pkgtrans -s $TMPDIR $TMPDIR/$PACKAGE_NAME.pkg $PACKAGE_NAME pkgtrans -s $TMPDIR $TMPDIR/$PACKAGE_NAME-$VERSION.pkg $PACKAGE_NAME
bzip2 $TMPDIR/$PACKAGE_NAME.pkg bzip2 $TMPDIR/$PACKAGE_NAME-$VERSION.pkg
cp $TMPDIR/$PACKAGE_NAME.pkg.bz2 . cp $TMPDIR/$PACKAGE_NAME-$VERSION.pkg.bz2 .
exit exit

View File

@@ -1,12 +1,12 @@
ARCH=i386 ARCH=i386
PKG={__PKGNAME} PKG=@PACKAGE_NAME@
NAME={__APPNAME} SDK and run time libraries NAME=@PACKAGE_NAME@ SDK and run time libraries
VERSION={__VERSION},REV={__BUILD} VERSION=@VERSION@,REV=@BUILD@
SUNW_PKGVERS=1.0 SUNW_PKGVERS=1.0
DESC=A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs DESC=A SIMD-accelerated JPEG codec which provides both the libjpeg and TurboJPEG APIs
VENDOR=The libjpeg-turbo Project VENDOR=The libjpeg-turbo Project
HOTLINE=http://libjpeg-turbo.VirtualGL.org HOTLINE=http://www.libjpeg-turbo.org
EMAIL=information@virtualgl.org EMAIL=information@libjpeg-turbo.org
MAXINST=1 MAXINST=1
CATEGORY=application CATEGORY=application
BASEDIR=/opt BASEDIR=/opt

View File

@@ -1,4 +1,4 @@
# Copyright (C)2009-2010 D. R. Commander # Copyright (C)2009-2011 D. R. Commander
# Copyright (C)2009 Sun Microsystems, Inc. # Copyright (C)2009 Sun Microsystems, Inc.
# #
# This library is free software and may be redistributed and/or modified under # This library is free software and may be redistributed and/or modified under
@@ -23,7 +23,7 @@ if [ ! "`id -u`" = "0" ]; then
error "This command must be run as root" error "This command must be run as root"
fi fi
PKGNAME={__APPNAME} PKGNAME=@PACKAGE_NAME@
MACPKGNAME=com.$PKGNAME.$PKGNAME MACPKGNAME=com.$PKGNAME.$PKGNAME
RCPT=/Library/Receipts/$PKGNAME.pkg RCPT=/Library/Receipts/$PKGNAME.pkg

View File

@@ -15,69 +15,6 @@
#ifndef __RRTIMER_H__ #ifndef __RRTIMER_H__
#define __RRTIMER_H__ #define __RRTIMER_H__
#ifdef __cplusplus
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif
class rrtimer
{
public:
rrtimer(void) : t1(0.0)
{
#ifdef _WIN32
highres=false; tick=0.001;
LARGE_INTEGER Frequency;
if(QueryPerformanceFrequency(&Frequency)!=0)
{
tick=(double)1.0/(double)(Frequency.QuadPart);
highres=true;
}
#endif
}
void start(void)
{
t1=time();
}
double time(void)
{
#ifdef _WIN32
if(highres)
{
LARGE_INTEGER Time;
QueryPerformanceCounter(&Time);
return((double)(Time.QuadPart)*tick);
}
else
return((double)GetTickCount()*tick);
#else
struct timeval __tv;
gettimeofday(&__tv, (struct timezone *)NULL);
return((double)(__tv.tv_sec)+(double)(__tv.tv_usec)*0.000001);
#endif
}
double elapsed(void)
{
return time()-t1;
}
private:
#ifdef _WIN32
bool highres; double tick;
#endif
double t1;
};
#endif // __cplusplus
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@@ -111,4 +48,3 @@ static __inline double rrtime(void)
#endif #endif
#endif #endif

58
sharedlib/CMakeLists.txt Executable file
View File

@@ -0,0 +1,58 @@
# Anything that must be linked against the shared C library on Windows must
# be built in this subdirectory, because CMake doesn't allow us to override
# the compiler flags for each build type except at directory scope. Note
# to CMake developers: Add a COMPILE_FLAGS_<CONFIG> target property, or
# better yet, provide a friendly way of configuring a Windows target to use the
# static C library.
if(MSVC)
# Build all configurations against shared C library
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
endif()
endforeach()
endif()
foreach(src ${JPEG_SOURCES})
set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_SOURCE_DIR}/${src})
endforeach()
if(WITH_SIMD)
# This tells CMake that the "source" files haven't been generated yet
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
endif()
add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS}
${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def)
set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION}
VERSION ${FULLVERSION})
if(MSVC)
set_target_properties(jpeg PROPERTIES SUFFIX ${DLL_VERSION}.dll)
elseif(MINGW OR CYGWIN)
set_target_properties(jpeg PROPERTIES SUFFIX -${DLL_VERSION}.dll)
endif(MSVC)
if(WITH_SIMD)
add_dependencies(jpeg simd)
endif()
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdbmp.c ../rdgif.c ../rdppm.c
../rdswitch.c ../rdtarga.c)
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
target_link_libraries(cjpeg jpeg)
add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c
../wrbmp.c ../wrgif.c ../wrppm.c ../wrtarga.c)
set_property(TARGET djpeg PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
target_link_libraries(djpeg jpeg)
add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c)
target_link_libraries(jpegtran jpeg)
install(TARGETS jpeg cjpeg djpeg jpegtran
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

58
simd/CMakeLists.txt Executable file
View File

@@ -0,0 +1,58 @@
if(NOT DEFINED NASM)
set(NASM nasm)
endif()
if(SIMD_X86_64)
set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__ -I${CMAKE_SOURCE_DIR}/win/
-I${CMAKE_CURRENT_SOURCE_DIR}/)
else()
set(NAFLAGS -fwin32 -DWIN32 -I${CMAKE_SOURCE_DIR}/win/
-I${CMAKE_CURRENT_SOURCE_DIR}/)
endif()
# This only works if building from the command line. There is currently no way
# to set a variable's value based on the build type when using the MSVC IDE.
if(CMAKE_BUILD_TYPE STREQUAL "Debug"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(NAFLAGS ${NAFLAGS} -g)
endif()
if(SIMD_X86_64)
set(SIMD_BASENAMES jfsseflt-64 jccolss2-64 jdcolss2-64 jcsamss2-64
jdsamss2-64 jdmerss2-64 jcqnts2i-64 jfss2fst-64 jfss2int-64 jiss2red-64
jiss2int-64 jiss2fst-64 jcqnts2f-64 jiss2flt-64)
message(STATUS "Building x86_64 SIMD extensions")
else()
set(SIMD_BASENAMES jsimdcpu jccolmmx jdcolmmx jcsammmx jdsammmx jdmermmx
jcqntmmx jfmmxfst jfmmxint jimmxred jimmxint jimmxfst jcqnt3dn jf3dnflt
ji3dnflt jcqntsse jfsseflt jisseflt jccolss2 jdcolss2 jcsamss2 jdsamss2
jdmerss2 jcqnts2i jfss2fst jfss2int jiss2red jiss2int jiss2fst jcqnts2f
jiss2flt)
message(STATUS "Building i386 SIMD extensions")
endif()
if(MSVC_IDE)
set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
else()
set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
foreach(file ${SIMD_BASENAMES})
set(DEPFILE "")
set(SIMD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${file}.asm)
if(${file} MATCHES col)
set(DEPFILE ${SIMD_SRC})
string(REGEX REPLACE "col" "clr" DEPFILE ${DEPFILE})
endif()
if(${file} MATCHES mer)
set(DEPFILE ${SIMD_SRC})
string(REGEX REPLACE "mer" "mrg" DEPFILE ${DEPFILE})
endif()
set(SIMD_OBJ ${OBJDIR}/${file}.obj)
add_custom_command(OUTPUT ${SIMD_OBJ} DEPENDS ${SIMD_SRC} ${DEPFILE} *.inc
COMMAND ${NASM} ${NAFLAGS} ${SIMD_SRC} -o${SIMD_OBJ})
set(SIMD_OBJS ${SIMD_OBJS} ${SIMD_OBJ})
endforeach()
set(SIMD_OBJS ${SIMD_OBJS} PARENT_SCOPE)
add_custom_target(simd DEPENDS ${SIMD_OBJS})

View File

@@ -4,7 +4,7 @@ BUILT_SOURCES = jsimdcfg.inc
EXTRA_DIST = nasm_lt.sh jcclrmmx.asm jcclrss2.asm jdclrmmx.asm jdclrss2.asm \ EXTRA_DIST = nasm_lt.sh jcclrmmx.asm jcclrss2.asm jdclrmmx.asm jdclrss2.asm \
jdmrgmmx.asm jdmrgss2.asm jcclrss2-64.asm jdclrss2-64.asm \ jdmrgmmx.asm jdmrgss2.asm jcclrss2-64.asm jdclrss2-64.asm \
jdmrgss2-64.asm jdmrgss2-64.asm CMakeLists.txt
if SIMD_X86_64 if SIMD_X86_64

View File

@@ -5,6 +5,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
*/ */

View File

@@ -6,6 +6,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
* This file contains the interface between the "normal" portions * This file contains the interface between the "normal" portions
* of the library and the SIMD implementations when running on a * of the library and the SIMD implementations when running on a

View File

@@ -6,6 +6,7 @@
* *
* Based on the x86 SIMD extension for IJG JPEG library, * Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru. * Copyright (C) 1999-2006, MIYASAKA Masaru.
* For conditions of distribution and use, see copyright notice in jsimdext.inc
* *
* This file contains the interface between the "normal" portions * This file contains the interface between the "normal" portions
* of the library and the SIMD implementations when running on a * of the library and the SIMD implementations when running on a

View File

@@ -48,9 +48,7 @@
; ;
%define SEG_TEXT .text align=16 public use64 class=CODE %define SEG_TEXT .text align=16 public use64 class=CODE
%define SEG_CONST .rdata align=16 public use64 class=CONST %define SEG_CONST .rdata align=16 public use64 class=CONST
%ifdef MSVC
%define EXTN(name) name ; foo() -> foo %define EXTN(name) name ; foo() -> foo
%endif
%elifdef OBJ32 ; ----(nasm -fobj -DOBJ32 ...)---------- %elifdef OBJ32 ; ----(nasm -fobj -DOBJ32 ...)----------
; * Borland C++ (Win32) ; * Borland C++ (Win32)

View File

@@ -1,6 +1,6 @@
IJG JPEG LIBRARY: SYSTEM ARCHITECTURE IJG JPEG LIBRARY: SYSTEM ARCHITECTURE
Copyright (C) 1991-1995, Thomas G. Lane. Copyright (C) 1991-2009, Thomas G. Lane, Guido Vollbeding.
This file is part of the Independent JPEG Group's software. This file is part of the Independent JPEG Group's software.
For conditions of distribution and use, see the accompanying README file. For conditions of distribution and use, see the accompanying README file.
@@ -12,9 +12,9 @@ convention, see the include files and comments in the source code.
We assume that the reader is already somewhat familiar with the JPEG standard. We assume that the reader is already somewhat familiar with the JPEG standard.
The README file includes references for learning about JPEG. The file The README file includes references for learning about JPEG. The file
libjpeg.doc describes the library from the viewpoint of an application libjpeg.txt describes the library from the viewpoint of an application
programmer using the library; it's best to read that file before this one. programmer using the library; it's best to read that file before this one.
Also, the file coderules.doc describes the coding style conventions we use. Also, the file coderules.txt describes the coding style conventions we use.
In this document, JPEG-specific terminology follows the JPEG standard: In this document, JPEG-specific terminology follows the JPEG standard:
A "component" means a color channel, e.g., Red or Luminance. A "component" means a color channel, e.g., Red or Luminance.
@@ -60,9 +60,6 @@ we treat 8-bit vs. 12-bit data precision as a compile-time switch, not a
run-time option, because most machines can store 8-bit pixels much more run-time option, because most machines can store 8-bit pixels much more
compactly than 12-bit. compactly than 12-bit.
For legal reasons, JPEG arithmetic coding is not currently supported, but
extending the library to include it would be straightforward.
By itself, the library handles only interchange JPEG datastreams --- in By itself, the library handles only interchange JPEG datastreams --- in
particular the widely used JFIF file format. The library can be used by particular the widely used JFIF file format. The library can be used by
surrounding code to process interchange or abbreviated JPEG datastreams that surrounding code to process interchange or abbreviated JPEG datastreams that
@@ -541,7 +538,7 @@ section needs more data.) In this way the application can avoid making
extra display passes when data is arriving faster than the display pass extra display passes when data is arriving faster than the display pass
can run. Furthermore, it is possible to abort an output pass without can run. Furthermore, it is possible to abort an output pass without
losing anything, since the coefficient buffer is read-only as far as the losing anything, since the coefficient buffer is read-only as far as the
output section is concerned. See libjpeg.doc for more detail. output section is concerned. See libjpeg.txt for more detail.
A full-image coefficient array is only created if the JPEG file has multiple A full-image coefficient array is only created if the JPEG file has multiple
scans (or if the application specifies buffered-image mode anyway). When scans (or if the application specifies buffered-image mode anyway). When
@@ -685,7 +682,7 @@ then resume compression or decompression at a later time.
This scenario is supported for simple cases. (For anything more complex, we This scenario is supported for simple cases. (For anything more complex, we
recommend that the application "bite the bullet" and develop real multitasking recommend that the application "bite the bullet" and develop real multitasking
capability.) The libjpeg.doc file goes into more detail about the usage and capability.) The libjpeg.txt file goes into more detail about the usage and
limitations of this capability; here we address the implications for library limitations of this capability; here we address the implications for library
structure. structure.
@@ -733,13 +730,14 @@ to bypass COM and APPn markers, so these can be larger than the buffer size
without causing problems; otherwise a 64K buffer would be needed in the worst without causing problems; otherwise a 64K buffer would be needed in the worst
case.) case.)
The JPEG marker writer currently does *not* cope with suspension. I feel that The JPEG marker writer currently does *not* cope with suspension.
this is not necessary; it is much easier simply to require the application to We feel that this is not necessary; it is much easier simply to require
ensure there is enough buffer space before starting. (An empty 2K buffer is the application to ensure there is enough buffer space before starting. (An
more than sufficient for the header markers; and ensuring there are a dozen or empty 2K buffer is more than sufficient for the header markers; and ensuring
two bytes available before calling jpeg_finish_compress() will suffice for the there are a dozen or two bytes available before calling jpeg_finish_compress()
trailer.) This would not work for writing multi-scan JPEG files, but will suffice for the trailer.) This would not work for writing multi-scan
we simply do not intend to support that capability with suspension. JPEG files, but we simply do not intend to support that capability with
suspension.
*** Memory manager services *** *** Memory manager services ***

BIN
testimgari.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

4
testimgari.ppm Normal file

File diff suppressed because one or more lines are too long

BIN
testimgcrop.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
testimgfst100.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

1151
transupp.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/* /*
* transupp.h * transupp.h
* *
* Copyright (C) 1997, Thomas G. Lane. * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@@ -22,32 +22,6 @@
#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
#endif #endif
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jtransform_request_workspace jTrRequest
#define jtransform_adjust_parameters jTrAdjust
#define jtransform_execute_transformation jTrExec
#define jcopy_markers_setup jCMrkSetup
#define jcopy_markers_execute jCMrkExec
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/*
* Codes for supported types of image transformations.
*/
typedef enum {
JXFORM_NONE, /* no transformation */
JXFORM_FLIP_H, /* horizontal flip */
JXFORM_FLIP_V, /* vertical flip */
JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
JXFORM_ROT_90, /* 90-degree clockwise rotation */
JXFORM_ROT_180, /* 180-degree rotation */
JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
} JXFORM_CODE;
/* /*
* Although rotating and flipping data expressed as DCT coefficients is not * Although rotating and flipping data expressed as DCT coefficients is not
* hard, there is an asymmetry in the JPEG format specification for images * hard, there is an asymmetry in the JPEG format specification for images
@@ -75,6 +49,24 @@ typedef enum {
* (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
* followed by -rot 180 -trim trims both edges.) * followed by -rot 180 -trim trims both edges.)
* *
* We also offer a lossless-crop option, which discards data outside a given
* image region but losslessly preserves what is inside. Like the rotate and
* flip transforms, lossless crop is restricted by the 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.)
*
* We also provide a lossless-resize option, which is kind of a lossless-crop
* operation in the DCT coefficient block domain - it discards higher-order
* coefficients and losslessly preserves lower-order coefficients of a
* sub-block.
*
* Rotate/flip transform, resize, and crop can be requested together in a
* single invocation. The crop is applied last --- that is, the crop region
* is specified in terms of the destination image after transform/resize.
*
* We also offer a "force to grayscale" option, which simply discards the * We also offer a "force to grayscale" option, which simply discards the
* chrominance channels of a YCbCr image. This is lossless in the sense that * chrominance channels of a YCbCr image. This is lossless in the sense that
* the luminance channel is preserved exactly. It's not the same kind of * the luminance channel is preserved exactly. It's not the same kind of
@@ -83,22 +75,91 @@ typedef enum {
* be aware of the option to know how many components to work on. * be aware of the option to know how many components to work on.
*/ */
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jtransform_parse_crop_spec jTrParCrop
#define jtransform_request_workspace jTrRequest
#define jtransform_adjust_parameters jTrAdjust
#define jtransform_execute_transform jTrExec
#define jtransform_perfect_transform jTrPerfect
#define jcopy_markers_setup jCMrkSetup
#define jcopy_markers_execute jCMrkExec
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/*
* Codes for supported types of image transformations.
*/
typedef enum {
JXFORM_NONE, /* no transformation */
JXFORM_FLIP_H, /* horizontal flip */
JXFORM_FLIP_V, /* vertical flip */
JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
JXFORM_ROT_90, /* 90-degree clockwise rotation */
JXFORM_ROT_180, /* 180-degree rotation */
JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
} JXFORM_CODE;
/*
* Codes for crop parameters, which can individually be unspecified,
* positive, or negative. (Negative width or height makes no sense, though.)
*/
typedef enum {
JCROP_UNSET,
JCROP_POS,
JCROP_NEG
} JCROP_CODE;
/*
* Transform parameters struct.
* NB: application must not change any elements of this struct after
* calling jtransform_request_workspace.
*/
typedef struct { typedef struct {
/* Options: set by caller */ /* Options: set by caller */
JXFORM_CODE transform; /* image transform operator */ JXFORM_CODE transform; /* image transform operator */
boolean perfect; /* if TRUE, fail if partial MCUs are requested */
boolean trim; /* if TRUE, trim partial MCUs as needed */ boolean trim; /* if TRUE, trim partial MCUs as needed */
boolean force_grayscale; /* if TRUE, convert color image to grayscale */ boolean force_grayscale; /* if TRUE, convert color image to grayscale */
boolean crop; /* if TRUE, crop source image */
/* Crop parameters: application need not set these unless crop is TRUE.
* These can be filled in by jtransform_parse_crop_spec().
*/
JDIMENSION crop_width; /* Width of selected region */
JCROP_CODE crop_width_set;
JDIMENSION crop_height; /* Height of selected region */
JCROP_CODE crop_height_set;
JDIMENSION crop_xoffset; /* X offset of selected region */
JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
JDIMENSION crop_yoffset; /* Y offset of selected region */
JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */
/* Internal workspace: caller should not touch these */ /* Internal workspace: caller should not touch these */
int num_components; /* # of components in workspace */ int num_components; /* # of components in workspace */
jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
JDIMENSION output_width; /* cropped destination dimensions */
JDIMENSION output_height;
JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */
JDIMENSION y_crop_offset;
int iMCU_sample_width; /* destination iMCU size */
int iMCU_sample_height;
} jpeg_transform_info; } jpeg_transform_info;
#if TRANSFORMS_SUPPORTED #if TRANSFORMS_SUPPORTED
/* Parse a crop specification (written in X11 geometry style) */
EXTERN(boolean) jtransform_parse_crop_spec
JPP((jpeg_transform_info *info, const char *spec));
/* Request any required workspace */ /* Request any required workspace */
EXTERN(void) jtransform_request_workspace EXTERN(boolean) jtransform_request_workspace
JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
/* Adjust output image parameters */ /* Adjust output image parameters */
EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
@@ -106,10 +167,24 @@ EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
jvirt_barray_ptr *src_coef_arrays, jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info)); jpeg_transform_info *info));
/* Execute the actual transformation, if any */ /* Execute the actual transformation, if any */
EXTERN(void) jtransform_execute_transformation EXTERN(void) jtransform_execute_transform
JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays, jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info)); jpeg_transform_info *info));
/* Determine whether lossless transformation is perfectly
* possible for a specified image and transformation.
*/
EXTERN(boolean) jtransform_perfect_transform
JPP((JDIMENSION image_width, JDIMENSION image_height,
int MCU_width, int MCU_height,
JXFORM_CODE transform));
/* jtransform_execute_transform used to be called
* jtransform_execute_transformation, but some compilers complain about
* routine names that long. This macro is here to avoid breaking any
* old source code that uses the original name...
*/
#define jtransform_execute_transformation jtransform_execute_transform
#endif /* TRANSFORMS_SUPPORTED */ #endif /* TRANSFORMS_SUPPORTED */

Some files were not shown because too many files have changed in this diff Show More