Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da58a91d1e | ||
|
|
0769f505bf | ||
|
|
b4a50ceefb | ||
|
|
361a637174 | ||
|
|
3484e0b160 | ||
|
|
d5a69afa5a | ||
|
|
0745c0fb6a | ||
|
|
94476c648b | ||
|
|
0cc1279e03 | ||
|
|
10e3193373 | ||
|
|
eeab6957dd | ||
|
|
5cb1b68d39 | ||
|
|
0b11d1c815 | ||
|
|
582a46a59e | ||
|
|
6e51e19b1c | ||
|
|
2ca3eb5660 | ||
|
|
404e82e070 | ||
|
|
7d9d434826 | ||
|
|
b4b31403c7 | ||
|
|
2a28599343 | ||
|
|
3e87c8b0a4 | ||
|
|
db8df01c85 | ||
|
|
240d82f8be | ||
|
|
8569c2f5a6 | ||
|
|
5d6f858235 | ||
|
|
f3281e8275 | ||
|
|
0d2d965364 | ||
|
|
16e761e59c | ||
|
|
69e15442f3 | ||
|
|
da509e32c6 | ||
|
|
23ce65d25d | ||
|
|
f38eee0739 | ||
|
|
c4ef01fc66 | ||
|
|
ab4db657db | ||
|
|
f0a5ba7542 | ||
|
|
7c1df0a430 | ||
|
|
bb4465f392 | ||
|
|
72abc29722 | ||
|
|
fc1970acef | ||
|
|
dbf80031ae | ||
|
|
8254df1a06 | ||
|
|
91e86ba6cf | ||
|
|
cfef7f1bd8 | ||
|
|
b8cc52bf1a | ||
|
|
e27124ab39 | ||
|
|
2e4d044cab | ||
|
|
daae6d966a | ||
|
|
4a1c2d9693 | ||
|
|
c4bce4857e | ||
|
|
a4efd4eec7 | ||
|
|
2d94e261ec | ||
|
|
01e6909180 |
51
BUILDING.txt
51
BUILDING.txt
@@ -91,17 +91,17 @@ This will generate the following files under .libs/
|
||||
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 v8b emulation is enabled. If using Cygwin, {version} is
|
||||
(default), v7, or v8 emulation is enabled. If using Cygwin, {version} is
|
||||
62, 7, or 8.
|
||||
|
||||
|
||||
libjpeg v7 or v8b Emulation
|
||||
---------------------------
|
||||
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 v8b. See README-turbo.txt for more information on libjpeg v7 and v8b
|
||||
libjpeg v8. See README-turbo.txt for more information on libjpeg v7 and v8
|
||||
emulation.
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ 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 v8b, but it works when emulating libjpeg
|
||||
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
|
||||
@@ -154,7 +154,7 @@ Build Recipes
|
||||
|
||||
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.
|
||||
|
||||
@@ -175,7 +175,7 @@ installed.
|
||||
|
||||
Add
|
||||
|
||||
CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS=-m32
|
||||
CFLAGS='-O3 -m32' LDFLAGS=-m32
|
||||
|
||||
to the configure command line.
|
||||
|
||||
@@ -187,8 +187,6 @@ Add
|
||||
|
||||
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
|
||||
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' \
|
||||
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
|
||||
-mmacosx-version-min=10.4'
|
||||
@@ -203,8 +201,6 @@ MacPorts, must be installed.
|
||||
Add
|
||||
|
||||
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'
|
||||
@@ -217,7 +213,7 @@ to the configure command line. The OS X 10.4 SDK must be installed.
|
||||
|
||||
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.
|
||||
|
||||
@@ -227,8 +223,8 @@ to the configure command line.
|
||||
|
||||
Add
|
||||
|
||||
--host i386-unknown-freebsd CC='gcc -B /usr/lib32' CXX='g++ -B/usr/lib32' \
|
||||
CFLAGS='-O3 -m32' CXXFLAGS='-O3 -m32' LDFLAGS='-B/usr/lib32'
|
||||
--host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
|
||||
LDFLAGS='-B/usr/lib32'
|
||||
|
||||
to the configure command line. NASM 2.07 or later from FreeBSD ports must be
|
||||
installed.
|
||||
@@ -239,15 +235,14 @@ Sun Studio
|
||||
|
||||
Add
|
||||
|
||||
CC=cc CXX=CC
|
||||
CC=cc
|
||||
|
||||
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
|
||||
|
||||
--host x86_64-pc-solaris CC=cc CXX=CC CFLAGS='-xO5 -m64' \
|
||||
CXXFLAGS='-xO5 -m64' LDFLAGS=-m64
|
||||
--host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
|
||||
|
||||
to the configure command line.
|
||||
|
||||
@@ -346,7 +341,7 @@ The following files will be generated under {build_directory}:
|
||||
Import library for TurboJPEG/OSS DLL
|
||||
|
||||
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
|
||||
v8b emulation is enabled.
|
||||
v8 emulation is enabled.
|
||||
|
||||
|
||||
Visual C++ (IDE)
|
||||
@@ -380,7 +375,7 @@ This will generate the following files under {build_directory}:
|
||||
|
||||
{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 v8b emulation is enabled.
|
||||
depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
|
||||
|
||||
|
||||
MinGW
|
||||
@@ -406,7 +401,7 @@ This will generate the following files under {build_directory}
|
||||
Import library for TurboJPEG/OSS DLL
|
||||
|
||||
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
|
||||
v8b emulation is enabled.
|
||||
v8 emulation is enabled.
|
||||
|
||||
|
||||
Debug Build
|
||||
@@ -417,13 +412,13 @@ NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
|
||||
NMake.)
|
||||
|
||||
|
||||
libjpeg v7 or v8b Emulation
|
||||
---------------------------
|
||||
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 v8b. See README-turbo.txt for more information on libjpeg v7 and v8b
|
||||
libjpeg v8. See README-turbo.txt for more information on libjpeg v7 and v8
|
||||
emulation.
|
||||
|
||||
|
||||
@@ -432,7 +427,7 @@ 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 v8b, but it works when emulating libjpeg
|
||||
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
|
||||
@@ -470,7 +465,7 @@ Build Recipes
|
||||
----------------------------
|
||||
|
||||
cd {build_directory}
|
||||
CC=/usr/bin/x86_64-w64-mingw32-gcc CXX=/usr/bin/x86_64-w64-mingw32-g++ \
|
||||
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}
|
||||
@@ -485,7 +480,7 @@ mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
|
||||
----------------------------
|
||||
|
||||
cd {build_directory}
|
||||
CC=/usr/bin/i686-w64-mingw32-gcc CXX=/usr/bin/i686-w64-mingw32-g++ \
|
||||
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}
|
||||
@@ -504,7 +499,6 @@ toolchain (which is faster than the Cygwin version):
|
||||
|
||||
cd {build_directory}
|
||||
CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \
|
||||
CXX={mingw-w64_binary_path}/x86_64-w64-mingw32-g++ \
|
||||
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 \
|
||||
@@ -517,7 +511,6 @@ MinGW Build on Linux
|
||||
|
||||
cd {build_directory}
|
||||
CC={mingw_binary_path}/i386-mingw32-gcc \
|
||||
CXX={mingw_binary_path}/i386-mingw32-g++ \
|
||||
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
|
||||
-DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
project(libjpeg-turbo)
|
||||
set(VERSION 1.0.90)
|
||||
project(libjpeg-turbo C)
|
||||
set(VERSION 1.1.0)
|
||||
|
||||
if(MINGW OR CYGWIN)
|
||||
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
|
||||
@@ -65,7 +65,7 @@ if(WITH_JPEG8)
|
||||
set(JPEG_LIB_VERSION 80)
|
||||
set(DLL_VERSION 8)
|
||||
set(FULLVERSION ${DLL_VERSION}.0.2)
|
||||
message(STATUS "Emulating libjpeg v8b API/ABI")
|
||||
message(STATUS "Emulating libjpeg v8 API/ABI")
|
||||
elseif(WITH_JPEG7)
|
||||
set(JPEG_LIB_VERSION 70)
|
||||
set(DLL_VERSION 7)
|
||||
@@ -76,9 +76,7 @@ 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
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
if(${var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
|
||||
endif()
|
||||
@@ -177,10 +175,10 @@ target_link_libraries(jpegut turbojpeg)
|
||||
add_executable(jpegut-static jpegut.c)
|
||||
target_link_libraries(jpegut-static turbojpeg-static)
|
||||
|
||||
add_executable(jpgtest jpgtest.cxx bmp.c)
|
||||
add_executable(jpgtest jpgtest.c bmp.c)
|
||||
target_link_libraries(jpgtest turbojpeg)
|
||||
|
||||
add_executable(jpgtest-static jpgtest.cxx bmp.c)
|
||||
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
|
||||
@@ -214,6 +212,8 @@ add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOUR
|
||||
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)
|
||||
@@ -257,6 +257,8 @@ add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_
|
||||
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)
|
||||
@@ -328,7 +330,7 @@ add_custom_target(installer
|
||||
DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static
|
||||
SOURCES libjpeg-turbo.nsi)
|
||||
|
||||
install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
|
||||
install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
|
||||
@@ -1,14 +1,48 @@
|
||||
Significant changes since 1.0.1
|
||||
===============================
|
||||
1.1.0
|
||||
=====
|
||||
|
||||
[1] Added emulation of the libjpeg v7 and v8b APIs and ABIs. See
|
||||
[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-chrominance 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 only.
|
||||
[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
|
||||
@@ -18,7 +52,7 @@ 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 via
|
||||
[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
|
||||
@@ -30,8 +64,8 @@ allows the caller to determine the type of subsampling used in a JPEG image.
|
||||
[10] Added further protections against invalid Huffman codes.
|
||||
|
||||
|
||||
Significant changes since 1.0.0
|
||||
===============================
|
||||
1.0.1
|
||||
=====
|
||||
|
||||
[1] The Huffman decoder will now handle erroneous Huffman codes (for instance,
|
||||
from a corrupt JPEG image.) Previously, these would cause libjpeg-turbo to
|
||||
@@ -44,8 +78,8 @@ be used instead of 4:2:0 when decompressing JPEG images using SSE2 code.
|
||||
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
|
||||
--host when configuring on a 64-bit system)
|
||||
@@ -69,18 +103,24 @@ contains just the 32-bit libjpeg-turbo libraries.
|
||||
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
|
||||
|
||||
[2] 2988188: Added support for Windows 64-bit systems
|
||||
|
||||
|
||||
Significant changes since 0.0.90
|
||||
================================
|
||||
0.0.91
|
||||
======
|
||||
|
||||
[1] Added documentation to .deb packages
|
||||
|
||||
[2] 2968313: Fixed data corruption issues when decompressing large JPEG images
|
||||
and/or using buffered I/O with the libjpeg-turbo decompressor
|
||||
|
||||
|
||||
0.0.90
|
||||
======
|
||||
|
||||
Initial release
|
||||
|
||||
19
Makefile.am
19
Makefile.am
@@ -37,14 +37,9 @@ endif
|
||||
libturbojpeg_la_SOURCES = $(libjpeg_la_SOURCES) turbojpegl.c turbojpeg.h \
|
||||
turbojpeg-mapfile
|
||||
|
||||
if ANON_VERSION_SCRIPT
|
||||
|
||||
libturbojpeg_la_LDFLAGS += $(ANON_VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile
|
||||
|
||||
endif
|
||||
|
||||
if VERSION_SCRIPT
|
||||
|
||||
libturbojpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)$(srcdir)/turbojpeg-mapfile
|
||||
libjpeg_la_LDFLAGS += $(VERSION_SCRIPT_FLAG)libjpeg.map
|
||||
|
||||
endif
|
||||
@@ -63,12 +58,12 @@ endif
|
||||
|
||||
TSTHDRS = rrutil.h rrtimer.h
|
||||
|
||||
bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom
|
||||
noinst_PROGRAMS = jpgtest jpegut
|
||||
bin_PROGRAMS = cjpeg djpeg jpegtran rdjpgcom wrjpgcom jpgtest
|
||||
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
|
||||
|
||||
@@ -113,7 +108,7 @@ DOCS= README install.txt usage.txt wizard.txt example.c libjpeg.txt \
|
||||
TESTFILES= testorig.jpg testorig.ppm testimg.bmp testimgflt.jpg \
|
||||
testimgfst.jpg testimgint.jpg testimgp.jpg testimgflt.ppm testimgfst.ppm \
|
||||
testimgint.ppm testimgflt-nosimd.jpg testimgcrop.jpg testimgari.jpg \
|
||||
testimgari.ppm
|
||||
testimgari.ppm testimgfst100.jpg
|
||||
|
||||
EXTRA_DIST = win release $(DOCS) $(TESTFILES) CMakeLists.txt \
|
||||
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in
|
||||
@@ -129,6 +124,8 @@ test: testclean all
|
||||
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
|
||||
cmp $(srcdir)/testimgflt.jpg testoutflt.jpg
|
||||
|
||||
122
README-turbo.txt
122
README-turbo.txt
@@ -2,22 +2,23 @@
|
||||
** Background
|
||||
*******************************************************************************
|
||||
|
||||
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
|
||||
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 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.
|
||||
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.
|
||||
|
||||
It was decided to split libjpeg-turbo into a separate SDK so that other
|
||||
projects could take advantage of this technology. The libjpeg-turbo shared
|
||||
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. The libjpeg-turbo shared
|
||||
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
|
||||
*******************************************************************************
|
||||
|
||||
Some of the optimizations to the Huffman encoder (jchuff.c) and decoder
|
||||
(jdhuff.c) were borrowed from VirtualGL, and thus any distribution of
|
||||
libjpeg-turbo which includes those optimizations must, as a whole, be subject
|
||||
to the terms of the wxWindows Library Licence, Version 3.1. A copy of this
|
||||
license can be found in this directory under LICENSE.txt. The wxWindows
|
||||
Library License is based on the LGPL but includes provisions which allow the
|
||||
Library to be statically linked into proprietary libraries and applications
|
||||
without requiring the resulting binaries to be distributed under the terms of
|
||||
the LGPL.
|
||||
The TurboJPEG/OSS wrapper, as well as some of the optimizations to the Huffman
|
||||
encoder (jchuff.c) and decoder (jdhuff.c), were borrowed from VirtualGL, and
|
||||
thus any distribution of libjpeg-turbo which includes those files must, as a
|
||||
whole, be subject to the terms of the wxWindows Library Licence, Version 3.1.
|
||||
A copy of this license can be found in this directory under LICENSE.txt. The
|
||||
wxWindows Library License is based on the LGPL but includes provisions which
|
||||
allow the Library to be statically linked into proprietary libraries and
|
||||
applications without requiring the resulting binaries to be distributed under
|
||||
the terms of the LGPL.
|
||||
|
||||
The rest of the source code, apart from the Huffman codec optimizations, falls
|
||||
under a less restrictive, BSD-style license (see README.) You can choose to
|
||||
distribute libjpeg-turbo, as a whole, under this BSD-style license by simply
|
||||
replacing the optimized jchuff.c and jdhuff.c with their unoptimized
|
||||
counterparts from the libjpeg v6b source.
|
||||
The rest of the source code, apart from TurboJPEG/OSS and the Huffman codec
|
||||
optimizations, falls under a less restrictive, BSD-style license (see README.)
|
||||
You can choose to distribute libjpeg-turbo, as a whole, under this BSD-style
|
||||
license by simply removing TurboJPEG/OSS and replacing the optimized jchuff.c
|
||||
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
|
||||
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:
|
||||
|
||||
[Using libjpeg]
|
||||
@@ -75,28 +76,29 @@ links to the libjpeg dynamic library located in /opt/libjpeg-turbo/{lib}. This
|
||||
will effectively accelerate every dynamically linked libjpeg application on the
|
||||
system.
|
||||
|
||||
The Windows distribution of the libjpeg-turbo SDK installs the libjpeg-turbo
|
||||
DLL (jpeg62.dll, jpeg7.dll, or jpeg8.dll, depending on whether libjpeg v6b,
|
||||
v7, or v8 emulation is enabled) into c:\libjpeg-turbo[64]\bin, and the PATH
|
||||
The libjpeg-turbo SDK for Visual C++ installs the libjpeg-turbo DLL
|
||||
(jpeg62.dll, jpeg7.dll, or jpeg8.dll, depending on whether libjpeg v6b, v7, or
|
||||
v8 emulation is enabled) into c:\libjpeg-turbo[64]\bin, and the PATH
|
||||
environment variable can be modified such that this directory is searched
|
||||
before any others that might contain a libjpeg DLL. However, if a libjpeg
|
||||
DLL exists in an application's install directory, then Windows will load this
|
||||
DLL first whenever the application is launched. Thus, if an application ships
|
||||
with jpeg62.dll, jpeg7.dll, or jpeg8.dll, then back up the application's
|
||||
version of this DLL and copy c:\libjpeg-turbo\bin\jpeg*.dll into the
|
||||
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 the libjpeg-turbo DLL distributed with the "official"
|
||||
libjpeg-turbo SDK requires the Visual C++ 2008 C run time DLL (msvcr90.dll).
|
||||
The version of the libjpeg-turbo DLL distributed in the libjpeg-turbo SDK for
|
||||
Visual C++ requires the Visual C++ 2008 C run time DLL (msvcr90.dll).
|
||||
msvcr90.dll ships with more recent versions of Windows, but users of older
|
||||
Windows releases can obtain it from the Visual C++ 2008 Redistributable
|
||||
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
|
||||
as a file handle, from an application to libjpeg will probably not work with
|
||||
the "official" version of the libjpeg-turbo DLL unless the application is also
|
||||
built to use the Visual C++ 2008 C run time DLL. In particular, this affects
|
||||
jpeg_stdio_dest() and jpeg_stdio_src().
|
||||
the version of the libjpeg-turbo DLL distributed in the libjpeg-turbo SDK for
|
||||
Visual C++, unless the application is also built to use the Visual C++ 2008 C
|
||||
run time DLL. In particular, this affects jpeg_stdio_dest() and
|
||||
jpeg_stdio_src().
|
||||
|
||||
Mac applications typically embed their own copies of the libjpeg dylib inside
|
||||
the (hidden) application bundle, so it is not possible to globally replace
|
||||
@@ -117,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
|
||||
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
|
||||
to make existing releases of VirtualGL 2.1.x and TurboVNC use the new codec at
|
||||
run time. Note that the 64-bit libjpeg-turbo packages contain only 64-bit
|
||||
to make existing releases of VirtualGL 2.1.x and TurboVNC 0.x use the new codec
|
||||
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
|
||||
32-bit binaries. Thus, to replace a TurboJPEG/IPP 64-bit package, install
|
||||
both the 64-bit and 32-bit versions of libjpeg-turbo.
|
||||
@@ -152,11 +154,11 @@ If using MinGW, then set
|
||||
|
||||
Building against libjpeg-turbo is useful, for instance, if you want to build an
|
||||
application that leverages the libjpeg-turbo colorspace extensions (see below.)
|
||||
On Linux and Solaris systems, you would still need to manipulate the
|
||||
LD_LIBRARY_PATH or sym links appropriately to use libjpeg-turbo at run time.
|
||||
On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker to
|
||||
force the use of libjpeg-turbo at run time rather than libjpeg (also useful if
|
||||
you want to leverage the colorspace extensions), or you can link against the
|
||||
On Linux and Solaris systems, you would still need to manipulate
|
||||
LD_LIBRARY_PATH or create appropriate sym links to use libjpeg-turbo at run
|
||||
time. On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker
|
||||
to force the use of libjpeg-turbo at run time rather than libjpeg (also useful
|
||||
if you want to leverage the colorspace extensions), or you can link against the
|
||||
libjpeg-turbo static library.
|
||||
|
||||
To force a Linux, Solaris, or MinGW application to link against the static
|
||||
@@ -168,8 +170,8 @@ On OS X, simply add /opt/libjpeg-turbo/lib/libjpeg.a to the linker command
|
||||
line (this also works on Linux and Solaris.)
|
||||
|
||||
To build Visual C++ applications using libjpeg-turbo, add
|
||||
c:\libjpeg-turbo[64]\include to your system or user INCLUDE environment
|
||||
variable and c:\libjpeg-turbo[64]\lib to your system or user LIB environment
|
||||
c:\libjpeg-turbo[64]\include to the system or user INCLUDE 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 the DLL version of
|
||||
libjpeg-turbo) or jpeg-static.lib (to use the static version of libjpeg-turbo.)
|
||||
|
||||
@@ -227,7 +229,7 @@ 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 v8b API/ABI, so that programs
|
||||
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.
|
||||
@@ -272,3 +274,31 @@ Not supported:
|
||||
|
||||
-- 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
3
bmp.h
@@ -1,5 +1,6 @@
|
||||
/* Copyright (C)2004 Landmark Graphics Corporation
|
||||
* 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
|
||||
* the terms of the wxWindows Library License, Version 3.1 or (at your option)
|
||||
@@ -19,7 +20,7 @@
|
||||
#define __BMP_H__
|
||||
|
||||
#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
|
||||
extern "C" {
|
||||
|
||||
39
configure.ac
39
configure.ac
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.56])
|
||||
AC_INIT([libjpeg-turbo], [1.0.90])
|
||||
AC_INIT([libjpeg-turbo], [1.1.0])
|
||||
BUILD=`date +%Y%m%d`
|
||||
|
||||
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.
|
||||
SAVED_CFLAGS=${CFLAGS}
|
||||
SAVED_CXXFLAGS=${CXXFLAGS}
|
||||
SAVED_CPPFLAGS=${CPPFLAGS}
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_LN_S
|
||||
@@ -32,8 +31,8 @@ if test "x${GCC}" = "xyes"; then
|
||||
if test "x${SAVED_CFLAGS}" = "x"; then
|
||||
CFLAGS=-O3
|
||||
fi
|
||||
if test "x${SAVED_CXXFLAGS}" = "x"; then
|
||||
CXXFLAGS=-O3
|
||||
if test "x${SAVED_CPPFLAGS}" = "x"; then
|
||||
CPPFLAGS=-Wall
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -42,9 +41,6 @@ if test "x${SUNCC}" = "xyes"; then
|
||||
if test "x${SAVED_CFLAGS}" = "x"; then
|
||||
CFLAGS=-xO5
|
||||
fi
|
||||
if test "x${SAVED_CXXFLAGS}" = "x"; then
|
||||
CXXFLAGS=-xO5
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checks for libraries.
|
||||
@@ -116,7 +112,7 @@ if test "x$JPEG_LIB_VERSION" = "x"; then
|
||||
AC_ARG_WITH([jpeg7],
|
||||
AC_HELP_STRING([--with-jpeg7], [Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
|
||||
AC_ARG_WITH([jpeg8],
|
||||
AC_HELP_STRING([--with-jpeg8], [Emulate libjpeg v8b API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b.)]))
|
||||
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
|
||||
@@ -176,36 +172,13 @@ if test "x$VERSION_SCRIPT_FLAG" = "x"; then
|
||||
VERSION_SCRIPT=no
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
ANON_VERSION_SCRIPT=yes
|
||||
AC_MSG_CHECKING([whether the linker supports anonymous version scripts])
|
||||
LDFLAGS="$SAVED_LDFLAGS -Wl,--version-script,conftest.map"
|
||||
cat > conftest.map <<EOF
|
||||
{
|
||||
global: main;
|
||||
local: *;
|
||||
};
|
||||
EOF
|
||||
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
|
||||
[ANON_VERSION_SCRIPT_FLAG=-Wl,--version-script,; AC_MSG_RESULT([yes (GNU style)])], [])
|
||||
if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
|
||||
LDFLAGS="$SAVED_LDFLAGS -Wl,-M,conftest.map"
|
||||
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []),
|
||||
[ANON_VERSION_SCRIPT_FLAG=-Wl,-M,; AC_MSG_RESULT([yes (Sun style)])], [])
|
||||
fi
|
||||
if test "x$ANON_VERSION_SCRIPT_FLAG" = "x"; then
|
||||
ANON_VERSION_SCRIPT=no
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
LDFLAGS="$SAVED_LDFLAGS"
|
||||
|
||||
AC_MSG_CHECKING([whether to use version script when building libjpeg])
|
||||
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")
|
||||
AM_CONDITIONAL(ANON_VERSION_SCRIPT, test "x$ANON_VERSION_SCRIPT" = "xyes")
|
||||
AC_SUBST(VERSION_SCRIPT_FLAG)
|
||||
AC_SUBST(ANON_VERSION_SCRIPT_FLAG)
|
||||
|
||||
AC_MSG_CHECKING([whether to include arithmetic encoding support])
|
||||
AC_ARG_WITH([arith-enc],
|
||||
|
||||
@@ -122,7 +122,7 @@ static const unsigned char green_lut[256] = {
|
||||
113, 113, 114, 114, 115, 116, 116, 117, 117, 118, 119, 119,
|
||||
120, 120, 121, 122, 122, 123, 123, 124, 124, 125, 126, 126,
|
||||
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,
|
||||
148, 149, 149, 150
|
||||
};
|
||||
@@ -258,14 +258,12 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
#if BITS_IN_JSAMPLE != 8
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
#endif
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPLE *maxoutptr;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
int rindex = rgb_red[cinfo->in_color_space];
|
||||
int gindex = rgb_green[cinfo->in_color_space];
|
||||
|
||||
18
jcdctmgr.c
18
jcdctmgr.c
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* 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.
|
||||
* 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,
|
||||
FAST_FLOAT * workspace));
|
||||
|
||||
METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
|
||||
|
||||
typedef struct {
|
||||
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
|
||||
* routines.
|
||||
*/
|
||||
LOCAL(void)
|
||||
LOCAL(int)
|
||||
compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
|
||||
{
|
||||
UDCTELEM2 fq, fr;
|
||||
@@ -189,6 +192,9 @@ compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
|
||||
dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */
|
||||
dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */
|
||||
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];
|
||||
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;
|
||||
#endif
|
||||
@@ -266,10 +274,12 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
||||
}
|
||||
dtbl = fdct->divisors[qtblno];
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
compute_reciprocal(
|
||||
if(!compute_reciprocal(
|
||||
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
|
||||
(INT32) aanscales[i]),
|
||||
CONST_BITS-3), &dtbl[i]);
|
||||
CONST_BITS-3), &dtbl[i])
|
||||
&& fdct->quantize == jsimd_quantize)
|
||||
fdct->quantize = quantize;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -223,7 +223,6 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
JSAMPLE *maxinptr;
|
||||
register JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
int rindex = rgb_red[cinfo->out_color_space];
|
||||
int gindex = rgb_green[cinfo->out_color_space];
|
||||
|
||||
102
jpegut.c
102
jpegut.c
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C)2004 Landmark Graphics Corporation
|
||||
* Copyright (C)2005 Sun Microsystems, Inc.
|
||||
* Copyright (C)2009-2010 D. R. Commander
|
||||
* 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)
|
||||
@@ -107,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,
|
||||
j;
|
||||
printf("\n");
|
||||
for(i=0; i<h; i++)
|
||||
{
|
||||
for(j=0; j<w; j++)
|
||||
{
|
||||
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");
|
||||
}
|
||||
@@ -225,8 +226,7 @@ int checkbuf(unsigned char *buf, int w, int h, int ps, int subsamp, int flags)
|
||||
|
||||
#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
|
||||
|
||||
int checkbufyuv(unsigned char *buf, unsigned long size, int w, int h,
|
||||
int subsamp)
|
||||
int checkbufyuv(unsigned char *buf, int w, int h, int subsamp)
|
||||
{
|
||||
int i, j;
|
||||
int hsf=_hsf[subsamp], vsf=_vsf[subsamp];
|
||||
@@ -234,13 +234,6 @@ int checkbufyuv(unsigned char *buf, unsigned long size, int w, int h,
|
||||
int cw=pw/hsf, ch=ph/vsf;
|
||||
int ypitch=PAD(pw, 4), uvpitch=PAD(cw, 4);
|
||||
int retval=1;
|
||||
unsigned long correctsize=ypitch*ph + (subsamp==TJ_GRAYSCALE? 0:uvpitch*ch*2);
|
||||
|
||||
if(size!=correctsize)
|
||||
{
|
||||
printf("\nIncorrect size %lu. Should be %lu\n", size, correctsize);
|
||||
retval=0; goto bailout;
|
||||
}
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
@@ -349,17 +342,15 @@ void gentestjpeg(tjhandle hnd, unsigned char *jpegbuf, unsigned long *size,
|
||||
char tempstr[1024]; unsigned char *bmpbuf=NULL;
|
||||
const char *pixformat; double t;
|
||||
|
||||
if(yuv==YUVENCODE) flags|=TJ_YUV;
|
||||
|
||||
if(flags&TJ_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
|
||||
{
|
||||
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";}
|
||||
}
|
||||
if(ps==1) pixformat="Grayscale";
|
||||
if(yuv==YUVENCODE)
|
||||
@@ -374,10 +365,20 @@ void gentestjpeg(tjhandle hnd, unsigned char *jpegbuf, unsigned long *size,
|
||||
printf("ERROR: Could not allocate buffer\n"); bailout();
|
||||
}
|
||||
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();
|
||||
_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;
|
||||
|
||||
if(yuv==YUVENCODE)
|
||||
@@ -389,8 +390,8 @@ void gentestjpeg(tjhandle hnd, unsigned char *jpegbuf, unsigned long *size,
|
||||
writejpeg(jpegbuf, *size, tempstr);
|
||||
if(yuv==YUVENCODE)
|
||||
{
|
||||
if(checkbufyuv(jpegbuf, *size, w, h, subsamp)) printf("Passed.");
|
||||
else printf("FAILED!");
|
||||
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);
|
||||
@@ -405,23 +406,18 @@ void gentestbmp(tjhandle hnd, unsigned char *jpegbuf, unsigned long jpegsize,
|
||||
unsigned char *bmpbuf=NULL;
|
||||
const char *pixformat; int _w=0, _h=0; double t;
|
||||
unsigned long size=0;
|
||||
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);
|
||||
|
||||
if(yuv==YUVDECODE) flags|=TJ_YUV;
|
||||
else if(yuv==YUVENCODE) return;
|
||||
if(yuv==YUVENCODE) return;
|
||||
|
||||
if(flags&TJ_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
|
||||
{
|
||||
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";}
|
||||
}
|
||||
if(ps==1) pixformat="Grayscale";
|
||||
if(yuv==YUVDECODE)
|
||||
@@ -436,30 +432,39 @@ void gentestbmp(tjhandle hnd, unsigned char *jpegbuf, unsigned long jpegsize,
|
||||
printf("Incorrect JPEG header\n"); bailout();
|
||||
}
|
||||
|
||||
if(yuv==YUVDECODE)
|
||||
size=ypitch*ph + (subsamp==TJ_GRAYSCALE? 0:uvpitch*ch*2);
|
||||
else
|
||||
size=w*h*ps;
|
||||
if((bmpbuf=(unsigned char *)malloc(size+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();
|
||||
}
|
||||
memset(bmpbuf, 0, size+1);
|
||||
memset(bmpbuf, 0, size);
|
||||
|
||||
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;
|
||||
|
||||
if(yuv==YUVDECODE)
|
||||
{
|
||||
if(checkbufyuv(bmpbuf, size, pw, ph, subsamp))
|
||||
printf("Passed.");
|
||||
else printf("FAILED!");
|
||||
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!"); dumpbuf(bmpbuf, w, h, ps, flags);}
|
||||
else
|
||||
{
|
||||
printf("FAILED!"); exitstatus=-1;
|
||||
dumpbuf(bmpbuf, w, h, ps, flags);
|
||||
}
|
||||
}
|
||||
printf(" %f ms\n\n", t*1000.);
|
||||
|
||||
@@ -472,7 +477,8 @@ void dotest(int w, int h, int ps, int subsamp, char *basefilename)
|
||||
tjhandle hnd=NULL, dhnd=NULL; unsigned char *jpegbuf=NULL;
|
||||
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();
|
||||
}
|
||||
@@ -542,9 +548,9 @@ void dotest1(void)
|
||||
{
|
||||
bmpbuf[i2*4]=pixels[i2%9][2];
|
||||
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));
|
||||
free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL;
|
||||
|
||||
@@ -553,12 +559,12 @@ void dotest1(void)
|
||||
{
|
||||
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;
|
||||
else bmpbuf[i2]=0;
|
||||
if(i2%2==0) bmpbuf[i2*4]=bmpbuf[i2*4+1]=bmpbuf[i2*4+2]=0xFF;
|
||||
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));
|
||||
free(bmpbuf); bmpbuf=NULL; free(jpgbuf); jpgbuf=NULL;
|
||||
}
|
||||
@@ -593,6 +599,12 @@ int main(int argc, char *argv[])
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C)2004 Landmark Graphics Corporation
|
||||
* Copyright (C)2005, 2006 Sun Microsystems, Inc.
|
||||
* Copyright (C)2009-2010 D. R. Commander
|
||||
* 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)
|
||||
@@ -40,11 +40,9 @@ const int _flags[BMPPIXELFORMATS]={0, 0, TJ_BGR, TJ_BGR,
|
||||
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 *_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"};
|
||||
const int _hsf[NUMSUBOPT]={1, 2, 2, 1};
|
||||
const int _vsf[NUMSUBOPT]={1, 1, 2, 1};
|
||||
|
||||
void printsigfig(double val, int figs)
|
||||
{
|
||||
@@ -64,43 +62,39 @@ void printsigfig(double val, int figs)
|
||||
printf(format, val);
|
||||
}
|
||||
|
||||
void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
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;
|
||||
FILE *outfile=NULL; tjhandle hnd=NULL;
|
||||
unsigned char **jpegbuf=NULL, *rgbbuf=NULL;
|
||||
rrtimer timer; double elapsed;
|
||||
int jpgbufsize=0, i, j, tilesizex, tilesizey, numtilesx, numtilesy, ITER;
|
||||
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];
|
||||
int pitch=w*ps, yuvsize;
|
||||
int hsf=_hsf[jpegsub], vsf=_vsf[jpegsub];
|
||||
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 ps=_ps[pf], tilen;
|
||||
int pitch=w*ps, yuvsize=0;
|
||||
|
||||
flags |= _flags[pf];
|
||||
if(bu) flags |= TJ_BOTTOMUP;
|
||||
if(yuv==YUVENCODE) flags |= TJ_YUV;
|
||||
|
||||
yuvsize=ypitch*ph + (jpegsub==TJ_GRAYSCALE? 0:uvpitch*ch*2);
|
||||
if((rgbbuf=(unsigned char *)malloc(max(yuvsize, pitch*h))) == NULL)
|
||||
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("\n>>>>> %s (%s) <--> YUV %s <<<<<\n", _pfname[pf],
|
||||
printf(">>>>> %s (%s) <--> YUV %s <<<<<\n", _pfname[pf],
|
||||
bu?"Bottom-up":"Top-down", _subnamel[jpegsub]);
|
||||
else
|
||||
printf("\n>>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", _pfname[pf],
|
||||
printf(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", _pfname[pf],
|
||||
bu?"Bottom-up":"Top-down", _subnamel[jpegsub], qual);
|
||||
}
|
||||
if(yuv==YUVDECODE) dotile=0;
|
||||
if(yuv) dotile=0;
|
||||
if(dotile) {tilesizex=tilesizey=4;} else {tilesizex=w; tilesizey=h;}
|
||||
|
||||
do
|
||||
@@ -115,30 +109,46 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
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)
|
||||
if((jpegbuf[i]=(unsigned char *)malloc(
|
||||
yuv==YUVENCODE? TJBUFSIZEYUV(tilesizex, tilesizey, jpegsub)
|
||||
: TJBUFSIZE(tilesizex, tilesizey))) == NULL)
|
||||
_throwunix("allocating image buffers");
|
||||
}
|
||||
|
||||
// Compression test
|
||||
if(quiet) printf("%s\t%s\t%s\t%d\t", _pfname[pf], bu?"BU":"TD",
|
||||
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(tjCompress(hnd, rgbbuf, tilesizex, pitch, tilesizey, ps,
|
||||
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;
|
||||
timer.start();
|
||||
start=rrtime();
|
||||
do
|
||||
{
|
||||
jpgbufsize=0; int tilen=0;
|
||||
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(tjCompress(hnd, &rgbbuf[pitch*i+j*ps], tempw, pitch,
|
||||
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()");
|
||||
@@ -147,17 +157,20 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
}
|
||||
}
|
||||
ITER++;
|
||||
} while((elapsed=timer.elapsed())<5.);
|
||||
} while((elapsed=rrtime()-start)<5.);
|
||||
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
|
||||
hnd=NULL;
|
||||
if(quiet)
|
||||
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("\t");
|
||||
printf("%c", quiet==2? '\n':'\t');
|
||||
printsigfig((double)(w*h*ps)/(double)jpgbufsize, 4);
|
||||
printf("\t");
|
||||
printf("%c", quiet==2? '\n':'\t');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,18 +198,25 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
fclose(outfile); outfile=NULL;
|
||||
if(!quiet) printf("Reference image written to %s\n", tempstr);
|
||||
}
|
||||
if(yuv==YUVENCODE) goto bailout;
|
||||
if(yuv==YUVENCODE)
|
||||
{
|
||||
if(quiet==1) printf("\n"); goto bailout;
|
||||
}
|
||||
|
||||
// Decompression test
|
||||
if(yuv==YUVDECODE) flags |= TJ_YUV;
|
||||
memset(rgbbuf, 127, max(yuvsize, pitch*h)); // Grey image means decompressor did nothing
|
||||
if((hnd=tjInitDecompress())==NULL)
|
||||
_throwtj("executing tjInitDecompress()");
|
||||
if(tjDecompress(hnd, jpegbuf[0], jpgbufsize, rgbbuf, tilesizex, pitch,
|
||||
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;
|
||||
timer.start();
|
||||
start=rrtime();
|
||||
do
|
||||
{
|
||||
int tilen=0;
|
||||
@@ -205,14 +225,20 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
for(j=0; j<w; j+=tilesizex)
|
||||
{
|
||||
int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
|
||||
if(tjDecompress(hnd, jpegbuf[tilen], comptilesize[tilen],
|
||||
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=timer.elapsed())<5.);
|
||||
} while((elapsed=rrtime()-start)<5.);
|
||||
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
|
||||
hnd=NULL;
|
||||
if(quiet)
|
||||
@@ -301,13 +327,13 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu,
|
||||
}
|
||||
|
||||
|
||||
void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
|
||||
void dodecomptest(char *filename, int pf, int bu, int useppm,
|
||||
int quiet)
|
||||
{
|
||||
char tempstr[1024];
|
||||
FILE *file=NULL; tjhandle hnd;
|
||||
FILE *file=NULL; tjhandle hnd=NULL;
|
||||
unsigned char *jpegbuf=NULL, *rgbbuf=NULL;
|
||||
rrtimer timer; double elapsed;
|
||||
double start, elapsed;
|
||||
int w, h, ITER;
|
||||
unsigned long jpgbufsize=0;
|
||||
int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0)
|
||||
@@ -315,11 +341,10 @@ void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
|
||||
|(fastupsample?TJ_FASTUPSAMPLE:0);
|
||||
int ps=_ps[pf], pitch, jpegsub=-1;
|
||||
char *temp=NULL;
|
||||
int hsf, vsf, pw, ph, cw, ch, ypitch, uvpitch, yuvsize;
|
||||
int yuvsize, bufsize;
|
||||
|
||||
flags |= _flags[pf];
|
||||
if(bu) flags |= TJ_BOTTOMUP;
|
||||
if(yuv==YUVDECODE) flags |= TJ_YUV;
|
||||
|
||||
if((file=fopen(filename, "rb"))==NULL)
|
||||
_throwunix("opening file");
|
||||
@@ -340,15 +365,11 @@ void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
|
||||
if(tjDecompressHeader2(hnd, jpegbuf, jpgbufsize, &w, &h, &jpegsub)==-1)
|
||||
_throwtj("executing tjDecompressHeader2()");
|
||||
|
||||
hsf=_hsf[jpegsub], vsf=_vsf[jpegsub];
|
||||
pw=PAD(w, hsf), ph=PAD(h, vsf);
|
||||
cw=pw/hsf, ch=ph/vsf;
|
||||
ypitch=PAD(pw, 4), uvpitch=PAD(cw, 4);
|
||||
yuvsize=ypitch*ph + (jpegsub==TJ_GRAYSCALE? 0:uvpitch*ch*2);
|
||||
yuvsize=TJBUFSIZEYUV(w, h, jpegsub);
|
||||
|
||||
pitch=w*ps;
|
||||
|
||||
if(quiet)
|
||||
if(quiet==1)
|
||||
{
|
||||
printf("All performance values in Mpixels/sec\n\n");
|
||||
printf("Bitmap\tBitmap\tImage Size\tDecomp\n"),
|
||||
@@ -356,31 +377,43 @@ void dodecomptest(char *filename, BMPPIXELFORMAT pf, int bu, int useppm,
|
||||
printf("%s\t%s\t%-4d %-4d\t", _pfname[pf], bu?"BU":"TD", w, h);
|
||||
}
|
||||
|
||||
if((rgbbuf=(unsigned char *)malloc(max(yuvsize, pitch*h)))==NULL)
|
||||
bufsize=(yuv==YUVDECODE? yuvsize:pitch*h);
|
||||
if((rgbbuf=(unsigned char *)malloc(bufsize))==NULL)
|
||||
_throwunix("allocating image buffer");
|
||||
|
||||
if(!quiet)
|
||||
{
|
||||
if(yuv==YUVDECODE)
|
||||
printf("\n>>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]);
|
||||
printf(">>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]);
|
||||
else
|
||||
printf("\n>>>>> JPEG --> %s (%s) <<<<<\n", _pfname[pf],
|
||||
printf(">>>>> JPEG --> %s (%s) <<<<<\n", _pfname[pf],
|
||||
bu?"Bottom-up":"Top-down");
|
||||
printf("\nImage size: %d x %d\n", w, h);
|
||||
}
|
||||
|
||||
memset(rgbbuf, 127, max(yuvsize, pitch*h)); // Grey image means decompressor did nothing
|
||||
if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags)==-1)
|
||||
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;
|
||||
timer.start();
|
||||
start=rrtime();
|
||||
do
|
||||
{
|
||||
if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags)
|
||||
==-1)
|
||||
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=timer.elapsed())<5.);
|
||||
} while((elapsed=rrtime()-start)<5.);
|
||||
if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
|
||||
hnd=NULL;
|
||||
if(quiet)
|
||||
@@ -427,8 +460,8 @@ void usage(char *progname)
|
||||
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(" 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");
|
||||
@@ -448,12 +481,10 @@ void usage(char *progname)
|
||||
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 qual=-1, dotile=0, quiet=0, hiqual=-1; char *temp;
|
||||
int pf=BMP_BGR;
|
||||
int bu=0, minarg=2;
|
||||
|
||||
printf("\n");
|
||||
|
||||
if(argc<minarg) usage(argv[0]);
|
||||
|
||||
temp=strrchr(argv[1], '.');
|
||||
@@ -463,18 +494,20 @@ int main(int argc, char *argv[])
|
||||
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");
|
||||
printf("Testing YUV planar encoding\n\n");
|
||||
yuv=YUVENCODE; hiqual=qual=100;
|
||||
}
|
||||
if(!stricmp(argv[i], "-yuvdecode"))
|
||||
{
|
||||
printf("Testing YUV planar decoding\n");
|
||||
printf("Testing YUV planar decoding\n\n");
|
||||
yuv=YUVDECODE;
|
||||
}
|
||||
}
|
||||
@@ -502,37 +535,38 @@ int main(int argc, char *argv[])
|
||||
if(!stricmp(argv[i], "-tile")) dotile=1;
|
||||
if(!stricmp(argv[i], "-forcesse3"))
|
||||
{
|
||||
printf("Using SSE3 code\n");
|
||||
printf("Using SSE3 code\n\n");
|
||||
forcesse3=1;
|
||||
}
|
||||
if(!stricmp(argv[i], "-forcesse2"))
|
||||
{
|
||||
printf("Using SSE2 code\n");
|
||||
printf("Using SSE2 code\n\n");
|
||||
forcesse2=1;
|
||||
}
|
||||
if(!stricmp(argv[i], "-forcesse"))
|
||||
{
|
||||
printf("Using SSE code\n");
|
||||
printf("Using SSE code\n\n");
|
||||
forcesse=1;
|
||||
}
|
||||
if(!stricmp(argv[i], "-forcemmx"))
|
||||
{
|
||||
printf("Using MMX code\n");
|
||||
printf("Using MMX code\n\n");
|
||||
forcemmx=1;
|
||||
}
|
||||
if(!stricmp(argv[i], "-fastupsample"))
|
||||
{
|
||||
printf("Using fast upsampling code\n");
|
||||
printf("Using fast upsampling code\n\n");
|
||||
fastupsample=1;
|
||||
}
|
||||
if(!stricmp(argv[i], "-rgb")) pf=BMP_RGB;
|
||||
if(!stricmp(argv[i], "-rgba")) pf=BMP_RGBA;
|
||||
if(!stricmp(argv[i], "-rgbx")) pf=BMP_RGBX;
|
||||
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], "-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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,7 +578,7 @@ int main(int argc, char *argv[])
|
||||
if(temp!=NULL) *temp='\0';
|
||||
}
|
||||
|
||||
if(quiet && !decomponly)
|
||||
if(quiet==1 && !decomponly)
|
||||
{
|
||||
printf("All performance values in Mpixels/sec\n\n");
|
||||
printf("Bitmap\tBitmap\tJPEG\tJPEG\tTile Size\tCompr\tCompr\tDecomp\n");
|
||||
@@ -554,19 +588,21 @@ int main(int argc, char *argv[])
|
||||
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);
|
||||
if(quiet) printf("\n");
|
||||
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");
|
||||
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");
|
||||
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);
|
||||
1
jsimd.h
1
jsimd.h
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* For conditions of distribution and use, see copyright notice in jsimdext.inc
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* For conditions of distribution and use, see copyright notice in jsimdext.inc
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
"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-2010 D. R. Commander"
|
||||
"Copyright (C) 2009-2011 D. R. Commander"
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\margl1440\margr1440\vieww15200\viewh9600\viewkind0
|
||||
\deftab720
|
||||
\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.\
|
||||
}
|
||||
@@ -5,19 +5,24 @@ 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
|
||||
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 for the TurboJPEG API used by VirtualGL and
|
||||
TurboVNC.
|
||||
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.
|
||||
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.
|
||||
|
||||
@@ -45,6 +45,12 @@ Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
|
||||
!else
|
||||
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpeg@DLL_VERSION@.dll"
|
||||
!endif
|
||||
File "@CMAKE_BINARY_DIR@\sharedlib\cjpeg.exe"
|
||||
File "@CMAKE_BINARY_DIR@\sharedlib\djpeg.exe"
|
||||
File "@CMAKE_BINARY_DIR@\sharedlib\jpegtran.exe"
|
||||
File "@CMAKE_BINARY_DIR@\jpgtest.exe"
|
||||
File "@CMAKE_BINARY_DIR@\rdjpgcom.exe"
|
||||
File "@CMAKE_BINARY_DIR@\wrjpgcom.exe"
|
||||
SetOutPath $INSTDIR\lib
|
||||
!ifdef GCC
|
||||
File "@CMAKE_BINARY_DIR@\libturbojpeg.dll.a"
|
||||
@@ -63,12 +69,13 @@ Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
|
||||
File "@CMAKE_SOURCE_DIR@\jmorecfg.h"
|
||||
File "@CMAKE_SOURCE_DIR@\jpeglib.h"
|
||||
File "@CMAKE_SOURCE_DIR@\turbojpeg.h"
|
||||
SetOutPath $INSTDIR
|
||||
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_NAME@ @VERSION@" "Install_Dir" "$INSTDIR"
|
||||
|
||||
@@ -106,20 +113,28 @@ Section "Uninstall"
|
||||
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\README
|
||||
Delete $INSTDIR\README-turbo.txt
|
||||
Delete $INSTDIR\libjpeg.txt
|
||||
Delete $INSTDIR\LGPL.txt
|
||||
Delete $INSTDIR\LICENSE.txt
|
||||
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"
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Summary: A SIMD-accelerated JPEG codec which provides both the libjpeg and Turbo
|
||||
Name: @PACKAGE_NAME@
|
||||
Version: @VERSION@
|
||||
Vendor: The libjpeg-turbo Project
|
||||
URL: http://libjpeg-turbo.virtualgl.org
|
||||
URL: http://libjpeg-turbo.VirtualGL.org
|
||||
Group: System Environment/Libraries
|
||||
#-->Source0: http://prdownloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-%{version}.tar.gz
|
||||
Release: @BUILD@
|
||||
@@ -19,21 +19,25 @@ Provides: %{name} = %{version}-%{release}, turbojpeg = 2.00
|
||||
Obsoletes: turbojpeg
|
||||
|
||||
%description
|
||||
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
|
||||
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 for the TurboJPEG API used by VirtualGL and
|
||||
TurboVNC.
|
||||
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.
|
||||
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.
|
||||
|
||||
#-->%prep
|
||||
#-->%setup -q
|
||||
@@ -71,6 +75,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/opt/%{name}/bin/cjpeg
|
||||
/opt/%{name}/bin/djpeg
|
||||
/opt/%{name}/bin/jpegtran
|
||||
/opt/%{name}/bin/jpgtest
|
||||
/opt/%{name}/bin/rdjpgcom
|
||||
/opt/%{name}/bin/wrjpgcom
|
||||
%dir /opt/%{name}/%{__lib}
|
||||
|
||||
@@ -102,6 +102,10 @@ if [ $UNIVERSAL = 1 ]; then
|
||||
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/jpegtran \
|
||||
-arch x86_64 $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 \
|
||||
-arch i386 $TMPDIR/dist.x86/opt/$PACKAGE_NAME/bin/rdjpgcom \
|
||||
-arch x86_64 $PKGROOT/opt/$PACKAGE_NAME/bin/rdjpgcom \
|
||||
|
||||
@@ -81,6 +81,7 @@ d none $PACKAGE_NAME/bin 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/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/wrjpgcom 0755 root bin
|
||||
d none $PACKAGE_NAME/lib 0755 root bin
|
||||
|
||||
64
rrtimer.h
64
rrtimer.h
@@ -15,69 +15,6 @@
|
||||
#ifndef __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
|
||||
|
||||
#include <windows.h>
|
||||
@@ -111,4 +48,3 @@ static __inline double rrtime(void)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
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
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
if(${var} MATCHES "/MT")
|
||||
string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
|
||||
endif()
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* For conditions of distribution and use, see copyright notice in jsimdext.inc
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* 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
|
||||
* of the library and the SIMD implementations when running on a
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* 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
|
||||
* of the library and the SIMD implementations when running on a
|
||||
|
||||
BIN
testimgfst100.jpg
Normal file
BIN
testimgfst100.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -1,3 +1,4 @@
|
||||
TURBOJPEG_1.0
|
||||
{
|
||||
global:
|
||||
tjInitCompress;
|
||||
@@ -5,10 +6,18 @@
|
||||
TJBUFSIZE;
|
||||
tjInitDecompress;
|
||||
tjDecompressHeader;
|
||||
tjDecompressHeader2;
|
||||
tjDecompress;
|
||||
tjDestroy;
|
||||
tjGetErrorStr;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
TURBOJPEG_1.1
|
||||
{
|
||||
global:
|
||||
TJBUFSIZEYUV;
|
||||
tjDecompressHeader2;
|
||||
tjDecompressToYUV;
|
||||
tjEncodeYUV;
|
||||
} TURBOJPEG_1.0;
|
||||
|
||||
196
turbojpeg.h
196
turbojpeg.h
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C)2004 Landmark Graphics Corporation
|
||||
* Copyright (C)2005, 2006 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
|
||||
* the terms of the wxWindows Library License, Version 3.1 or (at your option)
|
||||
@@ -52,28 +52,9 @@ enum {TJ_444=0, TJ_422, TJ_420, TJ_GRAYSCALE};
|
||||
(64-bit IPP version only) */
|
||||
#define TJ_FASTUPSAMPLE 256
|
||||
/* Use fast, inaccurate 4:2:2 and 4:2:0 YUV upsampling routines
|
||||
(libjpeg version only) */
|
||||
(libjpeg and libjpeg-turbo versions only) */
|
||||
#define TJ_YUV 512
|
||||
/* If passed to tjCompress(), this causes TurboJPEG/OSS to use the
|
||||
accelerated color conversion routines in libjpeg-turbo to produce a planar
|
||||
YUV image that is suitable for X Video. Specifically, if the chrominance
|
||||
components are subsampled along the horizontal dimension, then the width
|
||||
of the luminance plane is padded to 2 in the output image (same goes for
|
||||
the height of the luminance plane, if the chrominance components are
|
||||
subsampled along the vertical dimension.) Also, each line of each plane
|
||||
in the output image is padded to 4 bytes. Although this will work with
|
||||
any subsampling option, it is really only useful in combination with
|
||||
TJ_420, which produces an image compatible with the I420 (AKA "YUV420P")
|
||||
format.
|
||||
|
||||
If passed to tjDecompress(), this tells TurboJPEG/OSS to perform JPEG
|
||||
decompression but to leave out the color conversion step, so a planar YUV
|
||||
image is generated instead of an RGB image. The padding of the planes in
|
||||
this image is the same as in the above case. Note that, if the width or
|
||||
height of the output image is not a multiple of 8 (or a multiple of 16
|
||||
along any dimension in which chrominance subsampling is used), then an
|
||||
intermediate buffer copy will be performed within TurboJPEG/OSS.
|
||||
*/
|
||||
/* Nothing to see here. Pay no attention to the man behind the curtain. */
|
||||
|
||||
typedef void* tjhandle;
|
||||
|
||||
@@ -96,7 +77,8 @@ extern "C" {
|
||||
and returns a handle to the instance. Most applications will only
|
||||
need to call this once at the beginning of the program or once for each
|
||||
concurrent thread. Don't try to create a new instance every time you
|
||||
compress an image, because this will cause performance to suffer.
|
||||
compress an image, because this may cause performance to suffer in some
|
||||
TurboJPEG implementations.
|
||||
|
||||
RETURNS: NULL on error
|
||||
*/
|
||||
@@ -111,39 +93,40 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
|
||||
|
||||
[INPUT] j = instance handle previously returned from a call to
|
||||
tjInitCompress()
|
||||
[INPUT] srcbuf = pointer to user-allocated image buffer containing pixels in
|
||||
RGB(A) or BGR(A) form
|
||||
[INPUT] width = width (in pixels) of the source image
|
||||
[INPUT] srcbuf = pointer to user-allocated image buffer containing RGB or
|
||||
grayscale pixels to be compressed
|
||||
[INPUT] width = width (in pixels) of the source image
|
||||
[INPUT] pitch = bytes per line of the source image (width*pixelsize if the
|
||||
bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the bitmap
|
||||
is padded to the nearest 32-bit boundary, such as is the case for Windows
|
||||
bitmaps. You can also be clever and use this parameter to skip lines, etc.,
|
||||
as long as the pitch is greater than 0.)
|
||||
bitmaps. You can also be clever and use this parameter to skip lines,
|
||||
etc. Setting this parameter to 0 is the equivalent of setting it to
|
||||
width*pixelsize.
|
||||
[INPUT] height = height (in pixels) of the source image
|
||||
[INPUT] pixelsize = size (in bytes) of each pixel in the source image
|
||||
RGBA and BGRA: 4, RGB and BGR: 3, Grayscale: 1
|
||||
RGBX/BGRX/XRGB/XBGR: 4, RGB/BGR: 3, Grayscale: 1
|
||||
[INPUT] dstbuf = pointer to user-allocated image buffer which will receive
|
||||
the JPEG image. Use the macro TJBUFSIZE(width, height) to determine
|
||||
the JPEG image. Use the TJBUFSIZE(width, height) function to determine
|
||||
the appropriate size for this buffer based on the image width and height.
|
||||
[OUTPUT] size = pointer to unsigned long which receives the size (in bytes)
|
||||
of the compressed image
|
||||
[INPUT] jpegsubsamp = Specifies either 4:2:0, 4:2:2, or 4:4:4 subsampling.
|
||||
When the image is converted from the RGB to YCbCr colorspace as part of the
|
||||
JPEG compression process, every other Cb and Cr (chrominance) pixel can be
|
||||
discarded to produce a smaller image with little perceptible loss of
|
||||
image clarity (the human eye is more sensitive to small changes in
|
||||
brightness than small changes in color.)
|
||||
[INPUT] jpegsubsamp = Specifies either 4:2:0, 4:2:2, 4:4:4, or grayscale
|
||||
subsampling. When the image is converted from the RGB to YCbCr colorspace
|
||||
as part of the JPEG compression process, every other Cb and Cr
|
||||
(chrominance) pixel can be discarded to produce a smaller image with
|
||||
little perceptible loss of image clarity (the human eye is more sensitive
|
||||
to small changes in brightness than small changes in color.)
|
||||
|
||||
TJ_420: 4:2:0 subsampling. Discards every other Cb, Cr pixel in both
|
||||
horizontal and vertical directions.
|
||||
horizontal and vertical directions
|
||||
TJ_422: 4:2:2 subsampling. Discards every other Cb, Cr pixel only in
|
||||
the horizontal direction.
|
||||
TJ_444: no subsampling.
|
||||
the horizontal direction
|
||||
TJ_444: no subsampling
|
||||
TJ_GRAYSCALE: Generate grayscale JPEG image
|
||||
|
||||
[INPUT] jpegqual = JPEG quality (an integer between 0 and 100 inclusive.)
|
||||
[INPUT] jpegqual = JPEG quality (an integer between 0 and 100 inclusive)
|
||||
[INPUT] flags = the bitwise OR of one or more of the flags described in the
|
||||
"Flags" section above.
|
||||
"Flags" section above
|
||||
|
||||
RETURNS: 0 on success, -1 on error
|
||||
*/
|
||||
@@ -152,8 +135,77 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle j,
|
||||
unsigned char *dstbuf, unsigned long *size,
|
||||
int jpegsubsamp, int jpegqual, int flags);
|
||||
|
||||
|
||||
/*
|
||||
unsigned long TJBUFSIZE(int width, int height)
|
||||
|
||||
Convenience function which returns the maximum size of the buffer required to
|
||||
hold a JPEG image with the given width and height
|
||||
|
||||
RETURNS: -1 if arguments are out of bounds
|
||||
*/
|
||||
DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height);
|
||||
|
||||
|
||||
/*
|
||||
unsigned long TJBUFSIZEYUV(int width, int height, int subsamp)
|
||||
|
||||
Convenience function which returns the size of the buffer required to
|
||||
hold a YUV planar image with the given width, height, and level of
|
||||
chrominance subsampling
|
||||
|
||||
RETURNS: -1 if arguments are out of bounds
|
||||
*/
|
||||
DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
|
||||
int subsamp);
|
||||
|
||||
|
||||
/*
|
||||
int tjEncodeYUV(tjhandle j,
|
||||
unsigned char *srcbuf, int width, int pitch, int height, int pixelsize,
|
||||
unsigned char *dstbuf, int subsamp, int flags)
|
||||
|
||||
This function uses the accelerated color conversion routines in TurboJPEG's
|
||||
underlying codec to produce a planar YUV image that is suitable for X Video.
|
||||
Specifically, if the chrominance components are subsampled along the
|
||||
horizontal dimension, then the width of the luminance plane is padded to 2 in
|
||||
the output image (same goes for the height of the luminance plane, if the
|
||||
chrominance components are subsampled along the vertical dimension.) Also,
|
||||
each line of each plane in the output image is padded to 4 bytes. Although
|
||||
this will work with any subsampling option, it is really only useful in
|
||||
combination with TJ_420, which produces an image compatible with the I420
|
||||
(AKA "YUV420P") format.
|
||||
|
||||
[INPUT] j = instance handle previously returned from a call to
|
||||
tjInitCompress()
|
||||
[INPUT] srcbuf = pointer to user-allocated image buffer containing RGB or
|
||||
grayscale pixels to be encoded
|
||||
[INPUT] width = width (in pixels) of the source image
|
||||
[INPUT] pitch = bytes per line of the source image (width*pixelsize if the
|
||||
bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the bitmap
|
||||
is padded to the nearest 32-bit boundary, such as is the case for Windows
|
||||
bitmaps. You can also be clever and use this parameter to skip lines,
|
||||
etc. Setting this parameter to 0 is the equivalent of setting it to
|
||||
width*pixelsize.
|
||||
[INPUT] height = height (in pixels) of the source image
|
||||
[INPUT] pixelsize = size (in bytes) of each pixel in the source image
|
||||
RGBX/BGRX/XRGB/XBGR: 4, RGB/BGR: 3, Grayscale: 1
|
||||
[INPUT] dstbuf = pointer to user-allocated image buffer which will receive
|
||||
the YUV image. Use the TJBUFSIZEYUV(width, height, subsamp) function to
|
||||
determine the appropriate size for this buffer based on the image width,
|
||||
height, and level of subsampling.
|
||||
[INPUT] subsamp = Specifies either 4:2:0, 4:2:2, 4:4:4, or grayscale
|
||||
subsampling (see description under tjCompress())
|
||||
[INPUT] flags = the bitwise OR of one or more of the flags described in the
|
||||
"Flags" section above
|
||||
|
||||
RETURNS: 0 on success, -1 on error
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjEncodeYUV(tjhandle j,
|
||||
unsigned char *srcbuf, int width, int pitch, int height, int pixelsize,
|
||||
unsigned char *dstbuf, int subsamp, int flags);
|
||||
|
||||
|
||||
/*
|
||||
tjhandle tjInitDecompress(void)
|
||||
|
||||
@@ -161,7 +213,8 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height);
|
||||
structures, and returns a handle to the instance. Most applications will
|
||||
only need to call this once at the beginning of the program or once for each
|
||||
concurrent thread. Don't try to create a new instance every time you
|
||||
decompress an image, because this will cause performance to suffer.
|
||||
decompress an image, because this may cause performance to suffer in some
|
||||
TurboJPEG implementations.
|
||||
|
||||
RETURNS: NULL on error
|
||||
*/
|
||||
@@ -171,26 +224,25 @@ DLLEXPORT tjhandle DLLCALL tjInitDecompress(void);
|
||||
/*
|
||||
int tjDecompressHeader2(tjhandle j,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
int *width, int *height, int *jpegsub)
|
||||
int *width, int *height, int *jpegsubsamp)
|
||||
|
||||
[INPUT] j = instance handle previously returned from a call to
|
||||
tjInitDecompress()
|
||||
[INPUT] srcbuf = pointer to a user-allocated buffer containing the JPEG image
|
||||
to decompress
|
||||
[INPUT] srcbuf = pointer to a user-allocated buffer containing a JPEG image
|
||||
[INPUT] size = size of the JPEG image buffer (in bytes)
|
||||
[OUTPUT] width = width (in pixels) of the JPEG image
|
||||
[OUTPUT] height = height (in pixels) of the JPEG image
|
||||
[OUTPUT] jpegsub = type of chrominance subsampling used when compressing the
|
||||
JPEG image
|
||||
[OUTPUT] jpegsubsamp = type of chrominance subsampling used when compressing
|
||||
the JPEG image
|
||||
|
||||
RETURNS: 0 on success, -1 on error
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle j,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
int *width, int *height, int *jpegsub);
|
||||
int *width, int *height, int *jpegsubsamp);
|
||||
|
||||
/*
|
||||
Deprecated version of the above function
|
||||
Legacy version of the above function
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle j,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
@@ -212,15 +264,16 @@ DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle j,
|
||||
the bitmap image. This buffer should normally be pitch*height
|
||||
bytes in size, although this pointer may also be used to decompress into
|
||||
a specific region of a larger buffer.
|
||||
[INPUT] width = width (in pixels) of the destination image
|
||||
[INPUT] pitch = bytes per line of the destination image (width*pixelsize if the
|
||||
bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the bitmap
|
||||
is padded to the nearest 32-bit boundary, such as is the case for Windows
|
||||
bitmaps. You can also be clever and use this parameter to skip lines, etc.,
|
||||
as long as the pitch is greater than 0.)
|
||||
[INPUT] width = width (in pixels) of the destination image
|
||||
[INPUT] pitch = bytes per line of the destination image (width*pixelsize if
|
||||
the bitmap is unpadded, else TJPAD(width*pixelsize) if each line of the
|
||||
bitmap is padded to the nearest 32-bit boundary, such as is the case for
|
||||
Windows bitmaps. You can also be clever and use this parameter to skip
|
||||
lines, etc. Setting this parameter to 0 is the equivalent of setting it
|
||||
to width*pixelsize.
|
||||
[INPUT] height = height (in pixels) of the destination image
|
||||
[INPUT] pixelsize = size (in bytes) of each pixel in the destination image
|
||||
RGBA/RGBx and BGRA/BGRx: 4, RGB and BGR: 3, Grayscale: 1
|
||||
RGBX/BGRX/XRGB/XBGR: 4, RGB/BGR: 3, Grayscale: 1
|
||||
[INPUT] flags = the bitwise OR of one or more of the flags described in the
|
||||
"Flags" section above.
|
||||
|
||||
@@ -232,6 +285,37 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle j,
|
||||
int flags);
|
||||
|
||||
|
||||
/*
|
||||
int tjDecompressToYUV(tjhandle j,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
unsigned char *dstbuf, int flags)
|
||||
|
||||
This function performs JPEG decompression but leaves out the color conversion
|
||||
step, so a planar YUV image is generated instead of an RGB image. The
|
||||
padding of the planes in this image is the same as in tjEncodeYUV().
|
||||
Note that, if the width or height of the output image is not a multiple of 8
|
||||
(or a multiple of 16 along any dimension in which chrominance subsampling is
|
||||
used), then an intermediate buffer copy will be performed within TurboJPEG.
|
||||
|
||||
[INPUT] j = instance handle previously returned from a call to
|
||||
tjInitDecompress()
|
||||
[INPUT] srcbuf = pointer to a user-allocated buffer containing the JPEG image
|
||||
to decompress
|
||||
[INPUT] size = size of the JPEG image buffer (in bytes)
|
||||
[INPUT] dstbuf = pointer to user-allocated image buffer which will receive
|
||||
the YUV image. Use the TJBUFSIZEYUV(width, height, subsamp) function to
|
||||
determine the appropriate size for this buffer based on the image width,
|
||||
height, and level of subsampling.
|
||||
[INPUT] flags = the bitwise OR of one or more of the flags described in the
|
||||
"Flags" section above.
|
||||
|
||||
RETURNS: 0 on success, -1 on error
|
||||
*/
|
||||
DLLEXPORT int DLLCALL tjDecompressToYUV(tjhandle j,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
unsigned char *dstbuf, int flags);
|
||||
|
||||
|
||||
/*
|
||||
int tjDestroy(tjhandle h)
|
||||
|
||||
|
||||
158
turbojpegl.c
158
turbojpegl.c
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C)2004 Landmark Graphics Corporation
|
||||
* Copyright (C)2005 Sun Microsystems, Inc.
|
||||
* Copyright (C)2009-2010 D. R. Commander
|
||||
* 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)
|
||||
@@ -70,10 +70,9 @@ static const int hsampfactor[NUMSUBOPT]={1, 2, 2, 1};
|
||||
static const int vsampfactor[NUMSUBOPT]={1, 1, 2, 1};
|
||||
static const int pixelsize[NUMSUBOPT]={3, 3, 3, 1};
|
||||
|
||||
#define _throw(c) {sprintf(lasterror, "%s", c); return -1;}
|
||||
#define _catch(f) {if((f)==-1) return -1;}
|
||||
#define _throw(c) {sprintf(lasterror, "%s", c); retval=-1; goto bailout;}
|
||||
#define checkhandle(h) jpgstruct *j=(jpgstruct *)h; \
|
||||
if(!j) _throw("Invalid handle");
|
||||
if(!j) {sprintf(lasterror, "Invalid handle"); return -1;}
|
||||
|
||||
|
||||
// CO
|
||||
@@ -113,18 +112,46 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void)
|
||||
return (tjhandle)j;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height)
|
||||
{
|
||||
// This allows enough room in case the image doesn't compress
|
||||
return ((width+15)&(~15)) * ((height+15)&(~15)) * 6 + 2048;
|
||||
unsigned long retval=0;
|
||||
if(width<1 || height<1)
|
||||
_throw("Invalid argument in TJBUFSIZE()");
|
||||
|
||||
// This allows for rare corner cases in which a JPEG image can actually be
|
||||
// larger than the uncompressed input (we wouldn't mention it if it hadn't
|
||||
// happened before.)
|
||||
retval=((width+15)&(~15)) * ((height+15)&(~15)) * 6 + 2048;
|
||||
|
||||
bailout:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
|
||||
int subsamp)
|
||||
{
|
||||
unsigned long retval=0;
|
||||
int pw, ph, cw, ch;
|
||||
if(width<1 || height<1 || subsamp<0 || subsamp>=NUMSUBOPT)
|
||||
_throw("Invalid argument in TJBUFSIZEYUV()");
|
||||
pw=PAD(width, hsampfactor[subsamp]);
|
||||
ph=PAD(height, vsampfactor[subsamp]);
|
||||
cw=pw/hsampfactor[subsamp]; ch=ph/vsampfactor[subsamp];
|
||||
retval=PAD(pw, 4)*ph + (subsamp==TJ_GRAYSCALE? 0:PAD(cw, 4)*ch*2);
|
||||
|
||||
bailout:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjCompress(tjhandle h,
|
||||
unsigned char *srcbuf, int width, int pitch, int height, int ps,
|
||||
unsigned char *dstbuf, unsigned long *size,
|
||||
int jpegsub, int qual, int flags)
|
||||
{
|
||||
int i; JSAMPROW *row_pointer=NULL;
|
||||
int i, retval=0; JSAMPROW *row_pointer=NULL;
|
||||
JSAMPLE *_tmpbuf[MAX_COMPONENTS], *_tmpbuf2[MAX_COMPONENTS];
|
||||
JSAMPROW *tmpbuf[MAX_COMPONENTS], *tmpbuf2[MAX_COMPONENTS];
|
||||
JSAMPROW *outbuf[MAX_COMPONENTS];
|
||||
@@ -174,16 +201,8 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h,
|
||||
|
||||
if(setjmp(j->jerr.jb))
|
||||
{ // this will execute if LIBJPEG has an error
|
||||
if(row_pointer) free(row_pointer);
|
||||
for(i=0; i<MAX_COMPONENTS; i++)
|
||||
{
|
||||
if(tmpbuf[i]!=NULL) free(tmpbuf[i]);
|
||||
if(_tmpbuf[i]!=NULL) free(_tmpbuf[i]);
|
||||
if(tmpbuf2[i]!=NULL) free(tmpbuf2[i]);
|
||||
if(_tmpbuf2[i]!=NULL) free(_tmpbuf2[i]);
|
||||
if(outbuf[i]!=NULL) free(outbuf[i]);
|
||||
}
|
||||
return -1;
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
jpeg_set_defaults(&j->cinfo);
|
||||
@@ -193,7 +212,8 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h,
|
||||
jpeg_set_colorspace(&j->cinfo, JCS_GRAYSCALE);
|
||||
else
|
||||
jpeg_set_colorspace(&j->cinfo, JCS_YCbCr);
|
||||
j->cinfo.dct_method = JDCT_FASTEST;
|
||||
if(qual>=96) j->cinfo.dct_method=JDCT_ISLOW;
|
||||
else j->cinfo.dct_method=JDCT_FASTEST;
|
||||
|
||||
j->cinfo.comp_info[0].h_samp_factor=hsampfactor[jpegsub];
|
||||
j->cinfo.comp_info[1].h_samp_factor=1;
|
||||
@@ -301,6 +321,8 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h,
|
||||
*size=TJBUFSIZE(j->cinfo.image_width, j->cinfo.image_height)
|
||||
-(unsigned long)(j->jdms.free_in_buffer);
|
||||
|
||||
bailout:
|
||||
if(j->cinfo.global_state>CSTATE_START) jpeg_abort_compress(&j->cinfo);
|
||||
if(row_pointer) free(row_pointer);
|
||||
for(i=0; i<MAX_COMPONENTS; i++)
|
||||
{
|
||||
@@ -310,7 +332,17 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h,
|
||||
if(_tmpbuf2[i]!=NULL) free(_tmpbuf2[i]);
|
||||
if(outbuf[i]!=NULL) free(outbuf[i]);
|
||||
}
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjEncodeYUV(tjhandle h,
|
||||
unsigned char *srcbuf, int width, int pitch, int height, int ps,
|
||||
unsigned char *dstbuf, int subsamp, int flags)
|
||||
{
|
||||
unsigned long size;
|
||||
return tjCompress(h, srcbuf, width, pitch, height, ps, dstbuf, &size,
|
||||
subsamp, 0, flags|TJ_YUV);
|
||||
}
|
||||
|
||||
|
||||
@@ -360,45 +392,16 @@ DLLEXPORT tjhandle DLLCALL tjInitDecompress(void)
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle h,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
int *width, int *height)
|
||||
{
|
||||
checkhandle(h);
|
||||
|
||||
if(srcbuf==NULL || size<=0 || width==NULL || height==NULL)
|
||||
_throw("Invalid argument in tjDecompressHeader()");
|
||||
if(!j->initd) _throw("Instance has not been initialized for decompression");
|
||||
|
||||
if(setjmp(j->jerr.jb))
|
||||
{ // this will execute if LIBJPEG has an error
|
||||
return -1;
|
||||
}
|
||||
|
||||
j->jsms.bytes_in_buffer = size;
|
||||
j->jsms.next_input_byte = srcbuf;
|
||||
|
||||
jpeg_read_header(&j->dinfo, TRUE);
|
||||
|
||||
*width=j->dinfo.image_width; *height=j->dinfo.image_height;
|
||||
|
||||
jpeg_abort_decompress(&j->dinfo);
|
||||
|
||||
if(*width<1 || *height<1) _throw("Invalid data returned in header");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle h,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
int *width, int *height, int *jpegsub)
|
||||
{
|
||||
int i, k;
|
||||
int i, k, retval=0;
|
||||
|
||||
checkhandle(h);
|
||||
|
||||
if(srcbuf==NULL || size<=0 || width==NULL || height==NULL || jpegsub==NULL)
|
||||
_throw("Invalid argument in tjDecompressHeader()");
|
||||
_throw("Invalid argument in tjDecompressHeader2()");
|
||||
if(!j->initd) _throw("Instance has not been initialized for decompression");
|
||||
|
||||
if(setjmp(j->jerr.jb))
|
||||
@@ -439,7 +442,18 @@ DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle h,
|
||||
|
||||
if(*jpegsub<0) _throw("Could not determine subsampling type for JPEG image");
|
||||
if(*width<1 || *height<1) _throw("Invalid data returned in header");
|
||||
return 0;
|
||||
|
||||
bailout:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjDecompressHeader(tjhandle h,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
int *width, int *height)
|
||||
{
|
||||
int jpegsub;
|
||||
return tjDecompressHeader2(h, srcbuf, size, width, height, &jpegsub);
|
||||
}
|
||||
|
||||
|
||||
@@ -448,7 +462,7 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
unsigned char *dstbuf, int width, int pitch, int height, int ps,
|
||||
int flags)
|
||||
{
|
||||
int i, row; JSAMPROW *row_pointer=NULL, *outbuf[MAX_COMPONENTS];
|
||||
int i, row, retval=0; JSAMPROW *row_pointer=NULL, *outbuf[MAX_COMPONENTS];
|
||||
int cw[MAX_COMPONENTS], ch[MAX_COMPONENTS], iw[MAX_COMPONENTS],
|
||||
tmpbufsize=0, usetmpbuf=0, th[MAX_COMPONENTS];
|
||||
JSAMPLE *_tmpbuf=NULL; JSAMPROW *tmpbuf[MAX_COMPONENTS];
|
||||
@@ -475,14 +489,8 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
|
||||
if(setjmp(j->jerr.jb))
|
||||
{ // this will execute if LIBJPEG has an error
|
||||
for(i=0; i<MAX_COMPONENTS; i++)
|
||||
{
|
||||
if(tmpbuf[i]!=NULL) free(tmpbuf[i]);
|
||||
if(outbuf[i]!=NULL) free(outbuf[i]);
|
||||
}
|
||||
if(_tmpbuf) free(_tmpbuf);
|
||||
if(row_pointer) free(row_pointer);
|
||||
return -1;
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
j->jsms.bytes_in_buffer = size;
|
||||
@@ -501,15 +509,15 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
int ih;
|
||||
iw[i]=compptr->width_in_blocks*DCTSIZE;
|
||||
ih=compptr->height_in_blocks*DCTSIZE;
|
||||
cw[i]=PAD(width, dinfo->max_h_samp_factor)*compptr->h_samp_factor
|
||||
/dinfo->max_h_samp_factor;
|
||||
ch[i]=PAD(height, dinfo->max_v_samp_factor)*compptr->v_samp_factor
|
||||
/dinfo->max_v_samp_factor;
|
||||
cw[i]=PAD(dinfo->image_width, dinfo->max_h_samp_factor)
|
||||
*compptr->h_samp_factor/dinfo->max_h_samp_factor;
|
||||
ch[i]=PAD(dinfo->image_height, dinfo->max_v_samp_factor)
|
||||
*compptr->v_samp_factor/dinfo->max_v_samp_factor;
|
||||
if(iw[i]!=cw[i] || ih!=ch[i]) usetmpbuf=1;
|
||||
th[i]=compptr->v_samp_factor*DCTSIZE;
|
||||
tmpbufsize+=iw[i]*th[i];
|
||||
if((outbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]))==NULL)
|
||||
_throw("Memory allocation failed in tjInitDecompress()");
|
||||
_throw("Memory allocation failed in tjDecompress()");
|
||||
for(row=0; row<ch[i]; row++)
|
||||
{
|
||||
outbuf[i][row]=ptr;
|
||||
@@ -519,13 +527,12 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
if(usetmpbuf)
|
||||
{
|
||||
if((_tmpbuf=(JSAMPLE *)malloc(sizeof(JSAMPLE)*tmpbufsize))==NULL)
|
||||
_throw("Memory allocation failed in tjInitDecompress()");
|
||||
_throw("Memory allocation failed in tjDecompress()");
|
||||
ptr=_tmpbuf;
|
||||
for(i=0; i<dinfo->num_components; i++)
|
||||
{
|
||||
jpeg_component_info *compptr=&dinfo->comp_info[i];
|
||||
if((tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*th[i]))==NULL)
|
||||
_throw("Memory allocation failed in tjInitDecompress()");
|
||||
_throw("Memory allocation failed in tjDecompress()");
|
||||
for(row=0; row<th[i]; row++)
|
||||
{
|
||||
tmpbuf[i][row]=ptr;
|
||||
@@ -537,7 +544,7 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
else
|
||||
{
|
||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
|
||||
_throw("Memory allocation failed in tjInitDecompress()");
|
||||
_throw("Memory allocation failed in tjDecompress()");
|
||||
for(i=0; i<height; i++)
|
||||
{
|
||||
if(flags&TJ_BOTTOMUP) row_pointer[i]= &dstbuf[(height-i-1)*pitch];
|
||||
@@ -587,7 +594,6 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
int j;
|
||||
for(i=0; i<dinfo->num_components; i++)
|
||||
{
|
||||
jpeg_component_info *compptr=&dinfo->comp_info[i];
|
||||
for(j=0; j<min(th[i], ch[i]-crow[i]); j++)
|
||||
{
|
||||
memcpy(outbuf[i][crow[i]+j], tmpbuf[i][j], cw[i]);
|
||||
@@ -606,6 +612,8 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
}
|
||||
jpeg_finish_decompress(&j->dinfo);
|
||||
|
||||
bailout:
|
||||
if(j->dinfo.global_state>DSTATE_START) jpeg_abort_decompress(&j->dinfo);
|
||||
for(i=0; i<MAX_COMPONENTS; i++)
|
||||
{
|
||||
if(tmpbuf[i]) free(tmpbuf[i]);
|
||||
@@ -613,7 +621,15 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
|
||||
}
|
||||
if(_tmpbuf) free(_tmpbuf);
|
||||
if(row_pointer) free(row_pointer);
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT int DLLCALL tjDecompressToYUV(tjhandle h,
|
||||
unsigned char *srcbuf, unsigned long size,
|
||||
unsigned char *dstbuf, int flags)
|
||||
{
|
||||
return tjDecompress(h, srcbuf, size, dstbuf, 1, 0, 1, 3, flags|TJ_YUV);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user