Compare commits
97 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf6c774305 | ||
|
|
c308d43416 | ||
|
|
773040f9d9 | ||
|
|
a831b5a986 | ||
|
|
19b393b624 | ||
|
|
9d9d8fe658 | ||
|
|
78e97e38cb | ||
|
|
468f2fed27 | ||
|
|
5abf2536f6 | ||
|
|
5fce2e9421 | ||
|
|
907dd683a4 | ||
|
|
f008876cc1 | ||
|
|
5bc43c7821 | ||
|
|
f3ad13e3d8 | ||
|
|
94e152b186 | ||
|
|
073b0e88a1 | ||
|
|
1b385f37f3 | ||
|
|
fd778bba46 | ||
|
|
8d403aeb6a | ||
|
|
01b74c101e | ||
|
|
db0dec3c5a | ||
|
|
ba6e9d8a11 | ||
|
|
5426a4cb16 | ||
|
|
d0bac69a8a | ||
|
|
59322e0973 | ||
|
|
4ded4dfac6 | ||
|
|
02fa8f244e | ||
|
|
32120054c2 | ||
|
|
1478361204 | ||
|
|
e5c1613ccd | ||
|
|
b0971e47d7 | ||
|
|
e248d430e2 | ||
|
|
acb634931a | ||
|
|
1db1ce45da | ||
|
|
d0c3aa900b | ||
|
|
6a2b067428 | ||
|
|
11eec4a398 | ||
|
|
301ba4f305 | ||
|
|
70f236ddd7 | ||
|
|
2a4f189444 | ||
|
|
9d64f3c60b | ||
|
|
da2a27ef05 | ||
|
|
c082dc039d | ||
|
|
d4c41fe0da | ||
|
|
a0b7de9a47 | ||
|
|
2252795571 | ||
|
|
eb38b61bfe | ||
|
|
47b29e8cd9 | ||
|
|
e1e816e665 | ||
|
|
6441018150 | ||
|
|
fcfc6c5eed | ||
|
|
786b649331 | ||
|
|
f4ba09b33a | ||
|
|
0f4fcced0a | ||
|
|
82bf7f5858 | ||
|
|
3582ce90bb | ||
|
|
d6d7b53968 | ||
|
|
f9f0c75bb8 | ||
|
|
3da94de248 | ||
|
|
ab664e35fc | ||
|
|
ce26e83f47 | ||
|
|
74e4c793cd | ||
|
|
a280fa630c | ||
|
|
6aae007745 | ||
|
|
4ad94b2963 | ||
|
|
2d4b2f14d0 | ||
|
|
9366cf0bca | ||
|
|
13e6b151b0 | ||
|
|
1ee329d617 | ||
|
|
b47c5e737f | ||
|
|
ce262eb5d7 | ||
|
|
27f817cd11 | ||
|
|
0df2e2188b | ||
|
|
6d22430a3a | ||
|
|
e9e3a2edd7 | ||
|
|
211c69f317 | ||
|
|
1625253d49 | ||
|
|
a0047bdea4 | ||
|
|
7bfb22af12 | ||
|
|
ac4a899511 | ||
|
|
dfefba7752 | ||
|
|
4cf67f2363 | ||
|
|
9407cf7f47 | ||
|
|
cb88e5da80 | ||
|
|
e9d9c31fd2 | ||
|
|
077e5bb4e0 | ||
|
|
a1dd35680d | ||
|
|
a09ba29a55 | ||
|
|
8ce2c9119a | ||
|
|
db04435165 | ||
|
|
7723d7f7d0 | ||
|
|
628c168c86 | ||
|
|
1120ff29a1 | ||
|
|
1945ad961b | ||
|
|
6e9d43e085 | ||
|
|
9055fb408d | ||
|
|
9e6c6a14f8 |
131
.travis.yml
Normal file
131
.travis.yml
Normal file
@@ -0,0 +1,131 @@
|
||||
language: c
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: BUILD_OFFICIAL=1
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
- os: osx
|
||||
env: BUILD_OFFICIAL=1
|
||||
osx_image: xcode7.3
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
|
||||
CONFIGURE_FLAGS="--disable-shared"
|
||||
ASAN_OPTIONS="detect_leaks=1 symbolize=1"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- nasm
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CONFIGURE_FLAGS="--with-12bit"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CONFIGURE_FLAGS="--with-jpeg7"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- nasm
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CONFIGURE_FLAGS="--with-jpeg8"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- nasm
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: CONFIGURE_FLAGS="--without-simd"
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||
brew update &&
|
||||
brew install nasm homebrew/versions/gcc5 md5sha1sum Caskroom/versions/java6 &&
|
||||
ln -fs /usr/local/bin/gpg1 /usr/local/bin/gpg &&
|
||||
git clone --depth=1 https://github.com/libjpeg-turbo/gas-preprocessor.git ~/src/gas-preprocessor &&
|
||||
ln -fs /Applications/Xcode.app /Applications/Xcode72.app;
|
||||
fi
|
||||
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
|
||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||
docker pull dcommander/buildljt;
|
||||
fi &&
|
||||
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b $TRAVIS_BRANCH ~/src/buildscripts &&
|
||||
openssl aes-256-cbc -K $encrypted_f92e8533f6f1_key -iv $encrypted_f92e8533f6f1_iv -in ci/keys.enc -out ci/keys -d &&
|
||||
tar xf ci/keys &&
|
||||
rm ci/keys &&
|
||||
mv ci/gpgsign ~/src/buildscripts &&
|
||||
gpg --import ci/sign_ljt &&
|
||||
rm ci/sign_ljt;
|
||||
fi
|
||||
|
||||
script:
|
||||
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
|
||||
mkdir -p ~/src/ljt.nightly &&
|
||||
if [ -f .git/shallow ]; then
|
||||
mv .git/shallow .git/shallow.bak;
|
||||
fi &&
|
||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||
docker run -v $HOME/src/ljt.nightly:/root/src/ljt.nightly -v $HOME/src/buildscripts:/root/src/buildscripts -v $TRAVIS_BUILD_DIR:/root/src/libjpeg-turbo -v $HOME/.gnupg:/root/.gnupg -t dcommander/buildljt:latest bash -c "rpm --import http://pgp.mit.edu/pks/lookup?op=get\&search=0x0575F26BD5B3FDB1 && ~/src/buildscripts/buildljt -r file:///root/src/libjpeg-turbo $TRAVIS_BRANCH -v" &&
|
||||
sudo chown -R travis:travis ~/src/ljt.nightly &&
|
||||
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
|
||||
else
|
||||
PATH=$PATH:~/src/gas-preprocessor ~/src/buildscripts/buildljt -r file://$TRAVIS_BUILD_DIR $TRAVIS_BRANCH -v &&
|
||||
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
|
||||
fi &&
|
||||
if [ -f .git/shallow.bak ]; then
|
||||
mv .git/shallow.bak .git/shallow;
|
||||
fi
|
||||
fi
|
||||
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
|
||||
autoreconf -fiv &&
|
||||
mkdir build &&
|
||||
pushd build &&
|
||||
../configure ${CONFIGURE_FLAGS} &&
|
||||
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo` &&
|
||||
make -j$NUMCPUS --load-average=$NUMCPUS &&
|
||||
if [[ "${CONFIGURE_FLAGS}" =~ "with-12bit" ||
|
||||
"${CONFIGURE_FLAGS}" =~ "without-simd" ]]; then
|
||||
make test FLOATTEST=32bit;
|
||||
else
|
||||
make test FLOATTEST=sse &&
|
||||
JSIMD_FORCENONE=1 make test FLOATTEST=32bit;
|
||||
fi &&
|
||||
popd;
|
||||
fi
|
||||
|
||||
after_failure:
|
||||
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
|
||||
if [ -f $TRAVIS_BUILD_DIR/build/config.log ]; then
|
||||
cat $TRAVIS_BUILD_DIR/build/config.log;
|
||||
fi
|
||||
fi
|
||||
|
||||
deploy:
|
||||
- provider: s3
|
||||
bucket: libjpeg-turbo-pr
|
||||
access_key_id:
|
||||
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
|
||||
secret_access_key:
|
||||
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
|
||||
acl: public_read
|
||||
local-dir: $HOME/src/ljt.nightly/latest/files
|
||||
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
|
||||
on:
|
||||
branch: master
|
||||
condition: -n "$BUILD_OFFICIAL"
|
||||
- provider: s3
|
||||
bucket: libjpeg-turbo-pr
|
||||
access_key_id:
|
||||
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
|
||||
secret_access_key:
|
||||
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
|
||||
acl: public_read
|
||||
local-dir: $HOME/src/ljt.nightly/latest/files
|
||||
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
|
||||
on:
|
||||
branch: dev
|
||||
condition: -n "$BUILD_OFFICIAL"
|
||||
811
BUILDING.md
811
BUILDING.md
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ if(POLICY CMP0022)
|
||||
endif()
|
||||
|
||||
project(libjpeg-turbo C)
|
||||
set(VERSION 1.5.0)
|
||||
set(VERSION 1.5.3)
|
||||
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
|
||||
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
|
||||
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
|
||||
@@ -367,8 +367,20 @@ if(WITH_12BIT)
|
||||
set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
|
||||
set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
|
||||
set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
|
||||
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
|
||||
if(64BIT)
|
||||
# Windows/x64 uses SSE for floating point
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
|
||||
set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
|
||||
else()
|
||||
# Windows/x86 uses the 387 FPU for floating point
|
||||
if(MSVC)
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG e27840755870fa849872e58aa0cd1400)
|
||||
set(MD5_PPM_3x2_FLOAT 6c2880b83bb1aa41dfe330e7a9768690)
|
||||
else()
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG bc6dbbefac2872f6b9d6c4a0ae60c3c0)
|
||||
set(MD5_PPM_3x2_FLOAT f58119ee294198ac9b4a9f5645a34266)
|
||||
endif()
|
||||
endif()
|
||||
set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
|
||||
set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
|
||||
set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
|
||||
@@ -410,8 +422,18 @@ else()
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71)
|
||||
set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
|
||||
else()
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
|
||||
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
|
||||
if(64BIT)
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
|
||||
set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
|
||||
else()
|
||||
if(MSVC)
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 7999ce9cd0ee9b6c7043b7351ab7639d)
|
||||
set(MD5_PPM_3x2_FLOAT 28cdc448a6b75e97892f0e0f8d4b21f3)
|
||||
else()
|
||||
set(MD5_JPEG_3x2_FLOAT_PROG 1657664a410e0822c924b54f6f65e6e9)
|
||||
set(MD5_PPM_3x2_FLOAT cb0a1f027f3d2917c902b5640214e025)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
|
||||
set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
|
||||
@@ -844,7 +866,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
||||
|
||||
endforeach()
|
||||
|
||||
add_custom_target(testclean COMMAND ${MD5CMP} -P
|
||||
add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
|
||||
|
||||
|
||||
@@ -933,3 +955,8 @@ install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md
|
||||
install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
|
||||
${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
|
||||
DESTINATION include)
|
||||
|
||||
configure_file("${CMAKE_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
|
||||
"cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)
|
||||
|
||||
206
ChangeLog.md
206
ChangeLog.md
@@ -1,3 +1,209 @@
|
||||
1.5.3
|
||||
=====
|
||||
|
||||
### Significant changes relative to 1.5.2:
|
||||
|
||||
1. Fixed a NullPointerException in the TurboJPEG Java wrapper that occurred
|
||||
when using the YUVImage constructor that creates an instance backed by separate
|
||||
image planes and allocates memory for the image planes.
|
||||
|
||||
2. Fixed an issue whereby the Java version of TJUnitTest would fail when
|
||||
testing BufferedImage encoding/decoding on big endian systems.
|
||||
|
||||
3. Fixed a segfault in djpeg that would occur if an output format other than
|
||||
PPM/PGM was selected along with the `-crop` option. The `-crop` option now
|
||||
works with the GIF and Targa formats as well (unfortunately, it cannot be made
|
||||
to work with the BMP and RLE formats due to the fact that those output engines
|
||||
write scanlines in bottom-up order.) djpeg will now exit gracefully if an
|
||||
output format other than PPM/PGM, GIF, or Targa is selected along with the
|
||||
`-crop` option.
|
||||
|
||||
4. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color
|
||||
quantization was enabled.
|
||||
|
||||
5. TJBench (both C and Java versions) will now display usage information if any
|
||||
command-line argument is unrecognized. This prevents the program from silently
|
||||
ignoring typos.
|
||||
|
||||
6. Fixed an access violation in tjbench.exe (Windows) that occurred when the
|
||||
program was used to decompress an existing JPEG image.
|
||||
|
||||
7. Fixed an ArrayIndexOutOfBoundsException in the TJExample Java program that
|
||||
occurred when attempting to decompress a JPEG image that had been compressed
|
||||
with 4:1:1 chrominance subsampling.
|
||||
|
||||
8. Fixed an issue whereby, when using `jpeg_skip_scanlines()` to skip to the
|
||||
end of a single-scan (non-progressive) image, subsequent calls to
|
||||
`jpeg_consume_input()` would return `JPEG_SUSPENDED` rather than
|
||||
`JPEG_REACHED_EOI`.
|
||||
|
||||
9. `jpeg_crop_scanlines()` now works correctly when decompressing grayscale
|
||||
JPEG images that were compressed with a sampling factor other than 1 (for
|
||||
instance, with `cjpeg -grayscale -sample 2x2`).
|
||||
|
||||
|
||||
1.5.2
|
||||
=====
|
||||
|
||||
### Significant changes relative to 1.5.1:
|
||||
|
||||
1. Fixed a regression introduced by 1.5.1[7] that prevented libjpeg-turbo from
|
||||
building with Android NDK platforms prior to android-21 (5.0).
|
||||
|
||||
2. Fixed a regression introduced by 1.5.1[1] that prevented the MIPS DSPR2 SIMD
|
||||
code in libjpeg-turbo from building.
|
||||
|
||||
3. Fixed a regression introduced by 1.5 beta1[11] that prevented the Java
|
||||
version of TJBench from outputting any reference images (the `-nowrite` switch
|
||||
was accidentally enabled by default.)
|
||||
|
||||
4. libjpeg-turbo should now build and run with full AltiVec SIMD acceleration
|
||||
on PowerPC-based AmigaOS 4 and OpenBSD systems.
|
||||
|
||||
5. Fixed build and runtime errors on Windows that occurred when building
|
||||
libjpeg-turbo with libjpeg v7 API/ABI emulation and the in-memory
|
||||
source/destination managers. Due to an oversight, the `jpeg_skip_scanlines()`
|
||||
and `jpeg_crop_scanlines()` functions were not being included in jpeg7.dll when
|
||||
libjpeg-turbo was built with `-DWITH_JPEG7=1` and `-DWITH_MEMSRCDST=1`.
|
||||
|
||||
6. Fixed "Bogus virtual array access" error that occurred when using the
|
||||
lossless crop feature in jpegtran or the TurboJPEG API, if libjpeg-turbo was
|
||||
built with libjpeg v7 API/ABI emulation. This was apparently a long-standing
|
||||
bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
|
||||
in libjpeg-turbo v1.1.
|
||||
|
||||
7. The lossless transform features in jpegtran and the TurboJPEG API will now
|
||||
always attempt to adjust the EXIF image width and height tags if the image size
|
||||
changed as a result of the transform. This behavior has always existed when
|
||||
using libjpeg v8 API/ABI emulation. It was supposed to be available with
|
||||
libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
|
||||
Furthermore, there was never any good reason not to enable it with libjpeg v6b
|
||||
API/ABI emulation, since the behavior is entirely internal. Note that
|
||||
`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
|
||||
the source image to the destination image.
|
||||
|
||||
8. Fixed several memory leaks in the TurboJPEG API library that could occur
|
||||
if the library was built with certain compilers and optimization levels
|
||||
(known to occur with GCC 4.x and clang with `-O1` and higher but not with
|
||||
GCC 5.x or 6.x) and one of the underlying libjpeg API functions threw an error
|
||||
after a TurboJPEG API function allocated a local buffer.
|
||||
|
||||
9. The libjpeg-turbo memory manager will now honor the `max_memory_to_use`
|
||||
structure member in jpeg\_memory\_mgr, which can be set to the maximum amount
|
||||
of memory (in bytes) that libjpeg-turbo should use during decompression or
|
||||
multi-pass (including progressive) compression. This limit can also be set
|
||||
using the `JPEGMEM` environment variable or using the `-maxmemory` switch in
|
||||
cjpeg/djpeg/jpegtran (refer to the respective man pages for more details.)
|
||||
This has been a documented feature of libjpeg since v5, but the
|
||||
`malloc()`/`free()` implementation of the memory manager (jmemnobs.c) never
|
||||
implemented the feature. Restricting libjpeg-turbo's memory usage is useful
|
||||
for two reasons: it allows testers to more easily work around the 2 GB limit
|
||||
in libFuzzer, and it allows developers of security-sensitive applications to
|
||||
more easily defend against one of the progressive JPEG exploits (LJT-01-004)
|
||||
identified in
|
||||
[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
|
||||
|
||||
10. TJBench will now run each benchmark for 1 second prior to starting the
|
||||
timer, in order to improve the consistency of the results. Furthermore, the
|
||||
`-warmup` option is now used to specify the amount of warmup time rather than
|
||||
the number of warmup iterations.
|
||||
|
||||
11. Fixed an error (`short jump is out of range`) that occurred when assembling
|
||||
the 32-bit x86 SIMD extensions with NASM versions prior to 2.04. This was a
|
||||
regression introduced by 1.5 beta1[12].
|
||||
|
||||
|
||||
1.5.1
|
||||
=====
|
||||
|
||||
### Significant changes relative to 1.5.0:
|
||||
|
||||
1. Previously, the undocumented `JSIMD_FORCE*` environment variables could be
|
||||
used to force-enable a particular SIMD instruction set if multiple instruction
|
||||
sets were available on a particular platform. On x86 platforms, where CPU
|
||||
feature detection is bulletproof and multiple SIMD instruction sets are
|
||||
available, it makes sense for those environment variables to allow forcing the
|
||||
use of an instruction set only if that instruction set is available. However,
|
||||
since the ARM implementations of libjpeg-turbo can only use one SIMD
|
||||
instruction set, and since their feature detection code is less bulletproof
|
||||
(parsing /proc/cpuinfo), it makes sense for the `JSIMD_FORCENEON` environment
|
||||
variable to bypass the feature detection code and really force the use of NEON
|
||||
instructions. A new environment variable (`JSIMD_FORCEDSPR2`) was introduced
|
||||
in the MIPS implementation for the same reasons, and the existing
|
||||
`JSIMD_FORCENONE` environment variable was extended to that implementation.
|
||||
These environment variables provide a workaround for those attempting to test
|
||||
ARM and MIPS builds of libjpeg-turbo in QEMU, which passes through
|
||||
/proc/cpuinfo from the host system.
|
||||
|
||||
2. libjpeg-turbo previously assumed that AltiVec instructions were always
|
||||
available on PowerPC platforms, which led to "illegal instruction" errors when
|
||||
running on PowerPC chips that lack AltiVec support (such as the older 7xx/G3
|
||||
and newer e5500 series.) libjpeg-turbo now examines /proc/cpuinfo on
|
||||
Linux/Android systems and enables AltiVec instructions only if the CPU supports
|
||||
them. It also now provides two environment variables, `JSIMD_FORCEALTIVEC` and
|
||||
`JSIMD_FORCENONE`, to force-enable and force-disable AltiVec instructions in
|
||||
environments where /proc/cpuinfo is an unreliable means of CPU feature
|
||||
detection (such as when running in QEMU.) On OS X, libjpeg-turbo continues to
|
||||
assume that AltiVec support is always available, which means that libjpeg-turbo
|
||||
cannot be used with G3 Macs unless you set the environment variable
|
||||
`JSIMD_FORCENONE` to `1`.
|
||||
|
||||
3. Fixed an issue whereby 64-bit ARM (AArch64) builds of libjpeg-turbo would
|
||||
crash when built with recent releases of the Clang/LLVM compiler. This was
|
||||
caused by an ABI conformance issue in some of libjpeg-turbo's 64-bit NEON SIMD
|
||||
routines. Those routines were incorrectly using 64-bit instructions to
|
||||
transfer a 32-bit JDIMENSION argument, whereas the ABI allows the upper
|
||||
(unused) 32 bits of a 32-bit argument's register to be undefined. The new
|
||||
Clang/LLVM optimizer uses load combining to transfer multiple adjacent 32-bit
|
||||
structure members into a single 64-bit register, and this exposed the ABI
|
||||
conformance issue.
|
||||
|
||||
4. Fancy upsampling is now supported when decompressing JPEG images that use
|
||||
4:4:0 (h1v2) chroma subsampling. These images are generated when losslessly
|
||||
rotating or transposing JPEG images that use 4:2:2 (h2v1) chroma subsampling.
|
||||
The h1v2 fancy upsampling algorithm is not currently SIMD-accelerated.
|
||||
|
||||
5. If merged upsampling isn't SIMD-accelerated but YCbCr-to-RGB conversion is,
|
||||
then libjpeg-turbo will now disable merged upsampling when decompressing YCbCr
|
||||
JPEG images into RGB or extended RGB output images. This significantly speeds
|
||||
up the decompression of 4:2:0 and 4:2:2 JPEGs on ARM platforms if fancy
|
||||
upsampling is not used (for example, if the `-nosmooth` option to djpeg is
|
||||
specified.)
|
||||
|
||||
6. The TurboJPEG API will now decompress 4:2:2 and 4:4:0 JPEG images with
|
||||
2x2 luminance sampling factors and 2x1 or 1x2 chrominance sampling factors.
|
||||
This is a non-standard way of specifying 2x subsampling (normally 4:2:2 JPEGs
|
||||
have 2x1 luminance and 1x1 chrominance sampling factors, and 4:4:0 JPEGs have
|
||||
1x2 luminance and 1x1 chrominance sampling factors), but the JPEG specification
|
||||
and the libjpeg API both allow it.
|
||||
|
||||
7. Fixed an unsigned integer overflow in the libjpeg memory manager, detected
|
||||
by the Clang undefined behavior sanitizer, that could be triggered by
|
||||
attempting to decompress a specially-crafted malformed JPEG image. This issue
|
||||
affected only 32-bit code and did not pose a security threat, but removing the
|
||||
warning makes it easier to detect actual security issues, should they arise in
|
||||
the future.
|
||||
|
||||
8. Fixed additional negative left shifts and other issues reported by the GCC
|
||||
and Clang undefined behavior sanitizers when attempting to decompress
|
||||
specially-crafted malformed JPEG images. None of these issues posed a security
|
||||
threat, but removing the warnings makes it easier to detect actual security
|
||||
issues, should they arise in the future.
|
||||
|
||||
9. Fixed an out-of-bounds array reference, introduced by 1.4.90[2] (partial
|
||||
image decompression) and detected by the Clang undefined behavior sanitizer,
|
||||
that could be triggered by a specially-crafted malformed JPEG image with more
|
||||
than four components. Because the out-of-bounds reference was still within the
|
||||
same structure, it was not known to pose a security threat, but removing the
|
||||
warning makes it easier to detect actual security issues, should they arise in
|
||||
the future.
|
||||
|
||||
10. Fixed another ABI conformance issue in the 64-bit ARM (AArch64) NEON SIMD
|
||||
code. Some of the routines were incorrectly reading and storing data below the
|
||||
stack pointer, which caused segfaults in certain applications under specific
|
||||
circumstances.
|
||||
|
||||
|
||||
1.5.0
|
||||
=====
|
||||
|
||||
|
||||
57
LICENSE.md
57
LICENSE.md
@@ -9,12 +9,11 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
||||
This license applies to the libjpeg API library and associated programs
|
||||
(any code inherited from libjpeg, and any modifications to that code.)
|
||||
|
||||
- The Modified (3-clause) BSD License, which is listed in
|
||||
[turbojpeg.c](turbojpeg.c)
|
||||
- The Modified (3-clause) BSD License, which is listed below
|
||||
|
||||
This license covers the TurboJPEG API library and associated programs.
|
||||
|
||||
- The zlib License, which is listed in [simd/jsimdext.inc](simd/jsimdext.inc)
|
||||
- The zlib License, which is listed below
|
||||
|
||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||
SIMD extensions.
|
||||
@@ -86,3 +85,55 @@ best of our understanding.
|
||||
- IJG License
|
||||
- Modified BSD License
|
||||
- zlib License
|
||||
|
||||
|
||||
The Modified (3-clause) BSD License
|
||||
===================================
|
||||
|
||||
Copyright (C)\<YEAR\> \<AUTHOR\>. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
- Neither the name of the libjpeg-turbo Project nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The zlib License
|
||||
================
|
||||
|
||||
Copyright (C) \<YEAR\>, \<AUTHOR\>.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
28
Makefile.am
28
Makefile.am
@@ -11,7 +11,10 @@ endif
|
||||
nodist_include_HEADERS = jconfig.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = pkgscripts/libjpeg.pc pkgscripts/libturbojpeg.pc
|
||||
pkgconfig_DATA = pkgscripts/libjpeg.pc
|
||||
if WITH_TURBOJPEG
|
||||
pkgconfig_DATA += pkgscripts/libturbojpeg.pc
|
||||
endif
|
||||
|
||||
HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \
|
||||
jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h jpegcomp.h \
|
||||
@@ -170,7 +173,7 @@ dist_example_DATA = example.c
|
||||
EXTRA_DIST = win release $(DOCS) testimages CMakeLists.txt \
|
||||
sharedlib/CMakeLists.txt cmakescripts libjpeg.map.in doc doxygen.config \
|
||||
doxygen-extra.css jccolext.c jdcolext.c jdcol565.c jdmrgext.c jdmrg565.c \
|
||||
jstdhuff.c jdcoefct.h jdmainct.h jdmaster.h jdsample.h wrppm.h \
|
||||
jstdhuff.c jdcoefct.h jdmainct.h jdmaster.h jdsample.h \
|
||||
md5/CMakeLists.txt
|
||||
|
||||
dist-hook:
|
||||
@@ -199,6 +202,8 @@ MD5_PPM_3x2_FLOAT_SSE = 42876ab9e5c2f76a87d08db5fbd57956
|
||||
MD5_JPEG_3x2_FLOAT_PROG_32BIT = a8c17daf77b457725ec929e215b603f8
|
||||
MD5_PPM_3x2_FLOAT_32BIT = 42876ab9e5c2f76a87d08db5fbd57956
|
||||
MD5_PPM_3x2_FLOAT_64BIT = d6fbc71153b3d8ded484dbc17c7b9cf4
|
||||
MD5_JPEG_3x2_FLOAT_PROG_387 = bc6dbbefac2872f6b9d6c4a0ae60c3c0
|
||||
MD5_PPM_3x2_FLOAT_387 = bcc5723c61560463ac60f772e742d092
|
||||
MD5_JPEG_3x2_IFAST_PROG = 1396cc2b7185cfe943d408c9d305339e
|
||||
MD5_PPM_3x2_IFAST = 3975985ef6eeb0a2cdc58daa651ccc00
|
||||
MD5_PPM_420M_ISLOW_2_1 = 4ca6be2a6f326ff9eaab63e70a8259c0
|
||||
@@ -246,6 +251,8 @@ MD5_PPM_3x2_FLOAT_SSE = 1a75f36e5904d6fc3a85a43da9ad89bb
|
||||
MD5_JPEG_3x2_FLOAT_PROG_32BIT = 9bca803d2042bd1eb03819e2bf92b3e5
|
||||
MD5_PPM_3x2_FLOAT_32BIT = f6bfab038438ed8f5522fbd33595dcdc
|
||||
MD5_PPM_3x2_FLOAT_64BIT = 0e917a34193ef976b679a6b069b1be26
|
||||
MD5_JPEG_3x2_FLOAT_PROG_387 = 1657664a410e0822c924b54f6f65e6e9
|
||||
MD5_PPM_3x2_FLOAT_387 = cb0a1f027f3d2917c902b5640214e025
|
||||
MD5_JPEG_3x2_IFAST_PROG = 1ee5d2c1a77f2da495f993c8c7cceca5
|
||||
MD5_PPM_3x2_IFAST = fd283664b3b49127984af0a7f118fccd
|
||||
MD5_JPEG_420_ISLOW_ARI = e986fb0a637a8d833d96e8a6d6d84ea1
|
||||
@@ -334,7 +341,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
|
||||
# Test compressing from/decompressing to an arbitrary subregion of a larger
|
||||
# image buffer
|
||||
cp $(srcdir)/testimages/testorig.ppm testout_tile.ppm
|
||||
./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 >/dev/null 2>&1
|
||||
./tjbench testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
|
||||
for i in 8 16 32 64 128; do \
|
||||
md5/md5cmp $(MD5_PPM_GRAY_TILE) testout_tile_GRAY_Q95_$$i\x$$i.ppm; \
|
||||
done
|
||||
@@ -353,7 +360,7 @@ MD5_PPM_444_TILE = 7964e41e67cfb8d0a587c0aa4798f9c3
|
||||
done
|
||||
rm -f testout_tile_GRAY_* testout_tile_420_* testout_tile_422_* testout_tile_444_*
|
||||
|
||||
./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 >/dev/null 2>&1
|
||||
./tjbench testout_tile.ppm 95 -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0 >/dev/null 2>&1
|
||||
md5/md5cmp $(MD5_PPM_420M_8x8_TILE) testout_tile_420_Q95_8x8.ppm
|
||||
for i in 16 32 64 128; do \
|
||||
md5/md5cmp $(MD5_PPM_420M_TILE) testout_tile_420_Q95_$$i\x$$i.ppm; \
|
||||
@@ -478,6 +485,9 @@ endif
|
||||
# x86-64 compilers)
|
||||
# FLOATTEST=64bit validate against the exepected results from the C code
|
||||
# when running on a 64-bit FPU
|
||||
# FLOATTEST=387 validate against the expected results from the C code when
|
||||
# the 387 FPU is being used for floating point math (which is
|
||||
# generally the default with x86 compilers)
|
||||
|
||||
# CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
|
||||
./cjpeg -sample 3x2 -dct float -prog -outfile testout_3x2_float_prog.jpg $(srcdir)/testimages/testorig.ppm
|
||||
@@ -485,6 +495,8 @@ endif
|
||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_SSE) testout_3x2_float_prog.jpg; \
|
||||
elif [ "${FLOATTEST}" = "32bit" -o "${FLOATTEST}" = "64bit" ]; then \
|
||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_32BIT) testout_3x2_float_prog.jpg; \
|
||||
elif [ "${FLOATTEST}" = "387" ]; then \
|
||||
md5/md5cmp $(MD5_JPEG_3x2_FLOAT_PROG_387) testout_3x2_float_prog.jpg; \
|
||||
fi
|
||||
# CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
|
||||
./djpeg -dct float -outfile testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||
@@ -494,6 +506,8 @@ endif
|
||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT_32BIT) testout_3x2_float.ppm; \
|
||||
elif [ "${FLOATTEST}" = "64bit" ]; then \
|
||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT_64BIT) testout_3x2_float.ppm; \
|
||||
elif [ "${FLOATTEST}" = "387" ]; then \
|
||||
md5/md5cmp $(MD5_PPM_3x2_FLOAT_387) testout_3x2_float.ppm; \
|
||||
fi
|
||||
rm -f testout_3x2_float.ppm testout_3x2_float_prog.jpg
|
||||
|
||||
@@ -683,6 +697,8 @@ testclean:
|
||||
rm -f *_411_*.ppm
|
||||
rm -f *_411_*.jpg
|
||||
rm -f *_411.yuv
|
||||
rm -f tjbenchtest*.log
|
||||
rm -f tjexampletest*.log
|
||||
|
||||
|
||||
tjtest:
|
||||
@@ -757,12 +773,12 @@ udmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
||||
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32}
|
||||
|
||||
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
||||
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||
sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||
|
||||
else
|
||||
|
||||
iosdmg: all pkgscripts/makemacpkg pkgscripts/uninstall
|
||||
sh pkgscripts/makemacpkg -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||
sh pkgscripts/makemacpkg -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S} -buildarmv8 ${BUILDDIRARMV8} -lipo "${LIPO}"
|
||||
|
||||
endif
|
||||
|
||||
|
||||
26
README.md
26
README.md
@@ -42,7 +42,7 @@ Using libjpeg-turbo
|
||||
libjpeg-turbo includes two APIs that can be used to compress and decompress
|
||||
JPEG images:
|
||||
|
||||
- **TurboJPEG API**
|
||||
- **TurboJPEG API**<br>
|
||||
This API provides an easy-to-use interface for compressing and decompressing
|
||||
JPEG images in memory. It also provides some functionality that would not be
|
||||
straightforward to achieve using the underlying libjpeg API, such as
|
||||
@@ -50,7 +50,7 @@ JPEG images:
|
||||
transforms on an image. The Java interface for libjpeg-turbo is written on
|
||||
top of the TurboJPEG API.
|
||||
|
||||
- **libjpeg API**
|
||||
- **libjpeg API**<br>
|
||||
This is the de facto industry-standard API for compressing and decompressing
|
||||
JPEG images. It is more difficult to use than the TurboJPEG API but also
|
||||
more powerful. The libjpeg API implementation in libjpeg-turbo is both
|
||||
@@ -141,17 +141,17 @@ which aren't.
|
||||
|
||||
#### Fully supported
|
||||
|
||||
- **libjpeg: IDCT scaling extensions in decompressor**
|
||||
- **libjpeg: IDCT scaling extensions in decompressor**<br>
|
||||
libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
|
||||
1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
|
||||
and 1/2 are SIMD-accelerated.)
|
||||
|
||||
- **libjpeg: Arithmetic coding**
|
||||
|
||||
- **libjpeg: In-memory source and destination managers**
|
||||
- **libjpeg: In-memory source and destination managers**<br>
|
||||
See notes below.
|
||||
|
||||
- **cjpeg: Separate quality settings for luminance and chrominance**
|
||||
- **cjpeg: Separate quality settings for luminance and chrominance**<br>
|
||||
Note that the libpjeg v7+ API was extended to accommodate this feature only
|
||||
for convenience purposes. It has always been possible to implement this
|
||||
feature with libjpeg v6b (see rdswitch.c for an example.)
|
||||
@@ -180,14 +180,14 @@ means of quality improvement. The reader is invited to peruse the research at
|
||||
but it is the general belief of our project that these features have not
|
||||
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
||||
|
||||
- **libjpeg: DCT scaling in compressor**
|
||||
- **libjpeg: DCT scaling in compressor**<br>
|
||||
`cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
|
||||
There is no technical reason why DCT scaling could not be supported when
|
||||
emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
|
||||
below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
|
||||
8/9 would be available, which is of limited usefulness.
|
||||
|
||||
- **libjpeg: SmartScale**
|
||||
- **libjpeg: SmartScale**<br>
|
||||
`cinfo.block_size` is silently ignored.
|
||||
SmartScale is an extension to the JPEG format that allows for DCT block
|
||||
sizes other than 8x8. Providing support for this new format would be
|
||||
@@ -200,15 +200,15 @@ demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
||||
interest in providing this feature would be as a means of supporting
|
||||
additional DCT scaling factors.
|
||||
|
||||
- **libjpeg: Fancy downsampling in compressor**
|
||||
- **libjpeg: Fancy downsampling in compressor**<br>
|
||||
`cinfo.do_fancy_downsampling` is silently ignored.
|
||||
This requires the DCT scaling feature, which is not supported.
|
||||
|
||||
- **jpegtran: Scaling**
|
||||
- **jpegtran: Scaling**<br>
|
||||
This requires both the DCT scaling and SmartScale features, which are not
|
||||
supported.
|
||||
|
||||
- **Lossless RGB JPEG files**
|
||||
- **Lossless RGB JPEG files**<br>
|
||||
This requires the SmartScale feature, which is not supported.
|
||||
|
||||
### What About libjpeg v9?
|
||||
@@ -226,7 +226,7 @@ generally accomplish anything that can't already be accomplished better with
|
||||
existing, standard lossless formats. Therefore, at this time it is our belief
|
||||
that there is not sufficient technical justification for software projects to
|
||||
upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
|
||||
echnical justification for us to emulate the libjpeg v9 ABI.
|
||||
technical justification for us to emulate the libjpeg v9 ABI.
|
||||
|
||||
In-Memory Source/Destination Managers
|
||||
-------------------------------------
|
||||
@@ -249,8 +249,8 @@ libjpeg-turbo. This will restore the pre-1.3 behavior, in which
|
||||
libjpeg v8 API/ABI.
|
||||
|
||||
On Un*x systems, including the in-memory source/destination managers changes
|
||||
the dynamic library version from 62.0.0 to 62.1.0 if using libjpeg v6b API/ABI
|
||||
emulation and from 7.0.0 to 7.1.0 if using libjpeg v7 API/ABI emulation.
|
||||
the dynamic library version from 62.1.0 to 62.2.0 if using libjpeg v6b API/ABI
|
||||
emulation and from 7.1.0 to 7.2.0 if using libjpeg v7 API/ABI emulation.
|
||||
|
||||
Note that, on most Un*x systems, the dynamic linker will not look for a
|
||||
function in a library until that function is actually used. Thus, if a program
|
||||
|
||||
33
acinclude.m4
33
acinclude.m4
@@ -252,3 +252,36 @@ AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[
|
||||
$2
|
||||
fi
|
||||
])
|
||||
|
||||
# AC_CHECK_ALTIVEC
|
||||
# ----------------
|
||||
# Test whether AltiVec intrinsics are supported
|
||||
AC_DEFUN([AC_CHECK_ALTIVEC],[
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -maltivec"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <altivec.h>
|
||||
int main(void) {
|
||||
__vector int vi = { 0, 0, 0, 0 };
|
||||
int i[4];
|
||||
vec_st(vi, 0, i);
|
||||
return i[0];
|
||||
}]])], ac_has_altivec=yes)
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
if test "x$ac_has_altivec" = "xyes" ; then
|
||||
$1
|
||||
else
|
||||
$2
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_NO_SIMD],[
|
||||
AC_MSG_RESULT([no ("$1")])
|
||||
with_simd=no;
|
||||
if test "x${require_simd}" = "xyes"; then
|
||||
AC_MSG_ERROR([SIMD support not available for this CPU.])
|
||||
else
|
||||
AC_MSG_WARN([SIMD support not available for this CPU. Performance will\
|
||||
suffer.])
|
||||
fi
|
||||
])
|
||||
|
||||
57
appveyor.yml
Normal file
57
appveyor.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
install:
|
||||
- cmd: >-
|
||||
mkdir c:\installers
|
||||
|
||||
mkdir c:\temp
|
||||
|
||||
curl -fSL -o c:\installers\nasm-2.10.01-win32.zip http://www.nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip
|
||||
|
||||
7z x c:\installers\nasm-2.10.01-win32.zip -oc:\ > c:\installers\nasm.install.log
|
||||
|
||||
set INCLUDE=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include
|
||||
|
||||
set LIB=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib\x64
|
||||
|
||||
set PATH=c:\nasm-2.10.01;c:\Program Files (x86)\NSIS;c:\msys64\mingw32\bin;c:\msys64\usr\bin;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\x64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin;%PATH%
|
||||
|
||||
set MSYSTEM=MINGW32
|
||||
|
||||
bash -c "pacman --noconfirm -S autoconf automake libtool zip"
|
||||
|
||||
mklink /d "%ProgramData%\Oracle\Java32" "c:\Program Files (x86)\Java\jdk1.6.0"
|
||||
|
||||
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git c:/buildscripts
|
||||
|
||||
build_script:
|
||||
- cmd: >-
|
||||
for /f %%i in ('"cygpath %CD%"') do set MINGWPATH=%%i
|
||||
|
||||
bash c:/buildscripts/buildljt -r file://%MINGWPATH% -b /c/ljt.nightly %APPVEYOR_REPO_BRANCH% -v
|
||||
|
||||
move c:\ljt.nightly\files\*.tar.gz .
|
||||
|
||||
move c:\ljt.nightly\files\*.exe .
|
||||
|
||||
move c:\ljt.nightly\files\*.zip .
|
||||
|
||||
move c:\ljt.nightly\log-windows.txt .
|
||||
|
||||
artifacts:
|
||||
- path: '*.tar.gz'
|
||||
name: Source tarball
|
||||
|
||||
- path: '*-gcc*.exe'
|
||||
name: SDK for MinGW
|
||||
|
||||
- path: '*-vc*.exe'
|
||||
name: SDK for Visual C++
|
||||
|
||||
- path: '*.zip'
|
||||
name: Windows JNI JARs
|
||||
|
||||
- path: 'log-windows.txt'
|
||||
name: Build log
|
||||
|
||||
test: off
|
||||
|
||||
deploy: off
|
||||
21
bmp.c
21
bmp.c
@@ -108,10 +108,14 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
|
||||
m=(m-k)/(1.0-k);
|
||||
y=(y-k)/(1.0-k);
|
||||
}
|
||||
if(c>1.0) c=1.0; if(c<0.) c=0.;
|
||||
if(m>1.0) m=1.0; if(m<0.) m=0.;
|
||||
if(y>1.0) y=1.0; if(y<0.) y=0.;
|
||||
if(k>1.0) k=1.0; if(k<0.) k=0.;
|
||||
if(c>1.0) c=1.0;
|
||||
if(c<0.) c=0.;
|
||||
if(m>1.0) m=1.0;
|
||||
if(m<0.) m=0.;
|
||||
if(y>1.0) y=1.0;
|
||||
if(y<0.) y=0.;
|
||||
if(k>1.0) k=1.0;
|
||||
if(k<0.) k=0.;
|
||||
*dstcolptr++=(unsigned char)(255.0-c*255.0+0.5);
|
||||
*dstcolptr++=(unsigned char)(255.0-m*255.0+0.5);
|
||||
*dstcolptr++=(unsigned char)(255.0-y*255.0+0.5);
|
||||
@@ -133,9 +137,12 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
|
||||
double r=c*k/255.;
|
||||
double g=m*k/255.;
|
||||
double b=y*k/255.;
|
||||
if(r>255.0) r=255.0; if(r<0.) r=0.;
|
||||
if(g>255.0) g=255.0; if(g<0.) g=0.;
|
||||
if(b>255.0) b=255.0; if(b<0.) b=0.;
|
||||
if(r>255.0) r=255.0;
|
||||
if(r<0.) r=0.;
|
||||
if(g>255.0) g=255.0;
|
||||
if(g<0.) g=0.;
|
||||
if(b>255.0) b=255.0;
|
||||
if(b<0.) b=0.;
|
||||
dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5);
|
||||
dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5);
|
||||
dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5);
|
||||
|
||||
12
cdjpeg.h
12
cdjpeg.h
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -54,6 +54,14 @@ struct djpeg_dest_struct {
|
||||
JDIMENSION rows_supplied);
|
||||
/* Finish up at the end of the image. */
|
||||
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
|
||||
/* Re-calculate buffer dimensions based on output dimensions (for use with
|
||||
partial image decompression.) If this is NULL, then the output format
|
||||
does not support partial image decompression (BMP and RLE, in particular,
|
||||
cannot support partial decompression because they use an inversion buffer
|
||||
to write the image in bottom-up order.) */
|
||||
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
|
||||
djpeg_dest_ptr dinfo);
|
||||
|
||||
|
||||
/* Target file spec; filled in by djpeg.c after object is created. */
|
||||
FILE *output_file;
|
||||
|
||||
BIN
ci/keys.enc
Normal file
BIN
ci/keys.enc
Normal file
Binary file not shown.
4
cjpeg.1
4
cjpeg.1
@@ -1,4 +1,4 @@
|
||||
.TH CJPEG 1 "17 February 2016"
|
||||
.TH CJPEG 1 "18 March 2017"
|
||||
.SH NAME
|
||||
cjpeg \- compress an image file to a JPEG file
|
||||
.SH SYNOPSIS
|
||||
@@ -202,7 +202,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||
number. For example,
|
||||
.B \-max 4m
|
||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
||||
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||
.TP
|
||||
.BI \-outfile " name"
|
||||
Send output image to the named file, not to standard output.
|
||||
|
||||
6
cjpeg.c
6
cjpeg.c
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2011 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2013-2014, D. R. Commander.
|
||||
* Copyright (C) 2010, 2013-2014, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -197,11 +197,11 @@ usage (void)
|
||||
fprintf(stderr, " -version Print version information and exit\n");
|
||||
fprintf(stderr, "Switches for wizards:\n");
|
||||
fprintf(stderr, " -baseline Force baseline quantization tables\n");
|
||||
fprintf(stderr, " -qtables file Use quantization tables given in file\n");
|
||||
fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
|
||||
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
||||
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
||||
fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
|
||||
#endif
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
24
cmakescripts/cmake_uninstall.cmake.in
Normal file
24
cmakescripts/cmake_uninstall.cmake.in
Normal file
@@ -0,0 +1,24 @@
|
||||
# This code is from the CMake FAQ
|
||||
|
||||
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
list(REVERSE files)
|
||||
foreach (file ${files})
|
||||
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
if (EXISTS "$ENV{DESTDIR}${file}")
|
||||
execute_process(
|
||||
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RESULT_VARIABLE rm_retval
|
||||
)
|
||||
if(NOT ${rm_retval} EQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
endif (NOT ${rm_retval} EQUAL 0)
|
||||
else (EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
||||
@@ -24,7 +24,12 @@ file(GLOB FILES
|
||||
*_440_*.png
|
||||
*_440_*.ppm
|
||||
*_440_*.jpg
|
||||
*_440.yuv)
|
||||
*_440.yuv
|
||||
*_411_*.bmp
|
||||
*_411_*.png
|
||||
*_411_*.ppm
|
||||
*_411_*.jpg
|
||||
*_411.yuv)
|
||||
|
||||
if(NOT FILES STREQUAL "")
|
||||
message(STATUS "Removing test files")
|
||||
|
||||
31
configure.ac
31
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.5.0])
|
||||
AC_INIT([libjpeg-turbo], [1.5.3])
|
||||
|
||||
AM_INIT_AUTOMAKE([-Wall foreign dist-bzip2])
|
||||
AC_PREFIX_DEFAULT(/opt/libjpeg-turbo)
|
||||
@@ -225,9 +225,9 @@ AC_SUBST(MEM_SRCDST_FUNCTIONS)
|
||||
AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
|
||||
|
||||
m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
|
||||
m4_define(version_major,m4_argn(1,version_triplet))
|
||||
m4_define(version_minor,m4_argn(2,version_triplet))
|
||||
m4_define(version_revision,m4_argn(3,version_triplet))
|
||||
m4_define(version_major,m4_car(m4_shiftn(1,[],version_triplet)))
|
||||
m4_define(version_minor,m4_car(m4_shiftn(2,[],version_triplet)))
|
||||
m4_define(version_revision,m4_car(m4_shiftn(3,[],version_triplet)))
|
||||
VERSION_MAJOR=version_major
|
||||
VERSION_MINOR=version_minor
|
||||
VERSION_REVISION=version_revision
|
||||
@@ -361,6 +361,7 @@ if test "x$JAVAC" = "x"; then
|
||||
fi
|
||||
AC_SUBST(JAVAC)
|
||||
AC_ARG_VAR(JAVACFLAGS, [Java compiler flags])
|
||||
JAVACFLAGS="$JAVACFLAGS -J-Dfile.encoding=UTF8"
|
||||
AC_SUBST(JAVACFLAGS)
|
||||
AC_ARG_VAR(JAR, [Java archive command (default: jar)])
|
||||
if test "x$JAR" = "x"; then
|
||||
@@ -517,17 +518,13 @@ if test "x${with_simd}" != "xno"; then
|
||||
fi
|
||||
;;
|
||||
powerpc*)
|
||||
AC_MSG_RESULT([yes (powerpc)])
|
||||
simd_arch=powerpc
|
||||
AC_CHECK_ALTIVEC(
|
||||
[AC_MSG_RESULT([yes (powerpc)])
|
||||
simd_arch=powerpc],
|
||||
[AC_NO_SIMD(PowerPC SPE)])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([no ("$host_cpu")])
|
||||
with_simd=no;
|
||||
if test "x${require_simd}" = "xyes"; then
|
||||
AC_MSG_ERROR([SIMD support not available for this CPU.])
|
||||
else
|
||||
AC_MSG_WARN([SIMD support not available for this CPU. Performance will suffer.])
|
||||
fi
|
||||
AC_NO_SIMD($host_cpu)
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -565,6 +562,14 @@ case "$host_cpu" in
|
||||
RPMARCH=i386
|
||||
DEBARCH=i386
|
||||
;;
|
||||
powerpc64le)
|
||||
RPMARCH=`uname -m`
|
||||
DEBARCH=ppc64el
|
||||
;;
|
||||
powerpc)
|
||||
RPMARCH=ppc
|
||||
DEBARCH=ppc
|
||||
;;
|
||||
*)
|
||||
RPMARCH=`uname -m`
|
||||
DEBARCH=$RPMARCH
|
||||
|
||||
7
djpeg.1
7
djpeg.1
@@ -1,4 +1,4 @@
|
||||
.TH DJPEG 1 "18 February 2016"
|
||||
.TH DJPEG 1 "13 November 2017"
|
||||
.SH NAME
|
||||
djpeg \- decompress a JPEG file to an image file
|
||||
.SH SYNOPSIS
|
||||
@@ -185,7 +185,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||
number. For example,
|
||||
.B \-max 4m
|
||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
||||
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||
.TP
|
||||
.BI \-outfile " name"
|
||||
Send output image to the named file, not to standard output.
|
||||
@@ -204,7 +204,8 @@ Decompress only a rectangular subregion of the image, starting at point X,Y
|
||||
with width W and height H. If necessary, X will be shifted left to the nearest
|
||||
iMCU boundary, and the width will be increased accordingly. Note that if
|
||||
decompression scaling is being used, then X, Y, W, and H are relative to the
|
||||
scaled image dimensions.
|
||||
scaled image dimensions. Currently this option only works with the
|
||||
PBMPLUS (PPM/PGM), GIF, and Targa output formats.
|
||||
.TP
|
||||
.B \-verbose
|
||||
Enable debug printout. More
|
||||
|
||||
11
djpeg.c
11
djpeg.c
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2013 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010-2011, 2013-2016, D. R. Commander.
|
||||
* Copyright (C) 2010-2011, 2013-2017, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "jversion.h" /* for version message */
|
||||
#include "jconfigint.h"
|
||||
#include "wrppm.h"
|
||||
|
||||
#include <ctype.h> /* to declare isprint() */
|
||||
|
||||
@@ -173,6 +172,7 @@ usage (void)
|
||||
|
||||
fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n");
|
||||
fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n");
|
||||
fprintf(stderr, " [requires PBMPLUS (PPM/PGM), GIF, or Targa output format]\n");
|
||||
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
||||
fprintf(stderr, " -version Print version information and exit\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -713,9 +713,10 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
|
||||
((ppm_dest_ptr) dest_mgr)->buffer_width = cinfo.output_width *
|
||||
cinfo.out_color_components *
|
||||
sizeof(JSAMPLE);
|
||||
if (dest_mgr->calc_buffer_dimensions)
|
||||
(*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
|
||||
else
|
||||
ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
|
||||
|
||||
/* Write output file header. This is a hack to ensure that the destination
|
||||
* manager creates an output image of the proper size.
|
||||
|
||||
@@ -455,7 +455,7 @@ Variables</h2></td></tr>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Disable buffer (re)allocation. </p>
|
||||
<p>If passed to <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> or <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a>, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG. </p>
|
||||
<p>If passed to one of the JPEG compression or transform functions, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -812,7 +812,7 @@ Variables</h2></td></tr>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Allocate an image buffer for use with TurboJPEG. </p>
|
||||
<p>You should always use this function to allocate the JPEG destination buffer(s) for <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> and <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a> unless you are disabling automatic buffer (re)allocation (by setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>.)</p>
|
||||
<p>You should always use this function to allocate the JPEG destination buffer(s) for the compression and transform functions unless you are disabling automatic buffer (re)allocation (by setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>.)</p>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">bytes</td><td>the number of bytes to allocate</td></tr>
|
||||
@@ -1008,13 +1008,13 @@ Variables</h2></td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||
</ol>
|
||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">jpegSubsamp</td><td>the level of chrominance subsampling to be used when generating the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
|
||||
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1106,12 +1106,12 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||
</ol>
|
||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1203,12 +1203,12 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.)</li>
|
||||
</ol>
|
||||
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1301,7 +1301,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
|
||||
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1394,7 +1394,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
|
||||
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1479,7 +1479,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this is <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the decompressed image is unpadded, else <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the decompressed image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. (NOTE: <code>scaledWidth</code> can be determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df" title="Compute the scaled value of dimension using the given scaling factor.">TJSCALED()</a> with the JPEG image width and one of the scaling factors returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8" title="Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of Tur...">tjGetScalingFactors()</a>.) You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>desired height (in pixels) of the destination image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size.</td></tr>
|
||||
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1629,7 +1629,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1708,7 +1708,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1826,7 +1826,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> to determine the appropriate size for this buffer based on the image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
|
||||
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
|
||||
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1919,7 +1919,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Use <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> to determine the appropriate size for each plane based on the image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
|
||||
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image.</td></tr>
|
||||
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1942,7 +1942,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Free an image buffer previously allocated by TurboJPEG. </p>
|
||||
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by <a class="el" href="group___turbo_j_p_e_g.html#gaf38f2ed44bdc88e730e08b632fa6e88e" title="Compress an RGB, grayscale, or CMYK image into a JPEG image.">tjCompress2()</a> or <a class="el" href="group___turbo_j_p_e_g.html#gad02cd42b69f193a0623a9c801788df3a" title="Losslessly transform a JPEG image into another JPEG image.">tjTransform()</a> or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
||||
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">buffer</td><td>address of the buffer to free</td></tr>
|
||||
@@ -2270,12 +2270,12 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n image buffers. <code>dstBufs[i]</code> will receive a JPEG image that has been transformed using the parameters in <code>transforms[i]</code>. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
|
||||
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
|
||||
<li>set <code>dstBufs[i]</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a> with the transformed or cropped width and height. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
|
||||
<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a> with the transformed or cropped width and height. Under normal circumstances, this should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded EXIF or ICC profile data) in which the output image will be larger than the worst-case size, and <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> cannot be used in those cases.</li>
|
||||
</ol>
|
||||
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr>
|
||||
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr>
|
||||
<tr><td class="paramname">transforms</td><td>pointer to an array of n <a class="el" href="structtjtransform.html" title="Lossless transform.">tjtransform</a> structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image.</td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr>
|
||||
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
code {
|
||||
color: #4665A2;
|
||||
color: #4665A2;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2014, 2016 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2014, 2016-2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,8 @@ import org.libjpegturbo.turbojpeg.*;
|
||||
|
||||
class TJBench {
|
||||
|
||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1;
|
||||
static boolean compOnly, decompOnly, doTile, doYUV, write;
|
||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1;
|
||||
static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
||||
|
||||
static final String[] pixFormatStr = {
|
||||
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
|
||||
@@ -55,7 +55,7 @@ class TJBench {
|
||||
|
||||
static TJScalingFactor sf;
|
||||
static int xformOp = TJTransform.OP_NONE, xformOpt = 0;
|
||||
static double benchTime = 5.0;
|
||||
static double benchTime = 5.0, warmup = 1.0;
|
||||
|
||||
|
||||
static final double getTime() {
|
||||
@@ -162,7 +162,7 @@ class TJBench {
|
||||
}
|
||||
|
||||
/* Benchmark */
|
||||
iter -= warmup;
|
||||
iter = -1;
|
||||
elapsed = elapsedDecode = 0.0;
|
||||
while (true) {
|
||||
int tile = 0;
|
||||
@@ -184,11 +184,14 @@ class TJBench {
|
||||
tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags);
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if (iter >= 1) {
|
||||
elapsed += getTime() - start;
|
||||
elapsed += getTime() - start;
|
||||
if (iter >= 0) {
|
||||
iter++;
|
||||
if (elapsed >= benchTime)
|
||||
break;
|
||||
} else if (elapsed >= warmup) {
|
||||
iter = 0;
|
||||
elapsed = elapsedDecode = 0.0;
|
||||
}
|
||||
}
|
||||
if(doYUV)
|
||||
@@ -321,7 +324,7 @@ class TJBench {
|
||||
}
|
||||
|
||||
/* Benchmark */
|
||||
iter = -warmup;
|
||||
iter = -1;
|
||||
elapsed = elapsedEncode = 0.0;
|
||||
while (true) {
|
||||
int tile = 0;
|
||||
@@ -346,11 +349,14 @@ class TJBench {
|
||||
totalJpegSize += jpegSize[tile];
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if (iter >= 1) {
|
||||
elapsed += getTime() - start;
|
||||
elapsed += getTime() - start;
|
||||
if (iter >= 0) {
|
||||
iter++;
|
||||
if (elapsed >= benchTime)
|
||||
break;
|
||||
} else if (elapsed >= warmup) {
|
||||
iter = 0;
|
||||
elapsed = elapsedEncode = 0.0;
|
||||
}
|
||||
}
|
||||
if (doYUV)
|
||||
@@ -541,17 +547,20 @@ class TJBench {
|
||||
}
|
||||
}
|
||||
|
||||
iter = -warmup;
|
||||
iter = -1;
|
||||
elapsed = 0.;
|
||||
while (true) {
|
||||
start = getTime();
|
||||
tjt.transform(jpegBuf, t, flags);
|
||||
jpegSize = tjt.getTransformedSizes();
|
||||
iter++;
|
||||
if (iter >= 1) {
|
||||
elapsed += getTime() - start;
|
||||
elapsed += getTime() - start;
|
||||
if (iter >= 0) {
|
||||
iter++;
|
||||
if (elapsed >= benchTime)
|
||||
break;
|
||||
} else if (elapsed >= warmup) {
|
||||
iter = 0;
|
||||
elapsed = 0.0;
|
||||
}
|
||||
}
|
||||
t = null;
|
||||
@@ -582,8 +591,8 @@ class TJBench {
|
||||
System.out.print("N/A N/A ");
|
||||
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
||||
jpegSize = new int[1];
|
||||
jpegBuf[0] = srcBuf;
|
||||
jpegSize[0] = srcSize;
|
||||
System.arraycopy(srcBuf, 0, jpegBuf[0], 0, srcSize);
|
||||
}
|
||||
|
||||
if (w == tilew)
|
||||
@@ -659,8 +668,9 @@ class TJBench {
|
||||
System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression");
|
||||
System.out.println(" test (can be combined with the other transforms above)");
|
||||
System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)");
|
||||
System.out.println("-warmup <w> = Execute each benchmark <w> times to prime the cache before");
|
||||
System.out.println(" taking performance measurements (default = 1)");
|
||||
System.out.println("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to");
|
||||
System.out.println(" starting the timer, in order to prime the caches and thus improve the");
|
||||
System.out.println(" consistency of the results.");
|
||||
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
|
||||
System.out.println("-nowrite = Do not write reference or output images (improves consistency");
|
||||
System.out.println(" of performance measurements.)\n");
|
||||
@@ -711,37 +721,37 @@ class TJBench {
|
||||
if (argv[i].equalsIgnoreCase("-tile")) {
|
||||
doTile = true; xformOpt |= TJTransform.OPT_CROP;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
System.out.println("Using fast upsampling code\n");
|
||||
flags |= TJ.FLAG_FASTUPSAMPLE;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm\n");
|
||||
flags |= TJ.FLAG_FASTDCT;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
System.out.println("Using most accurate DCT/IDCT algorithm\n");
|
||||
flags |= TJ.FLAG_ACCURATEDCT;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-rgb"))
|
||||
else if (argv[i].equalsIgnoreCase("-rgb"))
|
||||
pf = TJ.PF_RGB;
|
||||
if (argv[i].equalsIgnoreCase("-rgbx"))
|
||||
else if (argv[i].equalsIgnoreCase("-rgbx"))
|
||||
pf = TJ.PF_RGBX;
|
||||
if (argv[i].equalsIgnoreCase("-bgr"))
|
||||
else if (argv[i].equalsIgnoreCase("-bgr"))
|
||||
pf = TJ.PF_BGR;
|
||||
if (argv[i].equalsIgnoreCase("-bgrx"))
|
||||
else if (argv[i].equalsIgnoreCase("-bgrx"))
|
||||
pf = TJ.PF_BGRX;
|
||||
if (argv[i].equalsIgnoreCase("-xbgr"))
|
||||
else if (argv[i].equalsIgnoreCase("-xbgr"))
|
||||
pf = TJ.PF_XBGR;
|
||||
if (argv[i].equalsIgnoreCase("-xrgb"))
|
||||
else if (argv[i].equalsIgnoreCase("-xrgb"))
|
||||
pf = TJ.PF_XRGB;
|
||||
if (argv[i].equalsIgnoreCase("-bottomup"))
|
||||
else if (argv[i].equalsIgnoreCase("-bottomup"))
|
||||
flags |= TJ.FLAG_BOTTOMUP;
|
||||
if (argv[i].equalsIgnoreCase("-quiet"))
|
||||
else if (argv[i].equalsIgnoreCase("-quiet"))
|
||||
quiet = 1;
|
||||
if (argv[i].equalsIgnoreCase("-qq"))
|
||||
else if (argv[i].equalsIgnoreCase("-qq"))
|
||||
quiet = 2;
|
||||
if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) {
|
||||
else if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) {
|
||||
int temp1 = 0, temp2 = 0;
|
||||
boolean match = false, scanned = true;
|
||||
Scanner scanner = new Scanner(argv[++i]).useDelimiter("/");
|
||||
@@ -764,25 +774,25 @@ class TJBench {
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
else if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
xformOp = TJTransform.OP_HFLIP;
|
||||
if (argv[i].equalsIgnoreCase("-vflip"))
|
||||
else if (argv[i].equalsIgnoreCase("-vflip"))
|
||||
xformOp = TJTransform.OP_VFLIP;
|
||||
if (argv[i].equalsIgnoreCase("-transpose"))
|
||||
else if (argv[i].equalsIgnoreCase("-transpose"))
|
||||
xformOp = TJTransform.OP_TRANSPOSE;
|
||||
if (argv[i].equalsIgnoreCase("-transverse"))
|
||||
else if (argv[i].equalsIgnoreCase("-transverse"))
|
||||
xformOp = TJTransform.OP_TRANSVERSE;
|
||||
if (argv[i].equalsIgnoreCase("-rot90"))
|
||||
else if (argv[i].equalsIgnoreCase("-rot90"))
|
||||
xformOp = TJTransform.OP_ROT90;
|
||||
if (argv[i].equalsIgnoreCase("-rot180"))
|
||||
else if (argv[i].equalsIgnoreCase("-rot180"))
|
||||
xformOp = TJTransform.OP_ROT180;
|
||||
if (argv[i].equalsIgnoreCase("-rot270"))
|
||||
else if (argv[i].equalsIgnoreCase("-rot270"))
|
||||
xformOp = TJTransform.OP_ROT270;
|
||||
if (argv[i].equalsIgnoreCase("-grayscale"))
|
||||
else if (argv[i].equalsIgnoreCase("-grayscale"))
|
||||
xformOpt |= TJTransform.OPT_GRAY;
|
||||
if (argv[i].equalsIgnoreCase("-nooutput"))
|
||||
else if (argv[i].equalsIgnoreCase("-nooutput"))
|
||||
xformOpt |= TJTransform.OPT_NOOUTPUT;
|
||||
if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) {
|
||||
else if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) {
|
||||
double temp = -1;
|
||||
try {
|
||||
temp = Double.parseDouble(argv[++i]);
|
||||
@@ -792,11 +802,11 @@ class TJBench {
|
||||
else
|
||||
usage();
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
else if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
System.out.println("Testing YUV planar encoding/decoding\n");
|
||||
doYUV = true;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
|
||||
else if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
|
||||
int temp = 0;
|
||||
try {
|
||||
temp = Integer.parseInt(argv[++i]);
|
||||
@@ -804,7 +814,7 @@ class TJBench {
|
||||
if (temp >= 1)
|
||||
yuvpad = temp;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
|
||||
else if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
|
||||
i++;
|
||||
if (argv[i].toUpperCase().startsWith("G"))
|
||||
subsamp = TJ.SAMP_GRAY;
|
||||
@@ -819,22 +829,22 @@ class TJBench {
|
||||
else if (argv[i].equals("411"))
|
||||
subsamp = TJ.SAMP_411;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-componly"))
|
||||
else if (argv[i].equalsIgnoreCase("-componly"))
|
||||
compOnly = true;
|
||||
if (argv[i].equalsIgnoreCase("-nowrite"))
|
||||
else if (argv[i].equalsIgnoreCase("-nowrite"))
|
||||
write = false;
|
||||
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
|
||||
int temp = -1;
|
||||
else if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
|
||||
double temp = -1;
|
||||
try {
|
||||
temp = Integer.parseInt(argv[++i]);
|
||||
temp = Double.parseDouble(argv[++i]);
|
||||
} catch (NumberFormatException e) {}
|
||||
if (temp >= 0) {
|
||||
if (temp >= 0.0) {
|
||||
warmup = temp;
|
||||
System.out.format("Warmup runs = %d\n\n", warmup);
|
||||
}
|
||||
System.out.format("Warmup time = %.1f seconds\n\n", warmup);
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-?"))
|
||||
usage();
|
||||
else usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C)2011-2012, 2014-2015 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -94,7 +95,7 @@ public class TJExample implements TJCustomFilter {
|
||||
}
|
||||
|
||||
private static final String[] sampName = {
|
||||
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0"
|
||||
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1"
|
||||
};
|
||||
|
||||
public static void main(String[] argv) {
|
||||
@@ -117,114 +118,114 @@ public class TJExample implements TJCustomFilter {
|
||||
int outSubsamp = -1, outQual = 95;
|
||||
boolean display = false;
|
||||
|
||||
if (argv.length > 1) {
|
||||
for (int i = 1; i < argv.length; i++) {
|
||||
if (argv[i].length() < 2)
|
||||
continue;
|
||||
if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 3).equalsIgnoreCase("-sc")) {
|
||||
int match = 0;
|
||||
if (i < argv.length - 1) {
|
||||
String[] scaleArg = argv[++i].split("/");
|
||||
if (scaleArg.length == 2) {
|
||||
TJScalingFactor tempsf =
|
||||
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
|
||||
Integer.parseInt(scaleArg[1]));
|
||||
for (int j = 0; j < sf.length; j++) {
|
||||
if (tempsf.equals(sf[j])) {
|
||||
scaleFactor = sf[j];
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
if (argv[1].substring(0, 2).equalsIgnoreCase("-d"))
|
||||
display = true;
|
||||
|
||||
for (int i = 2; i < argv.length; i++) {
|
||||
if (argv[i].length() < 2)
|
||||
continue;
|
||||
else if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 3).equalsIgnoreCase("-sc")) {
|
||||
int match = 0;
|
||||
if (i < argv.length - 1) {
|
||||
String[] scaleArg = argv[++i].split("/");
|
||||
if (scaleArg.length == 2) {
|
||||
TJScalingFactor tempsf =
|
||||
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
|
||||
Integer.parseInt(scaleArg[1]));
|
||||
for (int j = 0; j < sf.length; j++) {
|
||||
if (tempsf.equals(sf[j])) {
|
||||
scaleFactor = sf[j];
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match != 1) usage();
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-h") || argv[i].equalsIgnoreCase("-?"))
|
||||
usage();
|
||||
if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
|
||||
if (i < argv.length - 1) {
|
||||
i++;
|
||||
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
|
||||
outSubsamp = TJ.SAMP_GRAY;
|
||||
else if (argv[i].equals("444"))
|
||||
outSubsamp = TJ.SAMP_444;
|
||||
else if (argv[i].equals("422"))
|
||||
outSubsamp = TJ.SAMP_422;
|
||||
else if (argv[i].equals("420"))
|
||||
outSubsamp = TJ.SAMP_420;
|
||||
else
|
||||
usage();
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
|
||||
if (i < argv.length - 1) {
|
||||
int qual = Integer.parseInt(argv[++i]);
|
||||
if (qual >= 1 && qual <= 100)
|
||||
outQual = qual;
|
||||
else
|
||||
usage();
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
|
||||
xform.options |= TJTransform.OPT_GRAY;
|
||||
if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
xform.op = TJTransform.OP_HFLIP;
|
||||
if (argv[i].equalsIgnoreCase("-vflip"))
|
||||
xform.op = TJTransform.OP_VFLIP;
|
||||
if (argv[i].equalsIgnoreCase("-transpose"))
|
||||
xform.op = TJTransform.OP_TRANSPOSE;
|
||||
if (argv[i].equalsIgnoreCase("-transverse"))
|
||||
xform.op = TJTransform.OP_TRANSVERSE;
|
||||
if (argv[i].equalsIgnoreCase("-rot90"))
|
||||
xform.op = TJTransform.OP_ROT90;
|
||||
if (argv[i].equalsIgnoreCase("-rot180"))
|
||||
xform.op = TJTransform.OP_ROT180;
|
||||
if (argv[i].equalsIgnoreCase("-rot270"))
|
||||
xform.op = TJTransform.OP_ROT270;
|
||||
if (argv[i].equalsIgnoreCase("-custom"))
|
||||
xform.cf = new TJExample();
|
||||
else if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
|
||||
if (i >= argv.length - 1)
|
||||
usage();
|
||||
String[] cropArg = argv[++i].split(",");
|
||||
if (cropArg.length != 3)
|
||||
usage();
|
||||
String[] dimArg = cropArg[2].split("[xX]");
|
||||
if (dimArg.length != 2)
|
||||
usage();
|
||||
int tempx = Integer.parseInt(cropArg[0]);
|
||||
int tempy = Integer.parseInt(cropArg[1]);
|
||||
int tempw = Integer.parseInt(dimArg[0]);
|
||||
int temph = Integer.parseInt(dimArg[1]);
|
||||
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
|
||||
usage();
|
||||
xform.x = tempx;
|
||||
xform.y = tempy;
|
||||
xform.width = tempw;
|
||||
xform.height = temph;
|
||||
xform.options |= TJTransform.OPT_CROP;
|
||||
}
|
||||
if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
|
||||
display = true;
|
||||
if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
System.out.println("Using fast upsampling code");
|
||||
flags |= TJ.FLAG_FASTUPSAMPLE;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_FASTDCT;
|
||||
}
|
||||
if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
System.out.println("Using most accurate DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_ACCURATEDCT;
|
||||
}
|
||||
if (match != 1) usage();
|
||||
}
|
||||
else if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
|
||||
if (i < argv.length - 1) {
|
||||
i++;
|
||||
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
|
||||
outSubsamp = TJ.SAMP_GRAY;
|
||||
else if (argv[i].equals("444"))
|
||||
outSubsamp = TJ.SAMP_444;
|
||||
else if (argv[i].equals("422"))
|
||||
outSubsamp = TJ.SAMP_422;
|
||||
else if (argv[i].equals("420"))
|
||||
outSubsamp = TJ.SAMP_420;
|
||||
else
|
||||
usage();
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
|
||||
if (i < argv.length - 1) {
|
||||
int qual = Integer.parseInt(argv[++i]);
|
||||
if (qual >= 1 && qual <= 100)
|
||||
outQual = qual;
|
||||
else
|
||||
usage();
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
else if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
|
||||
xform.options |= TJTransform.OPT_GRAY;
|
||||
else if (argv[i].equalsIgnoreCase("-hflip"))
|
||||
xform.op = TJTransform.OP_HFLIP;
|
||||
else if (argv[i].equalsIgnoreCase("-vflip"))
|
||||
xform.op = TJTransform.OP_VFLIP;
|
||||
else if (argv[i].equalsIgnoreCase("-transpose"))
|
||||
xform.op = TJTransform.OP_TRANSPOSE;
|
||||
else if (argv[i].equalsIgnoreCase("-transverse"))
|
||||
xform.op = TJTransform.OP_TRANSVERSE;
|
||||
else if (argv[i].equalsIgnoreCase("-rot90"))
|
||||
xform.op = TJTransform.OP_ROT90;
|
||||
else if (argv[i].equalsIgnoreCase("-rot180"))
|
||||
xform.op = TJTransform.OP_ROT180;
|
||||
else if (argv[i].equalsIgnoreCase("-rot270"))
|
||||
xform.op = TJTransform.OP_ROT270;
|
||||
else if (argv[i].equalsIgnoreCase("-custom"))
|
||||
xform.cf = new TJExample();
|
||||
else if (argv[i].length() > 2 &&
|
||||
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
|
||||
if (i >= argv.length - 1)
|
||||
usage();
|
||||
String[] cropArg = argv[++i].split(",");
|
||||
if (cropArg.length != 3)
|
||||
usage();
|
||||
String[] dimArg = cropArg[2].split("[xX]");
|
||||
if (dimArg.length != 2)
|
||||
usage();
|
||||
int tempx = Integer.parseInt(cropArg[0]);
|
||||
int tempy = Integer.parseInt(cropArg[1]);
|
||||
int tempw = Integer.parseInt(dimArg[0]);
|
||||
int temph = Integer.parseInt(dimArg[1]);
|
||||
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
|
||||
usage();
|
||||
xform.x = tempx;
|
||||
xform.y = tempy;
|
||||
xform.width = tempw;
|
||||
xform.height = temph;
|
||||
xform.options |= TJTransform.OPT_CROP;
|
||||
}
|
||||
else if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
|
||||
display = true;
|
||||
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
|
||||
System.out.println("Using fast upsampling code");
|
||||
flags |= TJ.FLAG_FASTUPSAMPLE;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-fastdct")) {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_FASTDCT;
|
||||
}
|
||||
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
|
||||
System.out.println("Using most accurate DCT/IDCT algorithm");
|
||||
flags |= TJ.FLAG_ACCURATEDCT;
|
||||
}
|
||||
else usage();
|
||||
}
|
||||
String[] inFileTokens = argv[0].split("\\.");
|
||||
if (inFileTokens.length > 1)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011-2016 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011-2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -44,10 +44,10 @@ public class TJUnitTest {
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("\nUSAGE: java " + classname + " [options]\n");
|
||||
System.out.println("Options:\n");
|
||||
System.out.println("-yuv = test YUV encoding/decoding support\n");
|
||||
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
|
||||
System.out.println(" 4-byte boundary\n");
|
||||
System.out.println("Options:");
|
||||
System.out.println("-yuv = test YUV encoding/decoding support");
|
||||
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest");
|
||||
System.out.println(" 4-byte boundary");
|
||||
System.out.println("-bi = test BufferedImage support\n");
|
||||
System.exit(1);
|
||||
}
|
||||
@@ -109,21 +109,12 @@ public class TJUnitTest {
|
||||
case BufferedImage.TYPE_BYTE_GRAY:
|
||||
return TJ.PF_GRAY;
|
||||
case BufferedImage.TYPE_INT_BGR:
|
||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||
return TJ.PF_XBGR;
|
||||
else
|
||||
return TJ.PF_RGBX;
|
||||
return TJ.PF_RGBX;
|
||||
case BufferedImage.TYPE_INT_RGB:
|
||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||
return TJ.PF_XRGB;
|
||||
else
|
||||
return TJ.PF_BGRX;
|
||||
return TJ.PF_BGRX;
|
||||
case BufferedImage.TYPE_INT_ARGB:
|
||||
case BufferedImage.TYPE_INT_ARGB_PRE:
|
||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||
return TJ.PF_ARGB;
|
||||
else
|
||||
return TJ.PF_BGRA;
|
||||
return TJ.PF_BGRA;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -911,15 +902,13 @@ public class TJUnitTest {
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
if (argv[i].equalsIgnoreCase("-yuv"))
|
||||
doYUV = true;
|
||||
if (argv[i].equalsIgnoreCase("-noyuvpad"))
|
||||
else if (argv[i].equalsIgnoreCase("-noyuvpad"))
|
||||
pad = 1;
|
||||
if (argv[i].substring(0, 1).equalsIgnoreCase("-h") ||
|
||||
argv[i].equalsIgnoreCase("-?"))
|
||||
usage();
|
||||
if (argv[i].equalsIgnoreCase("-bi")) {
|
||||
else if (argv[i].equalsIgnoreCase("-bi")) {
|
||||
bi = true;
|
||||
testName = "javabitest";
|
||||
}
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
if (doYUV)
|
||||
_4byteFormats[4] = -1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2014, 2017 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -220,10 +220,13 @@ public class YUVImage {
|
||||
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
||||
|
||||
int nc = (subsamp == TJ.SAMP_GRAY ? 1 : 3);
|
||||
if (planes.length != nc || (offsets != null && offsets.length != nc) ||
|
||||
if ((planes != null && planes.length != nc) ||
|
||||
(offsets != null && offsets.length != nc) ||
|
||||
(strides != null && strides.length != nc))
|
||||
throw new IllegalArgumentException("YUVImage::setBuf(): planes, offsets, or strides array is the wrong size");
|
||||
|
||||
if (planes == null)
|
||||
planes = new byte[nc][];
|
||||
if (offsets == null)
|
||||
offsets = new int[nc];
|
||||
if (strides == null)
|
||||
|
||||
@@ -216,7 +216,7 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
|
||||
#endif
|
||||
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
|
||||
|
||||
if(r <= 16) return 0;
|
||||
if (r <= 16) return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/* libjpeg-turbo build number */
|
||||
#undef BUILD
|
||||
|
||||
/* Compiler's inline keyword */
|
||||
#undef inline
|
||||
|
||||
/* How to obtain function inlining. */
|
||||
#undef INLINE
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ int main(void)
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
jerr.pub.output_message = my_output_message;
|
||||
|
||||
if(setjmp(jerr.jb)) {
|
||||
if (setjmp(jerr.jb)) {
|
||||
/* this will execute if libjpeg has an error */
|
||||
jcs_valid = 0;
|
||||
goto done;
|
||||
@@ -104,7 +104,7 @@ int main(void)
|
||||
printf(" Not present at compile time\n");
|
||||
#endif
|
||||
|
||||
if(setjmp(jerr.jb)) {
|
||||
if (setjmp(jerr.jb)) {
|
||||
/* this will execute if libjpeg has an error */
|
||||
jcs_alpha_valid = 0;
|
||||
goto done2;
|
||||
|
||||
33
jdapistd.c
33
jdapistd.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2015-2016, D. R. Commander.
|
||||
* Copyright (C) 2010, 2015-2017, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -190,7 +190,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
* single-pass decompression case, allowing us to use the same MCU column
|
||||
* width for all of the components.
|
||||
*/
|
||||
align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
|
||||
if (cinfo->comps_in_scan == 1 && cinfo->num_components == 1)
|
||||
align = cinfo->_min_DCT_scaled_size;
|
||||
else
|
||||
align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
|
||||
|
||||
/* Adjust xoffset to the nearest iMCU boundary <= the requested value */
|
||||
input_xoffset = *xoffset;
|
||||
@@ -215,6 +218,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
int hsf = (cinfo->comps_in_scan == 1 && cinfo->num_components == 1) ?
|
||||
1 : compptr->h_samp_factor;
|
||||
|
||||
/* Set downsampled_width to the new output width. */
|
||||
orig_downsampled_width = compptr->downsampled_width;
|
||||
compptr->downsampled_width =
|
||||
@@ -228,11 +234,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||
* values will be used in multi-scan decompressions.
|
||||
*/
|
||||
cinfo->master->first_MCU_col[ci] =
|
||||
(JDIMENSION) (long) (*xoffset * compptr->h_samp_factor) /
|
||||
(long) align;
|
||||
(JDIMENSION) (long) (*xoffset * hsf) / (long) align;
|
||||
cinfo->master->last_MCU_col[ci] =
|
||||
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
|
||||
compptr->h_samp_factor),
|
||||
hsf),
|
||||
(long) align) - 1;
|
||||
}
|
||||
|
||||
@@ -293,6 +298,14 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
}
|
||||
|
||||
|
||||
/* Dummy quantize function used by jpeg_skip_scanlines() */
|
||||
LOCAL(void)
|
||||
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* In some cases, it is best to call jpeg_read_scanlines() and discard the
|
||||
* output, rather than skipping the scanlines, because this allows us to
|
||||
@@ -308,14 +321,22 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows);
|
||||
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||
JSAMPARRAY output_buf, int num_rows) = NULL;
|
||||
|
||||
color_convert = cinfo->cconvert->color_convert;
|
||||
cinfo->cconvert->color_convert = noop_convert;
|
||||
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
|
||||
color_quantize = cinfo->cquantize->color_quantize;
|
||||
cinfo->cquantize->color_quantize = noop_quantize;
|
||||
}
|
||||
|
||||
for (n = 0; n < num_lines; n++)
|
||||
jpeg_read_scanlines(cinfo, NULL, 1);
|
||||
|
||||
cinfo->cconvert->color_convert = color_convert;
|
||||
if (color_quantize)
|
||||
cinfo->cquantize->color_quantize = color_quantize;
|
||||
}
|
||||
|
||||
|
||||
@@ -370,6 +391,8 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
/* Do not skip past the bottom of the image. */
|
||||
if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
|
||||
cinfo->output_scanline = cinfo->output_height;
|
||||
(*cinfo->inputctl->finish_input_pass) (cinfo);
|
||||
cinfo->inputctl->eoi_reached = TRUE;
|
||||
return cinfo->output_height - cinfo->output_scanline;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Developed 1997-2015 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "jpeglib.h"
|
||||
|
||||
|
||||
#define NEG_1 ((unsigned int)-1)
|
||||
|
||||
|
||||
/* Expanded entropy decoder object for arithmetic decoding. */
|
||||
|
||||
typedef struct {
|
||||
@@ -382,7 +385,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (arith_decode(cinfo, st)) v |= m;
|
||||
v += 1; if (sign) v = -v;
|
||||
/* Scale and output coefficient in natural (dezigzagged) order */
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) (v << cinfo->Al);
|
||||
(*block)[jpeg_natural_order[k]] = (JCOEF) ((unsigned)v << cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -450,7 +453,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
|
||||
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
|
||||
/* Establish EOBx (previous stage end-of-block) index */
|
||||
for (kex = cinfo->Se; kex > 0; kex--)
|
||||
|
||||
@@ -130,7 +130,7 @@ term_mem_destination (j_compress_ptr cinfo)
|
||||
{
|
||||
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
|
||||
if(dest->alloc) *dest->outbuffer = dest->buffer;
|
||||
if (dest->alloc) *dest->outbuffer = dest->buffer;
|
||||
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ static const JLONG dither_matrix[4] = {
|
||||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
if (*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
4
jdhuff.c
4
jdhuff.c
@@ -109,9 +109,9 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
actbl = compptr->ac_tbl_no;
|
||||
/* Compute derived values for Huffman tables */
|
||||
/* We may do this more than once for a table, but it's not expensive */
|
||||
pdtbl = entropy->dc_derived_tbls + dctbl;
|
||||
pdtbl = (d_derived_tbl **)(entropy->dc_derived_tbls) + dctbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, pdtbl);
|
||||
pdtbl = entropy->ac_derived_tbls + actbl;
|
||||
pdtbl = (d_derived_tbl **)(entropy->ac_derived_tbls) + actbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, pdtbl);
|
||||
/* Initialize DC predictions to 0 */
|
||||
entropy->saved.last_dc_val[ci] = 0;
|
||||
|
||||
12
jdmaster.c
12
jdmaster.c
@@ -22,6 +22,7 @@
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
#include "jdmaster.h"
|
||||
#include "jsimd.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -69,6 +70,17 @@ use_merged_upsample (j_decompress_ptr cinfo)
|
||||
cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
|
||||
cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
|
||||
return FALSE;
|
||||
#ifdef WITH_SIMD
|
||||
/* If YCbCr-to-RGB color conversion is SIMD-accelerated but merged upsampling
|
||||
isn't, then disabling merged upsampling is likely to be faster when
|
||||
decompressing YCbCr JPEG images. */
|
||||
if (!jsimd_can_h2v2_merged_upsample() && !jsimd_can_h2v1_merged_upsample() &&
|
||||
jsimd_can_ycc_rgb() && cinfo->jpeg_color_space == JCS_YCbCr &&
|
||||
(cinfo->out_color_space == JCS_RGB ||
|
||||
(cinfo->out_color_space >= JCS_EXT_RGB &&
|
||||
cinfo->out_color_space <= JCS_EXT_ARGB)))
|
||||
return FALSE;
|
||||
#endif
|
||||
/* ??? also need to test for upsample-time rescaling, when & if supported */
|
||||
return TRUE; /* by golly, it'll work... */
|
||||
#else
|
||||
|
||||
@@ -503,7 +503,7 @@ static const JLONG dither_matrix[4] = {
|
||||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
if (*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -170,12 +170,12 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
|
||||
if (is_DC_band) {
|
||||
if (cinfo->Ah == 0) { /* DC refinement needs no table */
|
||||
tbl = compptr->dc_tbl_no;
|
||||
pdtbl = entropy->derived_tbls + tbl;
|
||||
pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, pdtbl);
|
||||
}
|
||||
} else {
|
||||
tbl = compptr->ac_tbl_no;
|
||||
pdtbl = entropy->derived_tbls + tbl;
|
||||
pdtbl = (d_derived_tbl **)(entropy->derived_tbls) + tbl;
|
||||
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, pdtbl);
|
||||
/* remember the single active table */
|
||||
entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
|
||||
|
||||
47
jdsample.c
47
jdsample.c
@@ -303,6 +303,48 @@ h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fancy processing for 1:1 horizontal and 2:1 vertical (4:4:0 subsampling).
|
||||
*
|
||||
* This is a less common case, but it can be encountered when losslessly
|
||||
* rotating/transposing a JPEG file that uses 4:2:2 chroma subsampling.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h1v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
JSAMPROW inptr0, inptr1, outptr;
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
int thiscolsum;
|
||||
#else
|
||||
JLONG thiscolsum;
|
||||
#endif
|
||||
JDIMENSION colctr;
|
||||
int inrow, outrow, v;
|
||||
|
||||
inrow = outrow = 0;
|
||||
while (outrow < cinfo->max_v_samp_factor) {
|
||||
for (v = 0; v < 2; v++) {
|
||||
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
||||
inptr0 = input_data[inrow];
|
||||
if (v == 0) /* next nearest is row above */
|
||||
inptr1 = input_data[inrow-1];
|
||||
else /* next nearest is row below */
|
||||
inptr1 = input_data[inrow+1];
|
||||
outptr = output_data[outrow++];
|
||||
|
||||
for(colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||
*outptr++ = (JSAMPLE) ((thiscolsum + 1) >> 2);
|
||||
}
|
||||
}
|
||||
inrow++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
|
||||
* Again a triangle filter; see comments for h2v1 case, above.
|
||||
@@ -431,6 +473,11 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
||||
else
|
||||
upsample->methods[ci] = h2v1_upsample;
|
||||
}
|
||||
} else if (h_in_group == h_out_group &&
|
||||
v_in_group * 2 == v_out_group && do_fancy) {
|
||||
/* Non-fancy upsampling is handled by the generic method */
|
||||
upsample->methods[ci] = h1v2_fancy_upsample;
|
||||
upsample->pub.need_context_rows = TRUE;
|
||||
} else if (h_in_group * 2 == h_out_group &&
|
||||
v_in_group * 2 == v_out_group) {
|
||||
/* Special cases for 2h2v upsampling */
|
||||
|
||||
20
jmemmgr.c
20
jmemmgr.c
@@ -32,6 +32,10 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jmemsys.h" /* import the system-dependent declarations */
|
||||
#ifndef _WIN32
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef NO_GETENV
|
||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
|
||||
@@ -650,18 +654,26 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
maximum_space += (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * sizeof(JSAMPLE);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 10);
|
||||
maximum_space += new_space;
|
||||
}
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
size_t new_space = (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
maximum_space += (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * sizeof(JBLOCK);
|
||||
if (SIZE_MAX - maximum_space < new_space)
|
||||
out_of_memory(cinfo, 11);
|
||||
maximum_space += new_space;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
jmemnobs.c
16
jmemnobs.c
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -15,7 +15,6 @@
|
||||
* This is very portable in the sense that it'll compile on almost anything,
|
||||
* but you'd better have lots of main memory (or virtual memory) if you want
|
||||
* to process big images.
|
||||
* Note that the max_memory_to_use option is ignored by this implementation.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@@ -66,14 +65,21 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
|
||||
|
||||
/*
|
||||
* This routine computes the total memory space available for allocation.
|
||||
* Here we always say, "we got all you want bud!"
|
||||
*/
|
||||
|
||||
GLOBAL(size_t)
|
||||
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
|
||||
size_t max_bytes_needed, size_t already_allocated)
|
||||
{
|
||||
return max_bytes_needed;
|
||||
if (cinfo->mem->max_memory_to_use) {
|
||||
if (cinfo->mem->max_memory_to_use > already_allocated)
|
||||
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||
else
|
||||
return 0;
|
||||
} else {
|
||||
/* Here we always say, "we got all you want bud!" */
|
||||
return max_bytes_needed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -155,8 +155,8 @@ struct jpeg_decomp_master {
|
||||
/* Partial decompression variables */
|
||||
JDIMENSION first_iMCU_col;
|
||||
JDIMENSION last_iMCU_col;
|
||||
JDIMENSION first_MCU_col[MAX_COMPS_IN_SCAN];
|
||||
JDIMENSION last_MCU_col[MAX_COMPS_IN_SCAN];
|
||||
JDIMENSION first_MCU_col[MAX_COMPONENTS];
|
||||
JDIMENSION last_MCU_col[MAX_COMPONENTS];
|
||||
boolean jinit_upsampler_no_alloc;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH JPEGTRAN 1 "18 February 2016"
|
||||
.TH JPEGTRAN 1 "18 March 2017"
|
||||
.SH NAME
|
||||
jpegtran \- lossless transformation of JPEG files
|
||||
.SH SYNOPSIS
|
||||
@@ -222,7 +222,7 @@ Set limit for amount of memory to use in processing large images. Value is
|
||||
in thousands of bytes, or millions of bytes if "M" is attached to the
|
||||
number. For example,
|
||||
.B \-max 4m
|
||||
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
||||
selects 4000000 bytes. If more space is needed, an error will occur.
|
||||
.TP
|
||||
.BI \-outfile " name"
|
||||
Send output image to the named file, not to standard output.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2014, D. R. Commander.
|
||||
* Copyright (C) 2010, 2014, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -90,7 +90,7 @@ usage (void)
|
||||
fprintf(stderr, " -version Print version information and exit\n");
|
||||
fprintf(stderr, "Switches for wizards:\n");
|
||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
||||
fprintf(stderr, " -scans FILE Create multi-scan JPEG per script FILE\n");
|
||||
#endif
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2012-2016, D. R. Commander.
|
||||
* Copyright (C) 2010, 2012-2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -35,7 +35,7 @@
|
||||
* their code
|
||||
*/
|
||||
|
||||
#define JCOPYRIGHT "Copyright (C) 2009-2016 D. R. Commander\n" \
|
||||
#define JCOPYRIGHT "Copyright (C) 2009-2017 D. R. Commander\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
|
||||
"Copyright (C) 2015 Google, Inc.\n" \
|
||||
@@ -46,4 +46,4 @@
|
||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \
|
||||
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2016 The libjpeg-turbo Project and many others"
|
||||
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2017 The libjpeg-turbo Project and many others"
|
||||
|
||||
15
libjpeg.txt
15
libjpeg.txt
@@ -3,7 +3,7 @@ USING THE IJG JPEG LIBRARY
|
||||
This file was part of the Independent JPEG Group's software:
|
||||
Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
|
||||
libjpeg-turbo Modifications:
|
||||
Copyright (C) 2010, 2014-2016, D. R. Commander.
|
||||
Copyright (C) 2010, 2014-2017, D. R. Commander.
|
||||
Copyright (C) 2015, Google, Inc.
|
||||
For conditions of distribution and use, see the accompanying README.ijg file.
|
||||
|
||||
@@ -34,6 +34,7 @@ Basic library usage:
|
||||
Data formats
|
||||
Compression details
|
||||
Decompression details
|
||||
Partial image decompression
|
||||
Mechanics of usage: include files, linking, etc
|
||||
Advanced features:
|
||||
Compression parameter selection
|
||||
@@ -2941,13 +2942,6 @@ Some operating modes (eg, two-pass color quantization) require full-image
|
||||
buffers. Such buffers are treated as "virtual arrays": only the current strip
|
||||
need be in memory, and the rest can be swapped out to a temporary file.
|
||||
|
||||
If you use the simplest memory manager back end (jmemnobs.c), then no
|
||||
temporary files are used; virtual arrays are simply malloc()'d. Images bigger
|
||||
than memory can be processed only if your system supports virtual memory.
|
||||
The other memory manager back ends support temporary files of various flavors
|
||||
and thus work in machines without virtual memory. They may also be useful on
|
||||
Unix machines if you need to process images that exceed available swap space.
|
||||
|
||||
When using temporary files, the library will make the in-memory buffers for
|
||||
its virtual arrays just big enough to stay within a "maximum memory" setting.
|
||||
Your application can set this limit by setting cinfo->mem->max_memory_to_use
|
||||
@@ -2960,6 +2954,11 @@ that space allocated with alloc_small() is ignored, on the assumption that
|
||||
it's too small to be worth worrying about; so a reasonable safety margin
|
||||
should be left when setting max_memory_to_use.
|
||||
|
||||
NOTE: Unless you develop your own memory manager back end, then temporary files
|
||||
will never be used. The back end provided in libjpeg-turbo (jmemnobs.c) simply
|
||||
malloc()s and free()s virtual arrays, and an error occurs if the required
|
||||
memory exceeds the limit specified in cinfo->mem->max_memory_to_use.
|
||||
|
||||
|
||||
Memory usage
|
||||
------------
|
||||
|
||||
@@ -31,6 +31,15 @@
|
||||
|
||||
#include "./md5.h"
|
||||
|
||||
#ifdef __amigaos4__
|
||||
#include <machine/endian.h>
|
||||
#define le32toh(x) (((x & 0xff) << 24) | \
|
||||
((x & 0xff00) << 8) | \
|
||||
((x & 0xff0000) >> 8) | \
|
||||
((x & 0xff000000) >> 24))
|
||||
#define htole32(x) le32toh(x)
|
||||
#endif
|
||||
|
||||
static void MD5Transform(unsigned int [4], const unsigned char [64]);
|
||||
|
||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
|
||||
4
rdppm.c
4
rdppm.c
@@ -251,7 +251,7 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
for (col = cinfo->image_width; col > 0; col--) {
|
||||
register int temp;
|
||||
register unsigned int temp;
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
@@ -278,7 +278,7 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ptr = source->pub.buffer[0];
|
||||
bufferptr = source->iobuffer;
|
||||
for (col = cinfo->image_width; col > 0; col--) {
|
||||
register int temp;
|
||||
register unsigned int temp;
|
||||
temp = UCH(*bufferptr++) << 8;
|
||||
temp |= UCH(*bufferptr++);
|
||||
if (temp > maxval)
|
||||
|
||||
@@ -13,12 +13,22 @@
|
||||
# Path under which headers should be installed
|
||||
%define _includedir %{__includedir}
|
||||
|
||||
# _libdir is set to %{_prefix}/%{_lib} by default
|
||||
%ifarch x86_64
|
||||
%define _lib lib64
|
||||
%if "%{?__isa_bits:1}" == "1"
|
||||
%define _bits %{__isa_bits}
|
||||
%else
|
||||
# RPM < 4.6
|
||||
%if "%{_lib}" == "lib64"
|
||||
%define _bits 64
|
||||
%else
|
||||
%define _bits 32
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if "%{_bits}" == "64"
|
||||
%define _libdir %{_exec_prefix}/lib64
|
||||
%else
|
||||
%if "%{_prefix}" == "/opt/libjpeg-turbo"
|
||||
%define _lib lib32
|
||||
%define _libdir %{_exec_prefix}/lib32
|
||||
%endif
|
||||
%endif
|
||||
|
||||
@@ -36,7 +46,7 @@ Release: @BUILD@
|
||||
License: BSD-style
|
||||
BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
|
||||
Prereq: /sbin/ldconfig
|
||||
%ifarch x86_64
|
||||
%if "%{_bits}" == "64"
|
||||
Provides: %{name} = %{version}-%{release}, @PACKAGE_NAME@ = %{version}-%{release}, libturbojpeg.so()(64bit)
|
||||
%else
|
||||
Provides: %{name} = %{version}-%{release}, @PACKAGE_NAME@ = %{version}-%{release}, libturbojpeg.so
|
||||
@@ -73,7 +83,8 @@ broader range of users and developers.
|
||||
#--> mandir=%{_mandir} JPEG_LIB_VERSION=@JPEG_LIB_VERSION@ \
|
||||
#--> SO_MAJOR_VERSION=@SO_MAJOR_VERSION@ SO_MINOR_VERSION=@SO_MINOR_VERSION@ \
|
||||
#--> --with-pic @RPM_CONFIG_ARGS@
|
||||
#-->make DESTDIR=$RPM_BUILD_ROOT
|
||||
#-->export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
|
||||
#-->make -j$NUMCPUS --load-average=$NUMCPUS DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
%install
|
||||
|
||||
@@ -86,7 +97,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
|
||||
LJT_LIBDIR=%{__libdir}
|
||||
if [ ! "$LJT_LIBDIR" = "%{_libdir}" ]; then
|
||||
echo ERROR: libjpeg-turbo must be configured with libdir=%{_prefix}/%{_lib} when generating an in-tree RPM for this architecture.
|
||||
echo ERROR: libjpeg-turbo must be configured with libdir=%{_libdir} when generating an in-tree RPM for this architecture.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
if(NOT DEFINED NASM)
|
||||
set(NASM nasm CACHE FILEPATH "Path to NASM/YASM executable")
|
||||
find_program(NASM NAMES nasm yasm DOC "Path to NASM/YASM executable")
|
||||
endif()
|
||||
message(STATUS "NASM = ${NASM}")
|
||||
|
||||
if(SIMD_X86_64)
|
||||
set(NAFLAGS -fwin64 -DWIN64 -D__x86_64__)
|
||||
|
||||
@@ -73,19 +73,24 @@ endif
|
||||
|
||||
if SIMD_POWERPC
|
||||
|
||||
libsimd_la_SOURCES = jsimd_powerpc.c jsimd_altivec.h jcsample.h \
|
||||
noinst_LTLIBRARIES += libsimd_altivec.la
|
||||
|
||||
libsimd_altivec_la_SOURCES = \
|
||||
jccolor-altivec.c jcgray-altivec.c jcsample-altivec.c \
|
||||
jdcolor-altivec.c jdmerge-altivec.c jdsample-altivec.c \
|
||||
jfdctfst-altivec.c jfdctint-altivec.c \
|
||||
jidctfst-altivec.c jidctint-altivec.c \
|
||||
jquanti-altivec.c
|
||||
libsimd_la_CFLAGS = -maltivec
|
||||
libsimd_altivec_la_CFLAGS = -maltivec
|
||||
|
||||
jccolor-altivec.lo: jccolext-altivec.c
|
||||
jcgray-altivec.lo: jcgryext-altivec.c
|
||||
jdcolor-altivec.lo: jdcolext-altivec.c
|
||||
jdmerge-altivec.lo: jdmrgext-altivec.c
|
||||
|
||||
libsimd_la_SOURCES = jsimd_powerpc.c jsimd_altivec.h jcsample.h
|
||||
libsimd_la_LIBADD = libsimd_altivec.la
|
||||
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;
|
||||
; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
|
||||
;
|
||||
; Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
||||
; Copyright (C) 2009-2011, 2014-2017, D. R. Commander.
|
||||
; Copyright (C) 2015, Matthieu Darbois.
|
||||
;
|
||||
; Based on the x86 SIMD extension for IJG JPEG library
|
||||
@@ -288,13 +288,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
||||
|
||||
.BLOOP:
|
||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||
jz .ELOOP
|
||||
jz near .ELOOP
|
||||
lea esi, [esi+ecx*2] ; k += r;
|
||||
shr edx, cl ; index >>= r;
|
||||
mov DWORD [esp+temp3], edx
|
||||
.BRLOOP:
|
||||
cmp ecx, 16 ; while (r > 15) {
|
||||
jl .ERLOOP
|
||||
jl near .ERLOOP
|
||||
sub ecx, 16 ; r -= 16;
|
||||
mov DWORD [esp+temp], ecx
|
||||
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
||||
@@ -348,7 +348,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
||||
sub eax, esi
|
||||
shr eax, 1
|
||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||
jz .ELOOP2
|
||||
jz near .ELOOP2
|
||||
shr edx, cl ; index >>= r;
|
||||
add ecx, eax
|
||||
lea esi, [esi+ecx*2] ; k += r;
|
||||
@@ -356,13 +356,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
|
||||
jmp .BRLOOP2
|
||||
.BLOOP2:
|
||||
bsf ecx, edx ; r = __builtin_ctzl(index);
|
||||
jz .ELOOP2
|
||||
jz near .ELOOP2
|
||||
lea esi, [esi+ecx*2] ; k += r;
|
||||
shr edx, cl ; index >>= r;
|
||||
mov DWORD [esp+temp3], edx
|
||||
.BRLOOP2:
|
||||
cmp ecx, 16 ; while (r > 15) {
|
||||
jl .ERLOOP2
|
||||
jl near .ERLOOP2
|
||||
sub ecx, 16 ; r -= 16;
|
||||
mov DWORD [esp+temp], ecx
|
||||
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jsimd_arm.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, Matthieu Darbois.
|
||||
*
|
||||
@@ -125,7 +126,7 @@ init_simd (void)
|
||||
/* Force different settings through environment variables */
|
||||
env = getenv("JSIMD_FORCENEON");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support &= JSIMD_ARM_NEON;
|
||||
simd_support = JSIMD_ARM_NEON;
|
||||
env = getenv("JSIMD_FORCENONE");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = 0;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* jsimd_arm64.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, Matthieu Darbois.
|
||||
*
|
||||
@@ -142,7 +143,7 @@ init_simd (void)
|
||||
/* Force different settings through environment variables */
|
||||
env = getenv("JSIMD_FORCENEON");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support &= JSIMD_ARM_NEON;
|
||||
simd_support = JSIMD_ARM_NEON;
|
||||
env = getenv("JSIMD_FORCENONE");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = 0;
|
||||
|
||||
@@ -210,10 +210,16 @@ asm_function jsimd_idct_islow_neon
|
||||
TMP7 .req x13
|
||||
TMP8 .req x14
|
||||
|
||||
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||
instruction ensures that those bits are set to zero. */
|
||||
uxtw x3, w3
|
||||
|
||||
sub sp, sp, #64
|
||||
adr x15, Ljsimd_idct_islow_neon_consts
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], #32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], #32
|
||||
mov x10, sp
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], #32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], #32
|
||||
ld1 {v0.8h, v1.8h}, [x15]
|
||||
ld1 {v2.8h, v3.8h, v4.8h, v5.8h}, [COEF_BLOCK], #64
|
||||
ld1 {v18.8h, v19.8h, v20.8h, v21.8h}, [DCT_TABLE], #64
|
||||
@@ -238,7 +244,6 @@ asm_function jsimd_idct_islow_neon
|
||||
shl v10.8h, v2.8h, #(PASS1_BITS)
|
||||
sqxtn v16.8b, v15.8h
|
||||
mov TMP1, v16.d[0]
|
||||
sub sp, sp, #64
|
||||
mvn TMP2, TMP1
|
||||
|
||||
cbnz TMP2, 2f
|
||||
@@ -807,6 +812,11 @@ asm_function jsimd_idct_ifast_neon
|
||||
TMP7 .req x13
|
||||
TMP8 .req x14
|
||||
|
||||
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||
instruction ensures that those bits are set to zero. */
|
||||
uxtw x3, w3
|
||||
|
||||
/* Load and dequantize coefficients into NEON registers
|
||||
* with the following allocation:
|
||||
* 0 1 2 3 | 4 5 6 7
|
||||
@@ -1101,19 +1111,18 @@ asm_function jsimd_idct_4x4_neon
|
||||
TMP3 .req x2
|
||||
TMP4 .req x15
|
||||
|
||||
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||
instruction ensures that those bits are set to zero. */
|
||||
uxtw x3, w3
|
||||
|
||||
/* Save all used NEON registers */
|
||||
sub sp, sp, 272
|
||||
str x15, [sp], 16
|
||||
sub sp, sp, 64
|
||||
mov x9, sp
|
||||
/* Load constants (v3.4h is just used for padding) */
|
||||
adr TMP4, Ljsimd_idct_4x4_neon_consts
|
||||
st1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
st1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
st1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||
ld1 {v0.4h, v1.4h, v2.4h, v3.4h}, [TMP4]
|
||||
|
||||
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
||||
@@ -1222,16 +1231,8 @@ asm_function jsimd_idct_4x4_neon
|
||||
#endif
|
||||
|
||||
/* vpop {v8.4h - v15.4h} ;not available */
|
||||
sub sp, sp, #272
|
||||
ldr x15, [sp], 16
|
||||
ld1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
ld1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
ld1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
||||
blr x30
|
||||
|
||||
.unreq DCT_TABLE
|
||||
@@ -1299,19 +1300,19 @@ asm_function jsimd_idct_2x2_neon
|
||||
TMP1 .req x0
|
||||
TMP2 .req x15
|
||||
|
||||
/* OUTPUT_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||
guarantee that the upper (unused) 32 bits of x3 are valid. This
|
||||
instruction ensures that those bits are set to zero. */
|
||||
uxtw x3, w3
|
||||
|
||||
/* vpush {v8.4h - v15.4h} ; not available */
|
||||
sub sp, sp, 208
|
||||
str x15, [sp], 16
|
||||
sub sp, sp, 64
|
||||
mov x9, sp
|
||||
|
||||
/* Load constants */
|
||||
adr TMP2, Ljsimd_idct_2x2_neon_consts
|
||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
st1 {v21.8b, v22.8b}, [sp], 16
|
||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
st1 {v30.8b, v31.8b}, [sp], 16
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||
ld1 {v14.4h}, [TMP2]
|
||||
|
||||
/* Load all COEF_BLOCK into NEON registers with the following allocation:
|
||||
@@ -1411,15 +1412,8 @@ asm_function jsimd_idct_2x2_neon
|
||||
st1 {v26.b}[1], [TMP2], 1
|
||||
st1 {v27.b}[5], [TMP2], 1
|
||||
|
||||
sub sp, sp, #208
|
||||
ldr x15, [sp], 16
|
||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
ld1 {v21.8b, v22.8b}, [sp], 16
|
||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
ld1 {v30.8b, v31.8b}, [sp], 16
|
||||
blr x30
|
||||
|
||||
.unreq DCT_TABLE
|
||||
@@ -1688,24 +1682,24 @@ asm_function jsimd_ycc_\colorid\()_convert_neon
|
||||
.else
|
||||
asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
||||
.endif
|
||||
OUTPUT_WIDTH .req x0
|
||||
OUTPUT_WIDTH .req w0
|
||||
INPUT_BUF .req x1
|
||||
INPUT_ROW .req x2
|
||||
INPUT_ROW .req w2
|
||||
OUTPUT_BUF .req x3
|
||||
NUM_ROWS .req x4
|
||||
NUM_ROWS .req w4
|
||||
|
||||
INPUT_BUF0 .req x5
|
||||
INPUT_BUF1 .req x6
|
||||
INPUT_BUF2 .req x1
|
||||
|
||||
RGB .req x7
|
||||
Y .req x8
|
||||
U .req x9
|
||||
V .req x10
|
||||
N .req x15
|
||||
Y .req x9
|
||||
U .req x10
|
||||
V .req x11
|
||||
N .req w15
|
||||
|
||||
sub sp, sp, 336
|
||||
str x15, [sp], 16
|
||||
sub sp, sp, 64
|
||||
mov x9, sp
|
||||
|
||||
/* Load constants to d1, d2, d3 (v0.4h is just used for padding) */
|
||||
.if \fast_st3 == 1
|
||||
@@ -1715,23 +1709,11 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
||||
.endif
|
||||
|
||||
/* Save NEON registers */
|
||||
st1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
||||
st1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
st1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
st1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
||||
st1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
st1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||
ld1 {v0.4h, v1.4h}, [x15], 16
|
||||
ld1 {v2.8h}, [x15]
|
||||
|
||||
/* Save ARM registers and handle input arguments */
|
||||
/* push {x4, x5, x6, x7, x8, x9, x10, x30} */
|
||||
stp x4, x5, [sp], 16
|
||||
stp x6, x7, [sp], 16
|
||||
stp x8, x9, [sp], 16
|
||||
stp x10, x30, [sp], 16
|
||||
ldr INPUT_BUF0, [INPUT_BUF]
|
||||
ldr INPUT_BUF1, [INPUT_BUF, #8]
|
||||
ldr INPUT_BUF2, [INPUT_BUF, #16]
|
||||
@@ -1745,11 +1727,10 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
||||
cmp NUM_ROWS, #1
|
||||
b.lt 9f
|
||||
0:
|
||||
lsl x16, INPUT_ROW, #3
|
||||
ldr Y, [INPUT_BUF0, x16]
|
||||
ldr U, [INPUT_BUF1, x16]
|
||||
ldr Y, [INPUT_BUF0, INPUT_ROW, uxtw #3]
|
||||
ldr U, [INPUT_BUF1, INPUT_ROW, uxtw #3]
|
||||
mov N, OUTPUT_WIDTH
|
||||
ldr V, [INPUT_BUF2, x16]
|
||||
ldr V, [INPUT_BUF2, INPUT_ROW, uxtw #3]
|
||||
add INPUT_ROW, INPUT_ROW, #1
|
||||
ldr RGB, [OUTPUT_BUF], #8
|
||||
|
||||
@@ -1799,21 +1780,8 @@ asm_function jsimd_ycc_\colorid\()_convert_neon_slowst3
|
||||
b.gt 0b
|
||||
9:
|
||||
/* Restore all registers and return */
|
||||
sub sp, sp, #336
|
||||
ldr x15, [sp], 16
|
||||
ld1 {v0.8b, v1.8b, v2.8b, v3.8b}, [sp], 32
|
||||
ld1 {v4.8b, v5.8b, v6.8b, v7.8b}, [sp], 32
|
||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
ld1 {v16.8b, v17.8b, v18.8b, v19.8b}, [sp], 32
|
||||
ld1 {v20.8b, v21.8b, v22.8b, v23.8b}, [sp], 32
|
||||
ld1 {v24.8b, v25.8b, v26.8b, v27.8b}, [sp], 32
|
||||
ld1 {v28.8b, v29.8b, v30.8b, v31.8b}, [sp], 32
|
||||
/* pop {r4, r5, r6, r7, r8, r9, r10, pc} */
|
||||
ldp x4, x5, [sp], 16
|
||||
ldp x6, x7, [sp], 16
|
||||
ldp x8, x9, [sp], 16
|
||||
ldp x10, x30, [sp], 16
|
||||
br x30
|
||||
.unreq OUTPUT_WIDTH
|
||||
.unreq INPUT_ROW
|
||||
@@ -2054,8 +2022,8 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
||||
OUTPUT_WIDTH .req w0
|
||||
INPUT_BUF .req x1
|
||||
OUTPUT_BUF .req x2
|
||||
OUTPUT_ROW .req x3
|
||||
NUM_ROWS .req x4
|
||||
OUTPUT_ROW .req w3
|
||||
NUM_ROWS .req w4
|
||||
|
||||
OUTPUT_BUF0 .req x5
|
||||
OUTPUT_BUF1 .req x6
|
||||
@@ -2082,17 +2050,18 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
||||
|
||||
/* Save NEON registers */
|
||||
sub sp, sp, #64
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
mov x9, sp
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x9], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x9], 32
|
||||
|
||||
/* Outer loop over scanlines */
|
||||
cmp NUM_ROWS, #1
|
||||
b.lt 9f
|
||||
0:
|
||||
ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, lsl #3]
|
||||
ldr U, [OUTPUT_BUF1, OUTPUT_ROW, lsl #3]
|
||||
ldr Y, [OUTPUT_BUF0, OUTPUT_ROW, uxtw #3]
|
||||
ldr U, [OUTPUT_BUF1, OUTPUT_ROW, uxtw #3]
|
||||
mov N, OUTPUT_WIDTH
|
||||
ldr V, [OUTPUT_BUF2, OUTPUT_ROW, lsl #3]
|
||||
ldr V, [OUTPUT_BUF2, OUTPUT_ROW, uxtw #3]
|
||||
add OUTPUT_ROW, OUTPUT_ROW, #1
|
||||
ldr RGB, [INPUT_BUF], #8
|
||||
|
||||
@@ -2136,7 +2105,6 @@ asm_function jsimd_\colorid\()_ycc_convert_neon_slowld3
|
||||
b.gt 0b
|
||||
9:
|
||||
/* Restore all registers and return */
|
||||
sub sp, sp, #64
|
||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
br x30
|
||||
@@ -2199,6 +2167,11 @@ asm_function jsimd_convsamp_neon
|
||||
TMP8 .req x4
|
||||
TMPDUP .req w3
|
||||
|
||||
/* START_COL is a JDIMENSION (unsigned int) argument, so the ABI doesn't
|
||||
guarantee that the upper (unused) 32 bits of x1 are valid. This
|
||||
instruction ensures that those bits are set to zero. */
|
||||
uxtw x1, w1
|
||||
|
||||
mov TMPDUP, #128
|
||||
ldp TMP1, TMP2, [SAMPLE_DATA], 16
|
||||
ldp TMP3, TMP4, [SAMPLE_DATA], 16
|
||||
@@ -2335,8 +2308,9 @@ asm_function jsimd_fdct_islow_neon
|
||||
|
||||
/* Save NEON registers */
|
||||
sub sp, sp, #64
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
mov x10, sp
|
||||
st1 {v8.8b, v9.8b, v10.8b, v11.8b}, [x10], 32
|
||||
st1 {v12.8b, v13.8b, v14.8b, v15.8b}, [x10], 32
|
||||
|
||||
/* Load all DATA into NEON registers with the following allocation:
|
||||
* 0 1 2 3 | 4 5 6 7
|
||||
@@ -2566,7 +2540,6 @@ asm_function jsimd_fdct_islow_neon
|
||||
st1 {v20.8h, v21.8h, v22.8h, v23.8h}, [DATA]
|
||||
|
||||
/* Restore NEON registers */
|
||||
sub sp, sp, #64
|
||||
ld1 {v8.8b, v9.8b, v10.8b, v11.8b}, [sp], 32
|
||||
ld1 {v12.8b, v13.8b, v14.8b, v15.8b}, [sp], 32
|
||||
|
||||
@@ -3080,7 +3053,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
||||
sub sp, sp, 272
|
||||
sub BUFFER, BUFFER, #0x1 /* BUFFER=buffer-- */
|
||||
/* Save ARM registers */
|
||||
stp x19, x20, [sp], 16
|
||||
stp x19, x20, [sp]
|
||||
.if \fast_tbl == 1
|
||||
adr x15, Ljsimd_huff_encode_one_block_neon_consts
|
||||
.else
|
||||
@@ -3294,7 +3267,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
||||
and v18.16b, v18.16b, v23.16b
|
||||
add x3, x4, #0x400 /* r1 = dctbl->ehufsi */
|
||||
and v20.16b, v20.16b, v23.16b
|
||||
add x15, sp, #0x80 /* x15 = t2 */
|
||||
add x15, sp, #0x90 /* x15 = t2 */
|
||||
and v22.16b, v22.16b, v23.16b
|
||||
ldr w10, [x4, x12, lsl #2]
|
||||
addp v16.16b, v16.16b, v18.16b
|
||||
@@ -3317,7 +3290,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
||||
rbit x9, x9 /* x9 = index0 */
|
||||
ldrb w14, [x4, #0xf0] /* x14 = actbl->ehufsi[0xf0] */
|
||||
cmp w12, #(64-8)
|
||||
mov x11, sp
|
||||
add x11, sp, #16
|
||||
b.lt 4f
|
||||
cbz x9, 6f
|
||||
st1 {v0.8h, v1.8h, v2.8h, v3.8h}, [x11], #64
|
||||
@@ -3421,7 +3394,7 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
||||
put_bits x3, x11
|
||||
cbnz x9, 1b
|
||||
6:
|
||||
add x13, sp, #0xfe
|
||||
add x13, sp, #0x10e
|
||||
cmp x15, x13
|
||||
b.hs 1f
|
||||
ldr w12, [x5]
|
||||
@@ -3429,7 +3402,6 @@ asm_function jsimd_huff_encode_one_block_neon_slowtbl
|
||||
checkbuf47
|
||||
put_bits x12, x14
|
||||
1:
|
||||
sub sp, sp, 16
|
||||
str PUT_BUFFER, [x0, #0x10]
|
||||
str PUT_BITSw, [x0, #0x18]
|
||||
ldp x19, x20, [sp], 16
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jsimd_mips.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2011, 2014, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014, 2016, D. R. Commander.
|
||||
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
|
||||
* Copyright (C) 2015, Matthieu Darbois.
|
||||
*
|
||||
@@ -63,6 +63,8 @@ parse_proc_cpuinfo(const char* search_string)
|
||||
LOCAL(void)
|
||||
init_simd (void)
|
||||
{
|
||||
char *env = NULL;
|
||||
|
||||
if (simd_support != ~0U)
|
||||
return;
|
||||
|
||||
@@ -77,6 +79,14 @@ init_simd (void)
|
||||
if (!parse_proc_cpuinfo("MIPS 74K"))
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Force different settings through environment variables */
|
||||
env = getenv("JSIMD_FORCEDSPR2");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = JSIMD_MIPS_DSPR2;
|
||||
env = getenv("JSIMD_FORCENONE");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = 0;
|
||||
}
|
||||
|
||||
static const int mips_idct_ifast_coefs[4] = {
|
||||
|
||||
@@ -4484,4 +4484,3 @@ LEAF_MIPS_DSPR2(jsimd_convsamp_float_mips_dspr2)
|
||||
END(jsimd_convsamp_float_mips_dspr2)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@@ -281,5 +281,3 @@ LEAF_MIPS32R2(symbol) \
|
||||
addiu sp, sp, \stack_offset
|
||||
.endif
|
||||
.endm
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jsimd_powerpc.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2011, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
||||
* Copyright (C) 2015, Matthieu Darbois.
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
@@ -14,6 +14,11 @@
|
||||
* PowerPC architecture.
|
||||
*/
|
||||
|
||||
#ifdef __amigaos4__
|
||||
/* This must be defined first as it re-defines GLOBAL otherwise */
|
||||
#include <proto/exec.h>
|
||||
#endif
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "../jinclude.h"
|
||||
#include "../jpeglib.h"
|
||||
@@ -22,19 +27,125 @@
|
||||
#include "../jsimddct.h"
|
||||
#include "jsimd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/cpu.h>
|
||||
#endif
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
|
||||
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
|
||||
|
||||
#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
|
||||
|
||||
LOCAL(int)
|
||||
check_feature (char *buffer, char *feature)
|
||||
{
|
||||
char *p;
|
||||
if (*feature == 0)
|
||||
return 0;
|
||||
if (strncmp(buffer, "cpu", 3) != 0)
|
||||
return 0;
|
||||
buffer += 3;
|
||||
while (isspace(*buffer))
|
||||
buffer++;
|
||||
|
||||
/* Check if 'feature' is present in the buffer as a separate word */
|
||||
while ((p = strstr(buffer, feature))) {
|
||||
if (p > buffer && !isspace(*(p - 1))) {
|
||||
buffer++;
|
||||
continue;
|
||||
}
|
||||
p += strlen(feature);
|
||||
if (*p != 0 && !isspace(*p)) {
|
||||
buffer++;
|
||||
continue;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL(int)
|
||||
parse_proc_cpuinfo (int bufsize)
|
||||
{
|
||||
char *buffer = (char *)malloc(bufsize);
|
||||
FILE *fd;
|
||||
simd_support = 0;
|
||||
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
fd = fopen("/proc/cpuinfo", "r");
|
||||
if (fd) {
|
||||
while (fgets(buffer, bufsize, fd)) {
|
||||
if (!strchr(buffer, '\n') && !feof(fd)) {
|
||||
/* "impossible" happened - insufficient size of the buffer! */
|
||||
fclose(fd);
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
if (check_feature(buffer, "altivec"))
|
||||
simd_support |= JSIMD_ALTIVEC;
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
free(buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd (void)
|
||||
{
|
||||
char *env = NULL;
|
||||
#if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
|
||||
int bufsize = 1024; /* an initial guess for the line buffer size limit */
|
||||
#elif defined(__amigaos4__)
|
||||
uint32 altivec = 0;
|
||||
#elif defined(__OpenBSD__)
|
||||
int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
|
||||
int altivec;
|
||||
size_t len = sizeof(altivec);
|
||||
#endif
|
||||
|
||||
if (simd_support != ~0U)
|
||||
return;
|
||||
|
||||
simd_support = JSIMD_ALTIVEC;
|
||||
simd_support = 0;
|
||||
|
||||
#if defined(__ALTIVEC__) || defined(__APPLE__)
|
||||
simd_support |= JSIMD_ALTIVEC;
|
||||
#elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
|
||||
while (!parse_proc_cpuinfo(bufsize)) {
|
||||
bufsize *= 2;
|
||||
if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
|
||||
break;
|
||||
}
|
||||
#elif defined(__amigaos4__)
|
||||
IExec->GetCPUInfoTags(GCIT_VectorUnit, &altivec, TAG_DONE);
|
||||
if(altivec == VECTORTYPE_ALTIVEC)
|
||||
simd_support |= JSIMD_ALTIVEC;
|
||||
#elif defined(__OpenBSD__)
|
||||
if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0)
|
||||
simd_support |= JSIMD_ALTIVEC;
|
||||
#endif
|
||||
|
||||
/* Force different settings through environment variables */
|
||||
env = getenv("JSIMD_FORCEALTIVEC");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = JSIMD_ALTIVEC;
|
||||
env = getenv("JSIMD_FORCENONE");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = 0;
|
||||
|
||||
@@ -832,21 +832,19 @@ read_backing_store, manipulate a backing-store object
|
||||
write_backing_store,
|
||||
close_backing_store
|
||||
|
||||
On some systems there will be more than one type of backing-store object
|
||||
(specifically, in MS-DOS a backing store file might be an area of extended
|
||||
memory as well as a disk file). jpeg_open_backing_store is responsible for
|
||||
choosing how to implement a given object. The read/write/close routines
|
||||
are method pointers in the structure that describes a given object; this
|
||||
lets them be different for different object types.
|
||||
On some systems there will be more than one type of backing-store object.
|
||||
jpeg_open_backing_store is responsible for choosing how to implement a given
|
||||
object. The read/write/close routines are method pointers in the structure
|
||||
that describes a given object; this lets them be different for different object
|
||||
types.
|
||||
|
||||
It may be necessary to ensure that backing store objects are explicitly
|
||||
released upon abnormal program termination. For example, MS-DOS won't free
|
||||
extended memory by itself. To support this, we will expect the main program
|
||||
or surrounding application to arrange to call self_destruct (typically via
|
||||
jpeg_destroy) upon abnormal termination. This may require a SIGINT signal
|
||||
handler or equivalent. We don't want to have the back end module install its
|
||||
own signal handler, because that would pre-empt the surrounding application's
|
||||
ability to control signal handling.
|
||||
released upon abnormal program termination. To support this, we will expect
|
||||
the main program or surrounding application to arrange to call self_destruct
|
||||
(typically via jpeg_destroy) upon abnormal termination. This may require a
|
||||
SIGINT signal handler or equivalent. We don't want to have the back end module
|
||||
install its own signal handler, because that would pre-empt the surrounding
|
||||
application's ability to control signal handling.
|
||||
|
||||
The IJG distribution includes several memory manager back end implementations.
|
||||
Usually the same back end should be suitable for all applications on a given
|
||||
|
||||
160
tjbench.c
160
tjbench.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -40,13 +40,13 @@
|
||||
|
||||
#define _throw(op, err) { \
|
||||
printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
|
||||
retval=-1; goto bailout;}
|
||||
retval=-1; goto bailout;}
|
||||
#define _throwunix(m) _throw(m, strerror(errno))
|
||||
#define _throwtj(m) _throw(m, tjGetErrorStr())
|
||||
#define _throwbmp(m) _throw(m, bmpgeterr())
|
||||
|
||||
int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0,
|
||||
dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1, dowrite=1;
|
||||
dotile=0, pf=TJPF_BGR, yuvpad=1, dowrite=1;
|
||||
char *ext="ppm";
|
||||
const char *pixFormatStr[TJ_NUMPF]=
|
||||
{
|
||||
@@ -64,7 +64,7 @@ const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440", "411"};
|
||||
tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0;
|
||||
int xformop=TJXOP_NONE, xformopt=0;
|
||||
int (*customFilter)(short *, tjregion, tjregion, int, int, tjtransform *);
|
||||
double benchtime=5.0;
|
||||
double benchtime=5.0, warmup=1.0;
|
||||
|
||||
|
||||
char *formatName(int subsamp, int cs, char *buf)
|
||||
@@ -146,7 +146,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
||||
}
|
||||
|
||||
/* Benchmark */
|
||||
iter=-warmup;
|
||||
iter=-1;
|
||||
elapsed=elapsedDecode=0.;
|
||||
while(1)
|
||||
{
|
||||
@@ -176,12 +176,17 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
||||
_throwtj("executing tjDecompress2()");
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if(iter>=1)
|
||||
elapsed+=gettime()-start;
|
||||
if(iter>=0)
|
||||
{
|
||||
elapsed+=gettime()-start;
|
||||
iter++;
|
||||
if(elapsed>=benchtime) break;
|
||||
}
|
||||
else if(elapsed>=warmup)
|
||||
{
|
||||
iter=0;
|
||||
elapsed=elapsedDecode=0.;
|
||||
}
|
||||
}
|
||||
if(doyuv) elapsed-=elapsedDecode;
|
||||
|
||||
@@ -207,7 +212,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
||||
(double)(w*h)/1000000.*(double)iter/elapsed);
|
||||
if(doyuv)
|
||||
{
|
||||
printf("YUV Decode --> Frame rate: %f fps\n",
|
||||
printf("YUV Decode --> Frame rate: %f fps\n",
|
||||
(double)iter/elapsedDecode);
|
||||
printf(" Throughput: %f Megapixels/sec\n",
|
||||
(double)(w*h)/1000000.*(double)iter/elapsedDecode);
|
||||
@@ -248,7 +253,8 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
|
||||
int y=(int)((double)srcbuf[rindex]*0.299
|
||||
+ (double)srcbuf[gindex]*0.587
|
||||
+ (double)srcbuf[bindex]*0.114 + 0.5);
|
||||
if(y>255) y=255; if(y<0) y=0;
|
||||
if(y>255) y=255;
|
||||
if(y<0) y=0;
|
||||
dstbuf[rindex]=abs(dstbuf[rindex]-y);
|
||||
dstbuf[gindex]=abs(dstbuf[gindex]-y);
|
||||
dstbuf[bindex]=abs(dstbuf[bindex]-y);
|
||||
@@ -300,7 +306,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
||||
|
||||
for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
|
||||
{
|
||||
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
|
||||
if(tilew>w) tilew=w;
|
||||
if(tileh>h) tileh=h;
|
||||
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
||||
|
||||
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
||||
@@ -338,7 +345,7 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
||||
}
|
||||
|
||||
/* Benchmark */
|
||||
iter=-warmup;
|
||||
iter=-1;
|
||||
elapsed=elapsedEncode=0.;
|
||||
while(1)
|
||||
{
|
||||
@@ -372,12 +379,17 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
||||
totaljpegsize+=jpegsize[tile];
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if(iter>=1)
|
||||
elapsed+=gettime()-start;
|
||||
if(iter>=0)
|
||||
{
|
||||
elapsed+=gettime()-start;
|
||||
iter++;
|
||||
if(elapsed>=benchtime) break;
|
||||
}
|
||||
else if(elapsed>=warmup)
|
||||
{
|
||||
iter=0;
|
||||
elapsed=elapsedEncode=0.;
|
||||
}
|
||||
}
|
||||
if(doyuv) elapsed-=elapsedEncode;
|
||||
|
||||
@@ -447,7 +459,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
||||
|
||||
for(i=0; i<ntilesw*ntilesh; i++)
|
||||
{
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||
jpegbuf[i]=NULL;
|
||||
}
|
||||
free(jpegbuf); jpegbuf=NULL;
|
||||
free(jpegsize); jpegsize=NULL;
|
||||
@@ -465,7 +478,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
|
||||
{
|
||||
for(i=0; i<ntilesw*ntilesh; i++)
|
||||
{
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||
jpegbuf[i]=NULL;
|
||||
}
|
||||
free(jpegbuf); jpegbuf=NULL;
|
||||
}
|
||||
@@ -488,7 +502,7 @@ int decompTest(char *filename)
|
||||
char *temp=NULL, tempstr[80], tempstr2[80];
|
||||
int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0;
|
||||
double start, elapsed;
|
||||
int ps=tjPixelSize[pf], tile;
|
||||
int ps=tjPixelSize[pf], tile, decompsrc=0;
|
||||
|
||||
if((file=fopen(filename, "rb"))==NULL)
|
||||
_throwunix("opening file");
|
||||
@@ -532,7 +546,8 @@ int decompTest(char *filename)
|
||||
|
||||
for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
|
||||
{
|
||||
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
|
||||
if(tilew>w) tilew=w;
|
||||
if(tileh>h) tileh=h;
|
||||
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;
|
||||
|
||||
if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
|
||||
@@ -618,7 +633,7 @@ int decompTest(char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
iter=-warmup;
|
||||
iter=-1;
|
||||
elapsed=0.;
|
||||
while(1)
|
||||
{
|
||||
@@ -626,12 +641,17 @@ int decompTest(char *filename)
|
||||
if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf,
|
||||
jpegsize, t, flags)==-1)
|
||||
_throwtj("executing tjTransform()");
|
||||
iter++;
|
||||
if(iter>=1)
|
||||
elapsed+=gettime()-start;
|
||||
if(iter>=0)
|
||||
{
|
||||
elapsed+=gettime()-start;
|
||||
iter++;
|
||||
if(elapsed>=benchtime) break;
|
||||
}
|
||||
else if(elapsed>=warmup)
|
||||
{
|
||||
iter=0;
|
||||
elapsed=0.;
|
||||
}
|
||||
}
|
||||
|
||||
free(t); t=NULL;
|
||||
@@ -662,16 +682,17 @@ int decompTest(char *filename)
|
||||
else
|
||||
{
|
||||
if(quiet==1) printf("N/A N/A ");
|
||||
jpegsize[0]=srcsize;
|
||||
memcpy(jpegbuf[0], srcbuf, srcsize);
|
||||
tjFree(jpegbuf[0]);
|
||||
jpegbuf[0]=NULL;
|
||||
decompsrc=1;
|
||||
}
|
||||
|
||||
if(w==tilew) _tilew=_w;
|
||||
if(h==tileh) _tileh=_h;
|
||||
if(!(xformopt&TJXOPT_NOOUTPUT))
|
||||
{
|
||||
if(decomp(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0,
|
||||
filename, _tilew, _tileh)==-1)
|
||||
if(decomp(NULL, decompsrc? &srcbuf:jpegbuf, decompsrc? &srcsize:jpegsize,
|
||||
NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1)
|
||||
goto bailout;
|
||||
}
|
||||
else if(quiet==1) printf("N/A\n");
|
||||
@@ -692,7 +713,8 @@ int decompTest(char *filename)
|
||||
{
|
||||
for(i=0; i<ntilesw*ntilesh; i++)
|
||||
{
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
|
||||
if(jpegbuf[i]) tjFree(jpegbuf[i]);
|
||||
jpegbuf[i]=NULL;
|
||||
}
|
||||
free(jpegbuf); jpegbuf=NULL;
|
||||
}
|
||||
@@ -757,8 +779,9 @@ void usage(char *progname)
|
||||
printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n");
|
||||
printf(" test (can be combined with the other transforms above)\n");
|
||||
printf("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)\n");
|
||||
printf("-warmup <w> = Execute each benchmark <w> times to prime the cache before\n");
|
||||
printf(" taking performance measurements (default = 1)\n");
|
||||
printf("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to\n");
|
||||
printf(" starting the timer, in order to prime the caches and thus improve the\n");
|
||||
printf(" consistency of the results.\n");
|
||||
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
|
||||
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
|
||||
printf(" performance measurements.)\n\n");
|
||||
@@ -811,32 +834,32 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
dotile=1; xformopt|=TJXOPT_CROP;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-fastupsample"))
|
||||
else if(!strcasecmp(argv[i], "-fastupsample"))
|
||||
{
|
||||
printf("Using fast upsampling code\n\n");
|
||||
flags|=TJFLAG_FASTUPSAMPLE;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-fastdct"))
|
||||
else if(!strcasecmp(argv[i], "-fastdct"))
|
||||
{
|
||||
printf("Using fastest DCT/IDCT algorithm\n\n");
|
||||
flags|=TJFLAG_FASTDCT;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-accuratedct"))
|
||||
else if(!strcasecmp(argv[i], "-accuratedct"))
|
||||
{
|
||||
printf("Using most accurate DCT/IDCT algorithm\n\n");
|
||||
flags|=TJFLAG_ACCURATEDCT;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
|
||||
if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
|
||||
if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
|
||||
if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX;
|
||||
if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR;
|
||||
if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB;
|
||||
if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK;
|
||||
if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP;
|
||||
if(!strcasecmp(argv[i], "-quiet")) quiet=1;
|
||||
if(!strcasecmp(argv[i], "-qq")) quiet=2;
|
||||
if(!strcasecmp(argv[i], "-scale") && i<argc-1)
|
||||
else if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
|
||||
else if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
|
||||
else if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
|
||||
else if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX;
|
||||
else if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR;
|
||||
else if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB;
|
||||
else if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK;
|
||||
else if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP;
|
||||
else if(!strcasecmp(argv[i], "-quiet")) quiet=1;
|
||||
else if(!strcasecmp(argv[i], "-qq")) quiet=2;
|
||||
else if(!strcasecmp(argv[i], "-scale") && i<argc-1)
|
||||
{
|
||||
int temp1=0, temp2=0, match=0;
|
||||
if(sscanf(argv[++i], "%d/%d", &temp1, &temp2)==2)
|
||||
@@ -854,46 +877,42 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else usage(argv[0]);
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
|
||||
if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
|
||||
if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE;
|
||||
if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE;
|
||||
if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
|
||||
if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180;
|
||||
if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270;
|
||||
if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY;
|
||||
if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter;
|
||||
if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT;
|
||||
if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
|
||||
else if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
|
||||
else if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
|
||||
else if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE;
|
||||
else if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE;
|
||||
else if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
|
||||
else if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180;
|
||||
else if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270;
|
||||
else if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY;
|
||||
else if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter;
|
||||
else if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT;
|
||||
else if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
|
||||
{
|
||||
double temp=atof(argv[++i]);
|
||||
if(temp>0.0) benchtime=temp;
|
||||
else usage(argv[0]);
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
|
||||
else if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
|
||||
{
|
||||
int temp=atoi(argv[++i]);
|
||||
if(temp>=0)
|
||||
{
|
||||
warmup=temp;
|
||||
printf("Warmup runs = %d\n\n", warmup);
|
||||
}
|
||||
double temp=atof(argv[++i]);
|
||||
if(temp>=0.0) warmup=temp;
|
||||
else usage(argv[0]);
|
||||
printf("Warmup time = %.1f seconds\n\n", warmup);
|
||||
}
|
||||
if(!strcmp(argv[i], "-?")) usage(argv[0]);
|
||||
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
|
||||
if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
|
||||
if(!strcasecmp(argv[i], "-yuv"))
|
||||
else if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
|
||||
else if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
|
||||
else if(!strcasecmp(argv[i], "-yuv"))
|
||||
{
|
||||
printf("Testing YUV planar encoding/decoding\n\n");
|
||||
doyuv=1;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1)
|
||||
else if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1)
|
||||
{
|
||||
int temp=atoi(argv[++i]);
|
||||
if(temp>=1) yuvpad=temp;
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
|
||||
else if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
|
||||
{
|
||||
i++;
|
||||
if(toupper(argv[i][0])=='G') subsamp=TJSAMP_GRAY;
|
||||
@@ -910,8 +929,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!strcasecmp(argv[i], "-componly")) componly=1;
|
||||
if(!strcasecmp(argv[i], "-nowrite")) dowrite=0;
|
||||
else if(!strcasecmp(argv[i], "-componly")) componly=1;
|
||||
else if(!strcasecmp(argv[i], "-nowrite")) dowrite=0;
|
||||
else usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,9 @@ if [ -d $OUTDIR ]; then
|
||||
fi
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
exec >$EXEDIR/tjbenchtest.log
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
if [ "$1" = "-yuv" ]; then
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-yuv)
|
||||
NSARG=-nosmooth
|
||||
YUVARG=-yuv
|
||||
|
||||
@@ -60,12 +59,16 @@ if [ $# -gt 0 ]; then
|
||||
# phenomenon is not yet fully understood but is also believed to be some sort
|
||||
# of round-off error.)
|
||||
IMAGES="vgl_6548_0026a.${EXT}"
|
||||
fi
|
||||
if [ "$1" = "-alloc" ]; then
|
||||
;;
|
||||
-alloc)
|
||||
ALLOCARG=-alloc
|
||||
ALLOC=1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exec >$EXEDIR/tjbenchtest$YUVARG$ALLOCARG.log
|
||||
|
||||
# Standard tests
|
||||
for image in $IMAGES; do
|
||||
|
||||
@@ -33,8 +33,6 @@ if [ -d $OUTDIR ]; then
|
||||
fi
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
exec >$EXEDIR/tjbenchtest-java.log
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
if [ "$1" = "-yuv" ]; then
|
||||
NSARG=-nosmooth
|
||||
@@ -60,6 +58,8 @@ if [ $# -gt 0 ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
exec >$EXEDIR/tjbenchtest-java$YUVARG.log
|
||||
|
||||
# Standard tests
|
||||
for image in $IMAGES; do
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ runme()
|
||||
|
||||
IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
|
||||
IMGDIR=@srcdir@/testimages
|
||||
OUTDIR=__tjexampletest_output
|
||||
OUTDIR=`mktemp -d /tmp/__tjexampletest_output.XXXXXX`
|
||||
EXEDIR=.
|
||||
JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs"
|
||||
|
||||
@@ -36,23 +36,23 @@ for image in $IMAGES; do
|
||||
|
||||
cp $IMGDIR/$image $OUTDIR
|
||||
basename=`basename $image .bmp`
|
||||
$EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_fast_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_fast_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_fast_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_accurate_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_accurate_cjpeg.jpg
|
||||
$EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_accurate_cjpeg.jpg
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
||||
for samp in GRAY 420 422 444; do
|
||||
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.bmp
|
||||
$EXEDIR/djpeg -dct fast -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.bmp
|
||||
$EXEDIR/djpeg -dct int -rgb -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.bmp
|
||||
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
||||
runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
||||
runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
|
||||
done
|
||||
for samp in 420 422; do
|
||||
$EXEDIR/djpeg -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp
|
||||
$EXEDIR/djpeg -dct fast -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp
|
||||
$EXEDIR/djpeg -dct int -nosmooth -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp
|
||||
runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
||||
runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
||||
runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
|
||||
done
|
||||
|
||||
# Compression
|
||||
@@ -87,7 +87,7 @@ for image in $IMAGES; do
|
||||
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
|
||||
scalearg=`echo $scale | sed s@_@/@g`
|
||||
for samp in GRAY 420 422 444; do
|
||||
$EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
|
||||
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
||||
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${scale}.bmp -scale ${scalearg}
|
||||
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
|
||||
rm $OUTDIR/${basename}_${samp}_${scale}.bmp
|
||||
@@ -96,25 +96,25 @@ for image in $IMAGES; do
|
||||
|
||||
# Transforms
|
||||
for samp in GRAY 420 422 444; do
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg
|
||||
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
||||
done
|
||||
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
|
||||
for samp in GRAY 420 422 444; do
|
||||
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 16,16,70x60
|
||||
runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
||||
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
||||
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
||||
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60
|
||||
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
||||
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
|
||||
done
|
||||
for samp in 420 422; do
|
||||
$EXEDIR/djpeg -nosmooth -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
||||
runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
||||
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60 -fastupsample
|
||||
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
||||
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
|
||||
@@ -137,7 +137,7 @@ for image in $IMAGES; do
|
||||
for samp in GRAY 444 422 420; do
|
||||
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
|
||||
scalearg=`echo $scale | sed s@_@/@g`
|
||||
$EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
|
||||
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
||||
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp -$xform -scale ${scalearg} -crop 16,16,70x60
|
||||
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
|
||||
rm $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp
|
||||
|
||||
13
tjunittest.c
13
tjunittest.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2014, 2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -44,12 +44,12 @@
|
||||
|
||||
void usage(char *progName)
|
||||
{
|
||||
printf("\nUSAGE: %s [options]\n", progName);
|
||||
printf("\nUSAGE: %s [options]\n\n", progName);
|
||||
printf("Options:\n");
|
||||
printf("-yuv = test YUV encoding/decoding support\n");
|
||||
printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
|
||||
printf(" 4-byte boundary\n");
|
||||
printf("-alloc = test automatic buffer allocation\n");
|
||||
printf("-alloc = test automatic buffer allocation\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -697,10 +697,9 @@ int main(int argc, char *argv[])
|
||||
for(i=1; i<argc; i++)
|
||||
{
|
||||
if(!strcasecmp(argv[i], "-yuv")) doyuv=1;
|
||||
if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
|
||||
if(!strcasecmp(argv[i], "-alloc")) alloc=1;
|
||||
if(!strncasecmp(argv[i], "-h", 2) || !strcasecmp(argv[i], "-?"))
|
||||
usage(argv[0]);
|
||||
else if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
|
||||
else if(!strcasecmp(argv[i], "-alloc")) alloc=1;
|
||||
else usage(argv[0]);
|
||||
}
|
||||
}
|
||||
if(alloc) printf("Testing automatic buffer allocation\n");
|
||||
|
||||
19
transupp.c
19
transupp.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, D. R. Commander.
|
||||
* Copyright (C) 2010, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -1177,7 +1177,6 @@ transpose_critical_parameters (j_compress_ptr dstinfo)
|
||||
* We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible.
|
||||
*/
|
||||
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
LOCAL(void)
|
||||
adjust_exif_parameters (JOCTET *data, unsigned int length,
|
||||
JDIMENSION new_width, JDIMENSION new_height)
|
||||
@@ -1327,7 +1326,6 @@ adjust_exif_parameters (JOCTET *data, unsigned int length,
|
||||
offset += 12;
|
||||
} while (--number_of_tags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Adjust output image parameters as needed.
|
||||
@@ -1384,7 +1382,7 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
||||
/* Correct the destination's image dimensions as necessary
|
||||
* for rotate/flip, resize, and crop operations.
|
||||
*/
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
dstinfo->jpeg_width = info->output_width;
|
||||
dstinfo->jpeg_height = info->output_height;
|
||||
#endif
|
||||
@@ -1395,14 +1393,14 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
||||
case JXFORM_TRANSVERSE:
|
||||
case JXFORM_ROT_90:
|
||||
case JXFORM_ROT_270:
|
||||
#if JPEG_LIB_VERSION < 70
|
||||
#if JPEG_LIB_VERSION < 80
|
||||
dstinfo->image_width = info->output_height;
|
||||
dstinfo->image_height = info->output_width;
|
||||
#endif
|
||||
transpose_critical_parameters(dstinfo);
|
||||
break;
|
||||
default:
|
||||
#if JPEG_LIB_VERSION < 70
|
||||
#if JPEG_LIB_VERSION < 80
|
||||
dstinfo->image_width = info->output_width;
|
||||
dstinfo->image_height = info->output_height;
|
||||
#endif
|
||||
@@ -1421,14 +1419,21 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
|
||||
GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
|
||||
/* Suppress output of JFIF marker */
|
||||
dstinfo->write_JFIF_header = FALSE;
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
/* Adjust Exif image parameters */
|
||||
#if JPEG_LIB_VERSION >= 80
|
||||
if (dstinfo->jpeg_width != srcinfo->image_width ||
|
||||
dstinfo->jpeg_height != srcinfo->image_height)
|
||||
/* Align data segment to start of TIFF structure for parsing */
|
||||
adjust_exif_parameters(srcinfo->marker_list->data + 6,
|
||||
srcinfo->marker_list->data_length - 6,
|
||||
dstinfo->jpeg_width, dstinfo->jpeg_height);
|
||||
#else
|
||||
if (dstinfo->image_width != srcinfo->image_width ||
|
||||
dstinfo->image_height != srcinfo->image_height)
|
||||
/* Align data segment to start of TIFF structure for parsing */
|
||||
adjust_exif_parameters(srcinfo->marker_list->data + 6,
|
||||
srcinfo->marker_list->data_length - 6,
|
||||
dstinfo->image_width, dstinfo->image_height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
122
turbojpeg.c
122
turbojpeg.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -222,7 +222,7 @@ static int setCompDefaults(struct jpeg_compress_struct *cinfo,
|
||||
#ifndef NO_GETENV
|
||||
if((env=getenv("TJ_OPTIMIZE"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
|
||||
cinfo->optimize_coding=TRUE;
|
||||
if((env=getenv("TJ_ARITHMETIC"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
|
||||
if((env=getenv("TJ_ARITHMETIC"))!=NULL && strlen(env)>0 && !strcmp(env, "1"))
|
||||
cinfo->arith_code=TRUE;
|
||||
if((env=getenv("TJ_RESTART"))!=NULL && strlen(env)>0)
|
||||
{
|
||||
@@ -368,6 +368,29 @@ static int getSubsamp(j_decompress_ptr dinfo)
|
||||
retval=i; break;
|
||||
}
|
||||
}
|
||||
/* Handle 4:2:2 and 4:4:0 images whose sampling factors are specified
|
||||
in non-standard ways. */
|
||||
if(dinfo->comp_info[0].h_samp_factor==2 &&
|
||||
dinfo->comp_info[0].v_samp_factor==2 &&
|
||||
(i==TJSAMP_422 || i==TJSAMP_440))
|
||||
{
|
||||
int match=0;
|
||||
for(k=1; k<dinfo->num_components; k++)
|
||||
{
|
||||
int href=tjMCUHeight[i]/8, vref=tjMCUWidth[i]/8;
|
||||
if(dinfo->jpeg_color_space==JCS_YCCK && k==3)
|
||||
{
|
||||
href=vref=2;
|
||||
}
|
||||
if(dinfo->comp_info[k].h_samp_factor==href
|
||||
&& dinfo->comp_info[k].v_samp_factor==vref)
|
||||
match++;
|
||||
}
|
||||
if(match==dinfo->num_components-1)
|
||||
{
|
||||
retval=i; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
@@ -570,7 +593,8 @@ static tjhandle _tjInitCompress(tjinstance *this)
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
if(this) free(this); return NULL;
|
||||
if(this) free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jpeg_create_compress(&this->cinfo);
|
||||
@@ -748,13 +772,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
||||
|| jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT || jpegQual<0 || jpegQual>100)
|
||||
_throw("tjCompress2(): Invalid argument");
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
if(pitch==0) pitch=width*tjPixelSize[pixelFormat];
|
||||
|
||||
#ifndef JCS_EXTENSIONS
|
||||
@@ -767,6 +784,15 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
||||
}
|
||||
#endif
|
||||
|
||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
|
||||
_throw("tjCompress2(): Memory allocation failure");
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
cinfo->image_width=width;
|
||||
cinfo->image_height=height;
|
||||
|
||||
@@ -783,8 +809,6 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
||||
return -1;
|
||||
|
||||
jpeg_start_compress(cinfo, TRUE);
|
||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
|
||||
_throw("tjCompress2(): Memory allocation failure");
|
||||
for(i=0; i<height; i++)
|
||||
{
|
||||
if(flags&TJFLAG_BOTTOMUP)
|
||||
@@ -864,13 +888,6 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
||||
if(subsamp!=TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
|
||||
_throw("tjEncodeYUVPlanes(): Invalid argument");
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
if(pixelFormat==TJPF_CMYK)
|
||||
_throw("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
|
||||
|
||||
@@ -886,6 +903,12 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
||||
}
|
||||
#endif
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
cinfo->image_width=width;
|
||||
cinfo->image_height=height;
|
||||
|
||||
@@ -962,6 +985,12 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
|
||||
}
|
||||
}
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
for(row=0; row<ph0; row+=cinfo->max_v_samp_factor)
|
||||
{
|
||||
(*cinfo->cconvert->color_convert)(cinfo, &row_pointer[row], tmpbuf, 0,
|
||||
@@ -1076,8 +1105,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
cinfo->image_width=width;
|
||||
@@ -1136,6 +1164,12 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
|
||||
}
|
||||
}
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
for(row=0; row<(int)cinfo->image_height;
|
||||
row+=cinfo->max_v_samp_factor*DCTSIZE)
|
||||
{
|
||||
@@ -1231,7 +1265,8 @@ static tjhandle _tjInitDecompress(tjinstance *this)
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
if(this) free(this); return NULL;
|
||||
if(this) free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jpeg_create_decompress(&this->dinfo);
|
||||
@@ -1364,8 +1399,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||
@@ -1413,6 +1447,11 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
|
||||
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)
|
||||
*dinfo->output_height))==NULL)
|
||||
_throw("tjDecompress2(): Memory allocation failure");
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
for(i=0; i<(int)dinfo->output_height; i++)
|
||||
{
|
||||
if(flags&TJFLAG_BOTTOMUP)
|
||||
@@ -1543,8 +1582,7 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
if(pixelFormat==TJPF_CMYK)
|
||||
@@ -1635,6 +1673,12 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
|
||||
}
|
||||
}
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
for(row=0; row<ph0; row+=dinfo->max_v_samp_factor)
|
||||
{
|
||||
JDIMENSION inrow=0, outrow=0;
|
||||
@@ -1736,8 +1780,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
if(!this->headerRead)
|
||||
@@ -1815,6 +1858,12 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
}
|
||||
}
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
|
||||
if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
|
||||
dinfo->raw_data_out=TRUE;
|
||||
@@ -1992,20 +2041,19 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
|
||||
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
|
||||
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||
|
||||
if((xinfo=(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info)*n))
|
||||
==NULL)
|
||||
_throw("tjTransform(): Memory allocation failure");
|
||||
MEMZERO(xinfo, sizeof(jpeg_transform_info)*n);
|
||||
|
||||
if(setjmp(this->jerr.setjmp_buffer))
|
||||
{
|
||||
/* If we get here, the JPEG code has signaled an error. */
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
|
||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
{
|
||||
xinfo[i].transform=xformtypes[t[i].op];
|
||||
|
||||
61
turbojpeg.h
61
turbojpeg.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2009-2015, 2017 D. R. Commander. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -275,7 +275,6 @@ static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1}
|
||||
* then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
|
||||
*/
|
||||
static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1};
|
||||
|
||||
/**
|
||||
* Pixel size (in bytes) for a given pixel format.
|
||||
*/
|
||||
@@ -348,7 +347,7 @@ enum TJCS
|
||||
* The uncompressed source/destination image is stored in bottom-up (Windows,
|
||||
* OpenGL) order, not top-down (X11) order.
|
||||
*/
|
||||
#define TJFLAG_BOTTOMUP 2
|
||||
#define TJFLAG_BOTTOMUP 2
|
||||
/**
|
||||
* When decompressing an image that was compressed using chrominance
|
||||
* subsampling, use the fastest chrominance upsampling algorithm available in
|
||||
@@ -358,11 +357,11 @@ enum TJCS
|
||||
*/
|
||||
#define TJFLAG_FASTUPSAMPLE 256
|
||||
/**
|
||||
* Disable buffer (re)allocation. If passed to #tjCompress2() or
|
||||
* #tjTransform(), this flag will cause those functions to generate an error if
|
||||
* the JPEG image buffer is invalid or too small rather than attempting to
|
||||
* allocate or reallocate that buffer. This reproduces the behavior of earlier
|
||||
* versions of TurboJPEG.
|
||||
* Disable buffer (re)allocation. If passed to one of the JPEG compression or
|
||||
* transform functions, this flag will cause those functions to generate an
|
||||
* error if the JPEG image buffer is invalid or too small rather than
|
||||
* attempting to allocate or reallocate that buffer. This reproduces the
|
||||
* behavior of earlier versions of TurboJPEG.
|
||||
*/
|
||||
#define TJFLAG_NOREALLOC 1024
|
||||
/**
|
||||
@@ -645,7 +644,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
|
||||
* for you, or
|
||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||
* .
|
||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||
@@ -667,7 +666,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
|
||||
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
|
||||
* 100 = best)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -713,7 +712,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
||||
* for you, or
|
||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||
* .
|
||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||
@@ -731,7 +730,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
||||
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
|
||||
* 100 = best)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -783,7 +782,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
|
||||
* for you, or
|
||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||
* #tjBufSize(). This should ensure that the buffer never has to be
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
|
||||
* .
|
||||
* If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
|
||||
* pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
|
||||
@@ -801,7 +800,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
|
||||
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
|
||||
* 100 = best)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -961,7 +960,7 @@ DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
|
||||
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
|
||||
* image compatible with the I420 (AKA "YUV420P") format.
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1019,7 +1018,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle,
|
||||
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
|
||||
* image compatible with the I420 (AKA "YUV420P") format.
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1126,7 +1125,7 @@ DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
|
||||
* @param pixelFormat pixel format of the destination image (see @ref
|
||||
* TJPF "Pixel formats".)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1176,7 +1175,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
|
||||
* block height (see #tjMCUHeight), then an intermediate buffer copy will be
|
||||
* performed within TurboJPEG.
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1232,7 +1231,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
|
||||
* block height (see #tjMCUHeight), then an intermediate buffer copy will be
|
||||
* performed within TurboJPEG.
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1284,7 +1283,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
|
||||
* @param pixelFormat pixel format of the destination image (see @ref TJPF
|
||||
* "Pixel formats".)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1341,7 +1340,7 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
|
||||
* @param pixelFormat pixel format of the destination image (see @ref TJPF
|
||||
* "Pixel formats".)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1392,9 +1391,13 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
|
||||
* -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the buffer
|
||||
* for you, or
|
||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||
* #tjBufSize() with the transformed or cropped width and height. This should
|
||||
* ensure that the buffer never has to be re-allocated (setting
|
||||
* #TJFLAG_NOREALLOC guarantees this.)
|
||||
* #tjBufSize() with the transformed or cropped width and height. Under normal
|
||||
* circumstances, this should ensure that the buffer never has to be
|
||||
* re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) Note,
|
||||
* however, that there are some rare cases (such as transforming images with a
|
||||
* large amount of embedded EXIF or ICC profile data) in which the output image
|
||||
* will be larger than the worst-case size, and #TJFLAG_NOREALLOC cannot be
|
||||
* used in those cases.
|
||||
* .
|
||||
* If you choose option 1, <tt>dstSizes[i]</tt> should be set to the size of
|
||||
* your pre-allocated buffer. In any case, unless you have set
|
||||
@@ -1411,7 +1414,7 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
|
||||
* which specifies the transform parameters and/or cropping region for the
|
||||
* corresponding transformed output image.
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
|
||||
@@ -1435,8 +1438,8 @@ DLLEXPORT int DLLCALL tjDestroy(tjhandle handle);
|
||||
|
||||
/**
|
||||
* Allocate an image buffer for use with TurboJPEG. You should always use
|
||||
* this function to allocate the JPEG destination buffer(s) for #tjCompress2()
|
||||
* and #tjTransform() unless you are disabling automatic buffer
|
||||
* this function to allocate the JPEG destination buffer(s) for the compression
|
||||
* and transform functions unless you are disabling automatic buffer
|
||||
* (re)allocation (by setting #TJFLAG_NOREALLOC.)
|
||||
*
|
||||
* @param bytes the number of bytes to allocate
|
||||
@@ -1452,8 +1455,8 @@ DLLEXPORT unsigned char* DLLCALL tjAlloc(int bytes);
|
||||
/**
|
||||
* Free an image buffer previously allocated by TurboJPEG. You should always
|
||||
* use this function to free JPEG destination buffer(s) that were automatically
|
||||
* (re)allocated by #tjCompress2() or #tjTransform() or that were manually
|
||||
* allocated using #tjAlloc().
|
||||
* (re)allocated by the compression and transform functions or that were
|
||||
* manually allocated using #tjAlloc().
|
||||
*
|
||||
* @param buffer address of the buffer to free
|
||||
*
|
||||
|
||||
35
usage.txt
35
usage.txt
@@ -212,7 +212,7 @@ Switches for advanced users:
|
||||
large images. Value is in thousands of bytes, or
|
||||
millions of bytes if "M" is attached to the number.
|
||||
For example, -max 4m selects 4000000 bytes. If more
|
||||
space is needed, temporary files will be used.
|
||||
space is needed, an error will occur.
|
||||
|
||||
-verbose Enable debug printout. More -v's give more printout.
|
||||
or -debug Also, version information is printed at startup.
|
||||
@@ -377,7 +377,7 @@ Switches for advanced users:
|
||||
large images. Value is in thousands of bytes, or
|
||||
millions of bytes if "M" is attached to the number.
|
||||
For example, -max 4m selects 4000000 bytes. If more
|
||||
space is needed, temporary files will be used.
|
||||
space is needed, an error will occur.
|
||||
|
||||
-verbose Enable debug printout. More -v's give more printout.
|
||||
or -debug Also, version information is printed at startup.
|
||||
@@ -423,11 +423,6 @@ When producing a color-quantized image, "-onepass -dither ordered" is fast but
|
||||
much lower quality than the default behavior. "-dither none" may give
|
||||
acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
|
||||
|
||||
Two-pass color quantization requires a good deal of memory; on MS-DOS machines
|
||||
it may run out of memory even with -maxmemory 0. In that case you can still
|
||||
decompress, with some loss of image quality, by specifying -onepass for
|
||||
one-pass quantization.
|
||||
|
||||
To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF
|
||||
files. These are larger than they should be, but are readable by standard GIF
|
||||
decoders.
|
||||
@@ -435,24 +430,9 @@ decoders.
|
||||
|
||||
HINTS FOR BOTH PROGRAMS
|
||||
|
||||
If more space is needed than will fit in the available main memory (as
|
||||
determined by -maxmemory), temporary files will be used. (MS-DOS versions
|
||||
will try to get extended or expanded memory first.) The temporary files are
|
||||
often rather large: in typical cases they occupy three bytes per pixel, for
|
||||
example 3*800*600 = 1.44Mb for an 800x600 image. If you don't have enough
|
||||
free disk space, leave out -progressive and -optimize (for cjpeg) or specify
|
||||
-onepass (for djpeg).
|
||||
|
||||
On MS-DOS, the temporary files are created in the directory named by the TMP
|
||||
or TEMP environment variable, or in the current directory if neither of those
|
||||
exist. Amiga implementations put the temp files in the directory named by
|
||||
JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free
|
||||
space.
|
||||
|
||||
The default memory usage limit (-maxmemory) is set when the software is
|
||||
compiled. If you get an "insufficient memory" error, try specifying a smaller
|
||||
-maxmemory value, even -maxmemory 0 to use the absolute minimum space. You
|
||||
may want to recompile with a smaller default value if this happens often.
|
||||
If the memory needed by cjpeg or djpeg exceeds the limit specified by
|
||||
-maxmemory, an error will occur. You can leave out -progressive and -optimize
|
||||
(for cjpeg) or specify -onepass (for djpeg) to reduce memory usage.
|
||||
|
||||
On machines that have "environment" variables, you can define the environment
|
||||
variable JPEGMEM to set the default memory limit. The value is specified as
|
||||
@@ -460,11 +440,6 @@ described for the -maxmemory switch. JPEGMEM overrides the default value
|
||||
specified when the program was compiled, and itself is overridden by an
|
||||
explicit -maxmemory switch.
|
||||
|
||||
On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to
|
||||
use. (Extended or expanded memory is also used if available.) Most
|
||||
DOS-specific versions of this software do their own memory space estimation
|
||||
and do not need you to specify -maxmemory.
|
||||
|
||||
|
||||
JPEGTRAN
|
||||
|
||||
|
||||
@@ -104,3 +104,5 @@ EXPORTS
|
||||
jzero_far @ 103 ;
|
||||
jpeg_mem_dest @ 104 ;
|
||||
jpeg_mem_src @ 105 ;
|
||||
jpeg_skip_scanlines @ 106 ;
|
||||
jpeg_crop_scanline @ 107 ;
|
||||
|
||||
9
wrbmp.c
9
wrbmp.c
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2014-2015, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -70,7 +70,7 @@ LOCAL(void) write_colormap
|
||||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
if (*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
||||
inptr = dest->pub.buffer[0];
|
||||
outptr = image_ptr[0];
|
||||
|
||||
if(cinfo->out_color_space == JCS_RGB565) {
|
||||
if (cinfo->out_color_space == JCS_RGB565) {
|
||||
boolean big_endian = is_big_endian();
|
||||
unsigned short *inptr2 = (unsigned short *)inptr;
|
||||
for (col = cinfo->output_width; col > 0; col--) {
|
||||
@@ -437,6 +437,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
|
||||
sizeof(bmp_dest_struct));
|
||||
dest->pub.start_output = start_output_bmp;
|
||||
dest->pub.finish_output = finish_output_bmp;
|
||||
dest->pub.calc_buffer_dimensions = NULL;
|
||||
dest->is_os2 = is_os2;
|
||||
|
||||
if (cinfo->out_color_space == JCS_GRAYSCALE) {
|
||||
@@ -446,7 +447,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
|
||||
dest->pub.put_pixel_rows = put_gray_rows;
|
||||
else
|
||||
dest->pub.put_pixel_rows = put_pixel_rows;
|
||||
} else if(cinfo->out_color_space == JCS_RGB565 ) {
|
||||
} else if (cinfo->out_color_space == JCS_RGB565) {
|
||||
dest->pub.put_pixel_rows = put_pixel_rows;
|
||||
} else {
|
||||
ERREXIT(cinfo, JERR_BMP_COLORSPACE);
|
||||
|
||||
13
wrgif.c
13
wrgif.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -355,6 +355,16 @@ finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Re-calculate buffer dimensions based on output dimensions.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
calc_buffer_dimensions_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The module selection routine for GIF format output.
|
||||
*/
|
||||
@@ -372,6 +382,7 @@ jinit_write_gif (j_decompress_ptr cinfo)
|
||||
dest->pub.start_output = start_output_gif;
|
||||
dest->pub.put_pixel_rows = put_pixel_rows;
|
||||
dest->pub.finish_output = finish_output_gif;
|
||||
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_gif;
|
||||
|
||||
if (cinfo->out_color_space != JCS_GRAYSCALE &&
|
||||
cinfo->out_color_space != JCS_RGB)
|
||||
|
||||
@@ -247,7 +247,7 @@ copy_variable (void)
|
||||
if (length < 2)
|
||||
ERREXIT("Erroneous JPEG marker length");
|
||||
length -= 2;
|
||||
/* Skip over the remaining bytes */
|
||||
/* Copy the remaining bytes */
|
||||
while (length > 0) {
|
||||
write_1_byte(read_1_byte());
|
||||
length--;
|
||||
|
||||
38
wrppm.c
38
wrppm.c
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||
#include "wrppm.h"
|
||||
|
||||
#ifdef PPM_SUPPORTED
|
||||
|
||||
@@ -63,6 +62,21 @@
|
||||
*/
|
||||
|
||||
|
||||
/* Private version of data destination object */
|
||||
|
||||
typedef struct {
|
||||
struct djpeg_dest_struct pub; /* public fields */
|
||||
|
||||
/* Usually these two pointers point to the same place: */
|
||||
char *iobuffer; /* fwrite's I/O buffer */
|
||||
JSAMPROW pixrow; /* decompressor output buffer */
|
||||
size_t buffer_width; /* width of I/O buffer */
|
||||
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
|
||||
} ppm_dest_struct;
|
||||
|
||||
typedef ppm_dest_struct *ppm_dest_ptr;
|
||||
|
||||
|
||||
/*
|
||||
* Write some pixel data.
|
||||
* In this module rows_supplied will always be 1.
|
||||
@@ -196,6 +210,20 @@ finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Re-calculate buffer dimensions based on output dimensions.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
calc_buffer_dimensions_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
{
|
||||
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
|
||||
|
||||
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
|
||||
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The module selection routine for PPM format output.
|
||||
*/
|
||||
@@ -211,13 +239,13 @@ jinit_write_ppm (j_decompress_ptr cinfo)
|
||||
sizeof(ppm_dest_struct));
|
||||
dest->pub.start_output = start_output_ppm;
|
||||
dest->pub.finish_output = finish_output_ppm;
|
||||
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_ppm;
|
||||
|
||||
/* Calculate output image dimensions so we can allocate space */
|
||||
jpeg_calc_output_dimensions(cinfo);
|
||||
|
||||
/* Create physical I/O buffer */
|
||||
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
|
||||
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
|
||||
dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
|
||||
dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);
|
||||
|
||||
|
||||
26
wrppm.h
26
wrppm.h
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* wrppm.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994, Thomas G. Lane.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*/
|
||||
|
||||
#ifdef PPM_SUPPORTED
|
||||
|
||||
/* Private version of data destination object */
|
||||
|
||||
typedef struct {
|
||||
struct djpeg_dest_struct pub; /* public fields */
|
||||
|
||||
/* Usually these two pointers point to the same place: */
|
||||
char *iobuffer; /* fwrite's I/O buffer */
|
||||
JSAMPROW pixrow; /* decompressor output buffer */
|
||||
size_t buffer_width; /* width of I/O buffer */
|
||||
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
|
||||
} ppm_dest_struct;
|
||||
|
||||
typedef ppm_dest_struct *ppm_dest_ptr;
|
||||
|
||||
#endif
|
||||
5
wrrle.c
5
wrrle.c
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -286,6 +286,7 @@ jinit_write_rle (j_decompress_ptr cinfo)
|
||||
sizeof(rle_dest_struct));
|
||||
dest->pub.start_output = start_output_rle;
|
||||
dest->pub.finish_output = finish_output_rle;
|
||||
dest->pub.calc_buffer_dimensions = NULL;
|
||||
|
||||
/* Calculate output image dimensions so we can allocate space */
|
||||
jpeg_calc_output_dimensions(cinfo);
|
||||
|
||||
20
wrtarga.c
20
wrtarga.c
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code and
|
||||
* information relevant to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2017, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -211,6 +211,19 @@ finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Re-calculate buffer dimensions based on output dimensions.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
calc_buffer_dimensions_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
||||
{
|
||||
tga_dest_ptr dest = (tga_dest_ptr) dinfo;
|
||||
|
||||
dest->buffer_width = cinfo->output_width * cinfo->output_components;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The module selection routine for Targa format output.
|
||||
*/
|
||||
@@ -226,12 +239,13 @@ jinit_write_targa (j_decompress_ptr cinfo)
|
||||
sizeof(tga_dest_struct));
|
||||
dest->pub.start_output = start_output_tga;
|
||||
dest->pub.finish_output = finish_output_tga;
|
||||
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_tga;
|
||||
|
||||
/* Calculate output image dimensions so we can allocate space */
|
||||
jpeg_calc_output_dimensions(cinfo);
|
||||
|
||||
/* Create I/O buffer. */
|
||||
dest->buffer_width = cinfo->output_width * cinfo->output_components;
|
||||
dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
|
||||
dest->iobuffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (dest->buffer_width * sizeof(char)));
|
||||
|
||||
Reference in New Issue
Block a user