Import Upstream version 2.3.1
This commit is contained in:
commit
63c964585c
|
@ -0,0 +1,18 @@
|
||||||
|
# Ignore files and directories made by `cmake .`.
|
||||||
|
CMakeFiles/
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
/CMakeCache.txt
|
||||||
|
/CPackConfig.cmake
|
||||||
|
/CPackSourceConfig.cmake
|
||||||
|
/CTestCustom.cmake
|
||||||
|
/LICENSE.txt
|
||||||
|
/OpenJPEGConfig.cmake
|
||||||
|
/libopenjp2.pc
|
||||||
|
/src/bin/common/opj_apps_config.h
|
||||||
|
/src/lib/openjp2/opj_config.h
|
||||||
|
/src/lib/openjp2/opj_config_private.h
|
||||||
|
scripts/opjstyle*
|
||||||
|
|
||||||
|
# Ignore directories made by `make`.
|
||||||
|
/bin/
|
|
@ -0,0 +1,158 @@
|
||||||
|
language: cpp
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# OSX
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1
|
||||||
|
|
||||||
|
# Test code style
|
||||||
|
- os: linux
|
||||||
|
compiler: clang-3.8
|
||||||
|
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_CHECK_STYLE=1 OPJ_CI_SKIP_TESTS=1
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- llvm-toolchain-precise-3.8
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- clang-3.8
|
||||||
|
- flip
|
||||||
|
|
||||||
|
# Performance test with GCC
|
||||||
|
- os: linux
|
||||||
|
compiler: g++
|
||||||
|
dist: precise
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1 OPJ_CI_PERF_TESTS=1
|
||||||
|
|
||||||
|
# Test compilation with AVX2
|
||||||
|
- os: linux
|
||||||
|
# "sudo: yes" and "dist: trusty" give us a worker with the AVX2 instruction set
|
||||||
|
sudo: yes
|
||||||
|
dist: trusty
|
||||||
|
compiler: clang-3.8
|
||||||
|
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_INSTRUCTION_SETS="-mavx2" OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- llvm-toolchain-precise-3.8
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- clang-3.8
|
||||||
|
|
||||||
|
# Test multi-threading
|
||||||
|
- os: linux
|
||||||
|
compiler: g++
|
||||||
|
dist: precise
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_NUM_THREADS=2
|
||||||
|
|
||||||
|
# Test 32-bit compilation
|
||||||
|
- os: linux
|
||||||
|
compiler: g++
|
||||||
|
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
dist: trusty
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-multilib
|
||||||
|
- g++-multilib
|
||||||
|
|
||||||
|
# Profile code (gcc -pg)
|
||||||
|
- os: linux
|
||||||
|
compiler: g++
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_PROFILE=1
|
||||||
|
dist: trusty
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- valgrind
|
||||||
|
|
||||||
|
# Test under ASAN
|
||||||
|
# Temporarily disabled since broken. See https://github.com/uclouvain/openjpeg/issues/1091
|
||||||
|
# - os: linux
|
||||||
|
# compiler: clang
|
||||||
|
# env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
||||||
|
|
||||||
|
# Test with CLang 3.8
|
||||||
|
- os: linux
|
||||||
|
compiler: clang-3.8
|
||||||
|
env: OPJ_CI_CC=clang-3.8 OPJ_CI_CXX=clang-3.8 OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_PERF_TESTS=1 OPJ_CI_BUILD_FUZZERS=1
|
||||||
|
dist: trusty
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- llvm-toolchain-precise-3.8
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- clang-3.8
|
||||||
|
|
||||||
|
# Test with mingw 32 bit
|
||||||
|
- os: linux
|
||||||
|
compiler: x86_64-w64-mingw32-g++
|
||||||
|
env: OPJ_CI_CC=x86_64-w64-mingw32-gcc OPJ_CI_CXX=x86_64-w64-mingw32-g++ OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
dist: trusty
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-mingw-w64-base
|
||||||
|
- binutils-mingw-w64-i686
|
||||||
|
- gcc-mingw-w64-i686
|
||||||
|
- gcc-mingw-w64
|
||||||
|
- g++-mingw-w64-i686
|
||||||
|
- gcc-multilib
|
||||||
|
- g++-multilib
|
||||||
|
|
||||||
|
# Test with mingw 64 bit
|
||||||
|
- os: linux
|
||||||
|
compiler: x86_64-w64-mingw32-g++
|
||||||
|
env: OPJ_CI_CC=x86_64-w64-mingw32-gcc OPJ_CI_CXX=x86_64-w64-mingw32-g++ OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
dist: trusty
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-mingw-w64-base
|
||||||
|
- binutils-mingw-w64-x86-64
|
||||||
|
- gcc-mingw-w64-x86-64
|
||||||
|
- gcc-mingw-w64
|
||||||
|
- g++-mingw-w64-x86-64
|
||||||
|
|
||||||
|
# Test with gcc 4.8
|
||||||
|
- os: linux
|
||||||
|
compiler: g++-4.8
|
||||||
|
env: OPJ_CI_CC=gcc-4.8 OPJ_CI_CXX=g++-4.8 OPJ_CI_ABI_CHECK=1
|
||||||
|
dist: precise
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- gcc-4.8
|
||||||
|
- g++-4.8
|
||||||
|
- libelf-dev
|
||||||
|
- elfutils
|
||||||
|
- texinfo
|
||||||
|
- exuberant-ctags
|
||||||
|
|
||||||
|
install:
|
||||||
|
- "./tools/travis-ci/install.sh"
|
||||||
|
|
||||||
|
script:
|
||||||
|
- "./tools/travis-ci/run.sh"
|
||||||
|
- "./tools/travis-ci/abi-check.sh"
|
||||||
|
|
||||||
|
before_deploy:
|
||||||
|
- export OPJ_RELEASE_PKG_FILE=$(ls build/openjpeg-${TRAVIS_TAG}*)
|
||||||
|
- echo "deploying $OPJ_RELEASE_PKG_FILE to GitHub releases"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key:
|
||||||
|
secure: dJXdzoFwk9wYWIKztnXKlVIr1QDmeXtk3oK+2MEzy22fBTKPuphU/cYMvhi5B7sWDwm77f43vbAYO6z7IFmuThwhkuVMD/o+lUyCqGffGeiU1pKpxEvB+LbO/C5asdSnor3RfYdOyo3x4cNlhNtfhXIn7FcAg371yEY6VSIP87adoQcuE+taig0cYWcrNWYGHirHlzEz1utnKwCT/nlhV4nSIWxjwYUp3nt8PAw3RbqQkPPNBniW92g6JA25vLRc3HMD18ISCfNLC2fI6a/dTR+vd+bCySA7JvqeDZnv8SxbVIabu5T+A5CHzHbdp2l2kynPwqHOO47pGa+VfisXEwSsOpa+4EZsPLdwOhaFFnvDwKwR3EjI1TkRVd26IcK61Y5zVZQgalnXBowBEZoI4fT/oEPF7VZMjN3sy/do1U6d5kO0UGqCHCJIVwPeELhwq5z7Ld04K7dSFFVenZhhQKCwxI1o8vgkGNJUWD2Ii6ZLrZKYZ0lC65hr2d39e/KoK3Yh5KHF0cVn6ppBTcUjYr/tdHHO43rwoaf3r1CdAQAYpFvfi3900hl9I/GPwky0YJ6W2QDS2vincwaqWDQ0+WNGf4AKSdx5kCgQU45PSfDb/lxAyXkqmBuI3h/C2ellleaWVL9sGtNRWa/w6WseGMGwfCXgN82XRVM2bgP6pYg=
|
||||||
|
file_glob: true
|
||||||
|
file: "${OPJ_RELEASE_PKG_FILE}"
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: uclouvain/openjpeg
|
||||||
|
tags: true
|
||||||
|
condition: "$OPJ_CI_INCLUDE_IF_DEPLOY = 1"
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Authors of OpenJPEG
|
||||||
|
See also [THANKS](https://github.com/uclouvain/openjpeg/blob/master/THANKS.md)
|
||||||
|
|
||||||
|
David Janssens designed and implemented the first version of OpenJPEG.
|
||||||
|
|
||||||
|
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
||||||
|
|
||||||
|
Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
|
||||||
|
|
||||||
|
Giuseppe Baruffa added the JPWL functionalities.
|
||||||
|
|
||||||
|
Mickaël Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
|
||||||
|
|
||||||
|
Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
|
||||||
|
|
||||||
|
Yannick Verschueren,
|
||||||
|
Herve Drolon,
|
||||||
|
Francois-Olivier Devaux,
|
||||||
|
Antonin Descampe
|
||||||
|
improved the libraries and utilities.
|
||||||
|
|
|
@ -0,0 +1,683 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [v2.3.1](https://github.com/uclouvain/openjpeg/releases/v2.3.1) (2019-04-02)
|
||||||
|
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.0...v2.3.1)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- v2.2.0 regression for decoding images where TNsot == 0 [\#1120](https://github.com/uclouvain/openjpeg/issues/1120)
|
||||||
|
- Int overflow in jp3d [\#1162](https://github.com/uclouvain/openjpeg/issues/1162)
|
||||||
|
- Heap buffer overflow in opj\_j2k\_update\_image\_data\(\) triggered with Ghostscript [\#1157](https://github.com/uclouvain/openjpeg/issues/1157)
|
||||||
|
- LINUX install doesn't work when building shared libraries is disabled [\#1155](https://github.com/uclouvain/openjpeg/issues/1155)
|
||||||
|
- OPENJPEG null ptr dereference in openjpeg-2.3.0/src/bin/jp2/convert.c:2243 [\#1152](https://github.com/uclouvain/openjpeg/issues/1152)
|
||||||
|
- How to drop certain subbands/layers in DWT [\#1147](https://github.com/uclouvain/openjpeg/issues/1147)
|
||||||
|
- where is the MQ-Coder ouput stream in t2.c? [\#1146](https://github.com/uclouvain/openjpeg/issues/1146)
|
||||||
|
- OpenJPEG 2.3 \(and 2.2?\) multi component image fails to decode with KDU v7.10 [\#1132](https://github.com/uclouvain/openjpeg/issues/1132)
|
||||||
|
- Missing checks for header\_info.height and header\_info.width in function pnmtoimage in src/bin/jpwl/convert.c, which can lead to heap buffer overflow [\#1126](https://github.com/uclouvain/openjpeg/issues/1126)
|
||||||
|
- Assertion Failure in jp2.c [\#1125](https://github.com/uclouvain/openjpeg/issues/1125)
|
||||||
|
- Division-by-zero vulnerabilities in the function pi\_next\_pcrl, pi\_next\_cprl and pi\_next\_rpcl in src/lib/openjp3d/pi.c [\#1123](https://github.com/uclouvain/openjpeg/issues/1123)
|
||||||
|
- Precinct switch \(-c\) doesn't right-shift last record to remaining resolution levels [\#1117](https://github.com/uclouvain/openjpeg/issues/1117)
|
||||||
|
- Sample: encode J2K a data using streams??? [\#1114](https://github.com/uclouvain/openjpeg/issues/1114)
|
||||||
|
- HIGH THROUGHPUT JPEG 2000 \(HTJ2K\) [\#1112](https://github.com/uclouvain/openjpeg/issues/1112)
|
||||||
|
- How to build openjpeg for arm linux? [\#1108](https://github.com/uclouvain/openjpeg/issues/1108)
|
||||||
|
- crash [\#1106](https://github.com/uclouvain/openjpeg/issues/1106)
|
||||||
|
- JP2000 returning OPJ\_CLRSPC\_UNKNOWN color space [\#1103](https://github.com/uclouvain/openjpeg/issues/1103)
|
||||||
|
- Compilation successful but install unsuccessful: Calling executables throws libraries missing error [\#1102](https://github.com/uclouvain/openjpeg/issues/1102)
|
||||||
|
- fprintf format string requires 1 parameter but only 0 are given [\#1093](https://github.com/uclouvain/openjpeg/issues/1093)
|
||||||
|
- fprintf format string requires 1 parameter but only 0 are given [\#1092](https://github.com/uclouvain/openjpeg/issues/1092)
|
||||||
|
- sprintf buffer overflow [\#1088](https://github.com/uclouvain/openjpeg/issues/1088)
|
||||||
|
- sprintf buffer overflow [\#1085](https://github.com/uclouvain/openjpeg/issues/1085)
|
||||||
|
- Infinite loop when reading jp2 [\#1081](https://github.com/uclouvain/openjpeg/issues/1081)
|
||||||
|
- missing format string parameter [\#1074](https://github.com/uclouvain/openjpeg/issues/1074)
|
||||||
|
- Excessive Iteration in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1059](https://github.com/uclouvain/openjpeg/issues/1059)
|
||||||
|
- Out-of-bound left shift in opj\_j2k\_setup\_encoder \(src/lib/openjp2/j2k.c\) [\#1057](https://github.com/uclouvain/openjpeg/issues/1057)
|
||||||
|
- Encode image on Unsplash [\#1054](https://github.com/uclouvain/openjpeg/issues/1054)
|
||||||
|
- Integer overflow in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1053](https://github.com/uclouvain/openjpeg/issues/1053)
|
||||||
|
- Signed Integer Overflow - 68065512 [\#1048](https://github.com/uclouvain/openjpeg/issues/1048)
|
||||||
|
- Similar vulnerable functions related to CVE-2017-14041 [\#1044](https://github.com/uclouvain/openjpeg/issues/1044)
|
||||||
|
- \[ERROR\] COD marker already read. No more than one COD marker per tile. [\#1043](https://github.com/uclouvain/openjpeg/issues/1043)
|
||||||
|
- failing to install latest version of openjpeg from source [\#1041](https://github.com/uclouvain/openjpeg/issues/1041)
|
||||||
|
- Trouble compressing large raw image [\#1032](https://github.com/uclouvain/openjpeg/issues/1032)
|
||||||
|
- Download and installed code from 2.3 archive. Installing 2.2? [\#1030](https://github.com/uclouvain/openjpeg/issues/1030)
|
||||||
|
- missing fclose [\#1029](https://github.com/uclouvain/openjpeg/issues/1029)
|
||||||
|
- NULL Pointer Access in function imagetopnm of convert.c\(jp2\):1289 [\#860](https://github.com/uclouvain/openjpeg/issues/860)
|
||||||
|
- NULL Pointer Access in function imagetopnm of convert.c:2226\(jp2\) [\#859](https://github.com/uclouvain/openjpeg/issues/859)
|
||||||
|
- Heap Buffer Overflow in function imagetotga of convert.c\(jp2\):942 [\#858](https://github.com/uclouvain/openjpeg/issues/858)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- abi-check.sh: fix broken download URL [\#1188](https://github.com/uclouvain/openjpeg/pull/1188) ([rouault](https://github.com/rouault))
|
||||||
|
- opj\_t1\_encode\_cblks: fix UBSAN signed integer overflow [\#1187](https://github.com/uclouvain/openjpeg/pull/1187) ([rouault](https://github.com/rouault))
|
||||||
|
- convertbmp: detect invalid file dimensions early \(CVE-2018-6616\) [\#1172](https://github.com/uclouvain/openjpeg/pull/1172) ([hlef](https://github.com/hlef))
|
||||||
|
- color\_apply\_icc\_profile: avoid potential heap buffer overflow [\#1170](https://github.com/uclouvain/openjpeg/pull/1170) ([rouault](https://github.com/rouault))
|
||||||
|
- Fix multiple potential vulnerabilities and bugs [\#1168](https://github.com/uclouvain/openjpeg/pull/1168) ([Young-X](https://github.com/Young-X))
|
||||||
|
- Fix several memory and resource leaks [\#1163](https://github.com/uclouvain/openjpeg/pull/1163) ([nforro](https://github.com/nforro))
|
||||||
|
- Fix some potential overflow issues [\#1161](https://github.com/uclouvain/openjpeg/pull/1161) ([stweil](https://github.com/stweil))
|
||||||
|
- jp3d/jpwl convert: fix write stack buffer overflow [\#1160](https://github.com/uclouvain/openjpeg/pull/1160) ([hlef](https://github.com/hlef))
|
||||||
|
- Int overflow fixed [\#1159](https://github.com/uclouvain/openjpeg/pull/1159) ([ichlubna](https://github.com/ichlubna))
|
||||||
|
- Update knownfailures- files given current configurations [\#1149](https://github.com/uclouvain/openjpeg/pull/1149) ([rouault](https://github.com/rouault))
|
||||||
|
- CVE-2018-5785: fix issues with zero bitmasks [\#1148](https://github.com/uclouvain/openjpeg/pull/1148) ([hlef](https://github.com/hlef))
|
||||||
|
- openjp2/jp2: Fix two format strings [\#1143](https://github.com/uclouvain/openjpeg/pull/1143) ([stweil](https://github.com/stweil))
|
||||||
|
- Changes in pnmtoimage if image data are missing [\#1141](https://github.com/uclouvain/openjpeg/pull/1141) ([szukw000](https://github.com/szukw000))
|
||||||
|
- Relative path to header files is hardcoded in OpenJPEGConfig.cmake.in file [\#1140](https://github.com/uclouvain/openjpeg/pull/1140) ([bukatlib](https://github.com/bukatlib))
|
||||||
|
- Cast on uint ceildiv [\#1136](https://github.com/uclouvain/openjpeg/pull/1136) ([reverson](https://github.com/reverson))
|
||||||
|
- Add -DBUILD\_PKGCONFIG\_FILES to install instructions [\#1133](https://github.com/uclouvain/openjpeg/pull/1133) ([robe2](https://github.com/robe2))
|
||||||
|
- Fix some typos in code comments and documentation [\#1128](https://github.com/uclouvain/openjpeg/pull/1128) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix regression in reading files with TNsot == 0 \(refs \#1120\) [\#1121](https://github.com/uclouvain/openjpeg/pull/1121) ([rouault](https://github.com/rouault))
|
||||||
|
- Use local type declaration for POSIX standard type only for MS compiler [\#1119](https://github.com/uclouvain/openjpeg/pull/1119) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix Mac builds [\#1104](https://github.com/uclouvain/openjpeg/pull/1104) ([rouault](https://github.com/rouault))
|
||||||
|
- jp3d: Replace sprintf\(\) by snprintf\(\) in volumetobin\(\) [\#1101](https://github.com/uclouvain/openjpeg/pull/1101) ([kbabioch](https://github.com/kbabioch))
|
||||||
|
- opj\_mj2\_extract: Rename output\_location to output\_prefix [\#1096](https://github.com/uclouvain/openjpeg/pull/1096) ([kbabioch](https://github.com/kbabioch))
|
||||||
|
- mj2: Add missing variable to format string in fprintf\(\) invocation in meta\_out.c [\#1094](https://github.com/uclouvain/openjpeg/pull/1094) ([kbabioch](https://github.com/kbabioch))
|
||||||
|
- Convert files to UTF-8 encoding [\#1090](https://github.com/uclouvain/openjpeg/pull/1090) ([stweil](https://github.com/stweil))
|
||||||
|
- fix unchecked integer multiplication overflow [\#1080](https://github.com/uclouvain/openjpeg/pull/1080) ([setharnold](https://github.com/setharnold))
|
||||||
|
- Fixed typos [\#1062](https://github.com/uclouvain/openjpeg/pull/1062) ([radarhere](https://github.com/radarhere))
|
||||||
|
- Note that seek uses SEEK\_SET behavior. [\#1055](https://github.com/uclouvain/openjpeg/pull/1055) ([ideasman42](https://github.com/ideasman42))
|
||||||
|
- Some Doxygen tags are removed [\#1050](https://github.com/uclouvain/openjpeg/pull/1050) ([szukw000](https://github.com/szukw000))
|
||||||
|
- Fix resource leak \(CID 179466\) [\#1047](https://github.com/uclouvain/openjpeg/pull/1047) ([stweil](https://github.com/stweil))
|
||||||
|
- Changed cmake version test to allow for cmake 2.8.11.x [\#1042](https://github.com/uclouvain/openjpeg/pull/1042) ([radarhere](https://github.com/radarhere))
|
||||||
|
- Add missing fclose\(\) statement in error condition. [\#1037](https://github.com/uclouvain/openjpeg/pull/1037) ([gfiumara](https://github.com/gfiumara))
|
||||||
|
|
||||||
|
## [v2.3.0](https://github.com/uclouvain/openjpeg/releases/v2.3.0) (2017-10-04)
|
||||||
|
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.2.0...v2.3.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Sub-tile decoding: only decode precincts and codeblocks that intersect the window specified in opj_set_decode_area() [\#990](https://github.com/uclouvain/openjpeg/pull/990) ([rouault](https://github.com/rouault))
|
||||||
|
- Sub-tile decoding: only apply IDWT on areas that participate to the window of interest [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) ([rouault](https://github.com/rouault))
|
||||||
|
- Sub-tile decoding: memory use reduction and perf improvements [\#1010](https://github.com/uclouvain/openjpeg/pull/1010) ([rouault](https://github.com/rouault))
|
||||||
|
- Add capability to decode only a subset of all components of an image. [\#1022](https://github.com/uclouvain/openjpeg/pull/1022) ([rouault](https://github.com/rouault))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Setting x offset of decode region to -1 causes opj\_decompress to go into infinite loop [\#736](https://github.com/uclouvain/openjpeg/issues/736)
|
||||||
|
- Problem decoding multiple tiles with get\_decoded\_tile when cmap/pclr/cdef boxes are present in jp2 file [\#484](https://github.com/uclouvain/openjpeg/issues/484)
|
||||||
|
- set reduce\_factor\_may\_fail [\#474](https://github.com/uclouvain/openjpeg/issues/474)
|
||||||
|
- opj\_compress.exe, command line parser, infinite loop [\#469](https://github.com/uclouvain/openjpeg/issues/469)
|
||||||
|
- Various memory access issues found via fuzzing [\#448](https://github.com/uclouvain/openjpeg/issues/448)
|
||||||
|
- Multiple warnings when building OpenJPEG \(trunk\) [\#442](https://github.com/uclouvain/openjpeg/issues/442)
|
||||||
|
- Bulk fuzz-testing report [\#427](https://github.com/uclouvain/openjpeg/issues/427)
|
||||||
|
- remove all printf from openjpeg / use proper function pointer for logging [\#371](https://github.com/uclouvain/openjpeg/issues/371)
|
||||||
|
- minor changes, clean-up [\#349](https://github.com/uclouvain/openjpeg/issues/349)
|
||||||
|
- image-\>numcomps \> 4 [\#333](https://github.com/uclouvain/openjpeg/issues/333)
|
||||||
|
- Improve support for region of interest [\#39](https://github.com/uclouvain/openjpeg/issues/39)
|
||||||
|
- Public function to tell kernel type used \(5x3 vs 9x7\) [\#3](https://github.com/uclouvain/openjpeg/issues/3)
|
||||||
|
- elf binary in source package ? [\#1026](https://github.com/uclouvain/openjpeg/issues/1026)
|
||||||
|
- opj\_cio\_open [\#1025](https://github.com/uclouvain/openjpeg/issues/1025)
|
||||||
|
- Building with Visual Studio 2015 [\#1023](https://github.com/uclouvain/openjpeg/issues/1023)
|
||||||
|
- tcd.cpp\>:1617:33: error: assigning to 'OPJ\_INT32 \*' \(aka 'int \*'\) from incompatible type 'void \*' [\#1021](https://github.com/uclouvain/openjpeg/issues/1021)
|
||||||
|
- j2k.cpp \> comparison of address of 'p\_j2k-\>m\_cp.tcps\[0\].m\_data' not equal to a null pointer is always true [\#1020](https://github.com/uclouvain/openjpeg/issues/1020)
|
||||||
|
- Openjpeg 2.2.0 always build shared library even though -DBUILD\_SHARED\_LIBS:bool=off [\#1019](https://github.com/uclouvain/openjpeg/issues/1019)
|
||||||
|
- missing fclose [\#1018](https://github.com/uclouvain/openjpeg/issues/1018)
|
||||||
|
- Use opj\_image\_data\_free instead of opj\_free for image-\>comps\[\].data [\#1014](https://github.com/uclouvain/openjpeg/issues/1014)
|
||||||
|
- malloc poison on some compilers - cross compiling [\#1013](https://github.com/uclouvain/openjpeg/issues/1013)
|
||||||
|
- Add OPJ\_VERSION\_MAJOR, OPJ\_VERSION\_MINOR, OPJ\_VERSION\_MICRO macros in openjpeg.h [\#1011](https://github.com/uclouvain/openjpeg/issues/1011)
|
||||||
|
- Encode: do not perform rate control for single-tile lossless [\#1009](https://github.com/uclouvain/openjpeg/issues/1009)
|
||||||
|
- opj\_set\_decoded\_resolution\_factor\(\): bad interaction with opj\_set\_decode\_area\(\) and/or opj\_decode\(\) [\#1006](https://github.com/uclouvain/openjpeg/issues/1006)
|
||||||
|
- memory allocation failure with .pgx file [\#999](https://github.com/uclouvain/openjpeg/issues/999)
|
||||||
|
- Unable to fuzz with raw image as input [\#998](https://github.com/uclouvain/openjpeg/issues/998)
|
||||||
|
- stack-based buffer overflow write in pgxtoimage \(/convert.c\) [\#997](https://github.com/uclouvain/openjpeg/issues/997)
|
||||||
|
- freeze with a crafted bmp [\#996](https://github.com/uclouvain/openjpeg/issues/996)
|
||||||
|
- invalid memory write in tgatoimage \(convert.c\) [\#995](https://github.com/uclouvain/openjpeg/issues/995)
|
||||||
|
- static build on Windows fails [\#994](https://github.com/uclouvain/openjpeg/issues/994)
|
||||||
|
- another heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#993](https://github.com/uclouvain/openjpeg/issues/993)
|
||||||
|
- heap-based buffer overflow in opj\_t2\_encode\_packet \(t2.c\) [\#992](https://github.com/uclouvain/openjpeg/issues/992)
|
||||||
|
- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) \(unfixed \#985\) [\#991](https://github.com/uclouvain/openjpeg/issues/991)
|
||||||
|
- heap overflow in opj\_compress [\#988](https://github.com/uclouvain/openjpeg/issues/988)
|
||||||
|
- heap overflow in opj\_decompress [\#987](https://github.com/uclouvain/openjpeg/issues/987)
|
||||||
|
- heap-based buffer overflow in opj\_bio\_byteout \(bio.c\) [\#986](https://github.com/uclouvain/openjpeg/issues/986)
|
||||||
|
- heap-based buffer overflow in opj\_write\_bytes\_LE \(cio.c\) [\#985](https://github.com/uclouvain/openjpeg/issues/985)
|
||||||
|
- memory allocation failure in opj\_aligned\_alloc\_n \(opj\_malloc.c\) [\#983](https://github.com/uclouvain/openjpeg/issues/983)
|
||||||
|
- heap-base buffer overflow in opj\_mqc\_flush \(mqc.c\) [\#982](https://github.com/uclouvain/openjpeg/issues/982)
|
||||||
|
- Decode fails for JP2s with ICC profile [\#981](https://github.com/uclouvain/openjpeg/issues/981)
|
||||||
|
- Unit tests failing on Ubuntu 17.04 [\#916](https://github.com/uclouvain/openjpeg/issues/916)
|
||||||
|
- Encoder crashes on small images [\#901](https://github.com/uclouvain/openjpeg/issues/901)
|
||||||
|
- openjpeg-1.5.3 fails to compile [\#830](https://github.com/uclouvain/openjpeg/issues/830)
|
||||||
|
- opj\_compress crops image \(win\) or creates a jp2 which cannot be decompressed \(lin\) [\#716](https://github.com/uclouvain/openjpeg/issues/716)
|
||||||
|
- -d flag is silently ignored when decoding a single tile [\#693](https://github.com/uclouvain/openjpeg/issues/693)
|
||||||
|
- transition away from dev-utils [\#628](https://github.com/uclouvain/openjpeg/issues/628)
|
||||||
|
- update instructions to build with Visual Studio and 64-Bit Visual C++ Toolset. [\#1028](https://github.com/uclouvain/openjpeg/pull/1028) ([quangnh89](https://github.com/quangnh89))
|
||||||
|
- Add missing newline at end of file [\#1024](https://github.com/uclouvain/openjpeg/pull/1024) ([stweil](https://github.com/stweil))
|
||||||
|
- merge master into coverity\_scan to update coverity results [\#1008](https://github.com/uclouvain/openjpeg/pull/1008) ([detonin](https://github.com/detonin))
|
||||||
|
- Use more const qualifiers [\#984](https://github.com/uclouvain/openjpeg/pull/984) ([stweil](https://github.com/stweil))
|
||||||
|
- Changes in converttif.c for PPC64 [\#980](https://github.com/uclouvain/openjpeg/pull/980) ([szukw000](https://github.com/szukw000))
|
||||||
|
|
||||||
|
## [v2.2.0](https://github.com/uclouvain/openjpeg/releases/v2.2.0) (2017-08-10)
|
||||||
|
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.2...v2.2.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968) ([rouault](https://github.com/rouault))
|
||||||
|
- T1 & DWT multithreading decoding optimizations [\#786](https://github.com/uclouvain/openjpeg/pull/786) ([rouault](https://github.com/rouault))
|
||||||
|
- Tier1 decoder speed optimizations [\#783](https://github.com/uclouvain/openjpeg/pull/783) ([rouault](https://github.com/rouault))
|
||||||
|
- Inverse DWT 5x3: lift implementation / SSE accelerated version [\#953](https://github.com/uclouvain/openjpeg/issues/953)
|
||||||
|
- install static libraries [\#969](https://github.com/uclouvain/openjpeg/pull/969) ([jeroen](https://github.com/jeroen))
|
||||||
|
- IDWT 5x3 single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957) ([rouault](https://github.com/rouault))
|
||||||
|
- build both shared and static library [\#954](https://github.com/uclouvain/openjpeg/pull/954) ([jeroen](https://github.com/jeroen))
|
||||||
|
- T1 flag optimizations \(\#172\) [\#945](https://github.com/uclouvain/openjpeg/pull/945) ([rouault](https://github.com/rouault))
|
||||||
|
- CMake: add stronger warnings for openjp2 lib/bin by default, and error out on declaration-after-statement [\#936](https://github.com/uclouvain/openjpeg/pull/936) ([rouault](https://github.com/rouault))
|
||||||
|
- Quiet mode for opj\_decompress via -quiet long parameter. [\#928](https://github.com/uclouvain/openjpeg/pull/928) ([RussellMcOrmond](https://github.com/RussellMcOrmond))
|
||||||
|
- Implement predictive termination check [\#800](https://github.com/uclouvain/openjpeg/pull/800) ([rouault](https://github.com/rouault))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Several issues spotted by Google OSS Fuzz - [see here](https://github.com/search?l=&q=OSS+Fuzz+author-date%3A2017-07-04..2017-08-01+repo%3Auclouvain%2Fopenjpeg&ref=advsearch&type=Commits&utf8=%E2%9C%93)
|
||||||
|
- Missing fclose [\#976](https://github.com/uclouvain/openjpeg/issues/976)
|
||||||
|
- Heap buffer overflow read in openjpeg imagetopnm [\#970](https://github.com/uclouvain/openjpeg/issues/970)
|
||||||
|
- opj\_decompress opj\_j2k\_update\_image\_data\(\) Segment falut [\#948](https://github.com/uclouvain/openjpeg/issues/948)
|
||||||
|
- Generic Crash in 1.5.0 [\#941](https://github.com/uclouvain/openjpeg/issues/941)
|
||||||
|
- Segmentation Faults [\#940](https://github.com/uclouvain/openjpeg/issues/940)
|
||||||
|
- Assertions thrown [\#939](https://github.com/uclouvain/openjpeg/issues/939)
|
||||||
|
- Floating Point Errors [\#938](https://github.com/uclouvain/openjpeg/issues/938)
|
||||||
|
- Division by zero crash [\#937](https://github.com/uclouvain/openjpeg/issues/937)
|
||||||
|
- malformed jp2 can cause heap-buffer-overflow [\#909](https://github.com/uclouvain/openjpeg/issues/909)
|
||||||
|
- NULL dereference can cause by malformed file [\#908](https://github.com/uclouvain/openjpeg/issues/908)
|
||||||
|
- Out of bound read in opj\_j2k\_add\_mct [\#907](https://github.com/uclouvain/openjpeg/issues/907)
|
||||||
|
- Check bpno\_plus\_one in opj\_t1\_decode\_cblk [\#903](https://github.com/uclouvain/openjpeg/issues/903)
|
||||||
|
- Undefined-shift in opj\_j2k\_read\_siz [\#902](https://github.com/uclouvain/openjpeg/issues/902)
|
||||||
|
- opj\_compress v2.1.2 can create images opj\_decompress cannot read [\#891](https://github.com/uclouvain/openjpeg/issues/891)
|
||||||
|
- Improper usage of opj\_int\_ceildiv can cause overflows [\#889](https://github.com/uclouvain/openjpeg/issues/889)
|
||||||
|
- Undefined shift in opj\_get\_all\_encoding\_parameters [\#885](https://github.com/uclouvain/openjpeg/issues/885)
|
||||||
|
- Denial of service \(crash\) due to use-after-free when decoding an illegal JPEG2000 image file v2.1.2 \(2017-04 [\#880](https://github.com/uclouvain/openjpeg/issues/880)
|
||||||
|
- Denial of service \(crash\) when decoding an illegal JPEG2000 image file v2.1.2 \(2017-03\) [\#879](https://github.com/uclouvain/openjpeg/issues/879)
|
||||||
|
- bug png 2 j2k [\#868](https://github.com/uclouvain/openjpeg/issues/868)
|
||||||
|
- Inconsistent compression using cinema settings on folder of non-compliant image [\#864](https://github.com/uclouvain/openjpeg/issues/864)
|
||||||
|
- Openjpeg-2.1.2 Heap Buffer Overflow Vulnerability due to Insufficient check [\#862](https://github.com/uclouvain/openjpeg/issues/862)
|
||||||
|
- Heap Buffer Overflow in function pnmtoimage of convert.c [\#861](https://github.com/uclouvain/openjpeg/issues/861)
|
||||||
|
- CVE-2016-9112 FPE\(Floating Point Exception\) in lib/openjp2/pi.c:523 [\#855](https://github.com/uclouvain/openjpeg/issues/855)
|
||||||
|
- CVE-2016-5139, CVE-2016-5152, CVE-2016-5158, CVE-2016-5159 [\#854](https://github.com/uclouvain/openjpeg/issues/854)
|
||||||
|
- Undefined Reference error [\#853](https://github.com/uclouvain/openjpeg/issues/853)
|
||||||
|
- opj\_compress with lossy compression results in strange pixel values [\#851](https://github.com/uclouvain/openjpeg/issues/851)
|
||||||
|
- CVE-2016-1626 and CVE-2016-1628 [\#850](https://github.com/uclouvain/openjpeg/issues/850)
|
||||||
|
- Out-of-Bounds Write in opj\_mqc\_byteout of mqc.c [\#835](https://github.com/uclouvain/openjpeg/issues/835)
|
||||||
|
- WARNING in tgt\_create tree-\>numnodes == 0, no tree created. [\#794](https://github.com/uclouvain/openjpeg/issues/794)
|
||||||
|
- Potential overflow when precision is larger than 32 [\#781](https://github.com/uclouvain/openjpeg/issues/781)
|
||||||
|
- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 366\) [\#780](https://github.com/uclouvain/openjpeg/issues/780)
|
||||||
|
- division-by-zero in function opj\_pi\_next\_rpcl of pi.c \(line 363\) [\#779](https://github.com/uclouvain/openjpeg/issues/779)
|
||||||
|
- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 447\) [\#778](https://github.com/uclouvain/openjpeg/issues/778)
|
||||||
|
- division-by-zero in function opj\_pi\_next\_pcrl of pi.c \(line 444\) [\#777](https://github.com/uclouvain/openjpeg/issues/777)
|
||||||
|
- Encoding the following file with 32x32 tiling produces jp2 image with artifact [\#737](https://github.com/uclouvain/openjpeg/issues/737)
|
||||||
|
- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 526 of pi.c\) [\#732](https://github.com/uclouvain/openjpeg/issues/732)
|
||||||
|
- division-by-zero \(SIGFPE\) error in opj\_pi\_next\_cprl function \(line 523 of pi.c\) [\#731](https://github.com/uclouvain/openjpeg/issues/731)
|
||||||
|
- OpenJpeg 2.1 and 1.4 fails to decompress this file correctly [\#721](https://github.com/uclouvain/openjpeg/issues/721)
|
||||||
|
- MQ Encode :uninitialized memory access when first pass does not output any bytes [\#709](https://github.com/uclouvain/openjpeg/issues/709)
|
||||||
|
- Out-of-bounds read in opj\_j2k\_update\_image\_data and opj\_tgt\_reset function [\#704](https://github.com/uclouvain/openjpeg/issues/704)
|
||||||
|
- Remove opj\_aligned\_malloc / opj\_aligned\_realloc / opj\_aligned\_free? [\#689](https://github.com/uclouvain/openjpeg/issues/689)
|
||||||
|
- There is an issue with rendering some type of jpeg file. Please ref the link. [\#672](https://github.com/uclouvain/openjpeg/issues/672)
|
||||||
|
- Null Dereference in tcd\_malloc\_decode\_tile [\#657](https://github.com/uclouvain/openjpeg/issues/657)
|
||||||
|
- ETS-C1P0-p0\_12.j2k-compare2ref & NR-C1P0-p0\_12.j2k-compare2base failing under windows [\#655](https://github.com/uclouvain/openjpeg/issues/655)
|
||||||
|
- Memory leak [\#631](https://github.com/uclouvain/openjpeg/issues/631)
|
||||||
|
- Test 481 reports error in valgrind memcheck [\#612](https://github.com/uclouvain/openjpeg/issues/612)
|
||||||
|
- reserved identifier violation [\#587](https://github.com/uclouvain/openjpeg/issues/587)
|
||||||
|
- Buffer overflow when compressing some 16 bits images of the test suite [\#539](https://github.com/uclouvain/openjpeg/issues/539)
|
||||||
|
- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#480](https://github.com/uclouvain/openjpeg/issues/480)
|
||||||
|
- Automated fuzz testing [\#468](https://github.com/uclouvain/openjpeg/issues/468)
|
||||||
|
- Expected to find EPH marker [\#425](https://github.com/uclouvain/openjpeg/issues/425)
|
||||||
|
- read: segment too long \(6182\) with max \(35872\) for codeblock 0 \(p=19, b=2, r=5, c=1\) [\#284](https://github.com/uclouvain/openjpeg/issues/284)
|
||||||
|
- building 64bit version has lots of warnings [\#244](https://github.com/uclouvain/openjpeg/issues/244)
|
||||||
|
- Wrong encoding of small tiles with high level number [\#239](https://github.com/uclouvain/openjpeg/issues/239)
|
||||||
|
- Errors raised in pi.c by VS11 analyzer [\#190](https://github.com/uclouvain/openjpeg/issues/190)
|
||||||
|
- Undocumented optimization found in v2 branch of openjpeg [\#183](https://github.com/uclouvain/openjpeg/issues/183)
|
||||||
|
- T1 optimisations jpeg2000 [\#172](https://github.com/uclouvain/openjpeg/issues/172)
|
||||||
|
- Remove OPJ\_NOSANITIZE in opj\_bio\_read\(\) and opj\_bio\_write\(\) \(\#761\) [\#955](https://github.com/uclouvain/openjpeg/pull/955) ([rouault](https://github.com/rouault))
|
||||||
|
- Fix bypass pterm termall and lossless decomposition issue \(\#891, \#892\) [\#949](https://github.com/uclouvain/openjpeg/pull/949) ([rouault](https://github.com/rouault))
|
||||||
|
- Escape quotes to ensure README renders on GitHub correctly [\#914](https://github.com/uclouvain/openjpeg/pull/914) ([alexwlchan](https://github.com/alexwlchan))
|
||||||
|
- Remove spurious .R macros from manpages [\#899](https://github.com/uclouvain/openjpeg/pull/899) ([jwilk](https://github.com/jwilk))
|
||||||
|
- Remove warnings related to empty tag-trees. [\#893](https://github.com/uclouvain/openjpeg/pull/893) ([rouault](https://github.com/rouault))
|
||||||
|
|
||||||
|
**Maintenance-related tasks:**
|
||||||
|
|
||||||
|
- Submit OpenJPEG to oss-fuzz [\#965](https://github.com/uclouvain/openjpeg/issues/965)
|
||||||
|
- Updates for Doxygen to suppress warnings [\#849](https://github.com/uclouvain/openjpeg/issues/849)
|
||||||
|
- Remove useless knownfailures \(since LAZY encoding is fixed\) [\#964](https://github.com/uclouvain/openjpeg/pull/964) ([rouault](https://github.com/rouault))
|
||||||
|
- Enable AVX2 at runtime on Travis-CI and AppVeyor [\#963](https://github.com/uclouvain/openjpeg/pull/963) ([rouault](https://github.com/rouault))
|
||||||
|
- Tests: test opj\_compress in VSC mode \(related to \#172\) [\#935](https://github.com/uclouvain/openjpeg/pull/935) ([rouault](https://github.com/rouault))
|
||||||
|
- Reformat: apply reformattin on .h files \(\#128\) [\#926](https://github.com/uclouvain/openjpeg/pull/926) ([rouault](https://github.com/rouault))
|
||||||
|
- Add mechanisms to reformat and check code style, and reformat whole codebase \(\#128\) [\#919](https://github.com/uclouvain/openjpeg/pull/919) ([rouault](https://github.com/rouault))
|
||||||
|
- Add profiling of CPU and memory usage \(\#912\) [\#918](https://github.com/uclouvain/openjpeg/pull/918) ([rouault](https://github.com/rouault))
|
||||||
|
- Add performance benchmarking scripts [\#917](https://github.com/uclouvain/openjpeg/pull/917) ([rouault](https://github.com/rouault))
|
||||||
|
- Fix retrieval of jpylyzer in AppVeyor [\#915](https://github.com/uclouvain/openjpeg/pull/915) ([rouault](https://github.com/rouault))
|
||||||
|
|
||||||
|
## [v2.1.2](https://github.com/uclouvain/openjpeg/releases/v2.1.2) (2016-09-28)
|
||||||
|
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.1...v2.1.2)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- null ptr dereference in convert.c:1331 [\#843](https://github.com/uclouvain/openjpeg/issues/843)
|
||||||
|
- Out-of-Bounds Read in function bmp24toimage of convertbmp.c [\#833](https://github.com/uclouvain/openjpeg/issues/833)
|
||||||
|
- Disable automatic compilation of t1\_generate\_luts in CMakeLists.txt [\#831](https://github.com/uclouvain/openjpeg/issues/831)
|
||||||
|
- CVE-2016-7163 Integer overflow in opj\_pi\_create\_decode [\#826](https://github.com/uclouvain/openjpeg/issues/826)
|
||||||
|
- Security Advisory for OpenJPEG [\#810](https://github.com/uclouvain/openjpeg/issues/810)
|
||||||
|
- Add dashboard with static lib [\#804](https://github.com/uclouvain/openjpeg/issues/804)
|
||||||
|
- hidden visibility for the static library / building with -DOPJ\_STATIC against shared lib [\#802](https://github.com/uclouvain/openjpeg/issues/802)
|
||||||
|
- Optimization when building library from source [\#799](https://github.com/uclouvain/openjpeg/issues/799)
|
||||||
|
- unsigned int16 on Solaris 11.2/sparc [\#796](https://github.com/uclouvain/openjpeg/issues/796)
|
||||||
|
- appveyor [\#793](https://github.com/uclouvain/openjpeg/issues/793)
|
||||||
|
- FFMpeg will not link to 2.1.1 release built as shared library [\#766](https://github.com/uclouvain/openjpeg/issues/766)
|
||||||
|
- API change since v2: opj\_event\_mgr\_t not available [\#754](https://github.com/uclouvain/openjpeg/issues/754)
|
||||||
|
- openjpeg.h needs dependencies [\#673](https://github.com/uclouvain/openjpeg/issues/673)
|
||||||
|
- "master" does not build on ubuntu [\#658](https://github.com/uclouvain/openjpeg/issues/658)
|
||||||
|
- Package 'openjp2', required by 'libopenjpip', not found [\#594](https://github.com/uclouvain/openjpeg/issues/594)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Fix PNM file reading [\#847](https://github.com/uclouvain/openjpeg/pull/847) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix some issues reported by Coverity Scan [\#846](https://github.com/uclouvain/openjpeg/pull/846) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix potential out-of-bounds read \(coverity\) [\#844](https://github.com/uclouvain/openjpeg/pull/844) ([stweil](https://github.com/stweil))
|
||||||
|
- Remove TODO for overflow check [\#842](https://github.com/uclouvain/openjpeg/pull/842) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add overflow checks for opj\_aligned\_malloc [\#841](https://github.com/uclouvain/openjpeg/pull/841) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Flags in T1 shall be unsigned [\#840](https://github.com/uclouvain/openjpeg/pull/840) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix some warnings [\#838](https://github.com/uclouvain/openjpeg/pull/838) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix issue 833. [\#834](https://github.com/uclouvain/openjpeg/pull/834) ([trylab](https://github.com/trylab))
|
||||||
|
- Add overflow checks for opj\_aligned\_malloc [\#832](https://github.com/uclouvain/openjpeg/pull/832) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add test for issue 820 [\#829](https://github.com/uclouvain/openjpeg/pull/829) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add test for issue 826 [\#827](https://github.com/uclouvain/openjpeg/pull/827) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix coverity 113065 \(CWE-484\) [\#824](https://github.com/uclouvain/openjpeg/pull/824) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add sanity check for tile coordinates [\#823](https://github.com/uclouvain/openjpeg/pull/823) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add test for PR 818 [\#822](https://github.com/uclouvain/openjpeg/pull/822) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([mayeut](https://github.com/mayeut))
|
||||||
|
- CVE-2016-8332: fix incrementing of "l\_tcp-\>m\_nb\_mcc\_records" in opj\_j2k\_read\_mcc [\#820](https://github.com/uclouvain/openjpeg/pull/820) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add overflow check in opj\_tcd\_init\_tile [\#819](https://github.com/uclouvain/openjpeg/pull/819) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix leak & invalid behavior of opj\_jp2\_read\_ihdr [\#818](https://github.com/uclouvain/openjpeg/pull/818) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add overflow check in opj\_j2k\_update\_image\_data [\#817](https://github.com/uclouvain/openjpeg/pull/817) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Change 'restrict' define to 'OPJ\_RESTRICT' [\#816](https://github.com/uclouvain/openjpeg/pull/816) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Switch to clang 3.8 [\#814](https://github.com/uclouvain/openjpeg/pull/814) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix an integer overflow issue [\#809](https://github.com/uclouvain/openjpeg/pull/809) ([trylab](https://github.com/trylab))
|
||||||
|
- Update to lcms 2.8 [\#808](https://github.com/uclouvain/openjpeg/pull/808) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update to libpng 1.6.24 [\#807](https://github.com/uclouvain/openjpeg/pull/807) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Reenable clang-3.9 build on travis [\#806](https://github.com/uclouvain/openjpeg/pull/806) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Bit fields type [\#805](https://github.com/uclouvain/openjpeg/pull/805) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- Add compilation test for standalone inclusion of openjpeg.h [\#798](https://github.com/uclouvain/openjpeg/pull/798) ([mayeut](https://github.com/mayeut))
|
||||||
|
- jpwl: Remove non-portable data type u\_int16\_t \(fix issue \#796\) [\#797](https://github.com/uclouvain/openjpeg/pull/797) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix dependency for pkg-config \(issue \#594\) [\#795](https://github.com/uclouvain/openjpeg/pull/795) ([stweil](https://github.com/stweil))
|
||||||
|
- Add .gitignore [\#787](https://github.com/uclouvain/openjpeg/pull/787) ([stweil](https://github.com/stweil))
|
||||||
|
|
||||||
|
## [v2.1.1](https://github.com/uclouvain/openjpeg/releases/tag/v2.1.1) (2016-07-05)
|
||||||
|
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.1...v2.1.1)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- opj\_malloc replacement [\#625](https://github.com/uclouvain/openjpeg/issues/625)
|
||||||
|
- backport "-p" and "-force-rgb" options in 1.5 [\#606](https://github.com/uclouvain/openjpeg/issues/606)
|
||||||
|
- Use travis-ci matrix build [\#581](https://github.com/uclouvain/openjpeg/issues/581)
|
||||||
|
- Add Coverity Scan analysis [\#580](https://github.com/uclouvain/openjpeg/issues/580)
|
||||||
|
- Unnecessary rate distortion calculations [\#479](https://github.com/uclouvain/openjpeg/issues/479)
|
||||||
|
- Add images from various security issues to test suite [\#415](https://github.com/uclouvain/openjpeg/issues/415)
|
||||||
|
- Coding speed for 9/7 on 32bits platforms \(x86/ARM\) can be improved with a quick fix [\#220](https://github.com/uclouvain/openjpeg/issues/220)
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Out-of-Bounds Access in function opj\_tgt\_reset of tgt.c [\#775](https://github.com/uclouvain/openjpeg/issues/775)
|
||||||
|
- Heap Buffer Overflow in function color\_cmyk\_to\_rgb of color.c [\#774](https://github.com/uclouvain/openjpeg/issues/774)
|
||||||
|
- division-by-zero \(SIGFPE\) error in opj\_tcd\_init\_tile function \(line 730 of tcd.c\) [\#733](https://github.com/uclouvain/openjpeg/issues/733)
|
||||||
|
- Out-Of-Bounds Read in sycc422\_to\_rgb function [\#726](https://github.com/uclouvain/openjpeg/issues/726)
|
||||||
|
- Heap Corruption in opj\_free function [\#725](https://github.com/uclouvain/openjpeg/issues/725)
|
||||||
|
- Out-Of-Bounds Read in opj\_tcd\_free\_tile function [\#724](https://github.com/uclouvain/openjpeg/issues/724)
|
||||||
|
- Cannot handle box of undefined size [\#653](https://github.com/uclouvain/openjpeg/issues/653)
|
||||||
|
- Compilation fails without platform-supplied aligned malloc [\#642](https://github.com/uclouvain/openjpeg/issues/642)
|
||||||
|
- HP compiler warns about redeclaration of static function [\#640](https://github.com/uclouvain/openjpeg/issues/640)
|
||||||
|
- Implementation-defined behavior of malloc causes different behavior on Linux and AIX [\#635](https://github.com/uclouvain/openjpeg/issues/635)
|
||||||
|
- Build on AIX fails because "opj\_includes.h" is included after system headers [\#633](https://github.com/uclouvain/openjpeg/issues/633)
|
||||||
|
- Compiling with SSE2 on Linux 32-bit causes crashes in OpenJPEG [\#624](https://github.com/uclouvain/openjpeg/issues/624)
|
||||||
|
- Build on AIX fails because of "restrict" pointers [\#620](https://github.com/uclouvain/openjpeg/issues/620)
|
||||||
|
- bug in new tif conversion code [\#609](https://github.com/uclouvain/openjpeg/issues/609)
|
||||||
|
- bin/jp2/convert.c line 1085 Resource leak [\#607](https://github.com/uclouvain/openjpeg/issues/607)
|
||||||
|
- bin/jp2/convert.c memory leak [\#601](https://github.com/uclouvain/openjpeg/issues/601)
|
||||||
|
- Resource leak in opj\_j2k\_create\_cstr\_index in case of failure [\#599](https://github.com/uclouvain/openjpeg/issues/599)
|
||||||
|
- Resource leak in opj\_j2k\_encode in case of failure [\#598](https://github.com/uclouvain/openjpeg/issues/598)
|
||||||
|
- Resource leak in opj\_j2k\_decode\_one\_tile in case of failure [\#597](https://github.com/uclouvain/openjpeg/issues/597)
|
||||||
|
- Resource Leak [\#573](https://github.com/uclouvain/openjpeg/issues/573)
|
||||||
|
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) [\#571](https://github.com/uclouvain/openjpeg/issues/571)
|
||||||
|
- Use-after-free in opj\_j2k\_write\_mco [\#563](https://github.com/uclouvain/openjpeg/issues/563)
|
||||||
|
- openjpeg-master-2015-07-30 failed to compile on LINUX [\#556](https://github.com/uclouvain/openjpeg/issues/556)
|
||||||
|
- PNG images are always read as RGB\(A\) images [\#536](https://github.com/uclouvain/openjpeg/issues/536)
|
||||||
|
- g4\_colr.j2c not handled properly [\#532](https://github.com/uclouvain/openjpeg/issues/532)
|
||||||
|
- Bigendian: opj\_compress + opj\_decompress fails [\#518](https://github.com/uclouvain/openjpeg/issues/518)
|
||||||
|
- Suspicious code in j2k.c [\#517](https://github.com/uclouvain/openjpeg/issues/517)
|
||||||
|
- Decode times almost double\(!!\) on Visual Studio 2013, 2015 [\#505](https://github.com/uclouvain/openjpeg/issues/505)
|
||||||
|
- opj\_data/input/nonregression/issue226.j2k [\#500](https://github.com/uclouvain/openjpeg/issues/500)
|
||||||
|
- opj\_setup\_encoder always returns true [\#497](https://github.com/uclouvain/openjpeg/issues/497)
|
||||||
|
- Double free in j2k\_read\_ppm\_v3 parsing \(\(presumably invalid\) image. [\#496](https://github.com/uclouvain/openjpeg/issues/496)
|
||||||
|
- Invalid write in opj\_j2k\_update\_image\_data [\#495](https://github.com/uclouvain/openjpeg/issues/495)
|
||||||
|
- Undefined printf format specifier %ud used in code [\#494](https://github.com/uclouvain/openjpeg/issues/494)
|
||||||
|
- Potential double free on malloc failure in opj\_j2k\_copy\_default\_tcp\_and\_create\_tcp\(\) [\#492](https://github.com/uclouvain/openjpeg/issues/492)
|
||||||
|
- Do not link with -ffast-math [\#488](https://github.com/uclouvain/openjpeg/issues/488)
|
||||||
|
- Heap-buffer-overflow in opj\_dwt\_decode [\#486](https://github.com/uclouvain/openjpeg/issues/486)
|
||||||
|
- opj\_dump fails on Windows 7, 64 bits [\#482](https://github.com/uclouvain/openjpeg/issues/482)
|
||||||
|
- SIGSEGV in opj\_j2k\_update\_image\_data via pdfium\_test [\#481](https://github.com/uclouvain/openjpeg/issues/481)
|
||||||
|
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#477](https://github.com/uclouvain/openjpeg/issues/477)
|
||||||
|
- Invalid image causes write past end of heap buffer [\#476](https://github.com/uclouvain/openjpeg/issues/476)
|
||||||
|
- Assertion `l\_res-\>x0 \>= 0' fails when parsing invalid images [\#475](https://github.com/uclouvain/openjpeg/issues/475)
|
||||||
|
- Bug on opj\_write\_bytes\_BE function [\#472](https://github.com/uclouvain/openjpeg/issues/472)
|
||||||
|
- Refactor j2k\_read\_ppm\_v3 function [\#470](https://github.com/uclouvain/openjpeg/issues/470)
|
||||||
|
- compression: strange precinct dimensions [\#466](https://github.com/uclouvain/openjpeg/issues/466)
|
||||||
|
- \(:- Console message in opj\_decompress -:\) [\#465](https://github.com/uclouvain/openjpeg/issues/465)
|
||||||
|
- opj\_decompress fails to decompress any files [\#463](https://github.com/uclouvain/openjpeg/issues/463)
|
||||||
|
- bio-\>ct is unnecessarily set to zero in opj\_bio\_flush method [\#461](https://github.com/uclouvain/openjpeg/issues/461)
|
||||||
|
- Maximal unsigned short is 65535, not 65536 [\#460](https://github.com/uclouvain/openjpeg/issues/460)
|
||||||
|
- OpenJpeg fails to encode components with different precision properly [\#459](https://github.com/uclouvain/openjpeg/issues/459)
|
||||||
|
- component precision upscaling isn't correct in opj\_decompress [\#458](https://github.com/uclouvain/openjpeg/issues/458)
|
||||||
|
- Multiple precision components won't get encoded to jp2 if 1 component is unsigned 1 bit [\#457](https://github.com/uclouvain/openjpeg/issues/457)
|
||||||
|
- Incorrect code in ../bin/jp2/convert.c, function rawtoimage\_common\(...\) [\#456](https://github.com/uclouvain/openjpeg/issues/456)
|
||||||
|
- \[OpenJPEG-trunk\] opj\_stream\_get\_number\_byte\_left throws assert [\#455](https://github.com/uclouvain/openjpeg/issues/455)
|
||||||
|
- NR-DEC-kodak\_2layers\_lrcp.j2c-31-decode-md5 fails randomly when running tests in parallel [\#454](https://github.com/uclouvain/openjpeg/issues/454)
|
||||||
|
- compare\_raw\_files doesn't report an error on invalid arguments / missing input files [\#453](https://github.com/uclouvain/openjpeg/issues/453)
|
||||||
|
- Forward discrete wavelet transform: implement periodic symmetric extension at boundaries [\#452](https://github.com/uclouvain/openjpeg/issues/452)
|
||||||
|
- Bug in tiff reading method in convert.c [\#449](https://github.com/uclouvain/openjpeg/issues/449)
|
||||||
|
- Image in pdf don't display [\#447](https://github.com/uclouvain/openjpeg/issues/447)
|
||||||
|
- Multiple issues causing opj\_decompress to segfault [\#446](https://github.com/uclouvain/openjpeg/issues/446)
|
||||||
|
- opj\_compress: 40% of encode time is spent freeing data [\#445](https://github.com/uclouvain/openjpeg/issues/445)
|
||||||
|
- Multiple warnings when configuring OpenJPEG on MacOS with CMake 3.x \(trunk\) [\#443](https://github.com/uclouvain/openjpeg/issues/443)
|
||||||
|
- valgrind memleak found [\#437](https://github.com/uclouvain/openjpeg/issues/437)
|
||||||
|
- global-buffer-overflow src/lib/openjp2/t1.c:1146 opj\_t1\_getwmsedec [\#436](https://github.com/uclouvain/openjpeg/issues/436)
|
||||||
|
- Warning introduced on trunk r2923 & r2924 [\#435](https://github.com/uclouvain/openjpeg/issues/435)
|
||||||
|
- heap-buffer-overflow in opj\_t1\_decode\_cblks [\#432](https://github.com/uclouvain/openjpeg/issues/432)
|
||||||
|
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#431](https://github.com/uclouvain/openjpeg/issues/431)
|
||||||
|
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#430](https://github.com/uclouvain/openjpeg/issues/430)
|
||||||
|
- Heap-buffer-overflow in opj\_jp2\_apply\_pclr [\#429](https://github.com/uclouvain/openjpeg/issues/429)
|
||||||
|
- issue412 revisited [\#428](https://github.com/uclouvain/openjpeg/issues/428)
|
||||||
|
- Image distorted \(sides look cankered\) [\#423](https://github.com/uclouvain/openjpeg/issues/423)
|
||||||
|
- openjpeg-2.x-trunk-r2918 is broken in color.c [\#422](https://github.com/uclouvain/openjpeg/issues/422)
|
||||||
|
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#420](https://github.com/uclouvain/openjpeg/issues/420)
|
||||||
|
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#418](https://github.com/uclouvain/openjpeg/issues/418)
|
||||||
|
- UNKNOWN in opj\_read\_bytes\_LE [\#417](https://github.com/uclouvain/openjpeg/issues/417)
|
||||||
|
- Transparency problem [\#416](https://github.com/uclouvain/openjpeg/issues/416)
|
||||||
|
- Image with per channel alpha \(cdef\) does not decode properly [\#414](https://github.com/uclouvain/openjpeg/issues/414)
|
||||||
|
- OpenJPEG crashes with attached image [\#413](https://github.com/uclouvain/openjpeg/issues/413)
|
||||||
|
- Palette image with cdef fails to decompress [\#412](https://github.com/uclouvain/openjpeg/issues/412)
|
||||||
|
- Invalid member values from opj\_read\_header or opj\_decode ? [\#411](https://github.com/uclouvain/openjpeg/issues/411)
|
||||||
|
- MD5 Checksum hangs under valgrind on MacOS X [\#410](https://github.com/uclouvain/openjpeg/issues/410)
|
||||||
|
- Heap-buffer-overflow in opj\_tcd\_get\_decoded\_tile\_size [\#408](https://github.com/uclouvain/openjpeg/issues/408)
|
||||||
|
- C++ style comments in trunk/src/lib/openjp2/j2k.c [\#407](https://github.com/uclouvain/openjpeg/issues/407)
|
||||||
|
- Backport bugfixes from trunk to 2.1 branch [\#405](https://github.com/uclouvain/openjpeg/issues/405)
|
||||||
|
- Heap-buffer-overflow in parse\_cmdline\_encoder [\#403](https://github.com/uclouvain/openjpeg/issues/403)
|
||||||
|
- Heap-buffer-overflow in opj\_v4dwt\_interleave\_h [\#400](https://github.com/uclouvain/openjpeg/issues/400)
|
||||||
|
- Heap-buffer-overflow in opj\_dwt\_decode [\#399](https://github.com/uclouvain/openjpeg/issues/399)
|
||||||
|
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#398](https://github.com/uclouvain/openjpeg/issues/398)
|
||||||
|
- Heap-buffer-overflow in opj\_jp2\_apply\_cdef [\#397](https://github.com/uclouvain/openjpeg/issues/397)
|
||||||
|
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#396](https://github.com/uclouvain/openjpeg/issues/396)
|
||||||
|
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#395](https://github.com/uclouvain/openjpeg/issues/395)
|
||||||
|
- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#394](https://github.com/uclouvain/openjpeg/issues/394)
|
||||||
|
- Heap-double-free in j2k\_read\_ppm\_v3 [\#393](https://github.com/uclouvain/openjpeg/issues/393)
|
||||||
|
- Security hole in j2k.c [\#392](https://github.com/uclouvain/openjpeg/issues/392)
|
||||||
|
- Security: double-free in opj\_tcd\_code\_block\_dec\_deallocate [\#391](https://github.com/uclouvain/openjpeg/issues/391)
|
||||||
|
- check for negative-size params in code [\#390](https://github.com/uclouvain/openjpeg/issues/390)
|
||||||
|
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#389](https://github.com/uclouvain/openjpeg/issues/389)
|
||||||
|
- Heap overflow in OpenJpeg 1.5.2 [\#388](https://github.com/uclouvain/openjpeg/issues/388)
|
||||||
|
- openjpip.so.6 file too short [\#387](https://github.com/uclouvain/openjpeg/issues/387)
|
||||||
|
- Corrupted JP3D file [\#386](https://github.com/uclouvain/openjpeg/issues/386)
|
||||||
|
- variable assigned to itself [\#383](https://github.com/uclouvain/openjpeg/issues/383)
|
||||||
|
- Null pointer dereferencing [\#382](https://github.com/uclouvain/openjpeg/issues/382)
|
||||||
|
- bad use of case statement [\#381](https://github.com/uclouvain/openjpeg/issues/381)
|
||||||
|
- Release 2.1 as a Ubuntu package [\#380](https://github.com/uclouvain/openjpeg/issues/380)
|
||||||
|
- Bug in libopenjpwl.pc [\#374](https://github.com/uclouvain/openjpeg/issues/374)
|
||||||
|
- inconsistent tile numbering in decode output message [\#370](https://github.com/uclouvain/openjpeg/issues/370)
|
||||||
|
- error in code block calculations [\#369](https://github.com/uclouvain/openjpeg/issues/369)
|
||||||
|
- r2872 fails to compile due to "attempt to use poisoned malloc" error in j2k.c [\#368](https://github.com/uclouvain/openjpeg/issues/368)
|
||||||
|
- OSX build gives libopenjp2.6.dylib with not-absolute install name id [\#367](https://github.com/uclouvain/openjpeg/issues/367)
|
||||||
|
- opj\_decompress gives error but successfully decompress in OPJ 2.1 [\#366](https://github.com/uclouvain/openjpeg/issues/366)
|
||||||
|
- pngtoimage\(\) and imagetopng\(\) have wrong byte order for 16-Bit image [\#365](https://github.com/uclouvain/openjpeg/issues/365)
|
||||||
|
- PDF crash in chrome - part2 \(due to attachment limit\) [\#364](https://github.com/uclouvain/openjpeg/issues/364)
|
||||||
|
- PDF crash in chrome - part1 [\#363](https://github.com/uclouvain/openjpeg/issues/363)
|
||||||
|
- PDF crash in chrome - part0 [\#362](https://github.com/uclouvain/openjpeg/issues/362)
|
||||||
|
- Compilation fails on Windows with mingw32 gcc4.8 [\#361](https://github.com/uclouvain/openjpeg/issues/361)
|
||||||
|
- security issue [\#360](https://github.com/uclouvain/openjpeg/issues/360)
|
||||||
|
- improve memory management [\#359](https://github.com/uclouvain/openjpeg/issues/359)
|
||||||
|
- how to compress a yuv420 raw data using opj\_compress [\#357](https://github.com/uclouvain/openjpeg/issues/357)
|
||||||
|
- Some memory allocation are not checked [\#355](https://github.com/uclouvain/openjpeg/issues/355)
|
||||||
|
- Static library symbols shall be marked as hidden [\#354](https://github.com/uclouvain/openjpeg/issues/354)
|
||||||
|
- opj\_compress rejects valid bmp files [\#353](https://github.com/uclouvain/openjpeg/issues/353)
|
||||||
|
- opj\_compress crashes when number of resolutions is set to zero [\#352](https://github.com/uclouvain/openjpeg/issues/352)
|
||||||
|
- Compilation error under Visual Studio 2003 [\#351](https://github.com/uclouvain/openjpeg/issues/351)
|
||||||
|
- opj\_compress description example error \[Low priority\] [\#350](https://github.com/uclouvain/openjpeg/issues/350)
|
||||||
|
- opj\_write\_bytes\_BE is wrong in trunk [\#345](https://github.com/uclouvain/openjpeg/issues/345)
|
||||||
|
- PART1ONLY option in release.sh doesn't work properly [\#332](https://github.com/uclouvain/openjpeg/issues/332)
|
||||||
|
- openjpeg crash error [\#330](https://github.com/uclouvain/openjpeg/issues/330)
|
||||||
|
- openjpeg decompress error [\#329](https://github.com/uclouvain/openjpeg/issues/329)
|
||||||
|
- openjpeg decompress issue [\#326](https://github.com/uclouvain/openjpeg/issues/326)
|
||||||
|
- limited tif support [\#322](https://github.com/uclouvain/openjpeg/issues/322)
|
||||||
|
- asoc value of 65536 is allowed [\#321](https://github.com/uclouvain/openjpeg/issues/321)
|
||||||
|
- opj\_skip\_from\_file error [\#314](https://github.com/uclouvain/openjpeg/issues/314)
|
||||||
|
- Heavy quota usage in openjpeg [\#309](https://github.com/uclouvain/openjpeg/issues/309)
|
||||||
|
- Verify -help actually match letter [\#307](https://github.com/uclouvain/openjpeg/issues/307)
|
||||||
|
- g3\_colr.j2c not handled [\#288](https://github.com/uclouvain/openjpeg/issues/288)
|
||||||
|
- reopen/fix issue 165 [\#280](https://github.com/uclouvain/openjpeg/issues/280)
|
||||||
|
- kakadu conformance tests [\#279](https://github.com/uclouvain/openjpeg/issues/279)
|
||||||
|
- missing break after case statement in opj\_dwt\_decode\_real [\#274](https://github.com/uclouvain/openjpeg/issues/274)
|
||||||
|
- Run Coverity on trunk [\#270](https://github.com/uclouvain/openjpeg/issues/270)
|
||||||
|
- NR-ENC-random-issue-0005.tif-12-encode [\#259](https://github.com/uclouvain/openjpeg/issues/259)
|
||||||
|
- Use new add\_test signature to handle cross compilation [\#258](https://github.com/uclouvain/openjpeg/issues/258)
|
||||||
|
- Loss decoding quality in 2.0.0 [\#254](https://github.com/uclouvain/openjpeg/issues/254)
|
||||||
|
- Decompress that worked in 1.5.1 fails in 2.0 [\#252](https://github.com/uclouvain/openjpeg/issues/252)
|
||||||
|
- Expected endianness with raw input is not documented leading to SEGFAULT [\#251](https://github.com/uclouvain/openjpeg/issues/251)
|
||||||
|
- OpenJPEG writes to stderr [\#246](https://github.com/uclouvain/openjpeg/issues/246)
|
||||||
|
- Inconsistent logging of tile index [\#245](https://github.com/uclouvain/openjpeg/issues/245)
|
||||||
|
- patch for openjpeg-trunk-r2347 and BIG\_ENDIAN [\#242](https://github.com/uclouvain/openjpeg/issues/242)
|
||||||
|
- CMAP: MTYP == 0 \(direct use\) not handled properly [\#235](https://github.com/uclouvain/openjpeg/issues/235)
|
||||||
|
- Black Pixel [\#233](https://github.com/uclouvain/openjpeg/issues/233)
|
||||||
|
- opj\_compress runtime error after fresh Linux install due to apparent failure to execute ldconfig [\#219](https://github.com/uclouvain/openjpeg/issues/219)
|
||||||
|
- openjp2 debug works, release build does not [\#217](https://github.com/uclouvain/openjpeg/issues/217)
|
||||||
|
- openjpeg-branch15-r2299 and openjpeg-trunk-r2299 fail to decode a JP2 file [\#212](https://github.com/uclouvain/openjpeg/issues/212)
|
||||||
|
- openjpeg-trunk issue with Win7 [\#201](https://github.com/uclouvain/openjpeg/issues/201)
|
||||||
|
- undefined reference to `opj\_version' [\#200](https://github.com/uclouvain/openjpeg/issues/200)
|
||||||
|
- In tgt.c we used fprintf not the openjpeg message reporter [\#184](https://github.com/uclouvain/openjpeg/issues/184)
|
||||||
|
- Windows binaries not working under WinXP [\#176](https://github.com/uclouvain/openjpeg/issues/176)
|
||||||
|
- add ability to use intel ipp \(performance primitive\) within OpenJPEG [\#164](https://github.com/uclouvain/openjpeg/issues/164)
|
||||||
|
- Migration guide v2 [\#160](https://github.com/uclouvain/openjpeg/issues/160)
|
||||||
|
- Cannot decompress JPEG2000Aware3.18.7.3Win32\_kdutranscode6.3.1.j2k [\#158](https://github.com/uclouvain/openjpeg/issues/158)
|
||||||
|
- Cannot decompress JPEG2000Aware3.18.7.3Win32.j2k [\#157](https://github.com/uclouvain/openjpeg/issues/157)
|
||||||
|
- openjpeg@googlegroups.com has disappeared [\#153](https://github.com/uclouvain/openjpeg/issues/153)
|
||||||
|
- OpenJPEG 1.5.0 crashes on a ridiculously big file... [\#151](https://github.com/uclouvain/openjpeg/issues/151)
|
||||||
|
- opj\_image vs free [\#146](https://github.com/uclouvain/openjpeg/issues/146)
|
||||||
|
- Windows .dll file invalid [\#140](https://github.com/uclouvain/openjpeg/issues/140)
|
||||||
|
- Problem with second layer of a 2 layer coded LRCP \(with precincts\) [\#135](https://github.com/uclouvain/openjpeg/issues/135)
|
||||||
|
- version 1.4 crashes when opening PDF file with JPEG2000 images [\#133](https://github.com/uclouvain/openjpeg/issues/133)
|
||||||
|
- Setup a win64 dashboard [\#132](https://github.com/uclouvain/openjpeg/issues/132)
|
||||||
|
- J2KP4files/codestreams\_profile0/p0\_13.j2k question jpeg2000 [\#131](https://github.com/uclouvain/openjpeg/issues/131)
|
||||||
|
- Out of memory: Kill process 11204 \(opj\_server\) score 917 or sacrifice child [\#123](https://github.com/uclouvain/openjpeg/issues/123)
|
||||||
|
- FILE\* in opj API is unsafe [\#120](https://github.com/uclouvain/openjpeg/issues/120)
|
||||||
|
- third-party lib order [\#119](https://github.com/uclouvain/openjpeg/issues/119)
|
||||||
|
- openjpeg-1.5.0-Darwin-powerpc.dmg is huge ! [\#113](https://github.com/uclouvain/openjpeg/issues/113)
|
||||||
|
- misleading info in JP2 box lead to wrong number of components [\#110](https://github.com/uclouvain/openjpeg/issues/110)
|
||||||
|
- Image\_to\_j2k says that j2k files is generated but no file is on the HDD [\#109](https://github.com/uclouvain/openjpeg/issues/109)
|
||||||
|
- Error in openjpegV1.4 on compiling image\_to\_j2k: crash on reading bmp file [\#108](https://github.com/uclouvain/openjpeg/issues/108)
|
||||||
|
- Update to abi-compliance-checker 1.96 [\#106](https://github.com/uclouvain/openjpeg/issues/106)
|
||||||
|
- Decode error on the attached JPEG...works in KDU and with JASPER...please help! [\#101](https://github.com/uclouvain/openjpeg/issues/101)
|
||||||
|
- Mac binaries v1.4 is broken [\#95](https://github.com/uclouvain/openjpeg/issues/95)
|
||||||
|
- jp2\_read\_boxhdr\(\) has size bug in version 1 [\#92](https://github.com/uclouvain/openjpeg/issues/92)
|
||||||
|
- Support for Java JAI Imageio [\#90](https://github.com/uclouvain/openjpeg/issues/90)
|
||||||
|
- encoding test failing [\#86](https://github.com/uclouvain/openjpeg/issues/86)
|
||||||
|
- source archive on demand [\#85](https://github.com/uclouvain/openjpeg/issues/85)
|
||||||
|
- CMakeLists.txt and Makefile.am for JPIP are buggy [\#84](https://github.com/uclouvain/openjpeg/issues/84)
|
||||||
|
- pclr-cmap-cdef [\#82](https://github.com/uclouvain/openjpeg/issues/82)
|
||||||
|
- Error when compiling openjpeg\_v1\_4\_sources\_r697 [\#79](https://github.com/uclouvain/openjpeg/issues/79)
|
||||||
|
- J2K codec issue on Windows Mobile [\#77](https://github.com/uclouvain/openjpeg/issues/77)
|
||||||
|
- image\_to\_j2k.exe crashes on large .bmp file [\#75](https://github.com/uclouvain/openjpeg/issues/75)
|
||||||
|
- fatal error C1900 building the project on windows [\#65](https://github.com/uclouvain/openjpeg/issues/65)
|
||||||
|
- same option but different size [\#54](https://github.com/uclouvain/openjpeg/issues/54)
|
||||||
|
- Missing openjpegConfigure.h [\#38](https://github.com/uclouvain/openjpeg/issues/38)
|
||||||
|
- Not an issue in openjpeg, but ... [\#37](https://github.com/uclouvain/openjpeg/issues/37)
|
||||||
|
- OpenJPEG-1.3.0 pclr, cmap and cdef [\#27](https://github.com/uclouvain/openjpeg/issues/27)
|
||||||
|
- realloc maybe too big \(t2.c\) [\#26](https://github.com/uclouvain/openjpeg/issues/26)
|
||||||
|
- libopenjpeg/opj\_malloc.h breaks on FreeBSD/Darwin systems [\#20](https://github.com/uclouvain/openjpeg/issues/20)
|
||||||
|
- image\_to\_j2k not outputting to win32 console properly [\#18](https://github.com/uclouvain/openjpeg/issues/18)
|
||||||
|
- \[OpenJPEG\] OpenJPEG\_v13: tiled image part 2 [\#17](https://github.com/uclouvain/openjpeg/issues/17)
|
||||||
|
- JP2 Color Space modification by Matteo Italia [\#13](https://github.com/uclouvain/openjpeg/issues/13)
|
||||||
|
- Patch submission \( exotic video formats, and a few things \) [\#12](https://github.com/uclouvain/openjpeg/issues/12)
|
||||||
|
- 16 bits lossy compression [\#10](https://github.com/uclouvain/openjpeg/issues/10)
|
||||||
|
- pnm file formats not accepting bitdepth greater than 8 bpp [\#8](https://github.com/uclouvain/openjpeg/issues/8)
|
||||||
|
- Heap corruption in j2k encoder [\#5](https://github.com/uclouvain/openjpeg/issues/5)
|
||||||
|
- JPWL crash in marker reallocation\(+patch\), segfault while decoding image with main header protection [\#4](https://github.com/uclouvain/openjpeg/issues/4)
|
||||||
|
- a couple of small errors in libopenjpeg detected by coverity [\#1](https://github.com/uclouvain/openjpeg/issues/1)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Shared library build broken on ubuntu [\#728](https://github.com/uclouvain/openjpeg/issues/728)
|
||||||
|
- opj\_includes.h shouldn't define `\_\_attribute\_\_` [\#727](https://github.com/uclouvain/openjpeg/issues/727)
|
||||||
|
- Possible website problems due to Jekyll upgrade [\#713](https://github.com/uclouvain/openjpeg/issues/713)
|
||||||
|
- Stable Release? [\#712](https://github.com/uclouvain/openjpeg/issues/712)
|
||||||
|
- Meta Issue : try to fix some of these critical bugs before thinking about optimizing the library [\#710](https://github.com/uclouvain/openjpeg/issues/710)
|
||||||
|
- Tiled encoding broken for images with non power of 2 dimensions [\#702](https://github.com/uclouvain/openjpeg/issues/702)
|
||||||
|
- install\_name \(still\) not set on OS X [\#700](https://github.com/uclouvain/openjpeg/issues/700)
|
||||||
|
- Add section in wiki describing where one can get test images [\#699](https://github.com/uclouvain/openjpeg/issues/699)
|
||||||
|
- Make EvenManager into singleton [\#698](https://github.com/uclouvain/openjpeg/issues/698)
|
||||||
|
- Remove old branches from repo [\#696](https://github.com/uclouvain/openjpeg/issues/696)
|
||||||
|
- MQ Coder encode: Conditional jump or move depends on uninitialised value\(s\) [\#695](https://github.com/uclouvain/openjpeg/issues/695)
|
||||||
|
- Can we add these files to our test suite ? [\#688](https://github.com/uclouvain/openjpeg/issues/688)
|
||||||
|
- -t and -d command line flags for decode are not documented on OpenJPEG website [\#685](https://github.com/uclouvain/openjpeg/issues/685)
|
||||||
|
- Decoding at the precinct level [\#676](https://github.com/uclouvain/openjpeg/issues/676)
|
||||||
|
- Support unscaled 10 bit data for 2K cinema @ 48 FPS, as per DCI standard [\#671](https://github.com/uclouvain/openjpeg/issues/671)
|
||||||
|
- Use parallel jobs in ctest [\#664](https://github.com/uclouvain/openjpeg/issues/664)
|
||||||
|
- \[Security\]Multiple Memory error [\#663](https://github.com/uclouvain/openjpeg/issues/663)
|
||||||
|
- lossy encoding a 16 bit TIF file : severe artifacts in decompressed image [\#660](https://github.com/uclouvain/openjpeg/issues/660)
|
||||||
|
- opj\_compress and opj\_decompress : get\_next\_file method uses hard-coded unix path separator [\#630](https://github.com/uclouvain/openjpeg/issues/630)
|
||||||
|
- Uninitialized variable [\#629](https://github.com/uclouvain/openjpeg/issues/629)
|
||||||
|
- Use of enum variable for bit flags prevents compilation as C++ source [\#619](https://github.com/uclouvain/openjpeg/issues/619)
|
||||||
|
- Serious problem with quantization during lossy encoding [\#615](https://github.com/uclouvain/openjpeg/issues/615)
|
||||||
|
- Decompression does not work with sequential data source [\#613](https://github.com/uclouvain/openjpeg/issues/613)
|
||||||
|
- potential overflow in opj\_tcd\_tile\_t [\#605](https://github.com/uclouvain/openjpeg/issues/605)
|
||||||
|
- Logical condition [\#596](https://github.com/uclouvain/openjpeg/issues/596)
|
||||||
|
- file9.jp2 does not dump correctly on 1.5 [\#595](https://github.com/uclouvain/openjpeg/issues/595)
|
||||||
|
- opj\_compress man page is missing documentation of -jpip option [\#593](https://github.com/uclouvain/openjpeg/issues/593)
|
||||||
|
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) in 1.5 branch [\#591](https://github.com/uclouvain/openjpeg/issues/591)
|
||||||
|
- Example: opj\_compress -i image.j2k -o image.pgm [\#577](https://github.com/uclouvain/openjpeg/issues/577)
|
||||||
|
- Mismatching delete [\#575](https://github.com/uclouvain/openjpeg/issues/575)
|
||||||
|
- Compilation fails on Win7 [\#546](https://github.com/uclouvain/openjpeg/issues/546)
|
||||||
|
- NR-JP2-file5.jp2-compare2base fails with third party libcms [\#540](https://github.com/uclouvain/openjpeg/issues/540)
|
||||||
|
- CTest spits out an error at the end of the test run [\#516](https://github.com/uclouvain/openjpeg/issues/516)
|
||||||
|
- opj\_uint\_adds\(\) is questionable [\#515](https://github.com/uclouvain/openjpeg/issues/515)
|
||||||
|
- Might consider renaming this method: [\#491](https://github.com/uclouvain/openjpeg/issues/491)
|
||||||
|
- opj\_compress run twice gives different fiile sizes for same file [\#490](https://github.com/uclouvain/openjpeg/issues/490)
|
||||||
|
- Android Support [\#483](https://github.com/uclouvain/openjpeg/issues/483)
|
||||||
|
- Add SSE2/SSE41 implementations for mct.c [\#451](https://github.com/uclouvain/openjpeg/issues/451)
|
||||||
|
- Reduce encoder code block memory usage for non 64x64 code block sizes [\#444](https://github.com/uclouvain/openjpeg/issues/444)
|
||||||
|
- valgrind "Uninitialized Memory Read" & "Uninitialized Memory Conditional" found [\#438](https://github.com/uclouvain/openjpeg/issues/438)
|
||||||
|
- No way to debug opj\_tcd\_init\_encode\_tile or opj\_tcd\_init\_decode\_tile [\#433](https://github.com/uclouvain/openjpeg/issues/433)
|
||||||
|
- Add option to call dsymutil on built binaries [\#409](https://github.com/uclouvain/openjpeg/issues/409)
|
||||||
|
- Allow opj\_compress and opj\_decompress to read/write images over stdin/stdout [\#379](https://github.com/uclouvain/openjpeg/issues/379)
|
||||||
|
- reduce memory significantly for single tile RGB encoding [\#375](https://github.com/uclouvain/openjpeg/issues/375)
|
||||||
|
- Switch code repo to github and start using pull request workflow [\#373](https://github.com/uclouvain/openjpeg/issues/373)
|
||||||
|
- This is a BigTIFF file. This format not supported [\#125](https://github.com/uclouvain/openjpeg/issues/125)
|
||||||
|
- Add a test suite to check the convert functions [\#99](https://github.com/uclouvain/openjpeg/issues/99)
|
||||||
|
- Add build config to the dashboard to verify the autotools build [\#88](https://github.com/uclouvain/openjpeg/issues/88)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Correct abi-check.sh for PR [\#791](https://github.com/uclouvain/openjpeg/pull/791) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update tcd.c [\#790](https://github.com/uclouvain/openjpeg/pull/790) ([maddin200](https://github.com/maddin200))
|
||||||
|
- Update lcms2 [\#773](https://github.com/uclouvain/openjpeg/pull/773) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Use lowercase for cmake commands consistently [\#769](https://github.com/uclouvain/openjpeg/pull/769) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Ignore clang's summary warning [\#768](https://github.com/uclouvain/openjpeg/pull/768) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Fix UBSan gcc warning for first arg to memset non null [\#767](https://github.com/uclouvain/openjpeg/pull/767) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Update to libtiff-4.0.6 [\#764](https://github.com/uclouvain/openjpeg/pull/764) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix warnings [\#763](https://github.com/uclouvain/openjpeg/pull/763) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Check SSIZ is valid in opj\_j2k\_read\_siz [\#762](https://github.com/uclouvain/openjpeg/pull/762) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix unsigned int overflow reported by UBSan [\#761](https://github.com/uclouvain/openjpeg/pull/761) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix unsigned int overflow reported by UBSan [\#759](https://github.com/uclouvain/openjpeg/pull/759) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix negative shift left reported by UBSan [\#758](https://github.com/uclouvain/openjpeg/pull/758) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix negative shift left reported by UBSan [\#757](https://github.com/uclouvain/openjpeg/pull/757) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add clang 3.9 build to Travis matrix [\#753](https://github.com/uclouvain/openjpeg/pull/753) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Fix implicit floating bool conversion [\#752](https://github.com/uclouvain/openjpeg/pull/752) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Do not define \_\_attribute\_\_ in opj\_includes.h [\#751](https://github.com/uclouvain/openjpeg/pull/751) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Allow to read/write 3/5/7/9/11/13/15 bpp TIF files [\#750](https://github.com/uclouvain/openjpeg/pull/750) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix heap-buffer-overflow in color\_esycc\_to\_rgb [\#748](https://github.com/uclouvain/openjpeg/pull/748) ([mayeut](https://github.com/mayeut))
|
||||||
|
- update libpng to from 1.6.17 to 1.6.21 [\#747](https://github.com/uclouvain/openjpeg/pull/747) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Update cmake & jpylyzer for travis builds [\#746](https://github.com/uclouvain/openjpeg/pull/746) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Fix Out-Of-Bounds Read in sycc42x\_to\_rgb function [\#745](https://github.com/uclouvain/openjpeg/pull/745) ([mayeut](https://github.com/mayeut))
|
||||||
|
- cppcheck fix for openjp2 [\#740](https://github.com/uclouvain/openjpeg/pull/740) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Fix uninitialized variable reported by cppcheck [\#735](https://github.com/uclouvain/openjpeg/pull/735) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- Remove dead code in opj\_dump [\#734](https://github.com/uclouvain/openjpeg/pull/734) ([julienmalik](https://github.com/julienmalik))
|
||||||
|
- issue \#695 MQ Encode: ensure that bp pointer never points to uninitialized memory [\#708](https://github.com/uclouvain/openjpeg/pull/708) ([boxerab](https://github.com/boxerab))
|
||||||
|
- Fix issue 135 [\#706](https://github.com/uclouvain/openjpeg/pull/706) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix implementation of opj\_calloc [\#705](https://github.com/uclouvain/openjpeg/pull/705) ([stweil](https://github.com/stweil))
|
||||||
|
- \[git/2.1 regression\] Fix opj\_write\_tile\(\) failure when numresolutions=1 [\#690](https://github.com/uclouvain/openjpeg/pull/690) ([rouault](https://github.com/rouault))
|
||||||
|
- Fix fatal crash on 64 bit Linux [\#687](https://github.com/uclouvain/openjpeg/pull/687) ([stweil](https://github.com/stweil))
|
||||||
|
- \[libtiff\] Add missing include statement for ssize\_t [\#686](https://github.com/uclouvain/openjpeg/pull/686) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix duplicate article in comments [\#684](https://github.com/uclouvain/openjpeg/pull/684) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix grammar in comment [\#679](https://github.com/uclouvain/openjpeg/pull/679) ([stweil](https://github.com/stweil))
|
||||||
|
- Remove whitespace and CR at line endings [\#678](https://github.com/uclouvain/openjpeg/pull/678) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix typos [\#665](https://github.com/uclouvain/openjpeg/pull/665) ([jwilk](https://github.com/jwilk))
|
||||||
|
- Add missing source for the JPIP library and executables \(issue \#658\) [\#659](https://github.com/uclouvain/openjpeg/pull/659) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix undefined size jp2 box handling [\#654](https://github.com/uclouvain/openjpeg/pull/654) ([mayeut](https://github.com/mayeut))
|
||||||
|
- opj\_decompress: Update error message [\#651](https://github.com/uclouvain/openjpeg/pull/651) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix support of posix\_memalloc for Linux [\#648](https://github.com/uclouvain/openjpeg/pull/648) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix typo in comments [\#647](https://github.com/uclouvain/openjpeg/pull/647) ([stweil](https://github.com/stweil))
|
||||||
|
- Avoid pointer arithmetic with \(void \*\) pointers [\#644](https://github.com/uclouvain/openjpeg/pull/644) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- Fix HP compiler warning about redeclaration of function \(\#640\) [\#641](https://github.com/uclouvain/openjpeg/pull/641) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- Fix format strings and unneeded assignment [\#638](https://github.com/uclouvain/openjpeg/pull/638) ([stweil](https://github.com/stweil))
|
||||||
|
- Fix repository for JPEG2000 test data [\#637](https://github.com/uclouvain/openjpeg/pull/637) ([stweil](https://github.com/stweil))
|
||||||
|
- Update allocation functions [\#636](https://github.com/uclouvain/openjpeg/pull/636) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix OpenJPEG GitHub issue \#633. [\#634](https://github.com/uclouvain/openjpeg/pull/634) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- travis-ci: Include add ons in matrix [\#632](https://github.com/uclouvain/openjpeg/pull/632) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add Appveyor [\#627](https://github.com/uclouvain/openjpeg/pull/627) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Use Travis-ci to run ABI check [\#626](https://github.com/uclouvain/openjpeg/pull/626) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix warnings for C++ [\#623](https://github.com/uclouvain/openjpeg/pull/623) ([stweil](https://github.com/stweil))
|
||||||
|
- Fixed problem that C++ compilation failed because of enum variable. [\#622](https://github.com/uclouvain/openjpeg/pull/622) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- Added missing casts for return values of opj\_malloc\(\)/opj\_calloc\(\). [\#618](https://github.com/uclouvain/openjpeg/pull/618) ([smuehlst](https://github.com/smuehlst))
|
||||||
|
- Add check for seek support before trying TPsot==TNsot workaround [\#617](https://github.com/uclouvain/openjpeg/pull/617) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix some typos found by codespell [\#610](https://github.com/uclouvain/openjpeg/pull/610) ([stweil](https://github.com/stweil))
|
||||||
|
- Correct leak in color\_cielab\_to\_rgb [\#590](https://github.com/uclouvain/openjpeg/pull/590) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add Travis-ci build matrix [\#584](https://github.com/uclouvain/openjpeg/pull/584) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Correct lossless issue on linux x86 [\#579](https://github.com/uclouvain/openjpeg/pull/579) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Travis-ci update [\#578](https://github.com/uclouvain/openjpeg/pull/578) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Correct CMake version requirements [\#572](https://github.com/uclouvain/openjpeg/pull/572) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add tests for CMYK/esYCC/CIELab [\#567](https://github.com/uclouvain/openjpeg/pull/567) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add support for CIELab, EYCC and CMYK [\#559](https://github.com/uclouvain/openjpeg/pull/559) ([szukw000](https://github.com/szukw000))
|
||||||
|
- Remove printf/fprintf to stdout/stderr throughout openjp2 lib [\#558](https://github.com/uclouvain/openjpeg/pull/558) ([mayeut](https://github.com/mayeut))
|
||||||
|
- better -ffast-math handling [\#555](https://github.com/uclouvain/openjpeg/pull/555) ([rdieter](https://github.com/rdieter))
|
||||||
|
- Add jpylyzer tests for JP2 compression [\#552](https://github.com/uclouvain/openjpeg/pull/552) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add COC/QCC in main header when needed [\#551](https://github.com/uclouvain/openjpeg/pull/551) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Use \_\_emul under msvc x86 for fast 64 = 32 \* 32 [\#550](https://github.com/uclouvain/openjpeg/pull/550) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update convert for PNG output [\#549](https://github.com/uclouvain/openjpeg/pull/549) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Remove some warnings when building [\#548](https://github.com/uclouvain/openjpeg/pull/548) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Switch to libpng-1.6.17 [\#547](https://github.com/uclouvain/openjpeg/pull/547) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add some missing static keywords [\#545](https://github.com/uclouvain/openjpeg/pull/545) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Switch to libcms2 mm2/Little-CMS@0e8234e090d6aab33f90e2eb0296f30aa0705e57 [\#544](https://github.com/uclouvain/openjpeg/pull/544) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Prevent overflow when coding 16 bits images [\#543](https://github.com/uclouvain/openjpeg/pull/543) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Switch to libcms2-2.6 [\#542](https://github.com/uclouvain/openjpeg/pull/542) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update PNG support [\#538](https://github.com/uclouvain/openjpeg/pull/538) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Various Minor fixes [\#537](https://github.com/uclouvain/openjpeg/pull/537) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Update TIFF conversion to support more bit depth. [\#535](https://github.com/uclouvain/openjpeg/pull/535) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add checks for odd looking cmap & for cmap outside jp2h box [\#534](https://github.com/uclouvain/openjpeg/pull/534) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Refactor opj\_j2k\_read\_ppm & opj\_j2k\_read\_ppt [\#533](https://github.com/uclouvain/openjpeg/pull/533) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Add option to force component splitting in imagetopnm [\#531](https://github.com/uclouvain/openjpeg/pull/531) ([mayeut](https://github.com/mayeut))
|
||||||
|
- fix Suspicious code in j2k.c \#517 [\#529](https://github.com/uclouvain/openjpeg/pull/529) ([renevanderark](https://github.com/renevanderark))
|
||||||
|
- Update zlib to version 1.2.8 [\#528](https://github.com/uclouvain/openjpeg/pull/528) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fix opj\_write\_bytes\_BE \(\#518\) [\#521](https://github.com/uclouvain/openjpeg/pull/521) ([manisandro](https://github.com/manisandro))
|
||||||
|
- Correctly decode files with incorrect tile-part header fields \(TPsot==TNsot\) [\#514](https://github.com/uclouvain/openjpeg/pull/514) ([mayeut](https://github.com/mayeut))
|
||||||
|
- Fixed typos [\#510](https://github.com/uclouvain/openjpeg/pull/510) ([radarhere](https://github.com/radarhere))
|
||||||
|
- Formatted the readme file [\#507](https://github.com/uclouvain/openjpeg/pull/507) ([htmfilho](https://github.com/htmfilho))
|
||||||
|
|
||||||
|
## [version.2.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.1) (2014-04-29)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0.1...version.2.1)
|
||||||
|
|
||||||
|
## [version.2.0.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0.1) (2014-04-22)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.2...version.2.0.1)
|
||||||
|
|
||||||
|
## [version.1.5.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.2) (2014-03-28)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0...version.1.5.2)
|
||||||
|
|
||||||
|
## [version.2.0](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0) (2014-03-28)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.1...version.2.0)
|
||||||
|
|
||||||
|
## [version.1.5.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.1) (2012-09-13)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5...version.1.5.1)
|
||||||
|
|
||||||
|
## [version.1.5](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5) (2012-02-07)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.3...version.1.5)
|
||||||
|
|
||||||
|
## [version.1.3](https://github.com/uclouvain/openjpeg/releases/tag/version.1.3) (2011-07-03)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.4...version.1.3)
|
||||||
|
|
||||||
|
## [version.1.4](https://github.com/uclouvain/openjpeg/releases/tag/version.1.4) (2011-07-03)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.2...version.1.4)
|
||||||
|
|
||||||
|
## [version.1.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.2) (2007-06-04)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.1...version.1.2)
|
||||||
|
|
||||||
|
## [version.1.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.1) (2007-01-31)
|
||||||
|
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.0...version.1.1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
|
@ -0,0 +1,396 @@
|
||||||
|
# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
|
||||||
|
# Written by Mathieu Malaterre
|
||||||
|
|
||||||
|
# This CMake project will by default create a library called openjpeg
|
||||||
|
# But if you want to use this project within your own (CMake) project
|
||||||
|
# you will eventually like to prefix the library to avoid linking confusion
|
||||||
|
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||||
|
# e.g.:
|
||||||
|
# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||||
|
cmake_minimum_required(VERSION 2.8.2)
|
||||||
|
|
||||||
|
if(COMMAND CMAKE_POLICY)
|
||||||
|
cmake_policy(SET CMP0003 NEW)
|
||||||
|
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||||
|
cmake_policy(SET CMP0042 NEW)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_NAMESPACE)
|
||||||
|
set(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||||
|
set(OPENJPEG_STANDALONE 1)
|
||||||
|
endif()
|
||||||
|
# In all cases:
|
||||||
|
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||||
|
set(OPENJPEG_LIBRARY_NAME openjp2)
|
||||||
|
|
||||||
|
project(${OPENJPEG_NAMESPACE})
|
||||||
|
|
||||||
|
# Do full dependency headers.
|
||||||
|
include_regular_expression("^.*$")
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
|
set(OPENJPEG_VERSION_MAJOR 2)
|
||||||
|
set(OPENJPEG_VERSION_MINOR 3)
|
||||||
|
set(OPENJPEG_VERSION_BUILD 1)
|
||||||
|
set(OPENJPEG_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
set(PACKAGE_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
|
||||||
|
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||||
|
# two numbering, one for the openjpeg version and one for openjpeg soversion
|
||||||
|
# version | soversion
|
||||||
|
# 1.0 | 0
|
||||||
|
# 1.1 | 1
|
||||||
|
# 1.2 | 2
|
||||||
|
# 1.3 | 3
|
||||||
|
# 1.4 | 4
|
||||||
|
# 1.5 | 5
|
||||||
|
# 1.5.1 | 5
|
||||||
|
# 2.0 | 6
|
||||||
|
# 2.0.1 | 6
|
||||||
|
# 2.1 | 7
|
||||||
|
# 2.1.1 | 7
|
||||||
|
# 2.1.2 | 7
|
||||||
|
# 2.2.0 | 7
|
||||||
|
# 2.3.0 | 7
|
||||||
|
# 2.3.1 | 7
|
||||||
|
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||||
|
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||||
|
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||||
|
if(NOT OPENJPEG_SOVERSION)
|
||||||
|
set(OPENJPEG_SOVERSION 7)
|
||||||
|
endif(NOT OPENJPEG_SOVERSION)
|
||||||
|
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
|
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Path to additional CMake modules
|
||||||
|
set(CMAKE_MODULE_PATH
|
||||||
|
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake
|
||||||
|
${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||||
|
# warnings
|
||||||
|
if(WIN32)
|
||||||
|
if(NOT BORLAND)
|
||||||
|
if(NOT CYGWIN)
|
||||||
|
if(NOT MINGW)
|
||||||
|
if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
|
add_definitions(
|
||||||
|
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||||
|
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||||
|
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||||
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
|
||||||
|
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
|
||||||
|
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
|
||||||
|
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||||
|
-D_SCL_SECURE_NO_DEPRECATE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Install directories
|
||||||
|
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||||
|
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||||
|
|
||||||
|
string(TOLOWER ${PROJECT_NAME} projectname)
|
||||||
|
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_DOC)
|
||||||
|
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||||
|
if(WIN32)
|
||||||
|
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
||||||
|
else()
|
||||||
|
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
|
# We could install *.cmake files in share/ however those files contains
|
||||||
|
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
||||||
|
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
||||||
|
set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
|
||||||
|
option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Big endian test:
|
||||||
|
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||||
|
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Setup file for setting custom ctest vars
|
||||||
|
configure_file(
|
||||||
|
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
||||||
|
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/CTestCustom.cmake
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# OpenJPEG build configuration options.
|
||||||
|
option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||||
|
option(BUILD_STATIC_LIBS "Build OpenJPEG static library." ON)
|
||||||
|
set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
||||||
|
set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
|
||||||
|
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# configure name mangling to allow multiple libraries to coexist
|
||||||
|
# peacefully
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
|
set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||||
|
@ONLY)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Compiler specific flags:
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
# For all builds, make sure openjpeg is std99 compliant:
|
||||||
|
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||||
|
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||||
|
set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||||
|
set(OPENJP2_COMPILE_OPTIONS ${OPENJP2_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>" -Wall -Wextra -Wconversion -Wunused-parameter -Wdeclaration-after-statement -Werror=declaration-after-statement)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (1/2)
|
||||||
|
|
||||||
|
# Check if some include files are provided by the system
|
||||||
|
include(EnsureFileInclude)
|
||||||
|
# These files are mandatory
|
||||||
|
ensure_file_include("string.h" HAVE_STRING_H YES)
|
||||||
|
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
|
||||||
|
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
|
||||||
|
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
|
||||||
|
ensure_file_include("math.h" HAVE_MATH_H YES)
|
||||||
|
ensure_file_include("float.h" HAVE_FLOAT_H YES)
|
||||||
|
ensure_file_include("time.h" HAVE_TIME_H YES)
|
||||||
|
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
|
||||||
|
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
|
||||||
|
ensure_file_include("assert.h" HAVE_ASSERT_H YES)
|
||||||
|
|
||||||
|
# For the following files, we provide an alternative, they are not mandatory
|
||||||
|
ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
|
||||||
|
ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
|
||||||
|
|
||||||
|
# why check this one ? for openjpip ?
|
||||||
|
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
||||||
|
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
|
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
|
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||||
|
|
||||||
|
# Enable Large file support
|
||||||
|
include(TestLargeFiles)
|
||||||
|
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||||
|
|
||||||
|
# Allocating Aligned Memory Blocks
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
||||||
|
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
|
# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
|
||||||
|
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
|
||||||
|
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||||
|
# memalign (obsolete)
|
||||||
|
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Build Library
|
||||||
|
if(BUILD_JPIP_SERVER)
|
||||||
|
find_package(CURL REQUIRED)
|
||||||
|
find_package(FCGI REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
if(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
message(FATAL_ERROR "Only pthread are supported")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
add_subdirectory(src/lib)
|
||||||
|
option(BUILD_LUTS_GENERATOR "Build utility to generate t1_luts.h" OFF)
|
||||||
|
option(BUILD_UNIT_TESTS "Build unit tests (bench_dwt, test_sparse_array, etc..)" OFF)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Build Applications
|
||||||
|
option(BUILD_CODEC "Build the CODEC executables" ON)
|
||||||
|
option(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||||
|
option(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||||
|
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||||
|
endif()
|
||||||
|
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||||
|
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||||
|
option(BUILD_JP3D "Build the JP3D comp" OFF)
|
||||||
|
mark_as_advanced(BUILD_VIEWER)
|
||||||
|
mark_as_advanced(BUILD_JAVA)
|
||||||
|
mark_as_advanced(BUILD_JP3D)
|
||||||
|
|
||||||
|
if(BUILD_CODEC OR BUILD_MJ2)
|
||||||
|
# OFF: It will only build 3rd party libs if they are not found on the system
|
||||||
|
# ON: 3rd party libs will ALWAYS be build, and used
|
||||||
|
option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
||||||
|
add_subdirectory(thirdparty)
|
||||||
|
add_subdirectory(src/bin)
|
||||||
|
endif ()
|
||||||
|
add_subdirectory(wrapping)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (2/2)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# build documentation in doc subdir:
|
||||||
|
if(BUILD_DOC)
|
||||||
|
add_subdirectory(doc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Buld Testing
|
||||||
|
option(BUILD_TESTING "Build the tests." OFF)
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
if(BUILD_CODEC)
|
||||||
|
enable_testing()
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
|
# Search openjpeg data needed for the tests
|
||||||
|
# They could be found via git on the OpenJPEG GitHub code project
|
||||||
|
# git clone https://github.com/uclouvain/openjpeg-data.git
|
||||||
|
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
||||||
|
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||||
|
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add repository where to find tests
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "You need build codec to run the tests")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install all targets referenced as OPENJPEGTargets
|
||||||
|
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||||
|
configure_file( ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
||||||
|
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install CHANGES and LICENSE
|
||||||
|
if(BUILD_DOC)
|
||||||
|
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
|
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include (cmake/OpenJPEGCPack.cmake)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# pkgconfig support
|
||||||
|
# enabled by default on Unix or if using GCC, disabled by default on other platforms
|
||||||
|
if(UNIX OR CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
|
||||||
|
else()
|
||||||
|
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
|
||||||
|
endif()
|
||||||
|
if(BUILD_PKGCONFIG_FILES)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
#
|
||||||
|
if(BUILD_JPWL)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpwl/libopenjpwl.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
#
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpip/libopenjpip.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
#
|
||||||
|
if(BUILD_JP3D)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp3d/libopenjp3d.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# build our version of astyle
|
||||||
|
SET (WITH_ASTYLE FALSE CACHE BOOL "If you plan to contribute you should reindent with scripts/prepare-commit.sh (using 'our' astyle)")
|
|
@ -0,0 +1,7 @@
|
||||||
|
set(CTEST_PROJECT_NAME "OPENJPEG")
|
||||||
|
set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
|
||||||
|
|
||||||
|
set(CTEST_DROP_METHOD "http")
|
||||||
|
set(CTEST_DROP_SITE "my.cdash.org")
|
||||||
|
set(CTEST_DROP_LOCATION "/submit.php?project=OPENJPEG")
|
||||||
|
set(CTEST_DROP_SITE_CDASH TRUE)
|
|
@ -0,0 +1,138 @@
|
||||||
|
|
||||||
|
# OpenJPEG installation
|
||||||
|
|
||||||
|
The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
|
||||||
|
|
||||||
|
## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
|
||||||
|
|
||||||
|
To build the library, type from source tree directory:
|
||||||
|
```
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make
|
||||||
|
```
|
||||||
|
Binaries are then located in the 'bin' directory.
|
||||||
|
|
||||||
|
To install the library, type with root privileges:
|
||||||
|
```
|
||||||
|
make install
|
||||||
|
make clean
|
||||||
|
```
|
||||||
|
|
||||||
|
To build the html documentation, you need doxygen to be installed on your system.
|
||||||
|
It will create an "html" directory in TOP\_LEVEL/build/doc)
|
||||||
|
```
|
||||||
|
make doc
|
||||||
|
```
|
||||||
|
|
||||||
|
Main available cmake flags:
|
||||||
|
* To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
|
||||||
|
* To build the shared libraries and links the executables against it: '-DBUILD\_SHARED\_LIBS:bool=on' (default: 'ON')
|
||||||
|
> Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||||
|
* PKG_CONFIG files are by default built for Unix compile, you can force to build on other platforms by adding: '-DBUILD_PKGCONFIG_FILES=on'
|
||||||
|
* To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
|
||||||
|
* To build opjstyle (internal version of astyle) for OpenJPEG development: '-DWITH_ASTYLE=ON'
|
||||||
|
* [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
|
||||||
|
* [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
|
||||||
|
* [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
|
||||||
|
* [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
|
||||||
|
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||||
|
```
|
||||||
|
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
|
||||||
|
make
|
||||||
|
make Experimental
|
||||||
|
```
|
||||||
|
Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
|
||||||
|
|
||||||
|
If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
|
||||||
|
|
||||||
|
Note 2 : to execute the encoding test suite, kakadu binaries are needed to decode encoded image and compare it to the baseline. Kakadu binaries are freely available for non-commercial purposes at http://www.kakadusoftware.com. kdu\_expand will need to be in your PATH for cmake to find it.
|
||||||
|
|
||||||
|
Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z. If these libraries are not found on the system, they are automatically built from the versions available in the source tree. You can force the use of these embedded version with BUILD\_THIRDPARTY:BOOL=ON. On a Debian-like system you can also simply install these libraries with:
|
||||||
|
```
|
||||||
|
sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
|
||||||
|
```
|
||||||
|
-DCMAKE_OSX_ARCHITECTURES:STRING=i386
|
||||||
|
```
|
||||||
|
|
||||||
|
## MacOS (XCode) - WINDOWS (VisualStudio, etc)
|
||||||
|
|
||||||
|
You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
|
||||||
|
Type `cmake --help` for available generators on your platform.
|
||||||
|
|
||||||
|
Examples for Windows with Visual Studio C++ compiler:
|
||||||
|
|
||||||
|
If using directly the cl compiler:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
To compile a 64-bit application, open 64-Bit Visual C\+\+ toolset on the command line and run cmake. For further information, please refer to: [How to: Enable a 64-Bit Visual C\+\+ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx).
|
||||||
|
|
||||||
|
|
||||||
|
If you do not want directly use the cl compiler, you could use:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
To create Visual Studio solution (.sln) and project files (.vcproj / .vcxproj):
|
||||||
|
```
|
||||||
|
cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
64-bit application:
|
||||||
|
```
|
||||||
|
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Enabling CPU specific optimizations
|
||||||
|
|
||||||
|
For Intel/AMD processors, OpenJPEG implements optimizations using the SSE4.1
|
||||||
|
instruction set (for example, for the 9x7 inverse MCT transform) and the AVX2
|
||||||
|
instruction set (for example, for the 5x3 inverse discrete wavelet transform).
|
||||||
|
Currently, those optimizations are only available if OpenJPEG is built to
|
||||||
|
use those instruction sets (and the resulting binary will only run on compatible
|
||||||
|
CPUs)
|
||||||
|
|
||||||
|
With gcc/clang, it is possible to enable those instruction sets with the following :
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_C_FLAGS="-O3 -msse4.1 -DNDEBUG" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_C_FLAGS="-O3 -mavx2 -DNDEBUG" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
(AVX2 implies SSE4.1)
|
||||||
|
|
||||||
|
Or if the binary is dedicated to run on the machine where it has
|
||||||
|
been compiled :
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG" ..
|
||||||
|
```
|
||||||
|
|
||||||
|
# Modifying OpenJPEG
|
||||||
|
|
||||||
|
Before committing changes, run:
|
||||||
|
```scripts/prepare-commit.sh```
|
||||||
|
|
||||||
|
# Using OpenJPEG
|
||||||
|
|
||||||
|
To use openjpeg exported cmake file, simply create your application doing:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cat CMakeLists.txt
|
||||||
|
find_package(OpenJPEG REQUIRED)
|
||||||
|
include_directories(${OPENJPEG_INCLUDE_DIRS})
|
||||||
|
add_executable(myapp myapp.c)
|
||||||
|
target_link_libraries(myapp ${OPENJPEG_LIBRARIES})
|
||||||
|
```
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2003-2009, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||||
|
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
|
@ -0,0 +1,111 @@
|
||||||
|
# OpenJPEG NEWS
|
||||||
|
|
||||||
|
More details in the [CHANGELOG](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
|
||||||
|
|
||||||
|
## OpenJPEG 2.3.1 (April 2019)
|
||||||
|
|
||||||
|
No API/ABI break compared to v2.3.0
|
||||||
|
|
||||||
|
* Many bug fixes (including security fixes)
|
||||||
|
|
||||||
|
## OpenJPEG 2.3.0 (October 2017)
|
||||||
|
|
||||||
|
No API/ABI break compared to v2.2.0 but additional symbols for subset of components decoding (hence the MINOR version bump).
|
||||||
|
|
||||||
|
* Sub-tile decoding: when setting a window of interest through the API function opj_set_decode_area(), only codeblocks that intersect this window are now decoded (i.e. MCT, IDWT, and entropy decoding are only done on the window of interest). Moreover, memory allocation now depends on the size of the window of interest (instead of the full tile size).
|
||||||
|
[\#990](https://github.com/uclouvain/openjpeg/pull/990) [\#1001](https://github.com/uclouvain/openjpeg/pull/1001) [\#1010](https://github.com/uclouvain/openjpeg/pull/1010)
|
||||||
|
* Ability to decode only a subset of components. This adds the following function `opj_set_decoded_components(opj_codec_t p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32 comps_indices, OPJ_BOOL apply_color_transforms)` and equivalent `opj_decompress -c compno[,compno]*`
|
||||||
|
option.
|
||||||
|
[\#1022](https://github.com/uclouvain/openjpeg/pull/1022)
|
||||||
|
* Many bug fixes (including security fixes)
|
||||||
|
|
||||||
|
## OpenJPEG 2.2.0 (August 2017)
|
||||||
|
|
||||||
|
No API/ABI break compared to v2.1.2 but additional symbols for multithreading support (hence the MINOR version bump).
|
||||||
|
|
||||||
|
### Codebase improvements
|
||||||
|
|
||||||
|
* Memory consumption reduction at decoding side [\#968](https://github.com/uclouvain/openjpeg/pull/968)
|
||||||
|
* Multi-threading support at decoding side [\#786](https://github.com/uclouvain/openjpeg/pull/786)
|
||||||
|
* Tier-1 speed optimizations (encoder and decoder) [\#945](https://github.com/uclouvain/openjpeg/pull/945)
|
||||||
|
* Tier-1 decoder further optimization [\#783](https://github.com/uclouvain/openjpeg/pull/783)
|
||||||
|
* Inverse 5x3 DWT speed optimization: single-pass lifting and SSE2/AVX2 implementation [\#957](https://github.com/uclouvain/openjpeg/pull/957)
|
||||||
|
* Fixed a bug that prevented OpenJPEG to compress losslessly in some situations [\#949](https://github.com/uclouvain/openjpeg/pull/949)
|
||||||
|
* Fixed BYPASS/LAZY, RESTART/TERMALL and PTERM mode switches
|
||||||
|
* Many other bug fixes (including security fixes)
|
||||||
|
|
||||||
|
### Maintenance improvements
|
||||||
|
|
||||||
|
* Benchmarking scripts to automatically compare the speed of latest OpenJPEG build with latest release and/or Kakadu binaries [\#917](https://github.com/uclouvain/openjpeg/pull/917)
|
||||||
|
* CPU and RAM usage profiling scripts [\#918](https://github.com/uclouvain/openjpeg/pull/918)
|
||||||
|
* Codebase reformatting (with astyle) and scripts to automatically check that new commits comply with formatting guidelines [\#919](https://github.com/uclouvain/openjpeg/pull/919)
|
||||||
|
* Register OpenJPEG at Google OSS Fuzz initiative, so as to automatically have OpenJPEG tested against Google fuzzer [\#965](https://github.com/uclouvain/openjpeg/issues/965)
|
||||||
|
|
||||||
|
## OpenJPEG 2.1.2 (September 2016)
|
||||||
|
|
||||||
|
* Bug fixes (including security fixes)
|
||||||
|
* No API/ABI break compared to v2.1.1
|
||||||
|
|
||||||
|
## OpenJPEG 2.1.1 (July 2016)
|
||||||
|
|
||||||
|
* Huge amount of critical bugfixes
|
||||||
|
* Speed improvements
|
||||||
|
* No API/ABI break compared to v2.1
|
||||||
|
|
||||||
|
## OpenJPEG 2.1.0 (April 2014)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* Digital Cinema profiles have been fixed and updated
|
||||||
|
* New option to disable MCT if needed
|
||||||
|
* extended RAW support: it is now possible to input raw images
|
||||||
|
with subsampled color components (422, 420, etc)
|
||||||
|
* New way to deal with profiles
|
||||||
|
|
||||||
|
### API/ABI modifications
|
||||||
|
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
|
||||||
|
|
||||||
|
* Removed deprecated functions
|
||||||
|
* opj_stream_create_default_file_stream(FILE*,...)
|
||||||
|
* opj_stream_create_file_stream(FILE*,...)
|
||||||
|
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
|
||||||
|
* Added
|
||||||
|
* opj_stream_create_default_file_stream(char*,...)
|
||||||
|
* opj_stream_create_file_stream(char*,...)
|
||||||
|
* opj_stream_destroy(opj_stream_t*)
|
||||||
|
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
|
||||||
|
... opj_stream_free_user_data_fn p_function)
|
||||||
|
* JPEG 2000 profiles and Part-2 extensions defined through '#define'
|
||||||
|
* Changed
|
||||||
|
* 'alpha' field added to 'opj_image_comp' structure
|
||||||
|
* 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
|
||||||
|
* 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
|
||||||
|
* 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
|
||||||
|
(not yet used in use)
|
||||||
|
* 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
||||||
|
and will soon become official reference software at the
|
||||||
|
JPEG committee.
|
||||||
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
|
|
||||||
|
|
||||||
|
## OpenJPEG 2.0.0
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* streaming capabilities
|
||||||
|
* merge JP3D
|
||||||
|
|
||||||
|
### API modifications
|
||||||
|
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
|
||||||
|
|
||||||
|
* Use a 64bits capable API
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
* removed autotools build system
|
||||||
|
* folders hierarchies reorganisation
|
||||||
|
* Huge amount of bug fixes. See CHANGES for details.
|
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
# OPENJPEG Library and Applications
|
||||||
|
|
||||||
|
## What is OpenJPEG ?
|
||||||
|
|
||||||
|
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
|
||||||
|
|
||||||
|
## Who can use the code ?
|
||||||
|
[![badge-license]][link-license]
|
||||||
|
|
||||||
|
Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
|
||||||
|
|
||||||
|
## How to install and use OpenJPEG ?
|
||||||
|
API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec).
|
||||||
|
|
||||||
|
## Current Status
|
||||||
|
[![badge-build]][link-build]
|
||||||
|
|
||||||
|
[![badge-msvc-build]][link-msvc-build]
|
||||||
|
|
||||||
|
[![badge-coverity]][link-coverity]
|
||||||
|
|
||||||
|
## Who are the developers ?
|
||||||
|
|
||||||
|
The library is developed and maintained by the Image and Signal Processing Group ([ISPGroup](http://sites.uclouvain.be/ispgroup/)), in the Université catholique de Louvain ([UCL](http://www.uclouvain.be/en-index.html), with the support of the [CNES](https://cnes.fr/), the [CS](http://www.c-s.fr/) company and the [intoPIX](http://www.intopix.com) company. The JPWL module has been developed by the Digital Signal Processing Lab ([DSPLab](http://dsplab.diei.unipg.it/)) of the University of Perugia, Italy ([UNIPG](http://www.unipg.it/)).
|
||||||
|
|
||||||
|
## Details on folders hierarchy
|
||||||
|
|
||||||
|
* src
|
||||||
|
* lib
|
||||||
|
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
|
||||||
|
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||||
|
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||||
|
* openjp3d: JP3D implementation
|
||||||
|
* openmj2: MJ2 implementation
|
||||||
|
* bin: contains all applications that use the openjpeg library
|
||||||
|
* common: common files to all applications
|
||||||
|
* jp2: a basic codec
|
||||||
|
* mj2: motion jpeg 2000 executables
|
||||||
|
* jpip: OpenJPIP applications (server and dec server)
|
||||||
|
* java: a Java client viewer for JPIP
|
||||||
|
* jp3d: JP3D applications
|
||||||
|
* tcltk: a test tool for JP3D
|
||||||
|
* wx
|
||||||
|
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||||
|
* wrapping
|
||||||
|
* java: java jni to use openjpeg in a java program
|
||||||
|
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||||
|
* doc: doxygen documentation setup file and man pages
|
||||||
|
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in [openjpeg-data](https://github.com/uclouvain/openjpeg-data) repository.
|
||||||
|
* cmake: cmake related files
|
||||||
|
* scripts: scripts for developers
|
||||||
|
|
||||||
|
See [LICENSE][link-license] for license and copyright information.
|
||||||
|
|
||||||
|
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) for installation procedures.
|
||||||
|
|
||||||
|
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) for user visible changes in successive releases.
|
||||||
|
|
||||||
|
## API/ABI
|
||||||
|
|
||||||
|
An API/ABI timeline is automatically updated [here][link-api-timeline].
|
||||||
|
|
||||||
|
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
||||||
|
only exposes a limited subset of its functions. It uses a mechanism of
|
||||||
|
exporting/hiding functions. If you are unsure which functions you can use in
|
||||||
|
your applications, you should compile OpenJPEG using something similar to gcc:
|
||||||
|
`-fvisibility=hidden` compilation flag.
|
||||||
|
See also: http://gcc.gnu.org/wiki/Visibility
|
||||||
|
|
||||||
|
On windows, MSVC directly supports export/hiding function and as such the only
|
||||||
|
API available is the one supported by OpenJPEG.
|
||||||
|
|
||||||
|
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
|
||||||
|
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
|
||||||
|
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
|
||||||
|
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=master "Build Status"
|
||||||
|
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
|
||||||
|
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
|
||||||
|
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
|
||||||
|
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
|
||||||
|
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
|
||||||
|
[link-api-timeline]: http://www.openjpeg.org/abi-check/timeline/openjpeg "OpenJPEG API/ABI timeline"
|
|
@ -0,0 +1,39 @@
|
||||||
|
# OpenJPEG THANKS file
|
||||||
|
|
||||||
|
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
||||||
|
or submitting actual code. Here is a list of these people. Help me keep
|
||||||
|
it complete and exempt of errors.
|
||||||
|
|
||||||
|
* Giuseppe Baruffa
|
||||||
|
* Ben Boeckel
|
||||||
|
* Aaron Boxer
|
||||||
|
* David Burken
|
||||||
|
* Matthieu Darbois
|
||||||
|
* Rex Dieter
|
||||||
|
* Herve Drolon
|
||||||
|
* Antonin Descampe
|
||||||
|
* Francois-Olivier Devaux
|
||||||
|
* Parvatha Elangovan
|
||||||
|
* Jerôme Fimes
|
||||||
|
* Bob Friesenhahn
|
||||||
|
* Kaori Hagihara
|
||||||
|
* Luc Hermitte
|
||||||
|
* Luis Ibanez
|
||||||
|
* David Janssens
|
||||||
|
* Hans Johnson
|
||||||
|
* Callum Lerwick
|
||||||
|
* Ke Liu (Tencent's Xuanwu LAB)
|
||||||
|
* Sebastien Lugan
|
||||||
|
* Benoit Macq
|
||||||
|
* Mathieu Malaterre
|
||||||
|
* Julien Malik
|
||||||
|
* Arnaud Maye
|
||||||
|
* Vincent Nicolas
|
||||||
|
* Aleksander Nikolic (Cisco Talos)
|
||||||
|
* Glenn Pearson
|
||||||
|
* Even Rouault
|
||||||
|
* Dzonatas Sol
|
||||||
|
* Winfried Szukalski
|
||||||
|
* Vincent Torri
|
||||||
|
* Yannick Verschueren
|
||||||
|
* Peter Wimmer
|
|
@ -0,0 +1,41 @@
|
||||||
|
version: 2.3.1.{build}
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- coverity_scan
|
||||||
|
skip_tags: false
|
||||||
|
clone_depth: 50
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- OPJ_CI_ARCH: x64
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||||
|
OPJ_CI_INSTRUCTION_SETS: "/arch:AVX2"
|
||||||
|
- OPJ_CI_ARCH: x86
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||||
|
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
||||||
|
- OPJ_CI_ARCH: x64
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||||
|
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
||||||
|
- OPJ_CI_ARCH: x86
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS100COMNTOOLS)
|
||||||
|
install:
|
||||||
|
- cmd: c:\cygwin\bin\bash ./tools/travis-ci/install.sh
|
||||||
|
build_script:
|
||||||
|
- cmd: >-
|
||||||
|
"%OPJ_CI_VSCOMNTOOLS%..\..\VC\vcvarsall.bat" %OPJ_CI_ARCH%
|
||||||
|
|
||||||
|
bash ./tools/travis-ci/run.sh
|
||||||
|
test: off
|
||||||
|
#before_deploy:
|
||||||
|
#- cmd: c:\cygwin\bin\bash ./tools/travis-ci/before_deploy.sh
|
||||||
|
deploy:
|
||||||
|
#release: openjpeg-$(appveyor_repo_tag_name)
|
||||||
|
description: 'OpenJPEG $(appveyor_repo_tag_name) has been released. More info [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/NEWS) and a detailed view [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/CHANGES).'
|
||||||
|
provider: GitHub
|
||||||
|
auth_token:
|
||||||
|
secure: XUL+IoRRw8U/4tupa/fMpinxurft7WRQHZiWHMLO5iuFbwZ+C3vCjVVVM+5Ebky7 # your encrypted token from GitHub
|
||||||
|
artifact: /.*\.zip/ # upload all zip packages to release assets
|
||||||
|
draft: true
|
||||||
|
prerelease: false
|
||||||
|
on:
|
||||||
|
appveyor_repo_tag: true # deploy on tag push only
|
||||||
|
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
|
@ -0,0 +1,40 @@
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# For further details regarding this file,
|
||||||
|
# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
|
||||||
|
#
|
||||||
|
# and
|
||||||
|
# http://www.kitware.com/blog/home/post/27
|
||||||
|
#
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||||
|
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
|
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||||
|
|
||||||
|
set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
|
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||||
|
|
||||||
|
# Exclude files from the Testing directories
|
||||||
|
".*/tests/.*"
|
||||||
|
|
||||||
|
# Exclude files from the ThirdParty Utilities directories
|
||||||
|
".*/thirdparty/.*"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
|
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||||
|
|
||||||
|
# Ignore clang's summary warning, assuming prior text has matched some
|
||||||
|
# other warning expression:
|
||||||
|
"[0-9,]+ warnings? generated."
|
||||||
|
# Suppress warning caused by intentional messages about deprecation
|
||||||
|
".*warning,.* is deprecated"
|
||||||
|
# java also warns about deprecated API
|
||||||
|
".*java.*deprecation"
|
||||||
|
".*deprecation.*"
|
||||||
|
# suppress warnings caused by 3rd party libs:
|
||||||
|
".*thirdparty.*"
|
||||||
|
"libtiff.*has no symbols"
|
||||||
|
"libpng.*has no symbols"
|
||||||
|
)
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Ensure that an include file is provided by the system
|
||||||
|
# Add the check about the mandatory status to the check_include_file macro
|
||||||
|
# provided by cmake
|
||||||
|
|
||||||
|
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
|
||||||
|
macro(ensure_file_include INCLUDE_FILENAME VARIABLE_NAME MANDATORY_STATUS)
|
||||||
|
|
||||||
|
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||||
|
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||||
|
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||||
|
|
||||||
|
CHECK_INCLUDE_FILE(${INCLUDE_FILENAME} ${VARIABLE_NAME})
|
||||||
|
|
||||||
|
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||||
|
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||||
|
# "VARIABLE_NAME_VALUE=${${VARIABLE_NAME}} \n"
|
||||||
|
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||||
|
|
||||||
|
if (NOT ${${VARIABLE_NAME}})
|
||||||
|
if (${MANDATORY_STATUS})
|
||||||
|
message(FATAL_ERROR "The file ${INCLUDE_FILENAME} is mandatory but not found on your system")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endmacro()
|
|
@ -0,0 +1,16 @@
|
||||||
|
# cppcheck
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(CPPCHECK_EXECUTABLE
|
||||||
|
cppcheck
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
CPPCHECK_EXECUTABLE
|
||||||
|
)
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Look for the header file.
|
||||||
|
find_path(FCGI_INCLUDE_DIR NAMES fastcgi.h)
|
||||||
|
|
||||||
|
# Look for the library.
|
||||||
|
find_library(FCGI_LIBRARY NAMES fcgi)
|
||||||
|
|
||||||
|
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
|
||||||
|
|
||||||
|
# Copy the results to the output variables.
|
||||||
|
if(FCGI_FOUND)
|
||||||
|
set(FCGI_LIBRARIES ${FCGI_LIBRARY})
|
||||||
|
set(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
set(FCGI_LIBRARIES)
|
||||||
|
set(FCGI_INCLUDE_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# this module looks for JPYLYZER
|
||||||
|
# http://jpylyzer.openpreservation.org
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(JPYLYZER_EXECUTABLE
|
||||||
|
jpylyzer
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
JPYLYZER_EXECUTABLE
|
||||||
|
)
|
|
@ -0,0 +1,24 @@
|
||||||
|
#
|
||||||
|
# this module looks for KAKADU
|
||||||
|
# http://www.kakadusoftware.com/
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(KDU_EXPAND_EXECUTABLE
|
||||||
|
kdu_expand
|
||||||
|
)
|
||||||
|
|
||||||
|
find_program(KDU_COMPRESS_EXECUTABLE
|
||||||
|
kdu_compress
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
KDU_EXPAND_EXECUTABLE
|
||||||
|
KDU_COMPRESS_EXECUTABLE
|
||||||
|
)
|
|
@ -0,0 +1,31 @@
|
||||||
|
# - Find LCMS library
|
||||||
|
# Find the native LCMS includes and library
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LCMS_INCLUDE_DIR - Where to find lcms.h, etc.
|
||||||
|
# LCMS_LIBRARIES - Libraries to link against to use LCMS.
|
||||||
|
# LCMS_FOUND - If false, do not try to use LCMS.
|
||||||
|
#
|
||||||
|
# also defined, but not for general use are
|
||||||
|
# LCMS_LIBRARY, where to find the LCMS library.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
find_path(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||||
|
|
||||||
|
set(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||||
|
|
||||||
|
find_library(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||||
|
|
||||||
|
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(LCMS_FOUND)
|
||||||
|
set( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||||
|
set( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||||
|
endif()
|
|
@ -0,0 +1,31 @@
|
||||||
|
# - Find LCMS2 library
|
||||||
|
# Find the native LCMS2 includes and library
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LCMS2_INCLUDE_DIR - Where to find lcms2.h, etc.
|
||||||
|
# LCMS2_LIBRARIES - Libraries to link against to use LCMS2.
|
||||||
|
# LCMS2_FOUND - If false, do not try to use LCMS2.
|
||||||
|
#
|
||||||
|
# also defined, but not for general use are
|
||||||
|
# LCMS2_LIBRARY - Where to find the LCMS2 library.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
find_path(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||||
|
|
||||||
|
set(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||||
|
|
||||||
|
find_library(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||||
|
|
||||||
|
mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(LCMS2_FOUND)
|
||||||
|
set( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||||
|
set( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||||
|
endif()
|
|
@ -0,0 +1,9 @@
|
||||||
|
# JPIP test driver
|
||||||
|
#message(STATUS "${D_URL}")
|
||||||
|
file(DOWNLOAD
|
||||||
|
"${D_URL}"
|
||||||
|
"${D_FILE}"
|
||||||
|
LOG log
|
||||||
|
EXPECTED_MD5 "${EXPECTED_MD5}"
|
||||||
|
)
|
||||||
|
message(STATUS "LOG: ${log}")
|
|
@ -0,0 +1,72 @@
|
||||||
|
# package bundler
|
||||||
|
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||||
|
if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||||
|
set(CMAKE_INSTALL_MFC_LIBRARIES 0)
|
||||||
|
set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
|
||||||
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||||
|
endif()
|
||||||
|
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
||||||
|
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
|
||||||
|
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
|
||||||
|
)
|
||||||
|
# For PackageMaker on MacOSX it is important to have a file extension:
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH "${OPENJPEG_VERSION_BUILD}")
|
||||||
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
|
|
||||||
|
# Make this explicit here, rather than accepting the CPack default value,
|
||||||
|
# so we can refer to it:
|
||||||
|
set(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||||
|
|
||||||
|
if(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
|
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||||
|
# cygwin is good for the system name
|
||||||
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
set(CPACK_SYSTEM_NAME Cygwin)
|
||||||
|
else()
|
||||||
|
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
if(CMAKE_CL_64)
|
||||||
|
set(CPACK_SYSTEM_NAME win64-x64)
|
||||||
|
else()
|
||||||
|
set(CPACK_SYSTEM_NAME win32-x86)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||||
|
# default to source package - system, on cygwin system is not
|
||||||
|
# needed
|
||||||
|
if(CYGWIN)
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
|
if(APPLE)
|
||||||
|
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
set(CPACK_BUNDLE_PLIST
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
#include(BundleUtilities)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|
@ -0,0 +1,53 @@
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# OPENJPEGConfig.cmake - CMake configuration file for external projects.
|
||||||
|
#
|
||||||
|
# This file is configured by OPENJPEG and used by the UseOPENJPEG.cmake
|
||||||
|
# module to load OPENJPEG's settings for an external project.
|
||||||
|
@OPENJPEG_CONFIG_INSTALL_ONLY@
|
||||||
|
# The OPENJPEG version number.
|
||||||
|
set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
||||||
|
set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||||
|
set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||||
|
|
||||||
|
# The libraries.
|
||||||
|
set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||||
|
|
||||||
|
# The CMake macros dir.
|
||||||
|
set(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||||
|
|
||||||
|
# The configuration options.
|
||||||
|
set(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||||
|
|
||||||
|
# The "use" file.
|
||||||
|
set(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||||
|
|
||||||
|
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
# This is an install tree
|
||||||
|
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
|
||||||
|
# We find a relative path from the PKG directory to header files.
|
||||||
|
set(PKG_DIR "@CMAKE_INSTALL_PREFIX@/@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||||
|
set(INC_DIR "@CMAKE_INSTALL_PREFIX@/@OPENJPEG_INSTALL_INCLUDE_DIR@")
|
||||||
|
file(RELATIVE_PATH PKG_TO_INC_RPATH "${PKG_DIR}" "${INC_DIR}")
|
||||||
|
|
||||||
|
get_filename_component(OPENJPEG_INCLUDE_DIRS "${SELF_DIR}/${PKG_TO_INC_RPATH}" ABSOLUTE)
|
||||||
|
|
||||||
|
else()
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
# This is a build tree
|
||||||
|
set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||||
|
|
||||||
|
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "ooops")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||||
|
|
||||||
|
# Backward compatible part:
|
||||||
|
set(OPENJPEG_FOUND TRUE)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* Cause a compile-time error if off_t is smaller than 64 bits */
|
||||||
|
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||||
|
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#cmakedefine _LARGEFILE_SOURCE
|
||||||
|
#cmakedefine _LARGE_FILES
|
||||||
|
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Cause a compile-time error if off_t is smaller than 64 bits,
|
||||||
|
* and make sure we have ftello / fseeko.
|
||||||
|
*/
|
||||||
|
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||||
|
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||||
|
FILE *fp = fopen(argv[0],"r");
|
||||||
|
off_t offset = ftello( fp );
|
||||||
|
|
||||||
|
fseeko( fp, offset, SEEK_CUR );
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
# - Define macro to check large file support
|
||||||
|
#
|
||||||
|
# OPJ_TEST_LARGE_FILES(VARIABLE)
|
||||||
|
#
|
||||||
|
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
|
||||||
|
# This macro will also defines the necessary variable enable large file support, for instance
|
||||||
|
# _LARGE_FILES
|
||||||
|
# _LARGEFILE_SOURCE
|
||||||
|
# _FILE_OFFSET_BITS 64
|
||||||
|
# OPJ_HAVE_FSEEKO
|
||||||
|
#
|
||||||
|
# However, it is YOUR job to make sure these defines are set in a #cmakedefine so they
|
||||||
|
# end up in a config.h file that is included in your source if necessary!
|
||||||
|
#
|
||||||
|
# Adapted from Gromacs project (http://www.gromacs.org/)
|
||||||
|
# by Julien Malik
|
||||||
|
#
|
||||||
|
|
||||||
|
macro(OPJ_TEST_LARGE_FILES VARIABLE)
|
||||||
|
if(NOT DEFINED ${VARIABLE})
|
||||||
|
|
||||||
|
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
|
||||||
|
# and then separately fseeko. However, in the future we might have 128-bit filesystems
|
||||||
|
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
|
||||||
|
|
||||||
|
message(STATUS "Checking for 64-bit off_t")
|
||||||
|
|
||||||
|
# First check without any special flags
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c")
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _FILE_OFFSET_BITS=64
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
||||||
|
set(_FILE_OFFSET_BITS 64)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _LARGE_FILES
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
||||||
|
set(_LARGE_FILES 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _LARGEFILE_SOURCE
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
||||||
|
set(_LARGEFILE_SOURCE 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
#if(NOT FILE64_OK)
|
||||||
|
# # now check for Windows stuff
|
||||||
|
# try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
# "${PROJECT_SOURCE_DIR}/cmake/TestWindowsFSeek.c")
|
||||||
|
# if(FILE64_OK)
|
||||||
|
# message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
||||||
|
# set(HAVE__FSEEKI64 1)
|
||||||
|
# endif()
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - not present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64")
|
||||||
|
set(_LARGE_FILES ${_LARGE_FILES} CACHE INTERNAL "Result of test for needed _LARGE_FILES")
|
||||||
|
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||||
|
|
||||||
|
# Set the flags we might have determined to be required above
|
||||||
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||||
|
|
||||||
|
message(STATUS "Checking for fseeko/ftello")
|
||||||
|
|
||||||
|
# Test if ftello/fseeko are available
|
||||||
|
try_compile(FSEEKO_COMPILE_OK
|
||||||
|
"${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Checking for fseeko/ftello - present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FSEEKO_COMPILE_OK)
|
||||||
|
# glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...)
|
||||||
|
try_compile(FSEEKO_COMPILE_OK
|
||||||
|
"${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
||||||
|
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
set(OPJ_HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||||
|
else()
|
||||||
|
message(STATUS "Checking for fseeko/ftello - not found")
|
||||||
|
set(OPJ_HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FILE64_OK AND FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Large File support - found")
|
||||||
|
set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support")
|
||||||
|
else()
|
||||||
|
message(STATUS "Large File support - not found")
|
||||||
|
set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__int64 off=0;
|
||||||
|
|
||||||
|
_fseeki64(NULL, off, SEEK_SET);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Cond
|
||||||
|
fun:deflate
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_row
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Value8
|
||||||
|
fun:crc32
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_chunk
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_row
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Param
|
||||||
|
write(buf)
|
||||||
|
fun:__write_nocancel
|
||||||
|
fun:_IO_file_write@@GLIBC_2.2.5
|
||||||
|
fun:_IO_do_write@@GLIBC_2.2.5
|
||||||
|
fun:_IO_file_close_it@@GLIBC_2.2.5
|
||||||
|
fun:fclose@@GLIBC_2.2.5
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Generate target to build the html documentation through CMake tool
|
||||||
|
# After having configured the project with the BUILD_DOC option you can run make doc
|
||||||
|
# to generate the html documentation in the doc/html repository of the build folder.
|
||||||
|
|
||||||
|
# Try to find the doxygen tool
|
||||||
|
find_package(Doxygen)
|
||||||
|
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
# Configure the doxygen config file with variable from CMake and move it
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
|
||||||
|
|
||||||
|
# Configure the html mainpage file of the doxygen documentation with variable
|
||||||
|
# from CMake and move it
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpip.dox.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/openjpip.dox @ONLY)
|
||||||
|
# copy png file to make local (binary tree) documentation valid:
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_architect.png
|
||||||
|
${CMAKE_BINARY_DIR}/doc/html/jpip_architect.png COPYONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_protocol.png
|
||||||
|
${CMAKE_BINARY_DIR}/doc/html/jpip_protocol.png COPYONLY)
|
||||||
|
|
||||||
|
file(GLOB headers
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.c
|
||||||
|
)
|
||||||
|
# Generate new target to build the html documentation
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
|
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||||
|
${CMAKE_BINARY_DIR}/doc/mainpage.dox
|
||||||
|
${CMAKE_BINARY_DIR}/doc/openjpip.dox
|
||||||
|
${headers}
|
||||||
|
)
|
||||||
|
add_custom_target(doc ALL
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
|
||||||
|
COMMENT "Building doxygen documentation"
|
||||||
|
)
|
||||||
|
|
||||||
|
# install HTML documentation (install png files too):
|
||||||
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
|
||||||
|
DESTINATION share/doc
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Doxygen not found, we cannot generate the documentation")
|
||||||
|
endif()
|
|
@ -0,0 +1,279 @@
|
||||||
|
# Doxyfile 1.7.1
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
DOXYFILE_ENCODING = UTF-8
|
||||||
|
PROJECT_NAME = OpenJPEG
|
||||||
|
PROJECT_NUMBER = @OPENJPEG_VERSION@
|
||||||
|
OUTPUT_DIRECTORY = @OPENJPEG_BINARY_DIR@/doc
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
BRIEF_MEMBER_DESC = YES
|
||||||
|
REPEAT_BRIEF = YES
|
||||||
|
ABBREVIATE_BRIEF = "The $name class" \
|
||||||
|
"The $name widget" \
|
||||||
|
"The $name file" \
|
||||||
|
is \
|
||||||
|
provides \
|
||||||
|
specifies \
|
||||||
|
contains \
|
||||||
|
represents \
|
||||||
|
a \
|
||||||
|
an \
|
||||||
|
the
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = NO
|
||||||
|
STRIP_FROM_PATH = C://
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = YES
|
||||||
|
QT_AUTOBRIEF = NO
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
SEPARATE_MEMBER_PAGES = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
OPTIMIZE_FOR_FORTRAN = NO
|
||||||
|
OPTIMIZE_OUTPUT_VHDL = NO
|
||||||
|
EXTENSION_MAPPING =
|
||||||
|
BUILTIN_STL_SUPPORT = NO
|
||||||
|
CPP_CLI_SUPPORT = NO
|
||||||
|
SIP_SUPPORT = NO
|
||||||
|
IDL_PROPERTY_SUPPORT = YES
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
TYPEDEF_HIDES_STRUCT = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = YES
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = NO
|
||||||
|
EXTRACT_ANON_NSPACES = NO
|
||||||
|
HIDE_UNDOC_MEMBERS = NO
|
||||||
|
HIDE_UNDOC_CLASSES = NO
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = NO
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = YES
|
||||||
|
FORCE_LOCAL_INCLUDES = NO
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = YES
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_MEMBERS_CTORS_1ST = NO
|
||||||
|
SORT_GROUP_NAMES = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
SHOW_FILES = YES
|
||||||
|
SHOW_NAMESPACES = YES
|
||||||
|
FILE_VERSION_FILTER =
|
||||||
|
LAYOUT_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = NO
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_NO_PARAMDOC = NO
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = @OPENJPEG_SOURCE_DIR@/src/lib/openjp2 \
|
||||||
|
@OPENJPEG_SOURCE_DIR@/src/lib/openjpip \
|
||||||
|
@OPENJPEG_BINARY_DIR@/doc
|
||||||
|
INPUT_ENCODING = UTF-8
|
||||||
|
FILE_PATTERNS = *.h \
|
||||||
|
*.c \
|
||||||
|
*.dox
|
||||||
|
RECURSIVE = YES
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS = */.svn/*
|
||||||
|
EXCLUDE_SYMBOLS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS = *
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH = @OPENJPEG_SOURCE_DIR@/doc
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_PATTERNS =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = NO
|
||||||
|
INLINE_SOURCES = NO
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = YES
|
||||||
|
REFERENCES_RELATION = YES
|
||||||
|
REFERENCES_LINK_SOURCE = YES
|
||||||
|
USE_HTAGS = NO
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = NO
|
||||||
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
|
IGNORE_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = ./html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_COLORSTYLE_HUE = 220
|
||||||
|
HTML_COLORSTYLE_SAT = 100
|
||||||
|
HTML_COLORSTYLE_GAMMA = 80
|
||||||
|
HTML_TIMESTAMP = NO
|
||||||
|
HTML_DYNAMIC_SECTIONS = NO
|
||||||
|
GENERATE_DOCSET = NO
|
||||||
|
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||||
|
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||||
|
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||||
|
DOCSET_PUBLISHER_NAME = Publisher
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
CHM_INDEX_ENCODING =
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
GENERATE_QHP = NO
|
||||||
|
QCH_FILE =
|
||||||
|
QHP_NAMESPACE = org.doxygen.Project
|
||||||
|
QHP_VIRTUAL_FOLDER = doc
|
||||||
|
QHP_CUST_FILTER_NAME =
|
||||||
|
QHP_CUST_FILTER_ATTRS =
|
||||||
|
QHP_SECT_FILTER_ATTRS =
|
||||||
|
QHG_LOCATION =
|
||||||
|
GENERATE_ECLIPSEHELP = NO
|
||||||
|
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = NO
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
EXT_LINKS_IN_WINDOW = NO
|
||||||
|
FORMULA_FONTSIZE = 10
|
||||||
|
FORMULA_TRANSPARENT = YES
|
||||||
|
SEARCHENGINE = NO
|
||||||
|
SERVER_BASED_SEARCH = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = NO
|
||||||
|
USE_PDFLATEX = NO
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
LATEX_SOURCE_CODE = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED = USE_JPWL \
|
||||||
|
USE_JPSEC
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES =
|
||||||
|
GENERATE_TAGFILE =
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
MSCGEN_PATH =
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = NO
|
||||||
|
DOT_NUM_THREADS = 0
|
||||||
|
DOT_FONTNAME = Helvetica
|
||||||
|
DOT_FONTSIZE = 10
|
||||||
|
DOT_FONTPATH =
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
GROUP_GRAPHS = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
CALLER_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DIRECTORY_GRAPH = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
DOT_GRAPH_MAX_NODES = 50
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 1000
|
||||||
|
DOT_TRANSPARENT = NO
|
||||||
|
DOT_MULTI_TARGETS = NO
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \mainpage OpenJPEG v@OPENJPEG_VERSION@ Documentation
|
||||||
|
*
|
||||||
|
* \section intro Introduction
|
||||||
|
* This manual documents the low-level OpenJPEG C API.\n
|
||||||
|
* The OpenJPEG library is an open-source JPEG 2000 library developed in order to promote the use of JPEG 2000.\n
|
||||||
|
* This documents is focused on the main part of the library which try to implement Part 1 and Part 2 of the JPEG2000 norm.\n
|
||||||
|
*
|
||||||
|
* \section home Home page
|
||||||
|
*
|
||||||
|
* The Home Page of the OpenJPEG project can be found at:
|
||||||
|
*
|
||||||
|
* http://www.openjpeg.org/
|
||||||
|
*
|
||||||
|
* The source code repository is available here:
|
||||||
|
*
|
||||||
|
* http://github.com/uclouvain/openjpeg
|
||||||
|
*
|
||||||
|
* The OpenJPEG mailing list is located here:
|
||||||
|
*
|
||||||
|
* http://groups.google.com/group/openjpeg
|
||||||
|
*
|
||||||
|
* The test files repository is available here:
|
||||||
|
*
|
||||||
|
* http://github.com/uclouvain/openjpeg-data
|
||||||
|
*
|
||||||
|
* \section license License
|
||||||
|
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||||
|
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||||
|
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
*
|
||||||
|
* \author OpenJPEG Team
|
||||||
|
*
|
||||||
|
*/
|
|
@ -0,0 +1,222 @@
|
||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_compress \-
|
||||||
|
This program reads in an image of a certain type and converts it to a
|
||||||
|
jpeg2000 file. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||||
|
.SP
|
||||||
|
Valid output image extensions are
|
||||||
|
.B .j2k, .jp2
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_compress \-i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||||
|
.P
|
||||||
|
.B opj_compress \-ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||||
|
.P
|
||||||
|
.B opj_compress \-h \fRPrint a help message and exit.
|
||||||
|
.P
|
||||||
|
See JPWL OPTIONS for special options
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^b " n,n"
|
||||||
|
(Size of code block (e.g. \-b 32,32). Default: 64 x 64)
|
||||||
|
.TP
|
||||||
|
.B \-\^c " n"
|
||||||
|
(Size of precinct (e.g. \-c 128,128). Default: 2^15 x 2^15)
|
||||||
|
.TP
|
||||||
|
.B \-\^cinema2K " fps"
|
||||||
|
Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or 48.
|
||||||
|
.TP
|
||||||
|
.B \-\^cinema4K
|
||||||
|
Digital Cinema 4K profile compliant codestream. Does not need an fps: default is 24 fps.
|
||||||
|
.TP
|
||||||
|
.B \-\^d " X,Y"
|
||||||
|
(Offset of image origin (e.g. \-d 150,300))
|
||||||
|
.TP
|
||||||
|
.B \-\^h
|
||||||
|
Print a help message and exit.
|
||||||
|
.TP
|
||||||
|
.B \-\^i " name"
|
||||||
|
(input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^n " n"
|
||||||
|
(Number of resolutions. Default: 6)
|
||||||
|
.TP
|
||||||
|
.B \-\^o " name"
|
||||||
|
(output file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^p " name"
|
||||||
|
Progression order. \fBname\fR can be one out of:LRCP, RLCP, RPCL, PCRL, CPRL. Default: LRCP.
|
||||||
|
.TP
|
||||||
|
.B \-\^q " n"
|
||||||
|
different psnr for successive layers
|
||||||
|
.br
|
||||||
|
.B Note: \fR(options \-r and \-q cannot be used together)
|
||||||
|
.TP
|
||||||
|
.B \-\^r " n"
|
||||||
|
different compression ratio(s) for successive layers. The rate specified for each quality level is the desired compression factor.
|
||||||
|
.br
|
||||||
|
.B Note: \fR(options \-r and \-q cannot be used together)
|
||||||
|
.TP
|
||||||
|
.B \-\^s " X,Y"
|
||||||
|
sub-sampling factor (e.g. \-s 2,2). Default: No sub-sampling in x or y direction.
|
||||||
|
.br
|
||||||
|
.B Remark: \fRsub-sampling bigger than 2 can produce errors.
|
||||||
|
.TP
|
||||||
|
.B \-\^t " W,H"
|
||||||
|
(Size of tile (e.g. \-t 512,512) )
|
||||||
|
.TP
|
||||||
|
.B \-\^x " name"
|
||||||
|
(Create index file and fill it. Default: no index file)
|
||||||
|
.TP
|
||||||
|
.B \-\^EPH
|
||||||
|
(Write EPH marker after each header packet. Default:no EPH)
|
||||||
|
.TP
|
||||||
|
.B \-\^F " rawWidth,rawHeight,rawComp,rawBitDepth,s_or_u"
|
||||||
|
characteristics of the raw input image
|
||||||
|
.TP
|
||||||
|
.B \-\^I
|
||||||
|
(Use the irreversible DWT 9-7. Default: Reversible DWT 5-3)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir " directory_name"
|
||||||
|
(directory containing input files)
|
||||||
|
.TP
|
||||||
|
.B \-\^M " n"
|
||||||
|
mode switch with values: 1, 2, 4, 8, 16, 32. Default:No mode switch activated.
|
||||||
|
.br
|
||||||
|
\fIMeaning:\fR
|
||||||
|
.br
|
||||||
|
BYPASS(1)
|
||||||
|
.br
|
||||||
|
RESET(2)
|
||||||
|
.br
|
||||||
|
RESTART(4)
|
||||||
|
.br
|
||||||
|
VSC(8)
|
||||||
|
.br
|
||||||
|
ERTERM(16)
|
||||||
|
.br
|
||||||
|
SEGMARK(32)
|
||||||
|
.br
|
||||||
|
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = \-M 38
|
||||||
|
.TP
|
||||||
|
.B \-\^OutFor "ext"
|
||||||
|
(extension for output files)
|
||||||
|
.TP
|
||||||
|
.B \-\^POC "TtileNr=resolutionStart, componentStart, layerEnd, resolutionEnd, componentEnd, progressionOrder"
|
||||||
|
(see Examples)
|
||||||
|
.TP
|
||||||
|
.B \-\^ROI "c=n,U=n"
|
||||||
|
quantization indices upshifted for component c (0 or 1 or 2) with a value of U (>= 0 and <= 37)
|
||||||
|
.br
|
||||||
|
e.g. \fB-ROI c=0,U=25\fR
|
||||||
|
.TP
|
||||||
|
.B \-\^SOP
|
||||||
|
(Write SOP marker before each packet. Default: No SOP marker in the codestream.)
|
||||||
|
.TP
|
||||||
|
.B \-\^T "X,Y"
|
||||||
|
(Offset of the origin of the tiles (e.g. \-T 100,75) )
|
||||||
|
.TP
|
||||||
|
.B \-\^W
|
||||||
|
(see JPWL OPTIONS)
|
||||||
|
.P
|
||||||
|
.SH JPWL OPTIONS
|
||||||
|
Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||||
|
.P
|
||||||
|
.B \-W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
|
||||||
|
.P
|
||||||
|
.B h\fR selects the header error protection (EPB): \fBtype\fR can be
|
||||||
|
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
|
||||||
|
if \fBtilepart\fR is absent, it is for main and tile headers
|
||||||
|
if \fBtilepart\fR is present, it applies from that tile
|
||||||
|
onwards, up to the next h<> spec, or to the last tilepart
|
||||||
|
in the codestream (max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B p \fRselects the packet error protection (EEP/UEP with EPBs)
|
||||||
|
to be applied to raw data: \fBtype\fR can be
|
||||||
|
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
|
||||||
|
if \fBtilepart:pack\fR is absent, it is from tile 0, packet 0
|
||||||
|
if \fBtilepart:pack\fR is present, it applies from that tile
|
||||||
|
and that packet onwards, up to the next packet spec
|
||||||
|
or to the last packet in the last tilepart in the stream
|
||||||
|
(max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B s \fRenables sensitivity data insertion (ESD): \fBmethod\fR can be
|
||||||
|
[\-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
|
||||||
|
4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
|
||||||
|
if \fBtilepart\fR is absent, it is for main header only
|
||||||
|
if \fBtilepart\fR is present, it applies from that tile
|
||||||
|
onwards, up to the next s<> spec, or to the last tilepart
|
||||||
|
in the codestream (max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B g \fRdetermines the addressing mode: \fBrange\fR can be
|
||||||
|
[0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
|
||||||
|
.P
|
||||||
|
.B a \fRdetermines the size of data addressing: \fBaddr\fR can be
|
||||||
|
2/4 bytes (small/large codestreams). If not set, auto-mode
|
||||||
|
.P
|
||||||
|
.B z \fRdetermines the size of sensitivity values: \fBsize\fR can be
|
||||||
|
1/2 bytes, for the transformed pseudo-floating point value
|
||||||
|
.P
|
||||||
|
.SH EXAMPLES
|
||||||
|
.P
|
||||||
|
.B opj_compress \-i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||||
|
.P
|
||||||
|
.B opj_compress \-i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||||
|
.P
|
||||||
|
.B opj_compress \-i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||||
|
.P
|
||||||
|
.B opj_compress \-i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||||
|
.P
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
.br
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
.br
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
.br
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
.br
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_decompress(1) opj_dump(1)
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_decompress \-
|
||||||
|
This program reads in a jpeg2000 image and converts it to another
|
||||||
|
image type. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .j2k, .jp2, .j2c, .jpt
|
||||||
|
.SP
|
||||||
|
Valid output image extensions are
|
||||||
|
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_decompress \-i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||||
|
.P
|
||||||
|
.B opj_decompress \-ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||||
|
.P
|
||||||
|
.B opj_decompress \-h \fRPrint help message and exit
|
||||||
|
.P
|
||||||
|
See JPWL OPTIONS for special options
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^i "name"
|
||||||
|
(jpeg2000 input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^l "n"
|
||||||
|
n is the maximum number of quality layers to decode. See LAYERS below)
|
||||||
|
.TP
|
||||||
|
.B \-\^o "name"
|
||||||
|
(output file name with extension)
|
||||||
|
.TP
|
||||||
|
.B \-\^r "n"
|
||||||
|
(n is the highest resolution level to be discarded. See REDUCTION below)
|
||||||
|
.TP
|
||||||
|
.B \-\^x "name"
|
||||||
|
(use name as index file and fill it)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir "directory_name"
|
||||||
|
(directory containing input files)
|
||||||
|
.TP
|
||||||
|
.B \-\^OutFor "ext"
|
||||||
|
(extension for output files)
|
||||||
|
.P
|
||||||
|
.SH JPIP OPTIONS
|
||||||
|
Options usable only if the library has been compiled with
|
||||||
|
.B BUILD_JPIP
|
||||||
|
.TP
|
||||||
|
.B -jpip
|
||||||
|
Embed index table box into the output JP2 file (compulsory for JPIP)
|
||||||
|
.TP
|
||||||
|
.B -TP R
|
||||||
|
Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream)
|
||||||
|
.P
|
||||||
|
.SH JPWL OPTIONS
|
||||||
|
Options usable only if the library has been compiled with
|
||||||
|
.B BUILD_JPWL
|
||||||
|
.TP
|
||||||
|
.B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3)
|
||||||
|
.TP
|
||||||
|
.B -W t\fR[=Nt] (Nt is the maximum number of tiles in the codestream; default:8192)
|
||||||
|
.TP
|
||||||
|
.B -W c\fR[=Nc]\fB, t\fR[=Nt] \fR(same as above)
|
||||||
|
.P
|
||||||
|
.SH REDUCTION
|
||||||
|
Set the number of highest resolution levels to be discarded.
|
||||||
|
The image resolution is effectively divided by 2 to the power of the number of discarded levels. The reduce factor is limited by the smallest total number of decomposition levels among tiles.
|
||||||
|
.SH TILES
|
||||||
|
Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
|
||||||
|
.P
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
.br
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
.br
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
.br
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
.br
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_compress(1) opj_dump(1)
|
|
@ -0,0 +1,62 @@
|
||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_dump \-
|
||||||
|
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .j2k, .jp2, .jpt
|
||||||
|
.SP
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_dump \-i \fRinfile.j2k
|
||||||
|
.P
|
||||||
|
.B opj_dump \-ImgDir \fRimages/ \fRDump all files in images/
|
||||||
|
.P
|
||||||
|
.B opj_dump \-h \fRPrint help message and exit
|
||||||
|
.P
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^i "name"
|
||||||
|
(jpeg2000 input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir "directory_name"
|
||||||
|
(directory containing jpeg2000 input files)
|
||||||
|
.P
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2010, Mathieu Malaterre
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_compress(1) opj_decompress(1)
|
|
@ -0,0 +1,337 @@
|
||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH libopenjp2 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
libopenjp2 -
|
||||||
|
a library for reading and writing JPEG2000 image files.
|
||||||
|
.SP
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B #include <openjpeg.h>
|
||||||
|
.P
|
||||||
|
.SS CONVERSION FORMATS
|
||||||
|
.B PGX: imagetopgx() \fR/\fB pgxtoimage()
|
||||||
|
.P
|
||||||
|
.B PXM: imagetopnm() \fR/\fB pnmtoimage()
|
||||||
|
.P
|
||||||
|
.B BMP: imagetobmp() \fR/\fB bmptoimage()
|
||||||
|
.P
|
||||||
|
.B TIF: imagetotif() \fR/\fB tiftoimage()
|
||||||
|
.P
|
||||||
|
.B RAW: imagetoraw() \fR/\fB rawtoimage()
|
||||||
|
.P
|
||||||
|
.B TGA: imagetotga() \fR/\fB tgatoimage()
|
||||||
|
.P
|
||||||
|
.B PNG: imagetopng() \fR/\fB pngtoimage()
|
||||||
|
.P
|
||||||
|
.B YUV: imagetoyuv() \fR/\fB yuvtoimage() \fR(MJ2)
|
||||||
|
.P
|
||||||
|
.SS READ
|
||||||
|
.B opj_set_default_decoder_parameters(opj_dparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
.B opj_dinfo_t *opj_create_decompress(OPJ_CODEC_FORMAT \fIformat\fB);
|
||||||
|
.P
|
||||||
|
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_setup_decoder(opj_dinfo_t *\fIdinfo\fB, opj_dparameters_t * \fIparams\fB);
|
||||||
|
.P
|
||||||
|
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIinfo\fB, unsigned char *\fIbuf\fB, int \fIbuf_len\fB);
|
||||||
|
.P
|
||||||
|
.B opj_image_t *opj_decode(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_decompress(opj_dinfo_t *\fIdinfo\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.SS WRITE
|
||||||
|
.B void opj_set_default_encoder_parameters(opj_cparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
/*
|
||||||
|
.B opj_image_t *FORMATtoimage(const char *\fIfname\fB, opj_cparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
*/
|
||||||
|
.br
|
||||||
|
.B opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT \fIformat\fB);
|
||||||
|
.P
|
||||||
|
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_setup_encoder(opj_cinfo_t *\fIcinfo\fB, opj_cparameters_t *\fIparams\fB, opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIcinfo\fB, \fINULL\fB, \fI0\fB);
|
||||||
|
.P
|
||||||
|
.B bool opj_encode(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, char *\fIindex\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_compress(opj_cinfo_t *\fIcinfo\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.SS GENERAL
|
||||||
|
.P
|
||||||
|
.B void opj_image_create(int \fInumcmpts\fB, opj_image_cmptparm_t *\fIcmptparms\fB, OPJ_COLOR_SPACE \fIclrspc\fB);
|
||||||
|
.P
|
||||||
|
.B int cio_tell(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void cio_seek(opj_cio_t *\fIcio\fB, int \fIpos\fB);
|
||||||
|
.P
|
||||||
|
.B opj_image_t *opj_decode_with_info(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB, opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B bool opj_encode_with_info(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_cstr_info(opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B const char *opj_version(\fIvoid\fB);
|
||||||
|
.P
|
||||||
|
.SH OPJ_CODEC_FORMAT
|
||||||
|
.P
|
||||||
|
.B CODEC_J2K\fR or \fBCODEC_JPT\fR or \fBCODEC_JP2
|
||||||
|
.P
|
||||||
|
.SH OPJ_COLOR_SPACE
|
||||||
|
.P
|
||||||
|
.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
|
||||||
|
.P
|
||||||
|
.SH DECOMPRESSION PARAMETERS
|
||||||
|
.p
|
||||||
|
typedef struct opj_dparameters
|
||||||
|
.br
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Set the number of highest resolution levels to be discarded.
|
||||||
|
The image resolution is effectively divided by 2 to the power
|
||||||
|
of the number of discarded levels.
|
||||||
|
The reduce factor is limited by the smallest total number of
|
||||||
|
decomposition levels among tiles.
|
||||||
|
if != 0, then original dimension divided by 2^(reduce);
|
||||||
|
if == 0 or not used, image is decoded to the full resolution
|
||||||
|
*/
|
||||||
|
\fBint\fR cp_reduce;
|
||||||
|
/*
|
||||||
|
Set the maximum number of quality layers to decode.
|
||||||
|
If there are less quality layers than the specified number,
|
||||||
|
all the quality layers are decoded.
|
||||||
|
if != 0, then only the first "layer" layers are decoded;
|
||||||
|
if == 0 or not used, all the quality layers are decoded
|
||||||
|
*/
|
||||||
|
\fBint\fR cp_layer;
|
||||||
|
|
||||||
|
/*command line encoder parameters (not used inside the library) */
|
||||||
|
/* input file name */
|
||||||
|
\fBchar\fR infile[OPJ_PATH_LEN];
|
||||||
|
/* output file name */
|
||||||
|
\fBchar\fR outfile[OPJ_PATH_LEN];
|
||||||
|
/* input file format: see OPJ_CODEC_FORMAT */
|
||||||
|
\fBint\fR decod_format;
|
||||||
|
/* output file format */
|
||||||
|
\fBint\fR cod_format;
|
||||||
|
|
||||||
|
/*JPWL decoding parameters */
|
||||||
|
/* activates the JPWL correction capabilities */
|
||||||
|
\fBbool\fR jpwl_correct;
|
||||||
|
/* expected number of components */
|
||||||
|
\fBint\fR jpwl_exp_comps;
|
||||||
|
/* maximum number of tiles */
|
||||||
|
\fBint\fR jpwl_max_tiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Specify whether the decoding should be done on the entire
|
||||||
|
codestream, or be limited to the main header
|
||||||
|
Limiting the decoding to the main header makes it possible
|
||||||
|
to extract the characteristics of the codestream
|
||||||
|
if == NO_LIMITATION, the entire codestream is decoded;
|
||||||
|
if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
|
||||||
|
*/
|
||||||
|
\fBOPJ_LIMIT_DECODING\fR cp_limit_decoding;
|
||||||
|
.br
|
||||||
|
} opj_dparameters_t;
|
||||||
|
|
||||||
|
.SH COMPRESSION PARAMETERS
|
||||||
|
.P
|
||||||
|
typedef struct opj_cparameters
|
||||||
|
.br
|
||||||
|
{
|
||||||
|
/* size of tile: tile_size_on = false (not in argument)
|
||||||
|
or tile_size_on = true (in argument) */
|
||||||
|
\fBbool\fR tile_size_on;
|
||||||
|
/* XTOsiz */
|
||||||
|
\fBint\fR cp_tx0;
|
||||||
|
/* YTOsiz */
|
||||||
|
\fBint\fR cp_ty0;
|
||||||
|
/* XTsiz */
|
||||||
|
\fBint\fR cp_tdx;
|
||||||
|
/* YTsiz */
|
||||||
|
\fBint\fR cp_tdy;
|
||||||
|
/* allocation by rate/distortion */
|
||||||
|
\fBint\fR cp_disto_alloc;
|
||||||
|
/* allocation by fixed layer */
|
||||||
|
\fBint\fR cp_fixed_alloc;
|
||||||
|
/* add fixed_quality */
|
||||||
|
\fBint\fR cp_fixed_quality;
|
||||||
|
/* fixed layer */
|
||||||
|
\fBint *\fRcp_matrice;
|
||||||
|
/* comment for coding */
|
||||||
|
\fBchar *\fRcp_comment;
|
||||||
|
/* coding style */
|
||||||
|
\fBint\fR csty;
|
||||||
|
/* progression order:
|
||||||
|
PROG_UNKNOWN, LRCP(default), RLCP, RPCL, PCRL, CPRL */
|
||||||
|
\fBOPJ_PROG_ORDER\fR prog_order;
|
||||||
|
/* progression order changes */
|
||||||
|
\fBopj_poc_t\fR POC[32];
|
||||||
|
/* number of progression order changes (POC), default: 0 */
|
||||||
|
\fBint\fR numpocs;
|
||||||
|
/* number of layers */
|
||||||
|
\fBint\fR tcp_numlayers;
|
||||||
|
/* rates of layers */
|
||||||
|
\fBfloat\fR tcp_rates[100];
|
||||||
|
/* different psnr for successive layers */
|
||||||
|
\fBfloat\fR tcp_distoratio[100];
|
||||||
|
/* number of resolutions */
|
||||||
|
\fBint\fR numresolution;
|
||||||
|
/* initial code block width, default: 64 */
|
||||||
|
\fBint\fR cblockw_init;
|
||||||
|
/* initial code block height, default: 64 */
|
||||||
|
\fBint\fR cblockh_init;
|
||||||
|
/* mode switch (cblk_style) */
|
||||||
|
/* 1 : use the irreversible DWT 9-7,
|
||||||
|
0 : use lossless compression (default) */
|
||||||
|
\fBint\fR irreversible;
|
||||||
|
/* region of interest: affected component in [0..3],
|
||||||
|
-1 means no ROI */
|
||||||
|
\fBint\fR roi_compno;
|
||||||
|
/* region of interest: upshift value */
|
||||||
|
\fBint\fR roi_shift;
|
||||||
|
/* number of precinct size specifications */
|
||||||
|
\fBint\fR res_spec;
|
||||||
|
/* initial precinct width */
|
||||||
|
\fBint\fR prcw_init[J2K_MAXRLVLS];
|
||||||
|
/* initial precinct height */
|
||||||
|
\fBint\fR prch_init[J2K_MAXRLVLS];
|
||||||
|
|
||||||
|
/*command line encoder parameters (not used inside the library) */
|
||||||
|
/* input file name */
|
||||||
|
\fBchar\fR infile[OPJ_PATH_LEN];
|
||||||
|
/* output file name */
|
||||||
|
\fBchar\fR outfile[OPJ_PATH_LEN];
|
||||||
|
/* DEPRECATED. Index generation is now handeld with the
|
||||||
|
opj_encode_with_info() function. Set to NULL */
|
||||||
|
\fBint\fR index_on;
|
||||||
|
/* DEPRECATED. Index generation is now handeld with the
|
||||||
|
opj_encode_with_info() function. Set to NULL */
|
||||||
|
\fBchar\fR index[OPJ_PATH_LEN];
|
||||||
|
/* subimage encoding: origin image offset in x direction */
|
||||||
|
\fBint\fR image_offset_x0;
|
||||||
|
/* subimage encoding: origin image offset in y direction */
|
||||||
|
\fBint\fR image_offset_y0;
|
||||||
|
/* subsampling value for dx */
|
||||||
|
\fBint\fR subsampling_dx;
|
||||||
|
/* subsampling value for dy */
|
||||||
|
\fBint\fR subsampling_dy;
|
||||||
|
/* input file format */
|
||||||
|
\fBint\fR decod_format;
|
||||||
|
/* output file format: see OPJ_CODEC_FORMAT */
|
||||||
|
\fBint\fR cod_format;
|
||||||
|
|
||||||
|
/*JPWL encoding parameters */
|
||||||
|
/* enables writing of EPC in MH, thus activating JPWL */
|
||||||
|
\fBbool\fR jpwl_epc_on;
|
||||||
|
/* error protection method for MH (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_hprot_MH;
|
||||||
|
/* tile number of header protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* error protection methods for TPHs (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* tile number of packet protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* packet number of packet protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* error protection methods for packets (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* enables writing of ESD, (0=no/1/2 bytes) */
|
||||||
|
\fBint\fR jpwl_sens_size;
|
||||||
|
/* sensitivity addressing size (0=auto/2/4 bytes) */
|
||||||
|
\fBint\fR jpwl_sens_addr;
|
||||||
|
/* sensitivity range (0-3) */
|
||||||
|
\fBint\fR jpwl_sens_range;
|
||||||
|
/* sensitivity method for MH (-1=no,0-7) */
|
||||||
|
\fBint\fR jpwl_sens_MH;
|
||||||
|
/* tile number of sensitivity specification (>=0) */
|
||||||
|
\fBint\fR jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* sensitivity methods for TPHs (-1=no,0-7) */
|
||||||
|
\fBint\fR jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
|
||||||
|
|
||||||
|
/* Digital Cinema compliance: OFF-not compliant,
|
||||||
|
CINEMA2K_24, CINEMA2K_48, CINEMA4K_24 */
|
||||||
|
\fBOPJ_CINEMA_MODE\fR cp_cinema;
|
||||||
|
/* Maximum rate for each component.
|
||||||
|
If == 0, component size limitation is not considered */
|
||||||
|
\fBint\fR max_comp_size;
|
||||||
|
/* Profile name*/
|
||||||
|
\fBOPJ_RSIZ_CAPABILITIES\fR cp_rsiz;
|
||||||
|
/* Tile part generation*/
|
||||||
|
\fBchar\fR tp_on;
|
||||||
|
/* Flag for Tile part generation*/
|
||||||
|
\fBchar\fR tp_flag;
|
||||||
|
/* MCT (multiple component transform) */
|
||||||
|
\fBchar\fR tcp_mct;
|
||||||
|
.br
|
||||||
|
} opj_cparameters_t;
|
||||||
|
|
||||||
|
|
||||||
|
'\".SH OPTIONS
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBimage_to_j2k\fR(1) \fBj2k_to_image\fR(1) \fBj2k_dump\fR(1)
|
||||||
|
|
||||||
|
\fBJPWL_image_to_j2k\fR(1) \fBJPWL_j2k_to_image\fR(1)
|
||||||
|
|
||||||
|
\fBextract_j2k_from_mj2\fR(1) \fBwrap_j2k_in_mj2\fR(1)
|
||||||
|
\fBframes_to_mj2\fR(1) \fBmj2_to_frames\fR(1)
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \page openjpippage OpenJPIP v@OPENJPEG_VERSION@ Documentation
|
||||||
|
*
|
||||||
|
* \section Introduction
|
||||||
|
* This manual documents the low-level OpenJPIP C API.\n
|
||||||
|
* OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).\n
|
||||||
|
* ( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)\n
|
||||||
|
*
|
||||||
|
* This whole documents covers the following six programs.\n
|
||||||
|
* - opj_server.c JPIP server supporting HTTP connection and JPT/JPP-stream
|
||||||
|
* - opj_dec_server.c Server to decode JPT/JPP-stream and communicate locally with JPIP client, which is coded in java
|
||||||
|
* - opj_jpip_addxml.c To Embed metadata into JP2 file
|
||||||
|
* - opj_jpip_transcode.c To Convert JPT/JPP-stream to JP2 or J2K
|
||||||
|
* - opj_jpip_test.c To test index code format of a JP2 file
|
||||||
|
*
|
||||||
|
* \section License
|
||||||
|
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||||
|
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||||
|
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section reqlibs Required libraries
|
||||||
|
* - OpenJPEG library
|
||||||
|
* - FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||||
|
* - libcURL library
|
||||||
|
*
|
||||||
|
* We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section compilenotes Compiling Notes
|
||||||
|
* When you are making opj_server, set anything (e.g. yes) to the parameter jpipserver to define itself in the Makefile, which enables to make it in server mode.\n
|
||||||
|
* Otherwise do not define (or do not set to) the parameter jpipserver.\n
|
||||||
|
* Be sure that any object files and library file libopenjpip.a are not reused to compile in the two different mode (server mode and non server mode).\n
|
||||||
|
* In other words, do make clean before making new targets which are in different modes as previous make.\n
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section sysarchtect System Architecture
|
||||||
|
* JPIP protocol is implemented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n
|
||||||
|
* Figure below represents the overview of our system architecture.\n
|
||||||
|
* The JPIP server parses JPIP query and sends corresponding JPT/JPP-stream.
|
||||||
|
* The JPIP client viewer is an image viewer with GUI to publish JPIP requests and receive JPT/JPP-stream.\n
|
||||||
|
* Particularly, our system has the image decoding module implemented on a server (opj_dec_server, Image decoding Server).
|
||||||
|
* Image decoding Server and JPIP client viewer communicate closely.
|
||||||
|
* This specific architecture enables sharing cache of image codestream data among all viewers connected to the same Image decoding Server not only locally but also remotely.
|
||||||
|
*
|
||||||
|
* \image html jpip_architect.png "OpenJPIP system architecture"
|
||||||
|
*
|
||||||
|
* JPIP server follows up the client cache during a session. \n
|
||||||
|
* Concretely, the JPIP server models cache in each session, to which Channel IDs are associated.
|
||||||
|
* A Channel ID identifies a JPIP client viewer.
|
||||||
|
* And, new viewers can belong to a session by referring to one of its channel ID.
|
||||||
|
* The Image decoding Server maintains the association between channel IDs and targets, and provides a reference channel ID to a Viewer on demand.\n
|
||||||
|
*
|
||||||
|
* Typical requests and replies among JPIP server, JPIP client, and Image decoding server is presented below.\n
|
||||||
|
* The JPIP server parses HTTP query and sends corresponding JPT/JPP-stream back to the JPIP client (Viewer).
|
||||||
|
* JPT/JPP-stream is unreadable by JPIP client, and it is directly passed to Image decoding Server, and which provides the image in raw format (PGM or PPM) to the JPIP client.
|
||||||
|
* The Image decoding Server handles the decoding and caching of JPT/JPP-stream.
|
||||||
|
* JPIP client can read PGM and PPM images natively.
|
||||||
|
* Before connecting to the JPIP server, every JPIP client checks local cache data of the requesting image with the image decoding server.
|
||||||
|
* If its cache exists, the image decoding server provides ChannelID (CID), which identifies the image and its cache model on the JPIP server, and the whole system can continue the session using the CID.
|
||||||
|
*
|
||||||
|
* \image html jpip_protocol.png "Message Sequence Chart of OpenJPIP implementation"
|
||||||
|
*
|
||||||
|
* \author Kaori Hagihara UCL/SST/ICTM/ELEN
|
||||||
|
*/
|
|
@ -0,0 +1,12 @@
|
||||||
|
# required dep for server:
|
||||||
|
#if(BUILD_JPIP_SERVER)
|
||||||
|
# find_package(CURL REQUIRED)
|
||||||
|
# find_package(FCGI REQUIRED)
|
||||||
|
# find_package(Threads REQUIRED)
|
||||||
|
# if(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
# message(FATAL_ERROR "Only pthread are supported")
|
||||||
|
# endif()
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
#add_subdirectory(lib)
|
||||||
|
#add_subdirectory(bin)
|
|
@ -0,0 +1,21 @@
|
||||||
|
# source code for openjpeg apps:
|
||||||
|
add_subdirectory(common)
|
||||||
|
# Part 1 & 2:
|
||||||
|
add_subdirectory(jp2)
|
||||||
|
|
||||||
|
# optionals components:
|
||||||
|
if(BUILD_JPWL)
|
||||||
|
add_subdirectory(jpwl)
|
||||||
|
endif()
|
||||||
|
if(BUILD_MJ2)
|
||||||
|
add_subdirectory(mj2)
|
||||||
|
endif()
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
add_subdirectory(jpip)
|
||||||
|
endif()
|
||||||
|
if(BUILD_JP3D)
|
||||||
|
add_subdirectory(jp3d)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wx apps:
|
||||||
|
add_subdirectory(wx)
|
|
@ -0,0 +1,7 @@
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_apps_config.h generation
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_apps_config.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_apps_config.h
|
||||||
|
@ONLY
|
||||||
|
)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _OPJ_COLOR_H_
|
||||||
|
#define _OPJ_COLOR_H_
|
||||||
|
|
||||||
|
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||||
|
extern void color_apply_icc_profile(opj_image_t *image);
|
||||||
|
extern void color_cielab_to_rgb(opj_image_t *image);
|
||||||
|
|
||||||
|
extern void color_cmyk_to_rgb(opj_image_t *image);
|
||||||
|
extern void color_esycc_to_rgb(opj_image_t *image);
|
||||||
|
#endif /* _OPJ_COLOR_H_ */
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _OPJ_FORMAT_DEFS_H_
|
||||||
|
#define _OPJ_FORMAT_DEFS_H_
|
||||||
|
|
||||||
|
#define J2K_CFMT 0
|
||||||
|
#define JP2_CFMT 1
|
||||||
|
#define JPT_CFMT 2
|
||||||
|
|
||||||
|
#define PXM_DFMT 10
|
||||||
|
#define PGX_DFMT 11
|
||||||
|
#define BMP_DFMT 12
|
||||||
|
#define YUV_DFMT 13
|
||||||
|
#define TIF_DFMT 14
|
||||||
|
#define RAW_DFMT 15 /* MSB / Big Endian */
|
||||||
|
#define TGA_DFMT 16
|
||||||
|
#define PNG_DFMT 17
|
||||||
|
#define RAWL_DFMT 18 /* LSB / Little Endian */
|
||||||
|
|
||||||
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "opj_config_private.h"
|
||||||
|
|
||||||
|
/* create opj_apps_config.h for CMake */
|
||||||
|
|
||||||
|
#cmakedefine OPJ_HAVE_LIBPNG @HAVE_LIBPNG@
|
||||||
|
#cmakedefine OPJ_HAVE_PNG_H @HAVE_PNG_H@
|
||||||
|
#cmakedefine OPJ_HAVE_LIBTIFF @HAVE_LIBTIFF@
|
||||||
|
#cmakedefine OPJ_HAVE_TIFF_H @HAVE_TIFF_H@
|
||||||
|
|
||||||
|
#cmakedefine OPJ_HAVE_LIBLCMS1
|
||||||
|
#cmakedefine OPJ_HAVE_LIBLCMS2
|
||||||
|
#cmakedefine OPJ_HAVE_LCMS1_H
|
||||||
|
#cmakedefine OPJ_HAVE_LCMS2_H
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,277 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 3-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
|
int opj_opterr = 1, /* if error message should be printed */
|
||||||
|
opj_optind = 1, /* index into parent argv vector */
|
||||||
|
opj_optopt, /* character checked for validity */
|
||||||
|
opj_optreset; /* reset getopt */
|
||||||
|
char *opj_optarg; /* argument associated with option */
|
||||||
|
|
||||||
|
#define BADCH (int)'?'
|
||||||
|
#define BADARG (int)':'
|
||||||
|
static char EMSG[] = {""};
|
||||||
|
|
||||||
|
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||||
|
void opj_reset_options_reading(void)
|
||||||
|
{
|
||||||
|
opj_opterr = 1;
|
||||||
|
opj_optind = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int opj_getopt(int nargc, char *const *nargv, const char *ostr)
|
||||||
|
{
|
||||||
|
# define __progname nargv[0]
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
const char *oli = NULL; /* option letter list index */
|
||||||
|
|
||||||
|
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||||
|
opj_optreset = 0;
|
||||||
|
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
|
++opj_optind;
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} /* option letter okay? */
|
||||||
|
if ((opj_optopt = (int) * place++) == (int) ':' ||
|
||||||
|
!(oli = strchr(ostr, opj_optopt))) {
|
||||||
|
/*
|
||||||
|
* if the user didn't specify '-' as an option,
|
||||||
|
* assume it means -1.
|
||||||
|
*/
|
||||||
|
if (opj_optopt == (int) '-') {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (!*place) {
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
if (opj_opterr && *ostr != ':') {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*++oli != ':') { /* don't need argument */
|
||||||
|
opj_optarg = NULL;
|
||||||
|
if (!*place) {
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
} else { /* need an argument */
|
||||||
|
if (*place) { /* no white space */
|
||||||
|
opj_optarg = place;
|
||||||
|
} else if (nargc <= ++opj_optind) { /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (*ostr == ':') {
|
||||||
|
return (BADARG);
|
||||||
|
}
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: option requires an argument -- %c\n",
|
||||||
|
__progname, opj_optopt);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
} else { /* white space */
|
||||||
|
opj_optarg = nargv[opj_optind];
|
||||||
|
}
|
||||||
|
place = EMSG;
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
return (opj_optopt); /* dump back option letter */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen)
|
||||||
|
{
|
||||||
|
static int lastidx, lastofs;
|
||||||
|
const char *tmp;
|
||||||
|
int i, len;
|
||||||
|
char param = 1;
|
||||||
|
|
||||||
|
again:
|
||||||
|
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind] != '-') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv[opj_optind][0] == '-' && argv[opj_optind][1] == 0) {
|
||||||
|
if (opj_optind >= (argc - 1)) { /* no more input parameters */
|
||||||
|
param = 0;
|
||||||
|
} else { /* more input parameters */
|
||||||
|
if (argv[opj_optind + 1][0] == '-') {
|
||||||
|
param = 0; /* Missing parameter after '-' */
|
||||||
|
} else {
|
||||||
|
param = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param == 0) {
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv[opj_optind][0] == '-') { /* long option */
|
||||||
|
char* arg;
|
||||||
|
const opj_option_t* o;
|
||||||
|
o = longopts;
|
||||||
|
len = sizeof(longopts[0]);
|
||||||
|
|
||||||
|
if (param > 1) {
|
||||||
|
if (opj_optind + 1 >= argc) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
arg = argv[opj_optind + 1];
|
||||||
|
opj_optind++;
|
||||||
|
} else {
|
||||||
|
arg = argv[opj_optind] + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(arg) > 1) {
|
||||||
|
for (i = 0; i < totlen; i = i + len, o++) {
|
||||||
|
if (!strcmp(o->name, arg)) { /* match */
|
||||||
|
if (o->has_arg == 0) {
|
||||||
|
if ((argv[opj_optind + 1]) && (!(argv[opj_optind + 1][0] == '-'))) {
|
||||||
|
fprintf(stderr, "%s: option does not require an argument. Ignoring %s\n", arg,
|
||||||
|
argv[opj_optind + 1]);
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
opj_optarg = argv[opj_optind + 1];
|
||||||
|
if (opj_optarg) {
|
||||||
|
if (opj_optarg[0] ==
|
||||||
|
'-') { /* Has read next input parameter: No arg for current parameter */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr, "%s: option requires an argument\n", arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!opj_optarg && o->has_arg == 1) { /* no argument there */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr, "%s: option requires an argument \n", arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
if (o->flag) {
|
||||||
|
*(o->flag) = o->val;
|
||||||
|
} else {
|
||||||
|
return o->val;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}/*(end for)String not found in the list*/
|
||||||
|
fprintf(stderr, "Invalid option %s\n", arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
} else { /*Single character input parameter*/
|
||||||
|
if (*optstring == ':') {
|
||||||
|
return ':';
|
||||||
|
}
|
||||||
|
if (lastidx != opj_optind) {
|
||||||
|
lastidx = opj_optind;
|
||||||
|
lastofs = 0;
|
||||||
|
}
|
||||||
|
opj_optopt = argv[opj_optind][lastofs + 1];
|
||||||
|
if ((tmp = strchr(optstring, opj_optopt))) { /*Found input parameter in list*/
|
||||||
|
if (*tmp == 0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||||
|
++opj_optind;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
if (tmp[1] == ':') { /* argument expected */
|
||||||
|
if (tmp[2] == ':' ||
|
||||||
|
argv[opj_optind][lastofs + 2]) { /* "-foo", return "oo" as opj_optarg */
|
||||||
|
if (!*(opj_optarg = argv[opj_optind] + lastofs + 2)) {
|
||||||
|
opj_optarg = 0;
|
||||||
|
}
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
opj_optarg = argv[opj_optind + 1];
|
||||||
|
if (opj_optarg) {
|
||||||
|
if (opj_optarg[0] ==
|
||||||
|
'-') { /* Has read next input parameter: No arg for current parameter */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr, "%s: option requires an argument\n", arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!opj_optarg) { /* missing argument */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr, "%s: option requires an argument\n", arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
} else {/*Argument not expected*/
|
||||||
|
++lastofs;
|
||||||
|
return opj_optopt;
|
||||||
|
}
|
||||||
|
found:
|
||||||
|
++opj_optind;
|
||||||
|
return opj_optopt;
|
||||||
|
} else { /* not found */
|
||||||
|
fprintf(stderr, "Invalid option %s\n", arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}/*end of not found*/
|
||||||
|
|
||||||
|
}/* end of single character*/
|
||||||
|
}/*end '-'*/
|
||||||
|
fprintf(stderr, "Invalid option\n");
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);;
|
||||||
|
}/*end function*/
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
typedef struct opj_option {
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
} opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG 0
|
||||||
|
#define REQ_ARG 1
|
||||||
|
#define OPT_ARG 2
|
||||||
|
|
||||||
|
extern int opj_opterr;
|
||||||
|
extern int opj_optind;
|
||||||
|
extern int opj_optopt;
|
||||||
|
extern int opj_optreset;
|
||||||
|
extern char *opj_optarg;
|
||||||
|
|
||||||
|
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen);
|
||||||
|
extern void opj_reset_options_reading(void);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, Matthieu Darbois
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OPJ_STRING_H
|
||||||
|
#define OPJ_STRING_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* strnlen is not standard, strlen_s is C11... */
|
||||||
|
/* keep in mind there still is a buffer read overflow possible */
|
||||||
|
static size_t opj_strnlen_s(const char *src, size_t max_len)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (src == NULL) {
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
for (len = 0U; (*src != '\0') && (len < max_len); src++, len++);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* should be equivalent to C11 function except for the handler */
|
||||||
|
/* keep in mind there still is a buffer read overflow possible */
|
||||||
|
static int opj_strcpy_s(char* dst, size_t dst_size, const char* src)
|
||||||
|
{
|
||||||
|
size_t src_len = 0U;
|
||||||
|
if ((dst == NULL) || (dst_size == 0U)) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
if (src == NULL) {
|
||||||
|
dst[0] = '\0';
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
src_len = opj_strnlen_s(src, dst_size);
|
||||||
|
if (src_len >= dst_size) {
|
||||||
|
return ERANGE;
|
||||||
|
}
|
||||||
|
memcpy(dst, src, src_len);
|
||||||
|
dst[src_len] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* OPJ_STRING_H */
|
|
@ -0,0 +1,88 @@
|
||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
set(common_SRCS
|
||||||
|
convert.c
|
||||||
|
convert.h
|
||||||
|
convertbmp.c
|
||||||
|
index.c
|
||||||
|
index.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
|
||||||
|
)
|
||||||
|
|
||||||
|
if(OPJ_HAVE_LIBTIFF)
|
||||||
|
list(APPEND common_SRCS converttif.c)
|
||||||
|
endif()
|
||||||
|
if(OPJ_HAVE_LIBPNG)
|
||||||
|
list(APPEND common_SRCS convertpng.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DOPJ_EXPORTS)
|
||||||
|
else()
|
||||||
|
add_definitions(-DOPJ_STATIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
foreach(exe opj_decompress opj_compress opj_dump)
|
||||||
|
add_executable(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
|
||||||
|
target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
|
||||||
|
endif()
|
||||||
|
target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
|
||||||
|
)
|
||||||
|
# To support universal exe:
|
||||||
|
if(ZLIB_FOUND AND APPLE)
|
||||||
|
target_link_libraries(${exe} z)
|
||||||
|
else(ZLIB_FOUND AND APPLE)
|
||||||
|
target_link_libraries(${exe} ${Z_LIBNAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(${exe} m)
|
||||||
|
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||||
|
target_link_libraries(${exe} rt)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
# Install exe
|
||||||
|
install(TARGETS ${exe}
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
if(OPJ_USE_DSYMUTIL)
|
||||||
|
add_custom_command(TARGET ${exe} POST_BUILD
|
||||||
|
COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
|
||||||
|
COMMENT "dsymutil $<TARGET_FILE:${exe}>"
|
||||||
|
DEPENDS ${exe})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(BUILD_DOC)
|
||||||
|
# Install man pages
|
||||||
|
install(
|
||||||
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_decompress.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||||
|
#
|
||||||
|
endif()
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#ifndef __J2K_CONVERT_H
|
||||||
|
#define __J2K_CONVERT_H
|
||||||
|
|
||||||
|
/**@name RAW component encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_comp_cparameters {
|
||||||
|
/** subsampling in X direction */
|
||||||
|
int dx;
|
||||||
|
/** subsampling in Y direction */
|
||||||
|
int dy;
|
||||||
|
/*@}*/
|
||||||
|
} raw_comp_cparameters_t;
|
||||||
|
|
||||||
|
/**@name RAW image encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_cparameters {
|
||||||
|
/** width of the raw image */
|
||||||
|
int rawWidth;
|
||||||
|
/** height of the raw image */
|
||||||
|
int rawHeight;
|
||||||
|
/** number of components of the raw image */
|
||||||
|
int rawComp;
|
||||||
|
/** bit depth of the raw image */
|
||||||
|
int rawBitDepth;
|
||||||
|
/** signed/unsigned raw image */
|
||||||
|
OPJ_BOOL rawSigned;
|
||||||
|
/** raw components parameters */
|
||||||
|
raw_comp_cparameters_t *rawComps;
|
||||||
|
/*@}*/
|
||||||
|
} raw_cparameters_t;
|
||||||
|
|
||||||
|
/* Component precision clipping */
|
||||||
|
void clip_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||||
|
/* Component precision scaling */
|
||||||
|
void scale_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||||
|
|
||||||
|
/* planar / interleaved conversions */
|
||||||
|
typedef void (* convert_32s_CXPX)(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst,
|
||||||
|
OPJ_SIZE_T length);
|
||||||
|
extern const convert_32s_CXPX convert_32s_CXPX_LUT[5];
|
||||||
|
typedef void (* convert_32s_PXCX)(OPJ_INT32 const* const* pSrc, OPJ_INT32* pDst,
|
||||||
|
OPJ_SIZE_T length, OPJ_INT32 adjust);
|
||||||
|
extern const convert_32s_PXCX convert_32s_PXCX_LUT[5];
|
||||||
|
/* bit depth conversions */
|
||||||
|
typedef void (* convert_XXx32s_C1R)(const OPJ_BYTE* pSrc, OPJ_INT32* pDst,
|
||||||
|
OPJ_SIZE_T length);
|
||||||
|
extern const convert_XXx32s_C1R convert_XXu32s_C1R_LUT[9]; /* up to 8bpp */
|
||||||
|
typedef void (* convert_32sXXx_C1R)(const OPJ_INT32* pSrc, OPJ_BYTE* pDst,
|
||||||
|
OPJ_SIZE_T length);
|
||||||
|
extern const convert_32sXXx_C1R convert_32sXXu_C1R_LUT[9]; /* up to 8bpp */
|
||||||
|
|
||||||
|
|
||||||
|
/* TGA conversion */
|
||||||
|
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotga(opj_image_t * image, const char *outfile);
|
||||||
|
|
||||||
|
/* BMP conversion */
|
||||||
|
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
/* TIFF conversion*/
|
||||||
|
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotif(opj_image_t *image, const char *outfile);
|
||||||
|
/**
|
||||||
|
Load a single image component encoded in PGX file format
|
||||||
|
@param filename Name of the PGX file to load
|
||||||
|
@param parameters *List ?*
|
||||||
|
@return Returns a greyscale image if successful, returns NULL otherwise
|
||||||
|
*/
|
||||||
|
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopgx(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopnm(opj_image_t *image, const char *outfile, int force_split);
|
||||||
|
|
||||||
|
/* RAW conversion */
|
||||||
|
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||||
|
int imagetorawl(opj_image_t * image, const char *outfile);
|
||||||
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters,
|
||||||
|
raw_cparameters_t *raw_cp);
|
||||||
|
opj_image_t* rawltoimage(const char *filename, opj_cparameters_t *parameters,
|
||||||
|
raw_cparameters_t *raw_cp);
|
||||||
|
|
||||||
|
/* PNG conversion*/
|
||||||
|
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
||||||
|
extern opj_image_t* pngtoimage(const char *filename,
|
||||||
|
opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
#endif /* __J2K_CONVERT_H */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,517 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* Copyright (c) 2015, Matthieu Darbois
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#include "opj_apps_config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||||
|
#define MAGIC_SIZE 8
|
||||||
|
/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
|
||||||
|
|
||||||
|
|
||||||
|
static void convert_16u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst,
|
||||||
|
OPJ_SIZE_T length)
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T i;
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
OPJ_INT32 val0 = *pSrc++;
|
||||||
|
OPJ_INT32 val1 = *pSrc++;
|
||||||
|
pDst[i] = val0 << 8 | val1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||||
|
{
|
||||||
|
png_structp png = NULL;
|
||||||
|
png_infop info = NULL;
|
||||||
|
double gamma;
|
||||||
|
int bit_depth, interlace_type, compression_type, filter_type;
|
||||||
|
OPJ_UINT32 i;
|
||||||
|
png_uint_32 width, height = 0U;
|
||||||
|
int color_type;
|
||||||
|
FILE *reader = NULL;
|
||||||
|
OPJ_BYTE** rows = NULL;
|
||||||
|
OPJ_INT32* row32s = NULL;
|
||||||
|
/* j2k: */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
opj_image_cmptparm_t cmptparm[4];
|
||||||
|
OPJ_UINT32 nr_comp;
|
||||||
|
OPJ_BYTE sigbuf[8];
|
||||||
|
convert_XXx32s_C1R cvtXXTo32s = NULL;
|
||||||
|
convert_32s_CXPX cvtCxToPx = NULL;
|
||||||
|
OPJ_INT32* planes[4];
|
||||||
|
|
||||||
|
if ((reader = fopen(read_idf, "rb")) == NULL) {
|
||||||
|
fprintf(stderr, "pngtoimage: can not open %s\n", read_idf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|
||||||
|
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0) {
|
||||||
|
fprintf(stderr, "pngtoimage: %s is no valid PNG file\n", read_idf);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL)) == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
if ((info = png_create_info_struct(png)) == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png))) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_init_io(png, reader);
|
||||||
|
png_set_sig_bytes(png, MAGIC_SIZE);
|
||||||
|
|
||||||
|
png_read_info(png, info);
|
||||||
|
|
||||||
|
if (png_get_IHDR(png, info, &width, &height,
|
||||||
|
&bit_depth, &color_type, &interlace_type,
|
||||||
|
&compression_type, &filter_type) == 0) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* png_set_expand():
|
||||||
|
* expand paletted images to RGB, expand grayscale images of
|
||||||
|
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||||
|
* to alpha channels.
|
||||||
|
*/
|
||||||
|
if (color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||||
|
png_set_expand(png);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (png_get_valid(png, info, PNG_INFO_tRNS)) {
|
||||||
|
png_set_expand(png);
|
||||||
|
}
|
||||||
|
/* We might wan't to expand background */
|
||||||
|
/*
|
||||||
|
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
|
||||||
|
png_color_16p bgnd;
|
||||||
|
png_get_bKGD(png, info, &bgnd);
|
||||||
|
png_set_background(png, bgnd, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!png_get_gAMA(png, info, &gamma)) {
|
||||||
|
gamma = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we're not displaying but converting, screen gamma == 1.0 */
|
||||||
|
png_set_gamma(png, 1.0, gamma);
|
||||||
|
|
||||||
|
png_read_update_info(png, info);
|
||||||
|
|
||||||
|
color_type = png_get_color_type(png, info);
|
||||||
|
|
||||||
|
switch (color_type) {
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
nr_comp = 1;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
|
nr_comp = 2;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
nr_comp = 3;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
|
nr_comp = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "pngtoimage: colortype %d is not supported\n", color_type);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
cvtCxToPx = convert_32s_CXPX_LUT[nr_comp];
|
||||||
|
bit_depth = png_get_bit_depth(png, info);
|
||||||
|
|
||||||
|
switch (bit_depth) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 8:
|
||||||
|
cvtXXTo32s = convert_XXu32s_C1R_LUT[bit_depth];
|
||||||
|
break;
|
||||||
|
case 16: /* 16 bpp is specific to PNG */
|
||||||
|
cvtXXTo32s = convert_16u32s_C1R;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "pngtoimage: bit depth %d is not supported\n", bit_depth);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rows = (OPJ_BYTE**)calloc(height + 1, sizeof(OPJ_BYTE*));
|
||||||
|
if (rows == NULL) {
|
||||||
|
fprintf(stderr, "pngtoimage: memory out\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
for (i = 0; i < height; ++i) {
|
||||||
|
rows[i] = (OPJ_BYTE*)malloc(png_get_rowbytes(png, info));
|
||||||
|
if (rows[i] == NULL) {
|
||||||
|
fprintf(stderr, "pngtoimage: memory out\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
png_read_image(png, rows);
|
||||||
|
|
||||||
|
/* Create image */
|
||||||
|
memset(cmptparm, 0, sizeof(cmptparm));
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
cmptparm[i].prec = (OPJ_UINT32)bit_depth;
|
||||||
|
/* bits_per_pixel: 8 or 16 */
|
||||||
|
cmptparm[i].bpp = (OPJ_UINT32)bit_depth;
|
||||||
|
cmptparm[i].sgnd = 0;
|
||||||
|
cmptparm[i].dx = (OPJ_UINT32)params->subsampling_dx;
|
||||||
|
cmptparm[i].dy = (OPJ_UINT32)params->subsampling_dy;
|
||||||
|
cmptparm[i].w = (OPJ_UINT32)width;
|
||||||
|
cmptparm[i].h = (OPJ_UINT32)height;
|
||||||
|
}
|
||||||
|
|
||||||
|
image = opj_image_create(nr_comp, &cmptparm[0],
|
||||||
|
(nr_comp > 2U) ? OPJ_CLRSPC_SRGB : OPJ_CLRSPC_GRAY);
|
||||||
|
if (image == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
image->x0 = (OPJ_UINT32)params->image_offset_x0;
|
||||||
|
image->y0 = (OPJ_UINT32)params->image_offset_y0;
|
||||||
|
image->x1 = (OPJ_UINT32)(image->x0 + (width - 1) * (OPJ_UINT32)
|
||||||
|
params->subsampling_dx + 1 + image->x0);
|
||||||
|
image->y1 = (OPJ_UINT32)(image->y0 + (height - 1) * (OPJ_UINT32)
|
||||||
|
params->subsampling_dy + 1 + image->y0);
|
||||||
|
|
||||||
|
row32s = (OPJ_INT32 *)malloc((size_t)width * nr_comp * sizeof(OPJ_INT32));
|
||||||
|
if (row32s == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set alpha channel */
|
||||||
|
image->comps[nr_comp - 1U].alpha = 1U - (nr_comp & 1U);
|
||||||
|
|
||||||
|
for (i = 0; i < nr_comp; i++) {
|
||||||
|
planes[i] = image->comps[i].data;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < height; ++i) {
|
||||||
|
cvtXXTo32s(rows[i], row32s, (OPJ_SIZE_T)width * nr_comp);
|
||||||
|
cvtCxToPx(row32s, planes, width);
|
||||||
|
planes[0] += width;
|
||||||
|
planes[1] += width;
|
||||||
|
planes[2] += width;
|
||||||
|
planes[3] += width;
|
||||||
|
}
|
||||||
|
fin:
|
||||||
|
if (rows) {
|
||||||
|
for (i = 0; i < height; ++i)
|
||||||
|
if (rows[i]) {
|
||||||
|
free(rows[i]);
|
||||||
|
}
|
||||||
|
free(rows);
|
||||||
|
}
|
||||||
|
if (row32s) {
|
||||||
|
free(row32s);
|
||||||
|
}
|
||||||
|
if (png) {
|
||||||
|
png_destroy_read_struct(&png, &info, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(reader);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
|
||||||
|
}/* pngtoimage() */
|
||||||
|
|
||||||
|
|
||||||
|
static void convert_32s16u_C1R(const OPJ_INT32* pSrc, OPJ_BYTE* pDst,
|
||||||
|
OPJ_SIZE_T length)
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T i;
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
OPJ_UINT32 val = (OPJ_UINT32)pSrc[i];
|
||||||
|
*pDst++ = (OPJ_BYTE)(val >> 8);
|
||||||
|
*pDst++ = (OPJ_BYTE)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int imagetopng(opj_image_t * image, const char *write_idf)
|
||||||
|
{
|
||||||
|
FILE * volatile writer = NULL;
|
||||||
|
png_structp png = NULL;
|
||||||
|
png_infop info = NULL;
|
||||||
|
png_bytep volatile row_buf = NULL;
|
||||||
|
int nr_comp, color_type;
|
||||||
|
volatile int prec;
|
||||||
|
png_color_8 sig_bit;
|
||||||
|
OPJ_INT32 const* planes[4];
|
||||||
|
int i;
|
||||||
|
OPJ_INT32* volatile buffer32s = NULL;
|
||||||
|
|
||||||
|
volatile int fails = 1;
|
||||||
|
|
||||||
|
memset(&sig_bit, 0, sizeof(sig_bit));
|
||||||
|
prec = (int)image->comps[0].prec;
|
||||||
|
planes[0] = image->comps[0].data;
|
||||||
|
nr_comp = (int)image->numcomps;
|
||||||
|
|
||||||
|
if (nr_comp > 4) {
|
||||||
|
nr_comp = 4;
|
||||||
|
}
|
||||||
|
for (i = 1; i < nr_comp; ++i) {
|
||||||
|
if (image->comps[0].dx != image->comps[i].dx) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].dy != image->comps[i].dy) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].prec != image->comps[i].prec) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
planes[i] = image->comps[i].data;
|
||||||
|
}
|
||||||
|
if (i != nr_comp) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"imagetopng: All components shall have the same subsampling, same bit depth, same sign.\n");
|
||||||
|
fprintf(stderr, "\tAborting\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||||
|
}
|
||||||
|
if (prec > 8 && prec < 16) {
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), 16);
|
||||||
|
}
|
||||||
|
prec = 16;
|
||||||
|
} else if (prec < 8 && nr_comp > 1) { /* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), 8);
|
||||||
|
}
|
||||||
|
prec = 8;
|
||||||
|
} else if ((prec > 1) && (prec < 8) && ((prec == 6) ||
|
||||||
|
((prec & 1) == 1))) { /* GRAY with non native precision */
|
||||||
|
if ((prec == 5) || (prec == 6)) {
|
||||||
|
prec = 8;
|
||||||
|
} else {
|
||||||
|
prec++;
|
||||||
|
}
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), (OPJ_UINT32)prec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16) {
|
||||||
|
fprintf(stderr, "imagetopng: can not create %s\n\twrong bit_depth %d\n",
|
||||||
|
write_idf, prec);
|
||||||
|
return fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
writer = fopen(write_idf, "wb");
|
||||||
|
|
||||||
|
if (writer == NULL) {
|
||||||
|
return fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create and initialize the png_struct with the desired error handler
|
||||||
|
* functions. If you want to use the default stderr and longjump method,
|
||||||
|
* you can supply NULL for the last three parameters. We also check that
|
||||||
|
* the library version is compatible with the one used at compile time,
|
||||||
|
* in case we are using dynamically linked libraries. REQUIRED.
|
||||||
|
*/
|
||||||
|
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
|
||||||
|
|
||||||
|
if (png == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate/initialize the image information data. REQUIRED
|
||||||
|
*/
|
||||||
|
info = png_create_info_struct(png);
|
||||||
|
|
||||||
|
if (info == NULL) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set error handling. REQUIRED if you are not supplying your own
|
||||||
|
* error handling functions in the png_create_write_struct() call.
|
||||||
|
*/
|
||||||
|
if (setjmp(png_jmpbuf(png))) {
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* I/O initialization functions is REQUIRED
|
||||||
|
*/
|
||||||
|
png_init_io(png, writer);
|
||||||
|
|
||||||
|
/* Set the image information here. Width and height are up to 2^31,
|
||||||
|
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||||
|
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||||
|
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||||
|
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||||
|
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||||
|
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||||
|
* REQUIRED
|
||||||
|
*
|
||||||
|
* ERRORS:
|
||||||
|
*
|
||||||
|
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
|
if (nr_comp >= 3) { /* RGB(A) */
|
||||||
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
|
||||||
|
} else { /* GRAY(A) */
|
||||||
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
sig_bit.gray = (png_byte)prec;
|
||||||
|
}
|
||||||
|
if ((nr_comp & 1) == 0) { /* ALPHA */
|
||||||
|
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||||
|
sig_bit.alpha = (png_byte)prec;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_set_IHDR(png, info, image->comps[0].w, image->comps[0].h, prec, color_type,
|
||||||
|
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
|
png_set_sBIT(png, info, &sig_bit);
|
||||||
|
/* png_set_gamma(png, 2.2, 1./2.2); */
|
||||||
|
/* png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); */
|
||||||
|
png_write_info(png, info);
|
||||||
|
|
||||||
|
/* setup conversion */
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T rowStride;
|
||||||
|
png_size_t png_row_size;
|
||||||
|
|
||||||
|
png_row_size = png_get_rowbytes(png, info);
|
||||||
|
rowStride = ((OPJ_SIZE_T)image->comps[0].w * (OPJ_SIZE_T)nr_comp *
|
||||||
|
(OPJ_SIZE_T)prec + 7U) / 8U;
|
||||||
|
if (rowStride != (OPJ_SIZE_T)png_row_size) {
|
||||||
|
fprintf(stderr, "Invalid PNG row size\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
row_buf = (png_bytep)malloc(png_row_size);
|
||||||
|
if (row_buf == NULL) {
|
||||||
|
fprintf(stderr, "Can't allocate memory for PNG row\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
buffer32s = (OPJ_INT32*)malloc((OPJ_SIZE_T)image->comps[0].w *
|
||||||
|
(OPJ_SIZE_T)nr_comp * sizeof(OPJ_INT32));
|
||||||
|
if (buffer32s == NULL) {
|
||||||
|
fprintf(stderr, "Can't allocate memory for interleaved 32s row\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert */
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T width = image->comps[0].w;
|
||||||
|
OPJ_UINT32 y;
|
||||||
|
convert_32s_PXCX cvtPxToCx = convert_32s_PXCX_LUT[nr_comp];
|
||||||
|
convert_32sXXx_C1R cvt32sToPack = NULL;
|
||||||
|
OPJ_INT32 adjust = image->comps[0].sgnd ? 1 << (prec - 1) : 0;
|
||||||
|
png_bytep row_buf_cpy = row_buf;
|
||||||
|
OPJ_INT32* buffer32s_cpy = buffer32s;
|
||||||
|
|
||||||
|
switch (prec) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 8:
|
||||||
|
cvt32sToPack = convert_32sXXu_C1R_LUT[prec];
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
cvt32sToPack = convert_32s16u_C1R;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* never here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = 0; y < image->comps[0].h; ++y) {
|
||||||
|
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
|
||||||
|
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (OPJ_SIZE_T)nr_comp);
|
||||||
|
png_write_row(png, row_buf_cpy);
|
||||||
|
planes[0] += width;
|
||||||
|
planes[1] += width;
|
||||||
|
planes[2] += width;
|
||||||
|
planes[3] += width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_write_end(png, info);
|
||||||
|
|
||||||
|
fails = 0;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
if (png) {
|
||||||
|
png_destroy_write_struct(&png, &info);
|
||||||
|
}
|
||||||
|
if (row_buf) {
|
||||||
|
free(row_buf);
|
||||||
|
}
|
||||||
|
if (buffer32s) {
|
||||||
|
free(buffer32s);
|
||||||
|
}
|
||||||
|
fclose(writer);
|
||||||
|
|
||||||
|
if (fails) {
|
||||||
|
(void)remove(write_idf); /* ignore return value */
|
||||||
|
}
|
||||||
|
|
||||||
|
return fails;
|
||||||
|
}/* imagetopng() */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,456 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "index.h"
|
||||||
|
#include "opj_inttypes.h"
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a structured index to a file
|
||||||
|
@param cstr_info Codestream information
|
||||||
|
@param index Index filename
|
||||||
|
@return Returns 0 if successful, returns 1 otherwise
|
||||||
|
*/
|
||||||
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
|
||||||
|
{
|
||||||
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
|
FILE *stream = NULL;
|
||||||
|
double total_disto = 0;
|
||||||
|
/* UniPG>> */
|
||||||
|
int tilepartno;
|
||||||
|
char disto_on, numpix_on;
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
|
if (!cstr_info) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream = fopen(index, "w");
|
||||||
|
if (!stream) {
|
||||||
|
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].distotile > 0.0) {
|
||||||
|
disto_on = 1;
|
||||||
|
} else {
|
||||||
|
disto_on = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].numpix) {
|
||||||
|
numpix_on = 1;
|
||||||
|
} else {
|
||||||
|
numpix_on = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->prog);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||||
|
|
||||||
|
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||||
|
fprintf(stream, "[%d,%d] ",
|
||||||
|
(1 << cstr_info->tile[0].pdx[resno]),
|
||||||
|
(1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||||
|
|
||||||
|
fprintf(stream, "\nINFO ON TILES\n");
|
||||||
|
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
if (numpix_on) {
|
||||||
|
fprintf(stream, " nbpix");
|
||||||
|
}
|
||||||
|
if (disto_on && numpix_on) {
|
||||||
|
fprintf(stream, " disto/nbpix");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||||
|
cstr_info->tile[tileno].tileno,
|
||||||
|
cstr_info->tile[tileno].start_pos,
|
||||||
|
cstr_info->tile[tileno].end_header,
|
||||||
|
cstr_info->tile[tileno].end_pos,
|
||||||
|
cstr_info->tile[tileno].num_tps);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %9e", cstr_info->tile[tileno].distotile);
|
||||||
|
}
|
||||||
|
if (numpix_on) {
|
||||||
|
fprintf(stream, " %9d", cstr_info->tile[tileno].numpix);
|
||||||
|
}
|
||||||
|
if (disto_on && numpix_on) {
|
||||||
|
fprintf(stream, " %9e", cstr_info->tile[tileno].distotile /
|
||||||
|
cstr_info->tile[tileno].numpix);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
OPJ_OFF_T start_pos, end_ph_pos, end_pos;
|
||||||
|
double disto = 0;
|
||||||
|
int max_numdecompos = 0;
|
||||||
|
pack_nb = 0;
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
if (max_numdecompos < cstr_info->numdecompos[compno]) {
|
||||||
|
max_numdecompos = cstr_info->numdecompos[compno];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||||
|
fprintf(stream,
|
||||||
|
"part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||||
|
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||||
|
tilepartno, tileno,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cstr_info->prog == OPJ_LRCP) { /* LRCP */
|
||||||
|
fprintf(stream,
|
||||||
|
"LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6" PRId64 " %6" PRId64 " %7"
|
||||||
|
PRId64,
|
||||||
|
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* LRCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == OPJ_RLCP) { /* RLCP */
|
||||||
|
fprintf(stream,
|
||||||
|
"RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||||
|
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* RLCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == OPJ_RPCL) { /* RPCL */
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < numprec; precno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||||
|
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* resno */
|
||||||
|
} /* RPCL */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == OPJ_PCRL) { /* PCRL */
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec) {
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (precno >= numprec) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||||
|
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* compno */
|
||||||
|
} /* precno */
|
||||||
|
} /* PCRL */
|
||||||
|
|
||||||
|
else { /* CPRL */
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec) {
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (precno >= numprec) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||||
|
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* CPRL */
|
||||||
|
} /* tileno */
|
||||||
|
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||||
|
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||||
|
}
|
||||||
|
/* UniPG>> */
|
||||||
|
/* print the markers' list */
|
||||||
|
if (cstr_info->marknum) {
|
||||||
|
fprintf(stream, "\nMARKER LIST\n");
|
||||||
|
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||||
|
fprintf(stream, "type\tstart_pos length\n");
|
||||||
|
for (x = 0; x < cstr_info->marknum; x++) {
|
||||||
|
fprintf(stream, "%X\t%9" PRId64 " %9d\n", cstr_info->marker[x].type,
|
||||||
|
cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* <<UniPG */
|
||||||
|
fclose(stream);
|
||||||
|
|
||||||
|
fprintf(stderr, "Generated index file %s\n", index);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __J2K_INDEX_H
|
||||||
|
#define __J2K_INDEX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a structured index to a file
|
||||||
|
@param cstr_info Codestream information
|
||||||
|
@param index Index filename
|
||||||
|
@return Returns 0 if successful, returns 1 otherwise
|
||||||
|
*/
|
||||||
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __J2K_INDEX_H */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,642 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||||
|
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||||
|
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#include "opj_config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "windirent.h"
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <strings.h>
|
||||||
|
#define _stricmp strcasecmp
|
||||||
|
#define _strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#include "format_defs.h"
|
||||||
|
#include "opj_string.h"
|
||||||
|
|
||||||
|
typedef struct dircnt {
|
||||||
|
/** Buffer for holding images read from Directory*/
|
||||||
|
char *filename_buf;
|
||||||
|
/** Pointer to the buffer*/
|
||||||
|
char **filename;
|
||||||
|
} dircnt_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct img_folder {
|
||||||
|
/** The directory path of the folder containing input images*/
|
||||||
|
char *imgdirpath;
|
||||||
|
/** Output format*/
|
||||||
|
const char *out_format;
|
||||||
|
/** Enable option*/
|
||||||
|
char set_imgdir;
|
||||||
|
/** Enable Cod Format for output*/
|
||||||
|
char set_out_format;
|
||||||
|
|
||||||
|
int flag;
|
||||||
|
} img_fol_t;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* Declarations */
|
||||||
|
static int get_num_images(char *imgdirpath);
|
||||||
|
static int load_images(dircnt_t *dirptr, char *imgdirpath);
|
||||||
|
static int get_file_format(const char *filename);
|
||||||
|
static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
|
||||||
|
opj_dparameters_t *parameters);
|
||||||
|
static int infile_format(const char *fname);
|
||||||
|
|
||||||
|
static int parse_cmdline_decoder(int argc, char **argv,
|
||||||
|
opj_dparameters_t *parameters, img_fol_t *img_fol);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static void decode_help_display(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "\nThis is the opj_dump utility from the OpenJPEG project.\n"
|
||||||
|
"It dumps JPEG 2000 codestream info to stdout or a given file.\n"
|
||||||
|
"It has been compiled against openjp2 library v%s.\n\n", opj_version());
|
||||||
|
|
||||||
|
fprintf(stdout, "Parameters:\n");
|
||||||
|
fprintf(stdout, "-----------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " -ImgDir <directory>\n");
|
||||||
|
fprintf(stdout, " Image file Directory path \n");
|
||||||
|
fprintf(stdout, " -i <compressed file>\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" REQUIRED only if an Input image directory not specified\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||||
|
fprintf(stdout, " is identified based on its suffix.\n");
|
||||||
|
fprintf(stdout, " -o <output file>\n");
|
||||||
|
fprintf(stdout, " OPTIONAL\n");
|
||||||
|
fprintf(stdout, " Output file where file info will be dump.\n");
|
||||||
|
fprintf(stdout, " By default it will be in the stdout.\n");
|
||||||
|
fprintf(stdout, " -v "); /* FIXME WIP_MSD */
|
||||||
|
fprintf(stdout, " OPTIONAL\n");
|
||||||
|
fprintf(stdout, " Enable informative messages\n");
|
||||||
|
fprintf(stdout, " By default verbose mode is off.\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int get_num_images(char *imgdirpath)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int num_images = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir = opendir(imgdirpath);
|
||||||
|
if (!dir) {
|
||||||
|
fprintf(stderr, "Could not open Folder %s\n", imgdirpath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((content = readdir(dir)) != NULL) {
|
||||||
|
if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
num_images++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return num_images;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int load_images(dircnt_t *dirptr, char *imgdirpath)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir = opendir(imgdirpath);
|
||||||
|
if (!dir) {
|
||||||
|
fprintf(stderr, "Could not open Folder %s\n", imgdirpath);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Folder opened successfully\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((content = readdir(dir)) != NULL) {
|
||||||
|
if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(dirptr->filename[i], content->d_name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int get_file_format(const char *filename)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||||
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||||
|
const char *ext = strrchr(filename, '.');
|
||||||
|
if (ext == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ext++;
|
||||||
|
if (ext) {
|
||||||
|
for (i = 0; i < sizeof(format) / sizeof(*format); i++) {
|
||||||
|
if (_strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
|
||||||
|
opj_dparameters_t *parameters)
|
||||||
|
{
|
||||||
|
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],
|
||||||
|
outfilename[OPJ_PATH_LEN], temp_ofname[OPJ_PATH_LEN];
|
||||||
|
char *temp_p, temp1[OPJ_PATH_LEN] = "";
|
||||||
|
|
||||||
|
strcpy(image_filename, dirptr->filename[imageno]);
|
||||||
|
fprintf(stderr, "File Number %d \"%s\"\n", imageno, image_filename);
|
||||||
|
parameters->decod_format = get_file_format(image_filename);
|
||||||
|
if (parameters->decod_format == -1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sprintf(infilename, "%s/%s", img_fol->imgdirpath, image_filename);
|
||||||
|
if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile),
|
||||||
|
infilename) != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Set output file*/
|
||||||
|
strcpy(temp_ofname, strtok(image_filename, "."));
|
||||||
|
while ((temp_p = strtok(NULL, ".")) != NULL) {
|
||||||
|
strcat(temp_ofname, temp1);
|
||||||
|
sprintf(temp1, ".%s", temp_p);
|
||||||
|
}
|
||||||
|
if (img_fol->set_out_format == 1) {
|
||||||
|
sprintf(outfilename, "%s/%s.%s", img_fol->imgdirpath, temp_ofname,
|
||||||
|
img_fol->out_format);
|
||||||
|
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile),
|
||||||
|
outfilename) != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
#define JP2_RFC3745_MAGIC "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"
|
||||||
|
#define JP2_MAGIC "\x0d\x0a\x87\x0a"
|
||||||
|
/* position 45: "\xff\x52" */
|
||||||
|
#define J2K_CODESTREAM_MAGIC "\xff\x4f\xff\x51"
|
||||||
|
|
||||||
|
static int infile_format(const char *fname)
|
||||||
|
{
|
||||||
|
FILE *reader;
|
||||||
|
const char *s, *magic_s;
|
||||||
|
int ext_format, magic_format;
|
||||||
|
unsigned char buf[12];
|
||||||
|
size_t l_nb_read;
|
||||||
|
|
||||||
|
reader = fopen(fname, "rb");
|
||||||
|
|
||||||
|
if (reader == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(buf, 0, 12);
|
||||||
|
l_nb_read = fread(buf, 1, 12, reader);
|
||||||
|
fclose(reader);
|
||||||
|
if (l_nb_read != 12) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ext_format = get_file_format(fname);
|
||||||
|
|
||||||
|
if (ext_format == JPT_CFMT) {
|
||||||
|
return JPT_CFMT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
|
||||||
|
magic_format = JP2_CFMT;
|
||||||
|
magic_s = ".jp2";
|
||||||
|
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
|
||||||
|
magic_format = J2K_CFMT;
|
||||||
|
magic_s = ".j2k or .jpc or .j2c";
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (magic_format == ext_format) {
|
||||||
|
return ext_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = fname + strlen(fname) - 4;
|
||||||
|
|
||||||
|
fputs("\n===========================================\n", stderr);
|
||||||
|
fprintf(stderr, "The extension of this file is incorrect.\n"
|
||||||
|
"FOUND %s. SHOULD BE %s\n", s, magic_s);
|
||||||
|
fputs("===========================================\n", stderr);
|
||||||
|
|
||||||
|
return magic_format;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* Parse the command line
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int parse_cmdline_decoder(int argc, char **argv,
|
||||||
|
opj_dparameters_t *parameters, img_fol_t *img_fol)
|
||||||
|
{
|
||||||
|
int totlen, c;
|
||||||
|
opj_option_t long_option[] = {
|
||||||
|
{"ImgDir", REQ_ARG, NULL, 'y'}
|
||||||
|
};
|
||||||
|
const char optlist[] = "i:o:f:hv";
|
||||||
|
|
||||||
|
totlen = sizeof(long_option);
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
do {
|
||||||
|
c = opj_getopt_long(argc, argv, optlist, long_option, totlen);
|
||||||
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (c) {
|
||||||
|
case 'i': { /* input file */
|
||||||
|
char *infile = opj_optarg;
|
||||||
|
parameters->decod_format = infile_format(infile);
|
||||||
|
switch (parameters->decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
break;
|
||||||
|
case JP2_CFMT:
|
||||||
|
break;
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"[ERROR] Unknown input file format: %s \n"
|
||||||
|
" Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infile) != 0) {
|
||||||
|
fprintf(stderr, "[ERROR] Path is too long\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'o': { /* output file */
|
||||||
|
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile),
|
||||||
|
opj_optarg) != 0) {
|
||||||
|
fprintf(stderr, "[ERROR] Path is too long\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'f': /* flag */
|
||||||
|
img_fol->flag = atoi(opj_optarg);
|
||||||
|
break;
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': /* display an help description */
|
||||||
|
decode_help_display();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'y': { /* Image Directory path */
|
||||||
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
if (img_fol->imgdirpath == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strcpy(img_fol->imgdirpath, opj_optarg);
|
||||||
|
img_fol->set_imgdir = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'v': { /* Verbose mode */
|
||||||
|
parameters->m_verbose = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "[WARNING] An invalid option has been ignored.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (c != -1);
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
if (img_fol->set_imgdir == 1) {
|
||||||
|
if (!(parameters->infile[0] == 0)) {
|
||||||
|
fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (img_fol->set_out_format == 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used.\n");
|
||||||
|
fprintf(stderr, "Only one format allowed.\n"
|
||||||
|
"Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!(parameters->outfile[0] == 0)) {
|
||||||
|
fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (parameters->infile[0] == 0) {
|
||||||
|
fprintf(stderr, "[ERROR] Required parameter is missing\n");
|
||||||
|
fprintf(stderr, "Example: %s -i image.j2k\n", argv[0]);
|
||||||
|
fprintf(stderr, " Help: %s -h\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
static void error_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
static void warning_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
static void info_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* OPJ_DUMP MAIN
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
FILE *fout = NULL;
|
||||||
|
|
||||||
|
opj_dparameters_t parameters; /* Decompression parameters */
|
||||||
|
opj_image_t* image = NULL; /* Image structure */
|
||||||
|
opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
|
||||||
|
opj_stream_t *l_stream = NULL; /* Stream */
|
||||||
|
opj_codestream_info_v2_t* cstr_info = NULL;
|
||||||
|
opj_codestream_index_t* cstr_index = NULL;
|
||||||
|
|
||||||
|
OPJ_INT32 num_images, imageno;
|
||||||
|
img_fol_t img_fol;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
|
||||||
|
/* Set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* Initialize img_fol */
|
||||||
|
memset(&img_fol, 0, sizeof(img_fol_t));
|
||||||
|
img_fol.flag = OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND;
|
||||||
|
|
||||||
|
/* Parse input and get user encoding parameters */
|
||||||
|
if (parse_cmdline_decoder(argc, argv, ¶meters, &img_fol) == 1) {
|
||||||
|
if (img_fol.imgdirpath) {
|
||||||
|
free(img_fol.imgdirpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if (img_fol.set_imgdir == 1) {
|
||||||
|
int it_image;
|
||||||
|
num_images = get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if (!dirptr) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
dirptr->filename_buf = (char*)malloc((size_t)num_images * OPJ_PATH_LEN * sizeof(
|
||||||
|
char)); /* Stores at max 10 image file names*/
|
||||||
|
if (!dirptr->filename_buf) {
|
||||||
|
free(dirptr);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
dirptr->filename = (char**) malloc((size_t)num_images * sizeof(char*));
|
||||||
|
|
||||||
|
if (!dirptr->filename) {
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (it_image = 0; it_image < num_images; it_image++) {
|
||||||
|
dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_images == 0) {
|
||||||
|
fprintf(stdout, "Folder is empty\n");
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
num_images = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to open for writing the output file if necessary */
|
||||||
|
if (parameters.outfile[0] != 0) {
|
||||||
|
fout = fopen(parameters.outfile, "w");
|
||||||
|
if (!fout) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fout = stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the header of each image one by one */
|
||||||
|
for (imageno = 0; imageno < num_images ; imageno++) {
|
||||||
|
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
if (img_fol.set_imgdir == 1) {
|
||||||
|
if (get_next_file(imageno, dirptr, &img_fol, ¶meters)) {
|
||||||
|
fprintf(stderr, "skipping file...\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the input file and put it in memory */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
|
||||||
|
l_stream = opj_stream_create_default_file_stream(parameters.infile, 1);
|
||||||
|
if (!l_stream) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",
|
||||||
|
parameters.infile);
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the JPEG2000 stream */
|
||||||
|
/* ------------------------ */
|
||||||
|
|
||||||
|
switch (parameters.decod_format) {
|
||||||
|
case J2K_CFMT: { /* JPEG-2000 codestream */
|
||||||
|
/* Get a decoder handle */
|
||||||
|
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JP2_CFMT: { /* JPEG 2000 compressed image data */
|
||||||
|
/* Get a decoder handle */
|
||||||
|
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JPT_CFMT: { /* JPEG 2000, JPIP */
|
||||||
|
/* Get a decoder handle */
|
||||||
|
l_codec = opj_create_decompress(OPJ_CODEC_JPT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_info_handler(l_codec, info_callback, 00);
|
||||||
|
opj_set_warning_handler(l_codec, warning_callback, 00);
|
||||||
|
opj_set_error_handler(l_codec, error_callback, 00);
|
||||||
|
|
||||||
|
parameters.flags |= OPJ_DPARAMETERS_DUMP_FLAG;
|
||||||
|
|
||||||
|
/* Setup the decoder decoding parameters using user parameters */
|
||||||
|
if (!opj_setup_decoder(l_codec, ¶meters)) {
|
||||||
|
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
fclose(fout);
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||||
|
if (! opj_read_header(l_stream, l_codec, &image)) {
|
||||||
|
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
fclose(fout);
|
||||||
|
goto fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_dump_codec(l_codec, img_fol.flag, fout);
|
||||||
|
|
||||||
|
cstr_info = opj_get_cstr_info(l_codec);
|
||||||
|
|
||||||
|
cstr_index = opj_get_cstr_index(l_codec);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if (l_codec) {
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* destroy the image header */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
/* destroy the codestream index */
|
||||||
|
opj_destroy_cstr_index(&cstr_index);
|
||||||
|
|
||||||
|
/* destroy the codestream info */
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the output file */
|
||||||
|
fclose(fout);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
if (dirptr) {
|
||||||
|
if (dirptr->filename) {
|
||||||
|
free(dirptr->filename);
|
||||||
|
}
|
||||||
|
if (dirptr->filename_buf) {
|
||||||
|
free(dirptr->filename_buf);
|
||||||
|
}
|
||||||
|
free(dirptr);
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
|
@ -0,0 +1,683 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* uce-dirent.h - operating system independent dirent implementation
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998-2002 Toni Ronkko
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* ``Software''), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* May 28 1998, Toni Ronkko <tronkko@messi.uku.fi>
|
||||||
|
*
|
||||||
|
* $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
|
||||||
|
*
|
||||||
|
* $Log: uce-dirent.h,v $
|
||||||
|
* Revision 1.7 2002/05/13 10:48:35 tr
|
||||||
|
* embedded some source code directly to the header so that no source
|
||||||
|
* modules need to be included in the MS Visual C project using the
|
||||||
|
* interface, removed all the dependencies to other headers of the `uce'
|
||||||
|
* library so that the header can be made public
|
||||||
|
*
|
||||||
|
* Revision 1.6 2002/04/12 16:22:04 tr
|
||||||
|
* Unified Compiling Environment (UCE) replaced `std' library
|
||||||
|
*
|
||||||
|
* Revision 1.5 2001/07/20 16:33:40 tr
|
||||||
|
* moved to `std' library and re-named defines accordingly
|
||||||
|
*
|
||||||
|
* Revision 1.4 2001/07/10 16:47:18 tronkko
|
||||||
|
* revised comments
|
||||||
|
*
|
||||||
|
* Revision 1.3 2001/01/11 13:16:43 tr
|
||||||
|
* using ``uce-machine.h'' for finding out defines such as `FREEBSD'
|
||||||
|
*
|
||||||
|
* Revision 1.2 2000/10/08 16:00:41 tr
|
||||||
|
* copy of FreeBSD man page
|
||||||
|
*
|
||||||
|
* Revision 1.1 2000/07/10 05:53:16 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
* Revision 1.2 1998/07/19 18:29:14 tr
|
||||||
|
* Added error reporting capabilities and some asserts.
|
||||||
|
*
|
||||||
|
* Revision 1.1 1998/07/04 16:27:51 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MSVC 1.0 scans automatic dependencies incorrectly when your project
|
||||||
|
* contains this very header. The problem is that MSVC cannot handle
|
||||||
|
* include directives inside #if..#endif block those are never entered.
|
||||||
|
* Since this header ought to compile in many different operating systems,
|
||||||
|
* there had to be several conditional blocks that are compiled only in
|
||||||
|
* operating systems for what they were designed for. MSVC 1.0 cannot
|
||||||
|
* handle inclusion of sys/dir.h in a part that is compiled only in Apollo
|
||||||
|
* operating system. To fix the problem you need to insert DIR.H into
|
||||||
|
* SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
|
||||||
|
* Consult manuals for more informaton about the problem.
|
||||||
|
*
|
||||||
|
* Since many UNIX systems have dirent.h we assume to have one also.
|
||||||
|
* However, if your UNIX system does not have dirent.h you can download one
|
||||||
|
* for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
|
||||||
|
* You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
|
||||||
|
* sys/dir.h and sys/ndir.h somewhere. Try defining HAVE_DIRENT_H,
|
||||||
|
* HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
|
||||||
|
* HAVE_SYS_NDIR_H according to the files found.
|
||||||
|
*/
|
||||||
|
#ifndef DIRENT_H
|
||||||
|
#define DIRENT_H
|
||||||
|
#define DIRENT_H_INCLUDED
|
||||||
|
|
||||||
|
/* find out platform */
|
||||||
|
#if defined(MSDOS) /* MS-DOS */
|
||||||
|
#elif defined(__MSDOS__) /* Turbo C/Borland */
|
||||||
|
# define MSDOS
|
||||||
|
#elif defined(__DOS__) /* Watcom */
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) /* MS-Windows */
|
||||||
|
#elif defined(__NT__) /* Watcom */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(_WIN32) /* Microsoft */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(__WIN32__) /* Borland */
|
||||||
|
# define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See what kind of dirent interface we have unless autoconf has already
|
||||||
|
* determinated that.
|
||||||
|
*/
|
||||||
|
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||||
|
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__MINGW32__) /* MinGW */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# define VOID_CLOSEDIR
|
||||||
|
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||||
|
# define HAVE_DIRECT_H
|
||||||
|
# elif defined(__apollo) /* Apollo */
|
||||||
|
# define HAVE_SYS_DIR_H
|
||||||
|
# elif defined(__hpux) /* HP-UX */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif (defined(__alpha) || defined(__alpha__)) && !defined(__linux__) /* Alpha OSF1 */
|
||||||
|
# error "not implemented"
|
||||||
|
# elif defined(__sgi) /* Silicon Graphics */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(sun) || defined(__sun) /* Sun Solaris */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__FreeBSD__) /* FreeBSD */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__linux__) /* Linux */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__GNUC__) /* GNU C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# else
|
||||||
|
# error "not implemented"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* include proper interface headers */
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
|
# include <dirent.h>
|
||||||
|
# ifdef FREEBSD
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
# else
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(HAVE_NDIR_H)
|
||||||
|
# include <ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_NDIR_H)
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIRECT_H)
|
||||||
|
# include <direct.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIR_H)
|
||||||
|
# include <dir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_DIR_H)
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# ifndef dirent
|
||||||
|
# define dirent direct
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(MSDOS) || defined(WIN32)
|
||||||
|
|
||||||
|
/* figure out type of underlaying directory interface to be used */
|
||||||
|
# if defined(WIN32)
|
||||||
|
# define DIRENT_WIN32_INTERFACE
|
||||||
|
# elif defined(MSDOS)
|
||||||
|
# define DIRENT_MSDOS_INTERFACE
|
||||||
|
# else
|
||||||
|
# error "missing native dirent interface"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** WIN32 specifics ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
# include <windows.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (MAX_PATH)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*** MS-DOS specifics ***/
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# include <dos.h>
|
||||||
|
|
||||||
|
/* Borland defines file length macros in dir.h */
|
||||||
|
# if defined(__BORLANDC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# if !defined(_find_t)
|
||||||
|
# define _find_t find_t
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Turbo C defines ffblk structure in dir.h */
|
||||||
|
# elif defined(__TURBOC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# define DIRENT_USE_FFBLK
|
||||||
|
|
||||||
|
/* MSVC */
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Watcom */
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# if defined(__OS2__) || defined(__NT__)
|
||||||
|
# define DIRENT_MAXNAMLEN (255)
|
||||||
|
# else
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||||
|
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||||
|
# endif
|
||||||
|
# if NAME_MAX < DIRENT_MAXNAMLEN
|
||||||
|
# error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||||
|
* true character array although we have it copied in the implementation
|
||||||
|
* dependent data. We could save some memory if we had declared `d_name'
|
||||||
|
* as a pointer referring the name within implementation dependent data.
|
||||||
|
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||||
|
* something other than four. Besides, directory entries are typically so
|
||||||
|
* small that it takes virtually no time to copy them from place to place.
|
||||||
|
*/
|
||||||
|
typedef struct dirent {
|
||||||
|
char d_name[NAME_MAX + 1];
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE) /*WIN32*/
|
||||||
|
WIN32_FIND_DATA data;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE) /*MSDOS*/
|
||||||
|
# if defined(DIRENT_USE_FFBLK)
|
||||||
|
struct ffblk data;
|
||||||
|
# else
|
||||||
|
struct _find_t data;
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
} dirent;
|
||||||
|
|
||||||
|
/* DIR substitute structure containing directory name. The name is
|
||||||
|
* essential for the operation of ``rewinndir'' function. */
|
||||||
|
typedef struct DIR {
|
||||||
|
char *dirname; /* directory being scanned */
|
||||||
|
dirent current; /* current entry */
|
||||||
|
int dirent_filled; /* is current un-processed? */
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
HANDLE search_handle;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# endif
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* supply prototypes for dirent functions */
|
||||||
|
static DIR *opendir(const char *dirname);
|
||||||
|
static struct dirent *readdir(DIR *dirp);
|
||||||
|
static int closedir(DIR *dirp);
|
||||||
|
#ifdef unused
|
||||||
|
static void rewinddir(DIR *dirp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implement dirent interface as static functions so that the user does not
|
||||||
|
* need to change his project in any way to use dirent function. With this
|
||||||
|
* it is sufficient to include this very header from source modules using
|
||||||
|
* dirent functions and the functions will be pulled in automatically.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* use ffblk instead of _find_t if requested */
|
||||||
|
#if defined(DIRENT_USE_FFBLK)
|
||||||
|
# define _A_ARCH (FA_ARCH)
|
||||||
|
# define _A_HIDDEN (FA_HIDDEN)
|
||||||
|
# define _A_NORMAL (0)
|
||||||
|
# define _A_RDONLY (FA_RDONLY)
|
||||||
|
# define _A_SUBDIR (FA_DIREC)
|
||||||
|
# define _A_SYSTEM (FA_SYSTEM)
|
||||||
|
# define _A_VOLID (FA_LABEL)
|
||||||
|
# define _dos_findnext(dest) findnext(dest)
|
||||||
|
# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int _initdir(DIR *p);
|
||||||
|
static const char *_getdirname(const struct dirent *dp);
|
||||||
|
static void _setdirname(struct DIR *dirp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="opendir">
|
||||||
|
* <intro>open directory stream for reading
|
||||||
|
* <syntax>DIR *opendir (const char *dirname);
|
||||||
|
*
|
||||||
|
* <desc>Open named directory stream for read and return pointer to the
|
||||||
|
* internal working area that is used for retrieving individual directory
|
||||||
|
* entries. The internal working area has no fields of your interest.
|
||||||
|
*
|
||||||
|
* <ret>Returns a pointer to the internal working area or NULL in case the
|
||||||
|
* directory stream could not be opened. Global `errno' variable will set
|
||||||
|
* in case of error as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EACESS |Permission denied.
|
||||||
|
* [EMFILE |Too many open files used by the process.
|
||||||
|
* [ENFILE |Too many open files in system.
|
||||||
|
* [ENOENT |Directory does not exist.
|
||||||
|
* [ENOMEM |Insufficient memory.
|
||||||
|
* [ENOTDIR |dirname does not refer to directory. This value is not
|
||||||
|
* reliable on MS-DOS and MS-Windows platforms. Many
|
||||||
|
* implementations return ENOENT even when the name refers to a
|
||||||
|
* file.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static DIR *opendir(const char *dirname)
|
||||||
|
{
|
||||||
|
DIR *dirp;
|
||||||
|
assert(dirname != NULL);
|
||||||
|
|
||||||
|
dirp = (DIR*)malloc(sizeof(struct DIR));
|
||||||
|
if (dirp != NULL) {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
/* allocate room for directory name */
|
||||||
|
dirp->dirname = (char*) malloc(strlen(dirname) + 1 + strlen("\\*.*"));
|
||||||
|
if (dirp->dirname == NULL) {
|
||||||
|
/* failed to duplicate directory name. errno set by malloc() */
|
||||||
|
free(dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Copy directory name while appending directory separator and "*.*".
|
||||||
|
* Directory separator is not appended if the name already ends with
|
||||||
|
* drive or directory separator. Directory separator is assumed to be
|
||||||
|
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||||
|
strcpy(dirp->dirname, dirname);
|
||||||
|
p = strchr(dirp->dirname, '\0');
|
||||||
|
if (dirp->dirname < p &&
|
||||||
|
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
||||||
|
strcpy(p++, "\\");
|
||||||
|
}
|
||||||
|
# ifdef DIRENT_WIN32_INTERFACE
|
||||||
|
strcpy(p, "*"); /*scan files with and without extension in win32*/
|
||||||
|
# else
|
||||||
|
strcpy(p, "*.*"); /*scan files with and without extension in DOS*/
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* open stream */
|
||||||
|
if (_initdir(dirp) == 0) {
|
||||||
|
/* initialization failed */
|
||||||
|
free(dirp->dirname);
|
||||||
|
free(dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="readdir">
|
||||||
|
* <intro>read a directory entry
|
||||||
|
* <syntax>struct dirent *readdir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Read individual directory entry and return pointer to a structure
|
||||||
|
* containing the name of the entry. Individual directory entries returned
|
||||||
|
* include normal files, sub-directories, pseudo-directories "." and ".."
|
||||||
|
* and also volume labels, hidden files and system files in MS-DOS and
|
||||||
|
* MS-Windows. You might want to use stat(2) function to determinate which
|
||||||
|
* one are you dealing with. Many dirent implementations already contain
|
||||||
|
* equivalent information in dirent structure but you cannot depend on
|
||||||
|
* this.
|
||||||
|
*
|
||||||
|
* The dirent structure contains several system dependent fields that
|
||||||
|
* generally have no interest to you. The only interesting one is char
|
||||||
|
* d_name[] that is also portable across different systems. The d_name
|
||||||
|
* field contains the name of the directory entry without leading path.
|
||||||
|
* While d_name is portable across different systems the actual storage
|
||||||
|
* capacity of d_name varies from system to system and there is no portable
|
||||||
|
* way to find out it at compile time as different systems define the
|
||||||
|
* capacity of d_name with different macros and some systems do not define
|
||||||
|
* capacity at all (besides actual declaration of the field). If you really
|
||||||
|
* need to find out storage capacity of d_name then you might want to try
|
||||||
|
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard although
|
||||||
|
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||||
|
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||||
|
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||||
|
* Decamps (Alain.Decamps@advalvas.be) for pointing it out to me.
|
||||||
|
*
|
||||||
|
* This all leads to the fact that it is difficult to allocate space
|
||||||
|
* for the directory names when the very same program is being compiled on
|
||||||
|
* number of operating systems. Therefore I suggest that you always
|
||||||
|
* allocate space for directory names dynamically.
|
||||||
|
*
|
||||||
|
* <ret>
|
||||||
|
* Returns a pointer to a structure containing name of the directory entry
|
||||||
|
* in `d_name' field or NULL if there was an error. In case of an error the
|
||||||
|
* global `errno' variable will set as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EBADF |dir parameter refers to an invalid directory stream. This value
|
||||||
|
* is not set reliably on all implementations.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static struct dirent *
|
||||||
|
readdir(DIR *dirp)
|
||||||
|
{
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dirp->dirent_filled != 0) {
|
||||||
|
/*
|
||||||
|
* Directory entry has already been retrieved and there is no need to
|
||||||
|
* retrieve a new one. Directory entry will be retrieved in advance
|
||||||
|
* when the user calls readdir function for the first time. This is so
|
||||||
|
* because real dirent has separate functions for opening and reading
|
||||||
|
* the stream whereas Win32 and DOS dirents open the stream
|
||||||
|
* automatically when we retrieve the first file. Therefore, we have to
|
||||||
|
* save the first file when opening the stream and later we have to
|
||||||
|
* return the saved entry when the user tries to read the first entry.
|
||||||
|
*/
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
} else {
|
||||||
|
/* fill in entry and return that */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (FindNextFile(dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||||
|
/* Last file has been processed or an error occurred */
|
||||||
|
FindClose(dirp->search_handle);
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
errno = ENOENT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findnext(&dirp->current.data) != 0) {
|
||||||
|
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
_setdirname(dirp);
|
||||||
|
assert(dirp->dirent_filled == 0);
|
||||||
|
}
|
||||||
|
return &dirp->current;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="closedir">
|
||||||
|
* <intro>close directory stream.
|
||||||
|
* <syntax>int closedir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Close directory stream opened by the `opendir' function. Close of
|
||||||
|
* directory stream invalidates the DIR structure as well as previously read
|
||||||
|
* dirent entry.
|
||||||
|
*
|
||||||
|
* <ret>The function typically returns 0 on success and -1 on failure but
|
||||||
|
* the function may be declared to return void on same systems. At least
|
||||||
|
* Borland C/C++ and some UNIX implementations use void as a return type.
|
||||||
|
* The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
|
||||||
|
* known to return nothing. The very same definition is made by the GNU
|
||||||
|
* autoconf if you happen to use it.
|
||||||
|
*
|
||||||
|
* The global `errno' variable will set to EBADF in case of error.
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
closedir(DIR *dirp)
|
||||||
|
{
|
||||||
|
int retcode = 0;
|
||||||
|
|
||||||
|
/* make sure that dirp points to legal structure */
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free directory name and search handles */
|
||||||
|
if (dirp->dirname != NULL) {
|
||||||
|
free(dirp->dirname);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose(dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
retcode = -1;
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||||
|
memset(dirp, 0, sizeof(*dirp));
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
free(dirp);
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef unused
|
||||||
|
/*
|
||||||
|
* <function name="rewinddir">
|
||||||
|
* <intro>rewind directory stream to the beginning
|
||||||
|
* <syntax>void rewinddir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Rewind directory stream to the beginning so that the next call of
|
||||||
|
* readdir() returns the very first directory entry again. However, note
|
||||||
|
* that next call of readdir() may not return the same directory entry as it
|
||||||
|
* did in first time. The directory stream may have been affected by newly
|
||||||
|
* created files.
|
||||||
|
*
|
||||||
|
* Almost every dirent implementation ensure that rewinddir will update
|
||||||
|
* the directory stream to reflect any changes made to the directory entries
|
||||||
|
* since the previous ``opendir'' or ``rewinddir'' call. Keep an eye on
|
||||||
|
* this if your program depends on the feature. I know at least one dirent
|
||||||
|
* implementation where you are required to close and re-open the stream to
|
||||||
|
* see the changes.
|
||||||
|
*
|
||||||
|
* <ret>Returns nothing. If something went wrong while rewinding, you will
|
||||||
|
* notice it later when you try to retrieve the first directory entry.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
rewinddir(DIR *dirp)
|
||||||
|
{
|
||||||
|
/* make sure that dirp is legal */
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assert(dirp->dirname != NULL);
|
||||||
|
|
||||||
|
/* close previous stream */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose(dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* re-open previous stream */
|
||||||
|
if (_initdir(dirp) == 0) {
|
||||||
|
/* initialization failed but we cannot deal with error. User will notice
|
||||||
|
* error later when she tries to retrieve first directory enty. */
|
||||||
|
/*EMPTY*/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open native directory stream object and retrieve first file.
|
||||||
|
* Be sure to close previous stream before opening new one.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
_initdir(DIR *dirp)
|
||||||
|
{
|
||||||
|
assert(dirp != NULL);
|
||||||
|
assert(dirp->dirname != NULL);
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
/* Open stream and retrieve first file */
|
||||||
|
dirp->search_handle = FindFirstFile(dirp->dirname, &dirp->current.data);
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* something went wrong but we don't know what. GetLastError() could
|
||||||
|
* give us more information about the error, but then we should map
|
||||||
|
* the error code into errno. */
|
||||||
|
errno = ENOENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findfirst(dirp->dirname,
|
||||||
|
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||||
|
&dirp->current.data) != 0) {
|
||||||
|
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* initialize DIR and it's first entry */
|
||||||
|
_setdirname(dirp);
|
||||||
|
dirp->dirent_filled = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return implementation dependent name of the current directory entry.
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
_getdirname(const struct dirent *dp)
|
||||||
|
{
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
return dp->data.cFileName;
|
||||||
|
|
||||||
|
#elif defined(DIRENT_USE_FFBLK)
|
||||||
|
return dp->data.ff_name;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return dp->data.name;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy name of implementation dependent directory entry to the d_name field.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_setdirname(struct DIR *dirp)
|
||||||
|
{
|
||||||
|
/* make sure that d_name is long enough */
|
||||||
|
assert(strlen(_getdirname(&dirp->current)) <= NAME_MAX);
|
||||||
|
|
||||||
|
strncpy(dirp->current.d_name,
|
||||||
|
_getdirname(&dirp->current),
|
||||||
|
NAME_MAX);
|
||||||
|
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
|
||||||
|
#else
|
||||||
|
# error "missing dirent interface"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*DIRENT_H*/
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
set(common_SRCS
|
||||||
|
convert.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp3d
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DOPJ_EXPORTS)
|
||||||
|
else()
|
||||||
|
add_definitions(-DOPJ_STATIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
foreach(exe opj_jp3d_compress opj_jp3d_decompress)
|
||||||
|
add_executable(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
target_link_libraries(${exe} openjp3d)
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(${exe} m)
|
||||||
|
endif(UNIX)
|
||||||
|
# Install exe
|
||||||
|
install(TARGETS ${exe}
|
||||||
|
EXPORT OpenJP3DTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
endforeach()
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||||
|
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#ifndef __JP3D_CONVERT_H
|
||||||
|
#define __JP3D_CONVERT_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
Load a single volume component encoded in PGX file format
|
||||||
|
@param filename Name of the PGX file to load
|
||||||
|
@param parameters *List ?*
|
||||||
|
@return Returns a greyscale volume if successful, returns NULL otherwise
|
||||||
|
*/
|
||||||
|
opj_volume_t* pgxtovolume(char *filename, opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
int volumetopgx(opj_volume_t *volume, char *outfile);
|
||||||
|
|
||||||
|
opj_volume_t* bintovolume(char *filename, char *fileimg,
|
||||||
|
opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
int volumetobin(opj_volume_t *volume, char *outfile);
|
||||||
|
|
||||||
|
opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
#endif /* __J2K_CONVERT_H */
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int opterr = 1, /* if error message should be printed */
|
||||||
|
optind = 1, /* index into parent argv vector */
|
||||||
|
optopt, /* character checked for validity */
|
||||||
|
optreset; /* reset getopt */
|
||||||
|
char *optarg; /* argument associated with option */
|
||||||
|
|
||||||
|
#define BADCH (int)'?'
|
||||||
|
#define BADARG (int)':'
|
||||||
|
#define EMSG ""
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int getopt(int nargc, char *const *nargv, const char *ostr)
|
||||||
|
{
|
||||||
|
|
||||||
|
# define __progname nargv[0] /* program name */
|
||||||
|
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
|
if (optreset || !*place) { /* update scanning pointer */
|
||||||
|
optreset = 0;
|
||||||
|
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
|
++optind;
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} /* option letter okay? */
|
||||||
|
|
||||||
|
if ((optopt = (int) * place++) == (int) ':' || !(oli = strchr(ostr, optopt))) {
|
||||||
|
/* if the user didn't specify '-' as an option, assume it means -1. */
|
||||||
|
if (optopt == (int) '-') {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (!*place) {
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
if (opterr && *ostr != ':') {
|
||||||
|
(void) fprintf(stdout, "[ERROR] %s: illegal option -- %c\n", __progname,
|
||||||
|
optopt);
|
||||||
|
}
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*++oli != ':') { /* don't need argument */
|
||||||
|
optarg = NULL;
|
||||||
|
if (!*place) {
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
} else { /* need an argument */
|
||||||
|
if (*place) { /* no white space */
|
||||||
|
optarg = place;
|
||||||
|
} else if (nargc <= ++optind) { /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (*ostr == ':') {
|
||||||
|
return (BADARG);
|
||||||
|
}
|
||||||
|
if (opterr) {
|
||||||
|
(void) fprintf(stdout, "[ERROR] %s: option requires an argument -- %c\n",
|
||||||
|
__progname, optopt);
|
||||||
|
}
|
||||||
|
return (BADCH);
|
||||||
|
} else { /* white space */
|
||||||
|
optarg = nargv[optind];
|
||||||
|
}
|
||||||
|
place = EMSG;
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
return (optopt); /* dump back option letter */
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
extern int opterr;
|
||||||
|
extern int optind;
|
||||||
|
extern int optopt;
|
||||||
|
extern int optreset;
|
||||||
|
extern char *optarg;
|
||||||
|
|
||||||
|
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
|
@ -0,0 +1,989 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||||
|
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjp3d.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void encode_help_display()
|
||||||
|
{
|
||||||
|
fprintf(stdout, "List of parameters for the JPEG2000 Part 10 encoder:\n");
|
||||||
|
fprintf(stdout, "------------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "Required Parameters (except with -h):\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-i : source file (-i source.bin or source*.pgx) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-m : source characteristics file (-m imgfile.img) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-o : destination file (-o dest.jp3d) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "Optional Parameters:\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-h : display the help information \n ");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-n : number of resolutions (-n 3,3,3) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-I : use the irreversible transforms: ICT + DWT 9-7 (-I) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-C : coding algorithm (-C 2EB) [2EB, 3EB] \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
|
||||||
|
fprintf(stdout,
|
||||||
|
" - The rate specified for each quality level is the desired compression factor.\n");
|
||||||
|
fprintf(stdout, " - Rate 1 means lossless compression\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" (options -r and -q cannot be used together)\n ");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-q : different psnr for successive layers (-q 30,40,50) \n ");
|
||||||
|
fprintf(stdout,
|
||||||
|
" (options -r and -q cannot be used together)\n ");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-b : size of code block (-b 32,32,32) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-c : size of precinct (-c 128,128,128) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-t : size of tile (-t 512,512,512) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-s : subsampling factor (-s 2,2,2) [-s X,Y,Z] \n");
|
||||||
|
fprintf(stdout, " - Remark: subsampling bigger than 2 can produce error\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-SOP : write SOP marker before each packet \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-EPH : write EPH marker after each header packet \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-M : code-block style (-M 0) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
|
||||||
|
fprintf(stdout, " 8=VSC 16=PTERM 32=SEGSYM 64=3DCTXT] \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Indicate multiple modes by adding their values. \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "-D : define DC offset (-D 12) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
||||||
|
fprintf(stdout, " for component c=%%d [%%d = 0,1,2]\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-d : offset of the origin of the volume (-d 150,300,100) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"-l : offset of the origin of the tiles (-l 100,75,25) \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "DEFAULT CODING:\n");
|
||||||
|
fprintf(stdout, "------------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " * Lossless\n");
|
||||||
|
fprintf(stdout, " * 1 tile\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" * Size of precinct : 2^15 x 2^15 x 2^15 (means 1 precinct)\n");
|
||||||
|
fprintf(stdout, " * Size of code-block : 64 x 64 x 64\n");
|
||||||
|
fprintf(stdout, " * Number of resolutions in x, y and z axis: 3\n");
|
||||||
|
fprintf(stdout, " * No SOP marker in the codestream\n");
|
||||||
|
fprintf(stdout, " * No EPH marker in the codestream\n");
|
||||||
|
fprintf(stdout, " * No sub-sampling in x, y or z direction\n");
|
||||||
|
fprintf(stdout, " * No mode switch activated\n");
|
||||||
|
fprintf(stdout, " * Progression order: LRCP\n");
|
||||||
|
fprintf(stdout, " * No index file\n");
|
||||||
|
fprintf(stdout, " * No ROI upshifted\n");
|
||||||
|
fprintf(stdout, " * No offset of the origin of the volume\n");
|
||||||
|
fprintf(stdout, " * No offset of the origin of the tiles\n");
|
||||||
|
fprintf(stdout, " * Reversible DWT 5-3 on each 2D slice\n");
|
||||||
|
fprintf(stdout, " * Coding algorithm: 2D-EBCOT \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "REMARKS:\n");
|
||||||
|
fprintf(stdout, "---------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"- The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"- COD and QCD markers will never appear in the tile_header.\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"- You need enough disk space memory (twice the original) to encode \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"the volume,i.e. for a 1.5 GB volume you need a minimum of 3GB of disk memory)\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"- When loading *.pgx files, a relative path to directory is needed for input argument \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" followed by the common prefix of the slices and a '*' character representing sequential numeration.\n");
|
||||||
|
fprintf(stdout, "( -i relativepath/slices*.pgx )\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " - The index file has the structure below:\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "\t Image_height Image_width Image_depth\n");
|
||||||
|
fprintf(stdout, "\t Progression order: 0 (LRCP)\n");
|
||||||
|
fprintf(stdout, "\t Tiles_size_X Tiles_size_Y Tiles_size_Z\n");
|
||||||
|
fprintf(stdout, "\t Components_nb\n");
|
||||||
|
fprintf(stdout, "\t Layers_nb\n");
|
||||||
|
fprintf(stdout, "\t Decomposition_levels\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t [Precincts_size_X_res_Nr Precincts_size_Y_res_Nr Precincts_size_Z_res_Nr]\n\t ...\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t [Precincts_size_X_res_0 Precincts_size_Y_res_0 Precincts_size_Z_res_0]\n");
|
||||||
|
fprintf(stdout, "\t Main_header_end_position\n");
|
||||||
|
fprintf(stdout, "\t Codestream_size\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t Tile_0 [start_pos end_header end_pos TotalDisto NumPix MaxMSE]\n");
|
||||||
|
fprintf(stdout, "\t ...\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t Tile_Nt [ '' '' '' '' '' '' ]\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t Tpacket_0 [Tile layer res. comp. prec. start_pos end_pos disto]\n");
|
||||||
|
fprintf(stdout, "\t ...\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
"\t Tpacket_Np ['' '' '' '' '' '' '' '' ]\n");
|
||||||
|
fprintf(stdout, "\t MaxDisto\n");
|
||||||
|
fprintf(stdout, "\t TotalDisto\n\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OPJ_PROG_ORDER give_progression(char progression[4])
|
||||||
|
{
|
||||||
|
if (strncmp(progression, "LRCP", 4) == 0) {
|
||||||
|
return LRCP;
|
||||||
|
}
|
||||||
|
if (strncmp(progression, "RLCP", 4) == 0) {
|
||||||
|
return RLCP;
|
||||||
|
}
|
||||||
|
if (strncmp(progression, "RPCL", 4) == 0) {
|
||||||
|
return RPCL;
|
||||||
|
}
|
||||||
|
if (strncmp(progression, "PCRL", 4) == 0) {
|
||||||
|
return PCRL;
|
||||||
|
}
|
||||||
|
if (strncmp(progression, "CPRL", 4) == 0) {
|
||||||
|
return CPRL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PROG_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPJ_TRANSFORM give_transform(char transform[4])
|
||||||
|
{
|
||||||
|
if (strncmp(transform, "2DWT", 4) == 0) {
|
||||||
|
return TRF_2D_DWT;
|
||||||
|
}
|
||||||
|
if (strncmp(transform, "3DWT", 4) == 0) {
|
||||||
|
return TRF_3D_DWT;
|
||||||
|
}
|
||||||
|
return TRF_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPJ_ENTROPY_CODING give_coding(char coding[3])
|
||||||
|
{
|
||||||
|
|
||||||
|
if (strncmp(coding, "2EB", 3) == 0) {
|
||||||
|
return ENCOD_2EB;
|
||||||
|
}
|
||||||
|
if (strncmp(coding, "3EB", 3) == 0) {
|
||||||
|
return ENCOD_3EB;
|
||||||
|
}
|
||||||
|
/*if(strncmp(coding, "2GR", 3) == 0) {
|
||||||
|
return ENCOD_2GR;
|
||||||
|
}
|
||||||
|
if(strncmp(coding, "3GR", 3) == 0) {
|
||||||
|
return ENCOD_3GR;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return ENCOD_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_file_format(char *filename)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
static const char *extension[] = {"pgx", "bin", "img", "j3d", "jp3d", "j2k"};
|
||||||
|
static const int format[] = { PGX_DFMT, BIN_DFMT, IMG_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT};
|
||||||
|
char * ext = strrchr(filename, '.');
|
||||||
|
if (ext) {
|
||||||
|
ext++;
|
||||||
|
for (i = 0; i < sizeof(format) / sizeof(*format); i++) {
|
||||||
|
if (strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
{
|
||||||
|
int i, value;
|
||||||
|
|
||||||
|
/* parse the command line */
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int c = opj_getopt(argc, argv,
|
||||||
|
"i:m:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:D:R:l:T:C:A:I");
|
||||||
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (c) {
|
||||||
|
case 'i': { /* input file */
|
||||||
|
char *infile = opj_optarg;
|
||||||
|
parameters->decod_format = get_file_format(infile);
|
||||||
|
switch (parameters->decod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
case BIN_DFMT:
|
||||||
|
case IMG_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized format for infile : %s [accept only *.pgx or *.bin] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'm': { /* input IMG file */
|
||||||
|
char *imgfile = opj_optarg;
|
||||||
|
int imgformat = get_file_format(imgfile);
|
||||||
|
switch (imgformat) {
|
||||||
|
case IMG_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n",
|
||||||
|
imgfile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile,
|
||||||
|
imgformat);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'o': { /* output file */
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
parameters->cod_format = get_file_format(outfile);
|
||||||
|
switch (parameters->cod_format) {
|
||||||
|
case J3D_CFMT:
|
||||||
|
case J2K_CFMT:
|
||||||
|
case LSE_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unknown output format volume %s [only *.j2k, *.lse3d or *.jp3d]!! \n",
|
||||||
|
outfile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'r': { /* define compression rates for each layer */
|
||||||
|
char *s = opj_optarg;
|
||||||
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) ==
|
||||||
|
1) {
|
||||||
|
parameters->tcp_numlayers++;
|
||||||
|
while (*s && *s != ',') {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
if (!*s) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
parameters->cp_disto_alloc = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'q': { /* define distorsion (PSNR) for each layer */
|
||||||
|
char *s = opj_optarg;
|
||||||
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers])
|
||||||
|
== 1) {
|
||||||
|
parameters->tcp_numlayers++;
|
||||||
|
while (*s && *s != ',') {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
if (!*s) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
parameters->cp_fixed_quality = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'f': {
|
||||||
|
fprintf(stdout, "/---------------------------------------------------\\\n");
|
||||||
|
fprintf(stdout, "| Fixed layer allocation option not implemented !! |\n");
|
||||||
|
fprintf(stdout, "\\---------------------------------------------------/\n");
|
||||||
|
/*int *row = NULL, *col = NULL;
|
||||||
|
int numlayers = 0, matrix_width = 0;
|
||||||
|
|
||||||
|
char *s = opj_optarg;
|
||||||
|
sscanf(s, "%d", &numlayers);
|
||||||
|
s++;
|
||||||
|
if (numlayers > 9)
|
||||||
|
s++;
|
||||||
|
|
||||||
|
parameters->tcp_numlayers = numlayers;
|
||||||
|
matrix_width = parameters->numresolution[0] + parameters->numresolution[1] + parameters->numresolution[2];
|
||||||
|
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||||
|
s = s + 2;
|
||||||
|
|
||||||
|
for (i = 0; i < numlayers; i++) {
|
||||||
|
row = ¶meters->cp_matrice[i * matrix_width];
|
||||||
|
col = row;
|
||||||
|
parameters->tcp_rates[i] = 1;
|
||||||
|
sscanf(s, "%d,", &col[0]);
|
||||||
|
s += 2;
|
||||||
|
if (col[0] > 9)
|
||||||
|
s++;
|
||||||
|
col[1] = 0;
|
||||||
|
col[2] = 0;
|
||||||
|
for (j = 1; j < matrix_width; j++) {
|
||||||
|
col += 3; j+=2;
|
||||||
|
sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
|
||||||
|
s += 6;
|
||||||
|
if (col[0] > 9)
|
||||||
|
s++;
|
||||||
|
if (col[1] > 9)
|
||||||
|
s++;
|
||||||
|
if (col[2] > 9)
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
if (i < numlayers - 1)
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
parameters->cp_fixed_alloc = 1; */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 't': { /* tiles */
|
||||||
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy,
|
||||||
|
¶meters->cp_tdz) != 3) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] '-t' 'dimensions of tiles' argument error ! [-t tdx,tdy,tdz]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->tile_size_on = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'n': { /* resolution */
|
||||||
|
int aux;
|
||||||
|
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->numresolution[0],
|
||||||
|
¶meters->numresolution[1], ¶meters->numresolution[2]);
|
||||||
|
if (aux == 2) {
|
||||||
|
parameters->numresolution[2] = 1;
|
||||||
|
} else if (aux == 1) {
|
||||||
|
parameters->numresolution[1] = parameters->numresolution[0];
|
||||||
|
parameters->numresolution[2] = 1;
|
||||||
|
} else if (aux == 0) {
|
||||||
|
parameters->numresolution[0] = 1;
|
||||||
|
parameters->numresolution[1] = 1;
|
||||||
|
parameters->numresolution[2] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'c': { /* precinct dimension */
|
||||||
|
char sep;
|
||||||
|
int res_spec = 0;
|
||||||
|
int aux;
|
||||||
|
char *s = opj_optarg;
|
||||||
|
do {
|
||||||
|
sep = 0;
|
||||||
|
aux = sscanf(s, "[%d,%d,%d]%c", ¶meters->prct_init[0][res_spec],
|
||||||
|
¶meters->prct_init[1][res_spec], ¶meters->prct_init[2][res_spec], &sep);
|
||||||
|
if (sep == ',' && aux != 4) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] '-c' 'dimensions of precincts' argument error ! [-c [prcx_res0,prcy_res0,prcz_res0],...,[prcx_resN,prcy_resN,prcz_resN]]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->csty |= 0x01;
|
||||||
|
res_spec++;
|
||||||
|
s = strpbrk(s, "]") + 2;
|
||||||
|
} while (sep == ',');
|
||||||
|
parameters->res_spec = res_spec; /* number of precinct size specifications */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'b': { /* code-block dimension */
|
||||||
|
int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
|
||||||
|
if (sscanf(opj_optarg, "%d,%d,%d", &cblockw_init, &cblockh_init,
|
||||||
|
&cblockl_init) != 3) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] '-b' 'dimensions of codeblocks' argument error ! [-b cblkx,cblky,cblkz]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (cblockw_init * cblockh_init * cblockl_init > (1 << 18) ||
|
||||||
|
cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 ||
|
||||||
|
cblockh_init < 4 || cblockl_init > 1024 || cblockl_init < 4) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Size of code_block error (option -b) !!\n\nRestriction :\n * width*height*length<=4096\n * 4<=width,height,length<= 1024\n\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->cblock_init[0] = cblockw_init;
|
||||||
|
parameters->cblock_init[1] = cblockh_init;
|
||||||
|
parameters->cblock_init[2] = cblockl_init;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'x': { /* creation of index file */
|
||||||
|
char *index = opj_optarg;
|
||||||
|
strncpy(parameters->index, index, MAX_PATH);
|
||||||
|
parameters->index_on = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'p': { /* progression order */
|
||||||
|
char progression[4];
|
||||||
|
|
||||||
|
strncpy(progression, opj_optarg, 4);
|
||||||
|
parameters->prog_order = give_progression(progression);
|
||||||
|
if (parameters->prog_order == -1) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 's': { /* subsampling factor */
|
||||||
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->subsampling_dx,
|
||||||
|
¶meters->subsampling_dy, ¶meters->subsampling_dz) != 3) {
|
||||||
|
fprintf(stdout, "[ERROR] '-s' sub-sampling argument error ! [-s dx,dy,dz]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'd': { /* coordonnate of the reference grid */
|
||||||
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->volume_offset_x0,
|
||||||
|
¶meters->volume_offset_y0, ¶meters->volume_offset_z0) != 3) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': { /* display an help description */
|
||||||
|
encode_help_display();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'P': { /* POC */
|
||||||
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
|
char *s = opj_optarg;
|
||||||
|
POC = parameters->POC;
|
||||||
|
|
||||||
|
fprintf(stdout, "/----------------------------------\\\n");
|
||||||
|
fprintf(stdout, "| POC option not fully tested !! |\n");
|
||||||
|
fprintf(stdout, "\\----------------------------------/\n");
|
||||||
|
|
||||||
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%s", &POC[numpocs].tile,
|
||||||
|
&POC[numpocs].resno0, &POC[numpocs].compno0,
|
||||||
|
&POC[numpocs].layno1, &POC[numpocs].resno1,
|
||||||
|
&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
|
||||||
|
POC[numpocs].prg = give_progression(POC[numpocs].progorder);
|
||||||
|
/* POC[numpocs].tile; */
|
||||||
|
numpocs++;
|
||||||
|
while (*s && *s != '/') {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
if (!*s) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
parameters->numpocs = numpocs;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'S': { /* SOP marker */
|
||||||
|
parameters->csty |= 0x02;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'E': { /* EPH marker */
|
||||||
|
parameters->csty |= 0x04;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'M': { /* Codification mode switch */
|
||||||
|
fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
|
||||||
|
value = 0;
|
||||||
|
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||||
|
for (i = 0; i <= 6; i++) {
|
||||||
|
int cache = value & (1 << i);
|
||||||
|
if (cache) {
|
||||||
|
parameters->mode |= (1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'D': { /* DCO */
|
||||||
|
if (sscanf(opj_optarg, "%d", ¶meters->dcoffset) != 1) {
|
||||||
|
fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n", parameters->dcoffset);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'R': { /* ROI */
|
||||||
|
if (sscanf(opj_optarg, "OI:c=%d,U=%d", ¶meters->roi_compno,
|
||||||
|
¶meters->roi_shift) != 2) {
|
||||||
|
fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'l': { /* Tile offset */
|
||||||
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0,
|
||||||
|
¶meters->cp_tz0) != 3) {
|
||||||
|
fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------
|
||||||
|
|
||||||
|
case 'T': // Transformation of original data (2D-DWT/3D-DWT/3D-RLS/2D-DWT+1D-RLS)
|
||||||
|
{
|
||||||
|
char transform[4];
|
||||||
|
|
||||||
|
strncpy(transform, opj_optarg, 4);
|
||||||
|
parameters->transform_format = give_transform(transform);
|
||||||
|
if (parameters->transform_format == -1) {
|
||||||
|
fprintf(stdout, "[ERROR] -T 'Transform domain' argument error !! [-T 2DWT, 3DWT, 3RLS or 3LSE only]");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'C': { /* Coding of transformed data */
|
||||||
|
char coding[3];
|
||||||
|
|
||||||
|
strncpy(coding, opj_optarg, 3);
|
||||||
|
parameters->encoding_format = give_coding(coding);
|
||||||
|
if (parameters->encoding_format == -1) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -C 'Coding algorithm' argument error !! [-C 2EB, 3EB, 2GR, 3GR or GRI only]");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'I': { /* reversible or not */
|
||||||
|
parameters->irreversible = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stdout, "[ERROR] This option is not valid \"-%c %s\"\n", c, opj_optarg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
|
||||||
|
if ((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||||
|
fprintf(stdout, "usage: jp3d_vm_enc -i volume-file -o jp3d-file (+ options)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->decod_format == BIN_DFMT) && (parameters->imgfile[0] == 0)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"usage: jp3d_vm_enc -i bin-volume-file -m img-file -o jp3d-file (+ options)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->decod_format != BIN_DFMT) &&
|
||||||
|
(parameters->decod_format != PGX_DFMT) &&
|
||||||
|
(parameters->decod_format != IMG_DFMT)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ((parameters->cod_format != J3D_CFMT) &&
|
||||||
|
(parameters->cod_format != J2K_CFMT)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->encoding_format == ENCOD_2GR ||
|
||||||
|
parameters->encoding_format == ENCOD_3GR) &&
|
||||||
|
parameters->transform_format != TRF_3D_LSE &&
|
||||||
|
parameters->transform_format != TRF_3D_RLS) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Entropy coding options -C [2GR,3GR] are only compatible with predictive-based transform algorithms: -T [3RLS,3LSE].\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parameters->encoding_format == ENCOD_3EB) {
|
||||||
|
parameters->mode |= (1 << 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->mode >> 6) & 1) {
|
||||||
|
parameters->encoding_format = ENCOD_3EB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->numresolution[2] == 0 || (parameters->numresolution[1] == 0) ||
|
||||||
|
(parameters->numresolution[0] == 0))) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -n 'resolution levels' argument error ! Resolutions must be greater than 1 in order to perform DWT.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parameters->numresolution[1] != parameters->numresolution[0]) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -n 'resolution levels' argument error ! Resolutions in X and Y axis must be the same in this implementation.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters->numresolution[2] > parameters->numresolution[0]) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -n 'resolution levels' argument error ! Resolutions in Z axis must be lower than in X-Y axis.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters->dcoffset >= 128 && parameters->dcoffset <= -128) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] -D 'DC offset' argument error ! Value must be -128<=DCO<=128.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters->numresolution[2] != 1) {
|
||||||
|
parameters->transform_format = TRF_3D_DWT;
|
||||||
|
/*fprintf(stdout, "[Warning] Resolution level in axial dim > 1 : 3D-DWT will be performed... \n");*/
|
||||||
|
} else if (parameters->numresolution[2] == 1) {
|
||||||
|
parameters->transform_format = TRF_2D_DWT;
|
||||||
|
/*fprintf(stdout, "[Warning] Resolution level in axial dim == 1 : 2D-DWT will be performed... \n");*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->cod_format == J2K_CFMT) &&
|
||||||
|
(parameters->transform_format != TRF_2D_DWT ||
|
||||||
|
parameters->encoding_format != ENCOD_2EB)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[WARNING] Incompatible options -o *.j2k and defined transform or encoding algorithm. Latter will be ignored\n");
|
||||||
|
parameters->transform_format = TRF_2D_DWT;
|
||||||
|
parameters->encoding_format = ENCOD_2EB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc ||
|
||||||
|
parameters->cp_fixed_quality) &&
|
||||||
|
(!(parameters->cp_disto_alloc ^ parameters->cp_fixed_quality))) {
|
||||||
|
fprintf(stdout, "[ERROR] Options -r and -q cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
} /* mod fixed_quality */
|
||||||
|
|
||||||
|
/* if no rate entered, lossless by default */
|
||||||
|
if (parameters->tcp_numlayers == 0) {
|
||||||
|
parameters->tcp_rates[0] = 0.0; /* MOD antonin : losslessbug */
|
||||||
|
parameters->tcp_numlayers++;
|
||||||
|
parameters->cp_disto_alloc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parameters->cp_tx0 > parameters->volume_offset_x0) ||
|
||||||
|
(parameters->cp_ty0 > parameters->volume_offset_y0) ||
|
||||||
|
(parameters->cp_tz0 > parameters->volume_offset_z0)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) TZO(%d)<=IMG_Z0(%d)\n",
|
||||||
|
parameters->cp_tx0, parameters->volume_offset_x0, parameters->cp_ty0,
|
||||||
|
parameters->volume_offset_y0,
|
||||||
|
parameters->cp_tz0, parameters->volume_offset_z0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < parameters->numpocs; i++) {
|
||||||
|
if (parameters->POC[i].prg == -1) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
|
||||||
|
i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void error_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void warning_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void info_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
bool bSuccess;
|
||||||
|
bool delete_comment = true;
|
||||||
|
opj_cparameters_t parameters; /* compression parameters */
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_volume_t *volume = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
configure the event callbacks (not required)
|
||||||
|
setting of each callback is optional
|
||||||
|
*/
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = error_callback;
|
||||||
|
event_mgr.warning_handler = warning_callback;
|
||||||
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
/* set encoding parameters to default values */
|
||||||
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if (parse_cmdline_encoder(argc, argv, ¶meters) == 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters.cp_comment == NULL) {
|
||||||
|
parameters.cp_comment = "Created by OpenJPEG version JP3D";
|
||||||
|
/* no need to delete parameters.cp_comment on exit */
|
||||||
|
delete_comment = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* encode the destination volume */
|
||||||
|
/* ---------------------------- */
|
||||||
|
if (parameters.cod_format == J3D_CFMT || parameters.cod_format == J2K_CFMT) {
|
||||||
|
int codestream_length, pixels, bitsin;
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
FILE *f = NULL;
|
||||||
|
opj_cinfo_t* cinfo = NULL;
|
||||||
|
|
||||||
|
/* decode the source volume */
|
||||||
|
/* ----------------------- */
|
||||||
|
switch (parameters.decod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
fprintf(stdout, "[INFO] Loading pgx file(s)\n");
|
||||||
|
volume = pgxtovolume(parameters.infile, ¶meters);
|
||||||
|
if (!volume) {
|
||||||
|
fprintf(stdout, "[ERROR] Unable to load pgx files\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BIN_DFMT:
|
||||||
|
fprintf(stdout, "[INFO] Loading bin file\n");
|
||||||
|
volume = bintovolume(parameters.infile, parameters.imgfile, ¶meters);
|
||||||
|
if (!volume) {
|
||||||
|
fprintf(stdout, "[ERROR] Unable to load bin file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMG_DFMT:
|
||||||
|
fprintf(stdout, "[INFO] Loading img file\n");
|
||||||
|
volume = imgtovolume(parameters.infile, ¶meters);
|
||||||
|
if (!volume) {
|
||||||
|
fprintf(stderr, "[ERROR] Unable to load img file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get a JP3D or J2K compressor handle */
|
||||||
|
if (parameters.cod_format == J3D_CFMT) {
|
||||||
|
cinfo = opj_create_compress(CODEC_J3D);
|
||||||
|
} else if (parameters.cod_format == J2K_CFMT) {
|
||||||
|
cinfo = opj_create_compress(CODEC_J2K);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stdout);
|
||||||
|
|
||||||
|
/* setup the encoder parameters using the current volume and using user parameters */
|
||||||
|
opj_setup_encoder(cinfo, ¶meters, volume);
|
||||||
|
|
||||||
|
/* open a byte stream for writing */
|
||||||
|
/* allocate memory for all tiles */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||||
|
|
||||||
|
/* encode the volume */
|
||||||
|
/*fprintf(stdout, "[INFO] Encode the volume\n");*/
|
||||||
|
bSuccess = opj_encode(cinfo, cio, volume, parameters.index);
|
||||||
|
if (!bSuccess) {
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fprintf(stdout, "[ERROR] Failed to encode volume\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
codestream_length = cio_tell(cio);
|
||||||
|
pixels = (volume->x1 - volume->x0) * (volume->y1 - volume->y0) *
|
||||||
|
(volume->z1 - volume->z0);
|
||||||
|
bitsin = pixels * volume->comps[0].prec;
|
||||||
|
fprintf(stdout,
|
||||||
|
"[RESULT] Volume: %d x %d x %d (x %d bpv)\n Codestream: %d B, Ratio: %5.3f bpv, (%5.3f : 1) \n",
|
||||||
|
(volume->x1 - volume->x0), (volume->y1 - volume->y0), (volume->z1 - volume->z0),
|
||||||
|
volume->comps[0].prec,
|
||||||
|
codestream_length, ((double)codestream_length * 8.0 / (double)pixels),
|
||||||
|
((double)bitsin / (8.0 * (double)codestream_length)));
|
||||||
|
|
||||||
|
/* write the buffer to disk */
|
||||||
|
f = fopen(parameters.outfile, "wb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stdout, "[ERROR] Failed to open %s for writing\n", parameters.outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fwrite(cio->buffer, 1, codestream_length, f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
/* close and free the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* free remaining compression structures */
|
||||||
|
opj_destroy_compress(cinfo);
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "[ERROR] Cod_format != JP3d !!! \n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free user parameters structure */
|
||||||
|
if (delete_comment) {
|
||||||
|
if (parameters.cp_comment) {
|
||||||
|
free(parameters.cp_comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parameters.cp_matrice) {
|
||||||
|
free(parameters.cp_matrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free volume data */
|
||||||
|
opj_volume_destroy(volume);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,601 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||||
|
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjp3d.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
static double calc_PSNR(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
|
{
|
||||||
|
int max, i, k, compno = 0, size;
|
||||||
|
double sum, total = 0;
|
||||||
|
int global = 1;
|
||||||
|
|
||||||
|
max = (original->comps[compno].prec <= 8) ? 255 : (1 <<
|
||||||
|
original->comps[compno].prec) - 1;
|
||||||
|
if (global) {
|
||||||
|
size = (original->x1 - original->x0) * (original->y1 - original->y0) *
|
||||||
|
(original->z1 - original->z0);
|
||||||
|
|
||||||
|
for (compno = 0; compno < original->numcomps; compno++) {
|
||||||
|
for (sum = 0, i = 0; i < size; ++i) {
|
||||||
|
if ((decoded->comps[compno].data[i] < 0) ||
|
||||||
|
(decoded->comps[compno].data[i] > max)) {
|
||||||
|
fprintf(stdout, "[WARNING] Data out of range during PSNR computing...\n");
|
||||||
|
} else {
|
||||||
|
sum += (original->comps[compno].data[i] - decoded->comps[compno].data[i]) *
|
||||||
|
(original->comps[compno].data[i] - decoded->comps[compno].data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum /= size;
|
||||||
|
total = ((sum == 0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||||
|
} else {
|
||||||
|
size = (original->x1 - original->x0) * (original->y1 - original->y0);
|
||||||
|
|
||||||
|
for (k = 0; k < original->z1 - original->z0; k++) {
|
||||||
|
int offset = k * size;
|
||||||
|
for (sum = 0, compno = 0; compno < original->numcomps; compno++) {
|
||||||
|
for (i = 0; i < size; ++i) {
|
||||||
|
if ((decoded->comps[compno].data[i + offset] < 0) ||
|
||||||
|
(decoded->comps[compno].data[i + offset] > max)) {
|
||||||
|
fprintf(stdout, "[WARNING] Data out of range during PSNR computing...\n");
|
||||||
|
} else {
|
||||||
|
sum += (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i
|
||||||
|
+ offset]) * (original->comps[compno].data[i + offset] -
|
||||||
|
decoded->comps[compno].data[i + offset]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum /= size;
|
||||||
|
total = total + ((sum == 0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (total == 0) { /* perfect reconstruction, PSNR should return infinity */
|
||||||
|
return -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
/*return 20 * log10((max - 1) / sqrt(sum));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
|
{
|
||||||
|
int max, i, compno = 0, size, sizeM;
|
||||||
|
double sum;
|
||||||
|
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
||||||
|
sigmaxy = 0.0/*, structx = 0.0, structy = 0.0*/;
|
||||||
|
double lcomp, ccomp, scomp;
|
||||||
|
double C1, C2, C3;
|
||||||
|
|
||||||
|
max = (original->comps[compno].prec <= 8) ? 255 : (1 <<
|
||||||
|
original->comps[compno].prec) - 1;
|
||||||
|
size = (original->x1 - original->x0) * (original->y1 - original->y0) *
|
||||||
|
(original->z1 - original->z0);
|
||||||
|
|
||||||
|
/*MSSIM*/
|
||||||
|
|
||||||
|
/* sizeM = size / (original->z1 - original->z0);*/
|
||||||
|
|
||||||
|
sizeM = size;
|
||||||
|
for (sum = 0, i = 0; i < sizeM; ++i) {
|
||||||
|
/* First, the luminance of each signal is compared.*/
|
||||||
|
mux += original->comps[compno].data[i];
|
||||||
|
muy += decoded->comps[compno].data[i];
|
||||||
|
}
|
||||||
|
mux /= sizeM;
|
||||||
|
muy /= sizeM;
|
||||||
|
|
||||||
|
/*We use the standard deviation (the square root of variance) as an estimate of the signal contrast.*/
|
||||||
|
for (sum = 0, i = 0; i < sizeM; ++i) {
|
||||||
|
/* First, the luminance of each signal is compared.*/
|
||||||
|
sigmax += (original->comps[compno].data[i] - mux) *
|
||||||
|
(original->comps[compno].data[i] - mux);
|
||||||
|
sigmay += (decoded->comps[compno].data[i] - muy) *
|
||||||
|
(decoded->comps[compno].data[i] - muy);
|
||||||
|
sigmaxy += (original->comps[compno].data[i] - mux) *
|
||||||
|
(decoded->comps[compno].data[i] - muy);
|
||||||
|
}
|
||||||
|
sigmax /= sizeM - 1;
|
||||||
|
sigmay /= sizeM - 1;
|
||||||
|
sigmaxy /= sizeM - 1;
|
||||||
|
|
||||||
|
sigmax = sqrt(sigmax);
|
||||||
|
sigmay = sqrt(sigmay);
|
||||||
|
sigmaxy = sqrt(sigmaxy);
|
||||||
|
|
||||||
|
/*Third, the signal is normalized (divided) by its own standard deviation, */
|
||||||
|
/*so that the two signals being compared have unit standard deviation.*/
|
||||||
|
|
||||||
|
/*Luminance comparison*/
|
||||||
|
C1 = (0.01 * max) * (0.01 * max);
|
||||||
|
lcomp = ((2 * mux * muy) + C1) / ((mux * mux) + (muy * mux) + C1);
|
||||||
|
/*Constrast comparison*/
|
||||||
|
C2 = (0.03 * max) * (0.03 * max);
|
||||||
|
ccomp = ((2 * sigmax * sigmay) + C2) / ((sigmax * sigmax) +
|
||||||
|
(sigmay * sigmay) + C2);
|
||||||
|
/*Structure comparison*/
|
||||||
|
C3 = C2 / 2;
|
||||||
|
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
||||||
|
/*Similarity measure*/
|
||||||
|
|
||||||
|
sum = lcomp * ccomp * scomp;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void decode_help_display()
|
||||||
|
{
|
||||||
|
fprintf(stdout, "HELP\n----\n\n");
|
||||||
|
fprintf(stdout, "- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "List of parameters for the JPEG 2000 encoder:\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " Required arguments \n");
|
||||||
|
fprintf(stdout, " ---------------------------- \n");
|
||||||
|
fprintf(stdout, " -i <compressed file> ( *.jp3d, *.j3d )\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Currently accepts J3D-files. The file type is identified based on its suffix.\n");
|
||||||
|
fprintf(stdout, " -o <decompressed file> ( *.pgx, *.bin )\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Currently accepts PGX-files and BIN-files. Binary data is written to the file (not ascii). \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" If a PGX filename is given, there will be as many output files as slices; \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" an indice starting from 0 will then be appended to the output filename,\n");
|
||||||
|
fprintf(stdout, " just before the \"pgx\" extension.\n");
|
||||||
|
fprintf(stdout, " -m <characteristics file> ( *.img ) \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Required only for BIN-files. Ascii data of volume characteristics is written. \n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " Optional \n");
|
||||||
|
fprintf(stdout, " ---------------------------- \n");
|
||||||
|
fprintf(stdout, " -h \n ");
|
||||||
|
fprintf(stdout, " Display the help information\n");
|
||||||
|
fprintf(stdout, " -r <RFx,RFy,RFz>\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Set the number of highest resolution levels to be discarded on each dimension. \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" The volume resolution is effectively divided by 2 to the power of the\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" number of discarded levels. The reduce factor is limited by the\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" smallest total number of decomposition levels among tiles.\n");
|
||||||
|
fprintf(stdout, " -l <number of quality layers to decode>\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Set the maximum number of quality layers to decode. If there are\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" less quality layers than the specified number, all the quality layers\n");
|
||||||
|
fprintf(stdout, " are decoded. \n");
|
||||||
|
fprintf(stdout, " -O original-file \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" This option offers the possibility to compute some quality results \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" for the decompressed volume, like the PSNR value achieved or the global SSIM value. \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Needs the original file in order to compare with the new one.\n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions) \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option. \n");
|
||||||
|
fprintf(stdout, " (i.e. -O original-BIN-file -m original-IMG-file) \n");
|
||||||
|
fprintf(stdout, " -BE \n");
|
||||||
|
fprintf(stdout,
|
||||||
|
" Define that the recovered volume data will be saved with big endian byte order.\n");
|
||||||
|
fprintf(stdout, " By default, little endian byte order is used.\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int get_file_format(char *filename)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
|
||||||
|
static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
|
||||||
|
char * ext = strrchr(filename, '.');
|
||||||
|
if (ext) {
|
||||||
|
ext++;
|
||||||
|
for (i = 0; i < sizeof(format) / sizeof(format[0]); i++) {
|
||||||
|
if (strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
{
|
||||||
|
/* parse the command line */
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int c = opj_getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
||||||
|
if (c == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (c) {
|
||||||
|
case 'i': { /* input file */
|
||||||
|
char *infile = opj_optarg;
|
||||||
|
parameters->decod_format = get_file_format(infile);
|
||||||
|
switch (parameters->decod_format) {
|
||||||
|
case J3D_CFMT:
|
||||||
|
case J2K_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout, "[ERROR] Unknown format for infile %s [only *.j3d]!! \n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'm': { /* img file */
|
||||||
|
char *imgfile = opj_optarg;
|
||||||
|
int imgformat = get_file_format(imgfile);
|
||||||
|
switch (imgformat) {
|
||||||
|
case IMG_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n",
|
||||||
|
imgfile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile,
|
||||||
|
imgformat);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'o': { /* output file */
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
parameters->cod_format = get_file_format(outfile);
|
||||||
|
switch (parameters->cod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
case BIN_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized format for outfile : %s [accept only *.pgx or *.bin] !!\n\n",
|
||||||
|
outfile);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'O': { /* Original image for PSNR computing */
|
||||||
|
char *original = opj_optarg;
|
||||||
|
parameters->orig_format = get_file_format(original);
|
||||||
|
switch (parameters->orig_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
case BIN_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] Unrecognized format for original file : %s [accept only *.pgx or *.bin] !!\n\n",
|
||||||
|
original);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strncpy(parameters->original, original, MAX_PATH);
|
||||||
|
fprintf(stdout, "[INFO] Original file: %s \n", parameters->original);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'r': { /* reduce option */
|
||||||
|
/*sscanf(opj_optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);*/
|
||||||
|
int aux;
|
||||||
|
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_reduce[0],
|
||||||
|
¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||||
|
if (aux == 2) {
|
||||||
|
parameters->cp_reduce[2] = 0;
|
||||||
|
} else if (aux == 1) {
|
||||||
|
parameters->cp_reduce[1] = parameters->cp_reduce[0];
|
||||||
|
parameters->cp_reduce[2] = 0;
|
||||||
|
} else if (aux == 0) {
|
||||||
|
parameters->cp_reduce[0] = 0;
|
||||||
|
parameters->cp_reduce[1] = 0;
|
||||||
|
parameters->cp_reduce[2] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'l': { /* layering option */
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'B': { /* BIGENDIAN vs. LITTLEENDIAN */
|
||||||
|
parameters->bigendian = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'L': { /* BIGENDIAN vs. LITTLEENDIAN */
|
||||||
|
parameters->decod_format = LSE_CFMT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': { /* display an help description */
|
||||||
|
decode_help_display();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stdout, "[WARNING] This option is not valid \"-%c %s\"\n", c,
|
||||||
|
opj_optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
|
||||||
|
if ((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"[ERROR] At least one required argument is missing\n Check jp3d_to_volume -help for usage information\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void error_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void warning_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
void info_callback(const char *msg, void *client_data)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_volume_t *volume = NULL;
|
||||||
|
|
||||||
|
opj_volume_t *original = NULL;
|
||||||
|
opj_cparameters_t cparameters; /* original parameters */
|
||||||
|
|
||||||
|
FILE *fsrc = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int decodeok;
|
||||||
|
double psnr, ssim;
|
||||||
|
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
|
||||||
|
/* configure the event callbacks (not required) */
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = error_callback;
|
||||||
|
event_mgr.warning_handler = warning_callback;
|
||||||
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* parse input and get user decoding parameters */
|
||||||
|
strcpy(parameters.original, "NULL");
|
||||||
|
strcpy(parameters.imgfile, "NULL");
|
||||||
|
if (parse_cmdline_decoder(argc, argv, ¶meters) == 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the input file and put it in memory */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fprintf(stdout, "[INFO] Loading %s file \n",
|
||||||
|
parameters.decod_format == J3D_CFMT ? ".jp3d" : ".j2k");
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stdout, "[ERROR] Failed to open %s for reading\n", parameters.infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
file_length = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
fread(src, 1, file_length, fsrc);
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
if (parameters.decod_format == J3D_CFMT ||
|
||||||
|
parameters.decod_format == J2K_CFMT) {
|
||||||
|
/* get a JP3D or J2K decoder handle */
|
||||||
|
if (parameters.decod_format == J3D_CFMT) {
|
||||||
|
dinfo = opj_create_decompress(CODEC_J3D);
|
||||||
|
} else if (parameters.decod_format == J2K_CFMT) {
|
||||||
|
dinfo = opj_create_decompress(CODEC_J2K);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the volume structure */
|
||||||
|
volume = opj_decode(dinfo, cio);
|
||||||
|
if (!volume) {
|
||||||
|
fprintf(stdout, "[ERROR] jp3d_to_volume: failed to decode volume!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
/* create output volume */
|
||||||
|
/* ------------------- */
|
||||||
|
|
||||||
|
switch (parameters.cod_format) {
|
||||||
|
case PGX_DFMT: /* PGX */
|
||||||
|
decodeok = volumetopgx(volume, parameters.outfile);
|
||||||
|
if (decodeok) {
|
||||||
|
fprintf(stdout, "[ERROR] Unable to write decoded volume into pgx files\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BIN_DFMT: /* BMP */
|
||||||
|
decodeok = volumetobin(volume, parameters.outfile);
|
||||||
|
if (decodeok) {
|
||||||
|
fprintf(stdout, "[ERROR] Unable to write decoded volume into pgx files\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (parameters.orig_format) {
|
||||||
|
case PGX_DFMT: /* PGX */
|
||||||
|
if (strcmp("NULL", parameters.original) != 0) {
|
||||||
|
fprintf(stdout, "Loading original file %s \n", parameters.original);
|
||||||
|
cparameters.subsampling_dx = 1;
|
||||||
|
cparameters.subsampling_dy = 1;
|
||||||
|
cparameters.subsampling_dz = 1;
|
||||||
|
cparameters.volume_offset_x0 = 0;
|
||||||
|
cparameters.volume_offset_y0 = 0;
|
||||||
|
cparameters.volume_offset_z0 = 0;
|
||||||
|
original = pgxtovolume(parameters.original, &cparameters);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BIN_DFMT: /* BMP */
|
||||||
|
if (strcmp("NULL", parameters.original) != 0 &&
|
||||||
|
strcmp("NULL", parameters.imgfile) != 0) {
|
||||||
|
fprintf(stdout, "Loading original file %s %s\n", parameters.original,
|
||||||
|
parameters.imgfile);
|
||||||
|
cparameters.subsampling_dx = 1;
|
||||||
|
cparameters.subsampling_dy = 1;
|
||||||
|
cparameters.subsampling_dz = 1;
|
||||||
|
cparameters.volume_offset_x0 = 0;
|
||||||
|
cparameters.volume_offset_y0 = 0;
|
||||||
|
cparameters.volume_offset_z0 = 0;
|
||||||
|
original = bintovolume(parameters.original, parameters.imgfile, &cparameters);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n ",
|
||||||
|
(volume->comps[0].w >> volume->comps[0].factor[0]),
|
||||||
|
(volume->comps[0].h >> volume->comps[0].factor[1]),
|
||||||
|
(volume->comps[0].l >> volume->comps[0].factor[2]),
|
||||||
|
volume->comps[0].prec);
|
||||||
|
|
||||||
|
if (original) {
|
||||||
|
psnr = calc_PSNR(original, volume);
|
||||||
|
ssim = calc_SSIM(original, volume);
|
||||||
|
if (psnr < 0.0) {
|
||||||
|
fprintf(stdout, " PSNR: Inf , SSMI %f -- Perfect reconstruction!\n", ssim);
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, " PSNR: %f , SSIM %f \n", psnr, ssim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* free remaining structures */
|
||||||
|
if (dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free volume data structure */
|
||||||
|
opj_volume_destroy(volume);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# The next line is executed by /bin/sh, but not tcl \
|
||||||
|
exec wish "$0" ${1+"$@"}
|
||||||
|
lappend auto_path /usr/share/tcltk/bwidget1.9.2
|
||||||
|
|
||||||
|
namespace eval jp3dVM {
|
||||||
|
|
||||||
|
variable _progress 0
|
||||||
|
variable _afterid ""
|
||||||
|
variable _status "Compute in progress..."
|
||||||
|
variable notebook
|
||||||
|
variable mainframe
|
||||||
|
variable dataout "Process execution information"
|
||||||
|
variable status
|
||||||
|
variable prgtext
|
||||||
|
variable prgindic
|
||||||
|
|
||||||
|
set pwd [pwd]
|
||||||
|
cd [file dirname [info script]]
|
||||||
|
variable VMDIR [pwd]
|
||||||
|
cd $pwd
|
||||||
|
|
||||||
|
foreach script {encoder.tcl decoder.tcl} {
|
||||||
|
namespace inscope :: source $VMDIR/$script
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc jp3dVM::create { } {
|
||||||
|
variable notebook
|
||||||
|
variable mainframe
|
||||||
|
variable dataout
|
||||||
|
|
||||||
|
bind all <F12> { catch {console show} }
|
||||||
|
|
||||||
|
# Menu description
|
||||||
|
set descmenu {
|
||||||
|
"&File" {} {} 0 {
|
||||||
|
{command "E&xit" {} "Exit BWidget jp3dVM" {} -command exit}
|
||||||
|
}
|
||||||
|
"&Options" {} {} 0 {
|
||||||
|
{command "&Encode" {} "Show encoder" {}
|
||||||
|
-command {$jp3dVM::notebook raise [$jp3dVM::notebook page 0]}
|
||||||
|
}
|
||||||
|
{command "&Decode" {} "Show decoder" {}
|
||||||
|
-command {$jp3dVM::notebook raise [$jp3dVM::notebook page 1]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"&Help" {} {} 0 {
|
||||||
|
{command "&About authors..." {} "Show info about authors" {}
|
||||||
|
-command {MessageDlg .msgdlg -parent . -title "About authors" -message " Copyright @ LPI-UVA 2006 " -type ok -icon info}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set mainframe [MainFrame .mainframe \
|
||||||
|
-menu $descmenu \
|
||||||
|
-textvariable jp3dVM::status \
|
||||||
|
-progressvar jp3dVM::prgindic]
|
||||||
|
|
||||||
|
$mainframe addindicator -text "JP3D Verification Model 1.0.0"
|
||||||
|
|
||||||
|
# NoteBook creation
|
||||||
|
set frame [$mainframe getframe]
|
||||||
|
set notebook [NoteBook $frame.nb]
|
||||||
|
|
||||||
|
set logo [frame $frame.logo]
|
||||||
|
#creo imagen logo
|
||||||
|
image create photo LPIimg -file logoLPI.gif
|
||||||
|
set logoimg [Label $logo.logoimg -image LPIimg]
|
||||||
|
|
||||||
|
set f0 [VMEncoder::create $notebook]
|
||||||
|
set f1 [VMDecoder::create $notebook]
|
||||||
|
|
||||||
|
set tfinfo [TitleFrame $frame.codinfo -text "Program Execution"]
|
||||||
|
set codinfo [$tfinfo getframe]
|
||||||
|
set sw [ScrolledWindow $codinfo.sw -relief sunken -borderwidth 2 -scrollbar both]
|
||||||
|
set sf [ScrollableFrame $codinfo.sf ]
|
||||||
|
$sw setwidget $sf
|
||||||
|
set subf [$sf getframe]
|
||||||
|
set labinfo [label $subf.labinfo -textvariable jp3dVM::dataout -justify left]
|
||||||
|
|
||||||
|
pack $labinfo -side left
|
||||||
|
pack $sw
|
||||||
|
|
||||||
|
$notebook compute_size
|
||||||
|
$notebook raise [$notebook page 0]
|
||||||
|
|
||||||
|
pack $logoimg -side left -fill x -expand yes
|
||||||
|
pack $notebook -expand yes
|
||||||
|
pack $logo $tfinfo -side left -expand yes
|
||||||
|
pack $mainframe -fill both -expand yes
|
||||||
|
update idletasks
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc jp3dVM::main {} {
|
||||||
|
variable VMDIR
|
||||||
|
|
||||||
|
lappend ::auto_path [file dirname $VMDIR]
|
||||||
|
namespace inscope :: package require BWidget
|
||||||
|
|
||||||
|
option add *TitleFrame.l.font {helvetica 11 bold italic}
|
||||||
|
|
||||||
|
wm withdraw .
|
||||||
|
wm title . "JP3D Verification Model @ LPI"
|
||||||
|
|
||||||
|
jp3dVM::create
|
||||||
|
BWidget::place . 0 0 center
|
||||||
|
wm deiconify .
|
||||||
|
raise .
|
||||||
|
focus -force .
|
||||||
|
}
|
||||||
|
|
||||||
|
jp3dVM::main
|
||||||
|
wm geom . [wm geom .]
|
|
@ -0,0 +1,13 @@
|
||||||
|
HOWTO USE THE TCL/TK APP IN 'jp3d/tcltk'
|
||||||
|
----------------------------------------
|
||||||
|
1. Download the 'BWidget-1.9.2'
|
||||||
|
http://www.sourceforge.net/projects/tcllib/
|
||||||
|
|
||||||
|
2. Install it e.g. in '/usr/local/BWidget-1.9.2/'
|
||||||
|
3. Add the lappend command in line 4
|
||||||
|
to jp3d/tcltk/LPI_JP3D_VM.tcl:
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
# The next line is executed by /bin/sh, but not tcl \
|
||||||
|
exec wish "$0" ${1+"$@"}
|
||||||
|
lappend auto_path /usr/local/BWidget-1.9.2
|
Binary file not shown.
|
@ -0,0 +1,272 @@
|
||||||
|
|
||||||
|
namespace eval VMDecoder {
|
||||||
|
variable var
|
||||||
|
variable JP3Ddecoder "../bin/jp3d_to_volume.exe"
|
||||||
|
#variable JP3Ddecoder "jp3d_to_volume.exe"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc VMDecoder::create { nb } {
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set frameD [$nb insert end VMDecoder -text "Decoder"]
|
||||||
|
set topfD [frame $frameD.topfD]
|
||||||
|
set medfD [frame $frameD.medfD]
|
||||||
|
set bottomfD [frame $frameD.bottomfD]
|
||||||
|
set srcfD [TitleFrame $topfD.srcfD -text "Source"]
|
||||||
|
set dstfD [TitleFrame $topfD.dstfD -text "Destination"]
|
||||||
|
set paramfD [TitleFrame $medfD.paramfD -text "Decoding parameters"]
|
||||||
|
set infofD [TitleFrame $medfD.infofD -text "Distortion measures"]
|
||||||
|
|
||||||
|
set frame1 [$srcfD getframe]
|
||||||
|
_sourceD $frame1
|
||||||
|
set frame2 [$dstfD getframe]
|
||||||
|
_destinationD $frame2
|
||||||
|
set frame3 [$infofD getframe]
|
||||||
|
_originalD $frame3
|
||||||
|
set frame4 [$paramfD getframe]
|
||||||
|
_paramsD $frame4
|
||||||
|
|
||||||
|
set butD [Button $bottomfD.butD -text "Decode!" \
|
||||||
|
-command "VMDecoder::_decode $frame1 $frame2 $frame3" \
|
||||||
|
-helptext "Decoding trigger button"]
|
||||||
|
set butR [Button $bottomfD.butR -text "Save info" \
|
||||||
|
-command "VMDecoder::_save $frame3" \
|
||||||
|
-helptext "Save information"]
|
||||||
|
|
||||||
|
pack $srcfD $dstfD -side left -fill both -padx 10 -ipadx 5 -expand yes
|
||||||
|
pack $topfD -pady 4 -fill x
|
||||||
|
|
||||||
|
pack $paramfD $infofD -side left -fill both -padx 10 -pady 2 -ipadx 5 -expand yes
|
||||||
|
pack $medfD -pady 4 -fill x
|
||||||
|
|
||||||
|
pack $butD $butR -side left -padx 4 -pady 5 -expand yes
|
||||||
|
pack $bottomfD -pady 4 -fill x
|
||||||
|
|
||||||
|
return $frameD
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc fileDialogD {w ent operation} {
|
||||||
|
|
||||||
|
variable file
|
||||||
|
|
||||||
|
if {$operation == "open"} {
|
||||||
|
#-----Type names---------Extension(s)---
|
||||||
|
set types {
|
||||||
|
{"JP3D Files" {.jp3d} }
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set file [tk_getOpenFile -filetypes $types -parent $w ]
|
||||||
|
} elseif {$operation == "original"} {
|
||||||
|
#-----Type names---------Extension(s)---
|
||||||
|
set types {
|
||||||
|
{"BIN Raw Image Files" {.bin} }
|
||||||
|
{"PGX Raw Image Files" {.pgx} }
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set file [tk_getOpenFile -filetypes $types -parent $w ]
|
||||||
|
} else {
|
||||||
|
#-----Type names---------Extension(s)---
|
||||||
|
set types {
|
||||||
|
{"BIN Raw Image Files" {.bin} }
|
||||||
|
{"PGX Raw Image Files" {.pgx} }
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set file [tk_getSaveFile -filetypes $types -parent $w -initialfile Untitled -defaultextension "*.bin"]
|
||||||
|
}
|
||||||
|
if {[string compare $file ""]} {
|
||||||
|
$ent delete 0 end
|
||||||
|
$ent insert end $file
|
||||||
|
$ent xview moveto 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMDecoder::_sourceD { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set labsrcD [LabelFrame $parent.labsrcD -text "Select compressed file: " -side top \
|
||||||
|
-anchor w -relief flat -borderwidth 0]
|
||||||
|
set subsrcD [$labsrcD getframe]
|
||||||
|
set listD [entry $subsrcD.entrysrcD -width 40 -textvariable VMDecoder::var(sourceD)]
|
||||||
|
|
||||||
|
set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
|
||||||
|
set subbrw [$labbrw getframe]
|
||||||
|
set butbrw [button $subbrw.butbrw -image [Bitmap::get open] \
|
||||||
|
-relief raised -borderwidth 1 -padx 1 -pady 1 \
|
||||||
|
-command "fileDialogD . $subsrcD.entrysrcD open"]
|
||||||
|
|
||||||
|
pack $listD -side top
|
||||||
|
pack $butbrw -side top
|
||||||
|
pack $labsrcD $labbrw -side left -fill both -expand yes
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMDecoder::_destinationD { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set labdstD [LabelFrame $parent.labdstD -text "Save decompressed volume file(s) as: " -side top \
|
||||||
|
-anchor w -relief flat -borderwidth 0]
|
||||||
|
set subdstD [$labdstD getframe]
|
||||||
|
set listD [entry $subdstD.entrydstD -width 40 -textvariable VMDecoder::var(destinationD)]
|
||||||
|
|
||||||
|
set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
|
||||||
|
set subbrw [$labbrw getframe]
|
||||||
|
set butbrw [button $subbrw.butbrw -image [Bitmap::get save] \
|
||||||
|
-relief raised -borderwidth 1 -padx 1 -pady 1 \
|
||||||
|
-command "fileDialogD . $subdstD.entrydstD save"]
|
||||||
|
|
||||||
|
pack $listD -side top
|
||||||
|
pack $butbrw -side top
|
||||||
|
pack $labdstD $labbrw -side left -fill both -expand yes
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMDecoder::_originalD { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set laborgD [LabelFrame $parent.laborgD -text "Select original file: " -side top \
|
||||||
|
-anchor w -relief flat -borderwidth 0]
|
||||||
|
set suborgD [$laborgD getframe]
|
||||||
|
set listorgD [entry $suborgD.entryorgD -width 30 -textvariable VMDecoder::var(originalD)]
|
||||||
|
|
||||||
|
set labbrw2 [LabelFrame $parent.labbrw2 -side top -anchor w -relief flat -borderwidth 0]
|
||||||
|
set subbrw2 [$labbrw2 getframe]
|
||||||
|
set butbrw2 [button $subbrw2.butbrw2 -image [Bitmap::get open] \
|
||||||
|
-relief raised -borderwidth 1 -padx 1 -pady 1 \
|
||||||
|
-command "fileDialogD . $suborgD.entryorgD original"]
|
||||||
|
|
||||||
|
set infoD [Label $parent.infoD -relief sunken -textvariable VMDecoder::var(decodinfo) -justify left]
|
||||||
|
|
||||||
|
pack $listorgD -side left -anchor n
|
||||||
|
pack $butbrw2 -side left -anchor n
|
||||||
|
pack $infoD -side bottom -anchor nw -pady 4 -ipadx 150 -ipady 20 -expand yes
|
||||||
|
pack $laborgD $labbrw2 -side left -fill both
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMDecoder::_paramsD { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
########### DECODING #############
|
||||||
|
set labcod [LabelFrame $parent.labcod -side top -anchor w -relief sunken -borderwidth 1]
|
||||||
|
set subcod [$labcod getframe]
|
||||||
|
|
||||||
|
set frameres [frame $subcod.frameres -borderwidth 1]
|
||||||
|
set labres [LabelEntry $frameres.labres -label "Resolutions to discard: " -labelwidth 20 -labelanchor w \
|
||||||
|
-textvariable VMDecoder::var(resdiscard) -editable 1 \
|
||||||
|
-helptext "Number of highest resolution levels to be discarded on each dimension" ]
|
||||||
|
set VMDecoder::var(resdiscard) "0,0,0"
|
||||||
|
|
||||||
|
set framelayer [frame $subcod.framelayer -borderwidth 1]
|
||||||
|
set lablayer [LabelEntry $framelayer.lablayer -label "Layers to decode: " -labelwidth 20 -labelanchor w \
|
||||||
|
-textvariable VMDecoder::var(layer) -editable 1 \
|
||||||
|
-helptext "Maximum number of quality layers to decode" ]
|
||||||
|
set VMDecoder::var(layer) "All"
|
||||||
|
|
||||||
|
set framebe [frame $subcod.framebe -borderwidth 1]
|
||||||
|
set chkbe [checkbutton $framebe.chkbe -text "Write decoded file with BigEndian byte order" \
|
||||||
|
-variable VMDecoder::var(be) -onvalue 1 -offvalue 0 ]
|
||||||
|
|
||||||
|
pack $labres -side left -padx 2 -anchor n
|
||||||
|
pack $lablayer -side left -padx 2 -anchor n
|
||||||
|
pack $chkbe -side left -padx 2 -anchor w
|
||||||
|
pack $frameres $framelayer $framebe -side top -anchor w
|
||||||
|
|
||||||
|
pack $subcod -anchor n
|
||||||
|
pack $labcod -side left -fill both -padx 4 -expand yes
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc VMDecoder::_decode { framesrc framedst frameinfo} {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set sourceD [$framesrc.labsrcD.f.entrysrcD get ]
|
||||||
|
set destinationD [$framedst.labdstD.f.entrydstD get ]
|
||||||
|
set originD [$frameinfo.laborgD.f.entryorgD get ]
|
||||||
|
set cond1 [string match *.pgx [string tolower $destinationD]]
|
||||||
|
set cond2 [string match *\**.pgx [string tolower $destinationD]]
|
||||||
|
set cond3 [string match *.bin [string tolower $destinationD]]
|
||||||
|
|
||||||
|
#comprobamos datos son correctos
|
||||||
|
if {($cond1 == 1) && ($cond2 == 0)} {
|
||||||
|
set pgx "*.pgx"
|
||||||
|
set pattern [string range $destinationD 0 [expr [string length $destinationD]-5]]
|
||||||
|
set destinationD $pattern$img
|
||||||
|
} elseif {$sourceD == ""} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : Source file is not defined !" -type ok -icon error
|
||||||
|
} elseif {$destinationD == ""} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : Destination file is not defined !" -type ok -icon error
|
||||||
|
} else {
|
||||||
|
|
||||||
|
#creamos datain a partir de los parametros de entrada
|
||||||
|
#set dirJP3Ddecoder [mk_relativepath $VMDecoder::JP3Ddecoder]
|
||||||
|
set dirJP3Ddecoder $VMDecoder::JP3Ddecoder
|
||||||
|
set datain [concat " $dirJP3Ddecoder -i [mk_relativepath $sourceD] "]
|
||||||
|
set datain [concat " $datain -o [mk_relativepath $destinationD] "]
|
||||||
|
if {$originD != ""} {
|
||||||
|
set datain [concat " $datain -O [mk_relativepath $originD] "]
|
||||||
|
if {$cond3 == 1} {
|
||||||
|
set img ".img"
|
||||||
|
set pattern [string range $originD 0 [expr [string length $originD]-5]]
|
||||||
|
set pattern $pattern$img
|
||||||
|
if {[file exists $pattern]} {
|
||||||
|
set datain [concat " $datain -m [mk_relativepath $pattern] "]
|
||||||
|
} else {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : IMG file associated to original BIN volume file not found in same directory !" -type ok -icon info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if {$VMDecoder::var(resdiscard) != "0,0,0"} {
|
||||||
|
set datain [concat " $datain -r $VMDecoder::var(resdiscard) "]
|
||||||
|
}
|
||||||
|
if {$VMDecoder::var(layer) != "All" && $VMDecoder::var(layer) > 0} {
|
||||||
|
set datain [concat " $datain -l $VMDecoder::var(layer) "]
|
||||||
|
}
|
||||||
|
if {$VMDecoder::var(be) == 1} {
|
||||||
|
set datain [concat " $datain -BE"]
|
||||||
|
}
|
||||||
|
|
||||||
|
set VMDecoder::var(progval) 10
|
||||||
|
ProgressDlg .progress -parent . -title "Wait..." \
|
||||||
|
-type infinite \
|
||||||
|
-width 20 \
|
||||||
|
-textvariable "Compute in progress..."\
|
||||||
|
-variable VMDecoder::progval \
|
||||||
|
-stop "Stop" \
|
||||||
|
-command {destroy .progress}
|
||||||
|
|
||||||
|
after 200 set VMDecoder::var(progval) 2
|
||||||
|
|
||||||
|
set fp [open "| $datain " r+]
|
||||||
|
fconfigure $fp -buffering line
|
||||||
|
set jp3dVM::dataout [concat "EXECUTED PROGRAM:\n\t$datain"]
|
||||||
|
while {-1 != [gets $fp tmp]} {
|
||||||
|
set jp3dVM::dataout [concat "$jp3dVM::dataout\n$tmp"]
|
||||||
|
}
|
||||||
|
close $fp
|
||||||
|
destroy .progress
|
||||||
|
set cond [string first "ERROR" $jp3dVM::dataout]
|
||||||
|
set cond2 [string first "PSNR" $jp3dVM::dataout]
|
||||||
|
set cond3 [string first "RESULT" $jp3dVM::dataout]
|
||||||
|
if {$cond != -1} {
|
||||||
|
MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond-1] end] -type ok -icon error
|
||||||
|
} elseif {$cond3 != -1} {
|
||||||
|
if {$cond2 != -1} {
|
||||||
|
set VMDecoder::var(decodinfo) [string range $jp3dVM::dataout [expr $cond2-1] end]
|
||||||
|
}
|
||||||
|
MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond3-1] end] -type ok -icon info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMDecoder::_save { frameinfo } {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,470 @@
|
||||||
|
|
||||||
|
namespace eval VMEncoder {
|
||||||
|
variable var
|
||||||
|
variable JP3Dencoder "../bin/bin/volume_to_jp3d"
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::create { nb } {
|
||||||
|
|
||||||
|
set frame [$nb insert end VMEncoder -text "Encoder"]
|
||||||
|
set topf [frame $frame.topf]
|
||||||
|
set midf [frame $frame.midf]
|
||||||
|
set bottomf [frame $frame.bottomf]
|
||||||
|
set srcf [TitleFrame $topf.srcf -text "Source"]
|
||||||
|
set dstf [TitleFrame $topf.dstf -text "Destination"]
|
||||||
|
set Tparf [TitleFrame $midf.parfT -text "Transform Parameters"]
|
||||||
|
set Cparf [TitleFrame $midf.parfC -text "Coding Parameters"]
|
||||||
|
|
||||||
|
set frame1 [$srcf getframe]
|
||||||
|
VMEncoder::_sourceE $frame1
|
||||||
|
|
||||||
|
set frame2 [$dstf getframe]
|
||||||
|
VMEncoder::_destinationE $frame2
|
||||||
|
|
||||||
|
set frame3 [$Tparf getframe]
|
||||||
|
VMEncoder::_transformE $frame3
|
||||||
|
|
||||||
|
set frame4 [$Cparf getframe]
|
||||||
|
VMEncoder::_codingE $frame4
|
||||||
|
|
||||||
|
set butE [Button $bottomf.butE -text "Encode!" \
|
||||||
|
-command "VMEncoder::_encode $frame1 $frame2" \
|
||||||
|
-helptext "Encoding trigger button"]
|
||||||
|
set butR [Button $bottomf.butR -text "Restore defaults" \
|
||||||
|
-command "VMEncoder::_reset $frame1 $frame2 $frame3 $frame4" \
|
||||||
|
-helptext "Reset to default values"]
|
||||||
|
|
||||||
|
pack $srcf $dstf -side left -fill y -padx 4 -expand yes
|
||||||
|
pack $topf -pady 2 -fill x
|
||||||
|
|
||||||
|
pack $Tparf $Cparf -side left -fill both -padx 4 -expand yes
|
||||||
|
pack $midf -pady 2 -fill x
|
||||||
|
|
||||||
|
pack $butE $butR -side left -padx 40 -pady 5 -fill y -expand yes
|
||||||
|
pack $bottomf -pady 2 -fill x
|
||||||
|
|
||||||
|
return $frame
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::_sourceE { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set labsrc [LabelFrame $parent.labsrc -text "Select volume file to encode: " -side top \
|
||||||
|
-anchor w -relief flat -borderwidth 0]
|
||||||
|
set subsrc [$labsrc getframe]
|
||||||
|
set list [entry $subsrc.entrysrc -width 30 -textvariable VMDecoder::var(source)]
|
||||||
|
|
||||||
|
set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
|
||||||
|
set subbrw [$labbrw getframe]
|
||||||
|
set butbrw [button $subbrw.butbrw -image [Bitmap::get open] \
|
||||||
|
-relief raised -borderwidth 1 -padx 1 -pady 1 \
|
||||||
|
-command "fileDialogE . $subsrc.entrysrc open"]
|
||||||
|
|
||||||
|
pack $list -side top
|
||||||
|
pack $butbrw -side top
|
||||||
|
pack $labsrc $labbrw -side left -fill both -expand yes
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::_destinationE { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set labdst [LabelFrame $parent.labdst -text "Save compressed volume as: " -side top \
|
||||||
|
-anchor w -relief flat -borderwidth 0]
|
||||||
|
set subdst [$labdst getframe]
|
||||||
|
set list [entry $subdst.entrydst -width 30 -textvariable VMDecoder::var(destination)]
|
||||||
|
|
||||||
|
set labbrw [LabelFrame $parent.labbrw -side top -anchor w -relief flat -borderwidth 0]
|
||||||
|
set subbrw [$labbrw getframe]
|
||||||
|
set butbrw [button $subbrw.butbrw -image [Bitmap::get save] \
|
||||||
|
-relief raised -borderwidth 1 -padx 1 -pady 1 \
|
||||||
|
-command "fileDialogE . $subdst.entrydst save"]
|
||||||
|
|
||||||
|
pack $list -side top
|
||||||
|
pack $butbrw -side top
|
||||||
|
pack $labdst $labbrw -side left -fill both -expand yes
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::_codingE { parent } {
|
||||||
|
|
||||||
|
|
||||||
|
########### CODING #############
|
||||||
|
set labcod [LabelFrame $parent.labcod -side top -anchor w -relief sunken -borderwidth 1]
|
||||||
|
set subcod [$labcod getframe]
|
||||||
|
|
||||||
|
set framerate [frame $subcod.framerate -borderwidth 1]
|
||||||
|
set labrate [LabelEntry $framerate.labrate -label "Rates: " -labelwidth 9 -labelanchor w \
|
||||||
|
-textvariable VMEncoder::var(rate) -editable 1 \
|
||||||
|
-helptext "Compression ratios for different layers (R1, R2, R3,...). If R=1, lossless coding" ]
|
||||||
|
set VMEncoder::var(rate) "1"
|
||||||
|
|
||||||
|
set framecblk [frame $subcod.framecblk -borderwidth 1]
|
||||||
|
set labcblk [LabelEntry $framecblk.labcblk -label "Codeblock: " -labelwidth 9 -labelanchor w \
|
||||||
|
-textvariable VMEncoder::var(cblksize) -editable 1 \
|
||||||
|
-helptext "Codeblock size (X, Y, Z)" ]
|
||||||
|
set VMEncoder::var(cblksize) "64,64,64"
|
||||||
|
|
||||||
|
set frametile [frame $subcod.frametile -borderwidth 1]
|
||||||
|
set labtile [LabelEntry $frametile.labtile -label "Tile size: " -labelwidth 9 -labelanchor w \
|
||||||
|
-textvariable VMEncoder::var(tilesize) -editable 1 \
|
||||||
|
-helptext "Tile size (X, Y, Z)" ]
|
||||||
|
set VMEncoder::var(tilesize) "512,512,512"
|
||||||
|
|
||||||
|
set framesop [frame $subcod.framesop -borderwidth 1]
|
||||||
|
set chksop [checkbutton $framesop.chksop -text "Write SOP marker" \
|
||||||
|
-variable VMEncoder::var(sop) -onvalue 1 -offvalue 0 ]
|
||||||
|
set frameeph [frame $subcod.frameeph -borderwidth 1]
|
||||||
|
set chkeph [checkbutton $frameeph.chkeph -text "Write EPH marker" \
|
||||||
|
-variable VMEncoder::var(eph) -onvalue 1 -offvalue 0 ]
|
||||||
|
|
||||||
|
set framepoc [frame $subcod.framepoc -borderwidth 1]
|
||||||
|
set labpoc [label $framepoc.labpoc -text "Progression order: " ]
|
||||||
|
set progorder [ComboBox $framepoc.progorder \
|
||||||
|
-text {Choose a progression order} \
|
||||||
|
-width 10 \
|
||||||
|
-textvariable VMEncoder::var(progorder) \
|
||||||
|
-values {"LRCP" "RLCP" "RPCL" "PCRL" "CPRL"} \
|
||||||
|
-helptext "Progression order"]
|
||||||
|
set VMEncoder::var(progorder) "LRCP"
|
||||||
|
|
||||||
|
pack $labrate -side left -padx 2 -anchor n
|
||||||
|
pack $labcblk -side left -padx 2 -anchor n
|
||||||
|
pack $labpoc $progorder -side left -padx 2 -anchor w
|
||||||
|
#pack $labtile -side left -padx 2 -anchor n
|
||||||
|
pack $chksop -side left -padx 2 -anchor w
|
||||||
|
pack $chkeph -side left -padx 2 -anchor w
|
||||||
|
########### ENTROPY CODING #############
|
||||||
|
set labent [LabelFrame $parent.labent -text "Entropy Coding" -side top -anchor w -relief sunken -borderwidth 1]
|
||||||
|
set subent [$labent getframe]
|
||||||
|
foreach entval {2EB 3EB} entropy {2D_EBCOT 3D_EBCOT} {
|
||||||
|
set rad [radiobutton $subent.$entval \
|
||||||
|
-text $entropy \
|
||||||
|
-variable VMEncoder::var(encoding) \
|
||||||
|
-command "disableGR $entval $labcblk $progorder $labrate $chksop $chkeph" \
|
||||||
|
-value $entval ]
|
||||||
|
pack $rad -anchor w
|
||||||
|
}
|
||||||
|
$subent.2EB select
|
||||||
|
|
||||||
|
pack $subent -padx 2 -anchor n
|
||||||
|
|
||||||
|
pack $framerate $framecblk $framepoc $framesop $frameeph -side top -anchor w
|
||||||
|
pack $subcod -anchor n
|
||||||
|
|
||||||
|
pack $labent $labcod -side left -fill both -padx 4 -expand yes
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::_transformE { parent } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
########### TRANSFORM #############
|
||||||
|
set labtrf [LabelFrame $parent.labtrf -text "Transform" -side top -anchor w -relief sunken -borderwidth 1]
|
||||||
|
set subtrf [$labtrf getframe]
|
||||||
|
set labres [LabelFrame $parent.labres -side top -anchor w -relief sunken -borderwidth 1]
|
||||||
|
set subres [$labres getframe]
|
||||||
|
|
||||||
|
########### ATK #############
|
||||||
|
set frameatk [frame $subres.frameatk -borderwidth 1]
|
||||||
|
set labatk [label $frameatk.labatk -text "Wavelet kernel: " -anchor w]
|
||||||
|
set atk [ComboBox $frameatk.atk \
|
||||||
|
-textvariable VMEncoder::var(atk) \
|
||||||
|
-width 20 \
|
||||||
|
-text {Choose a wavelet kernel} \
|
||||||
|
-editable false \
|
||||||
|
-values {"R5.3" "I9.7"} ]
|
||||||
|
set VMEncoder::var(atk) "R5.3"
|
||||||
|
pack $labatk $atk -side left -anchor w
|
||||||
|
########### RESOLUTIONS #############
|
||||||
|
set frameres1 [frame $subres.frameres1 -borderwidth 1]
|
||||||
|
set labresolution [label $frameres1.labresol -text "Resolutions: " -anchor w ]
|
||||||
|
set frameres2 [frame $subres.frameres2 -borderwidth 1]
|
||||||
|
set labresX [label $frameres2.labresX -text " X" -anchor w ]
|
||||||
|
set labresY [label $frameres2.labresY -text " Y" -anchor w ]
|
||||||
|
set labresZ [label $frameres2.labresZ -text " Z" -anchor w ]
|
||||||
|
|
||||||
|
|
||||||
|
set resX [SpinBox $frameres2.spinresX \
|
||||||
|
-range {1 6 1} -textvariable VMEncoder::var(resX) \
|
||||||
|
-helptext "Number of resolutions in X" \
|
||||||
|
-width 3 \
|
||||||
|
-editable false ]
|
||||||
|
set resY [SpinBox $frameres2.spinresY \
|
||||||
|
-range {1 6 1} -textvariable VMEncoder::var(resY) \
|
||||||
|
-helptext "Number of resolutions in Y" \
|
||||||
|
-width 3 \
|
||||||
|
-editable false ]
|
||||||
|
set resZ [SpinBox $frameres2.spinresZ \
|
||||||
|
-range {1 6 1} -textvariable VMEncoder::var(resZ) \
|
||||||
|
-helptext "Number of resolutions in Z" \
|
||||||
|
-width 3 \
|
||||||
|
-editable false \
|
||||||
|
-state disabled ]
|
||||||
|
set VMEncoder::var(resX) 3
|
||||||
|
set VMEncoder::var(resY) 3
|
||||||
|
set VMEncoder::var(resZ) 3
|
||||||
|
|
||||||
|
########### TRF #############
|
||||||
|
foreach trfval {2DWT 3DWT} trf {2D-DWT 3D-DWT} {
|
||||||
|
set rad [radiobutton $subtrf.$trfval -text $trf \
|
||||||
|
-variable VMEncoder::var(transform) \
|
||||||
|
-command "disable3RLS $trfval $atk $resX $resY $resZ"\
|
||||||
|
-value $trfval ]
|
||||||
|
pack $rad -anchor w
|
||||||
|
}
|
||||||
|
$subtrf.2DWT select
|
||||||
|
|
||||||
|
pack $subtrf -side left -padx 2 -pady 4
|
||||||
|
|
||||||
|
pack $labresolution -padx 2 -side left -anchor w
|
||||||
|
pack $labresX $resX -padx 2 -side left -anchor w
|
||||||
|
pack $labresY $resY -padx 2 -side left -anchor w
|
||||||
|
pack $labresZ $resZ -padx 2 -side left -anchor w
|
||||||
|
|
||||||
|
pack $frameres1 -side top -fill x
|
||||||
|
pack $frameres2 $frameatk -side top -padx 2 -pady 4 -anchor n
|
||||||
|
|
||||||
|
pack $subres -side left -padx 2 -pady 4
|
||||||
|
pack $labtrf $labres -side left -fill both -padx 4 -expand yes
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc VMEncoder::_encode { framesrc framedst } {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
set source [$framesrc.labsrc.f.entrysrc get ]
|
||||||
|
set destination [$framedst.labdst.f.entrydst get ]
|
||||||
|
set cond1 [string match *.pgx [string tolower $source]]
|
||||||
|
set cond2 [string match *-*.pgx [string tolower $source]]
|
||||||
|
set cond3 [string match *.bin [string tolower $source]]
|
||||||
|
|
||||||
|
set img ".img"
|
||||||
|
set pattern [string range $source 0 [expr [string length $source]-5]]
|
||||||
|
set pattern $pattern$img
|
||||||
|
set exist [file exists $pattern]
|
||||||
|
|
||||||
|
#comprobamos datos son correctos
|
||||||
|
if {($cond1 == 1) && ($cond2 == 0)} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Info : Really want to encode an slice instead of a volume?.\n For a group of .pgx slices, name must contain a - denoting a sequential index!" -type ok -icon info
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$source == ""} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : Source file is not defined !" -type ok -icon error
|
||||||
|
} elseif {$destination == ""} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : Destination file is not defined !" -type ok -icon error
|
||||||
|
} elseif { ($VMEncoder::var(transform) != "3RLS") && ($VMEncoder::var(atk) == "Choose a wavelet transformation kernel") } {
|
||||||
|
MessageDlg .msgdlg -parent . -title "Info" -message "Please choose a wavelet transformation kernel"\
|
||||||
|
-type ok -icon warning
|
||||||
|
} elseif {($exist == 0) && ($cond1 == 0) && ($cond3 == 1)} {
|
||||||
|
MessageDlg .msgdlg -parent . -message "Error : IMG file associated to BIN volume file not found in same directory !" -type ok -icon info
|
||||||
|
} else {
|
||||||
|
|
||||||
|
#creamos datain a partir de los parametros de entrada
|
||||||
|
# set dirJP3Dencoder [mk_relativepath $VMEncoder::JP3Dencoder]
|
||||||
|
set dirJP3Dencoder $VMEncoder::JP3Dencoder
|
||||||
|
set datain [concat " $dirJP3Dencoder -i [mk_relativepath $source] "]
|
||||||
|
if {$cond3 == 1} {
|
||||||
|
set datain [concat " $datain -m [mk_relativepath $pattern] "]
|
||||||
|
}
|
||||||
|
set datain [concat " $datain -o [mk_relativepath $destination] "]
|
||||||
|
if {$VMEncoder::var(encoding) != "2EB"} {
|
||||||
|
set datain [concat " $datain -C $VMEncoder::var(encoding) "]
|
||||||
|
}
|
||||||
|
if {$VMEncoder::var(transform) == "2DWT"} {
|
||||||
|
set datain [concat " $datain -n $VMEncoder::var(resX),$VMEncoder::var(resY) "]
|
||||||
|
} elseif {$VMEncoder::var(transform) == "3DWT"} {
|
||||||
|
set datain [concat " $datain -n $VMEncoder::var(resX),$VMEncoder::var(resY),$VMEncoder::var(resZ) "]
|
||||||
|
}
|
||||||
|
|
||||||
|
set datain [concat " $datain -r $VMEncoder::var(rate) "]
|
||||||
|
|
||||||
|
if {$VMEncoder::var(atk) == "I9.7"} {
|
||||||
|
set datain [concat " $datain -I "]
|
||||||
|
}
|
||||||
|
if {$VMEncoder::var(sop) == 1} {
|
||||||
|
set datain [concat " $datain -SOP "]
|
||||||
|
}
|
||||||
|
if {$VMEncoder::var(eph) == 1} {
|
||||||
|
set datain [concat " $datain -EPH "]
|
||||||
|
}
|
||||||
|
if {$VMEncoder::var(progorder) != "LRCP"} {
|
||||||
|
set datain [concat " $datain -p $VMEncoder::var(progorder) "]
|
||||||
|
}
|
||||||
|
if {$VMEncoder::var(cblksize) != "64,64,64"} {
|
||||||
|
set datain [concat " $datain -b $VMEncoder::var(cblksize) "]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Making this work would be great !!!
|
||||||
|
set VMEncoder::var(progval) 10
|
||||||
|
ProgressDlg .progress -parent . -title "Wait..." \
|
||||||
|
-type infinite \
|
||||||
|
-width 20 \
|
||||||
|
-textvariable "Compute in progress..."\
|
||||||
|
-variable VMEncoder::progval \
|
||||||
|
-stop "Stop" \
|
||||||
|
-command {destroy .progress}
|
||||||
|
after 200 set VMEncoder::var(progval) 2
|
||||||
|
set fp [open "| $datain " r+]
|
||||||
|
fconfigure $fp -buffering line
|
||||||
|
set jp3dVM::dataout [concat "EXECUTED PROGRAM:\n\t$datain"]
|
||||||
|
while {-1 != [gets $fp tmp]} {
|
||||||
|
set jp3dVM::dataout [concat "$jp3dVM::dataout\n$tmp"]
|
||||||
|
}
|
||||||
|
destroy .progress
|
||||||
|
set cond [string first "ERROR" $jp3dVM::dataout]
|
||||||
|
set cond2 [string first "RESULT" $jp3dVM::dataout]
|
||||||
|
if {$cond != -1} {
|
||||||
|
MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond-1] end] -type ok -icon error
|
||||||
|
} elseif {$cond2 != -1} {
|
||||||
|
MessageDlg .msgdlg -parent . -message [string range $jp3dVM::dataout [expr $cond2+7] end] -type ok -icon info
|
||||||
|
close $fp
|
||||||
|
} else {
|
||||||
|
#Must do something with this !!! [pid $fp]
|
||||||
|
close $fp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc VMEncoder::_reset { framesrc framedst frametrf framecod} {
|
||||||
|
|
||||||
|
variable var
|
||||||
|
|
||||||
|
#Restore defaults values
|
||||||
|
set VMEncoder::var(transform) 2DWT
|
||||||
|
set VMEncoder::var(encoding) 2EB
|
||||||
|
set VMEncoder::var(atk) "R5.3"
|
||||||
|
set VMEncoder::var(progorder) "LRCP"
|
||||||
|
set atk $frametrf.labres.f.frameatk.atk
|
||||||
|
set resX $frametrf.labres.f.frameres2.spinresX
|
||||||
|
set resY $frametrf.labres.f.frameres2.spinresY
|
||||||
|
set resZ $frametrf.labres.f.frameres2.spinresZ
|
||||||
|
disable3RLS 2DWT $atk $resX $resY $resZ
|
||||||
|
set labcblk $framecod.labcod.f.framecblk.labcblk
|
||||||
|
set progorder $framecod.labcod.f.framepoc.progorder
|
||||||
|
set labrate $framecod.labcod.f.framerate.labrate
|
||||||
|
set chksop $framecod.labcod.f.framesop.chksop
|
||||||
|
set chkeph $framecod.labcod.f.frameeph.chkeph
|
||||||
|
disableGR 3EB $labcblk $progorder $labrate $chksop $chkeph
|
||||||
|
|
||||||
|
$framesrc.labsrc.f.entrysrc delete 0 end
|
||||||
|
$framedst.labdst.f.entrydst delete 0 end
|
||||||
|
}
|
||||||
|
|
||||||
|
proc fileDialogE {w ent operation} {
|
||||||
|
|
||||||
|
variable file
|
||||||
|
variable i j
|
||||||
|
|
||||||
|
if {$operation == "open"} {
|
||||||
|
set types {
|
||||||
|
{"Source Image Files" {.pgx .bin} }
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set file [tk_getOpenFile -filetypes $types -parent $w]
|
||||||
|
if {[string compare $file ""]} {
|
||||||
|
$ent delete 0 end
|
||||||
|
$ent insert end $file
|
||||||
|
$ent xview moveto 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set types {
|
||||||
|
{"JP3D Files" {.jp3d} }
|
||||||
|
{"JPEG2000 Files" {.j2k} }
|
||||||
|
{"All files" *}
|
||||||
|
}
|
||||||
|
set file [tk_getSaveFile -filetypes $types -parent $w \
|
||||||
|
-initialfile Untitled -defaultextension .jp3d]
|
||||||
|
if {[string compare $file ""]} {
|
||||||
|
$ent delete 0 end
|
||||||
|
$ent insert end $file
|
||||||
|
$ent xview moveto 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc mk_relativepath {abspath} {
|
||||||
|
|
||||||
|
set mydir [split [string trimleft [pwd] {/}] {/}]
|
||||||
|
set abspathcomps [split [string trimleft $abspath {/}] {/}]
|
||||||
|
|
||||||
|
set i 0
|
||||||
|
while {$i<[llength $mydir]} {
|
||||||
|
if {![string compare [lindex $abspathcomps $i] [lindex $mydir $i]]} {
|
||||||
|
incr i
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set h [expr [llength $mydir]-$i]
|
||||||
|
set j [expr [llength $abspathcomps]-$i]
|
||||||
|
|
||||||
|
if {!$h} {
|
||||||
|
set relpath "./"
|
||||||
|
} else {
|
||||||
|
set relpath ""
|
||||||
|
while { $h > 0 } {
|
||||||
|
set relpath "../$relpath"
|
||||||
|
incr h -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set h [llength $abspathcomps]
|
||||||
|
while { $h > $i } {
|
||||||
|
set relpath [concat $relpath[lindex $abspathcomps [expr [llength $abspathcomps]-$j]]/]
|
||||||
|
incr h -1
|
||||||
|
incr j -1
|
||||||
|
}
|
||||||
|
return [string trim $relpath {/}]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc disable3RLS {flag atk resX resY resZ} {
|
||||||
|
|
||||||
|
if {$flag == "3RLS"} {
|
||||||
|
$atk configure -state disabled
|
||||||
|
$resX configure -state disabled
|
||||||
|
$resY configure -state disabled
|
||||||
|
$resZ configure -state disabled
|
||||||
|
} elseif {$flag == "2DWT"} {
|
||||||
|
$atk configure -state normal
|
||||||
|
$resX configure -state normal
|
||||||
|
$resY configure -state normal
|
||||||
|
$resZ configure -state disabled
|
||||||
|
} elseif {$flag == "3DWT"} {
|
||||||
|
$atk configure -state normal
|
||||||
|
$resX configure -state normal
|
||||||
|
$resY configure -state normal
|
||||||
|
$resZ configure -state normal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc disableGR {flag labcblk progorder labrate chksop chkeph} {
|
||||||
|
|
||||||
|
if {$flag == "2EB"} {
|
||||||
|
$labcblk configure -state normal
|
||||||
|
$progorder configure -state normal
|
||||||
|
$labrate configure -state normal
|
||||||
|
$chksop configure -state normal
|
||||||
|
$chkeph configure -state normal
|
||||||
|
set VMEncoder::var(cblksize) "64,64,64"
|
||||||
|
set VMEncoder::var(tilesize) "512,512,512"
|
||||||
|
} elseif {$flag == "3EB"} {
|
||||||
|
$labcblk configure -state normal
|
||||||
|
$progorder configure -state normal
|
||||||
|
$labrate configure -state normal
|
||||||
|
$chksop configure -state normal
|
||||||
|
$chkeph configure -state normal
|
||||||
|
set VMEncoder::var(cblksize) "64,64,64"
|
||||||
|
set VMEncoder::var(tilesize) "512,512,512"
|
||||||
|
} else {
|
||||||
|
$labcblk configure -state disabled
|
||||||
|
$progorder configure -state disabled
|
||||||
|
$labrate configure -state disabled
|
||||||
|
$chksop configure -state disabled
|
||||||
|
$chkeph configure -state disabled
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
|
@ -0,0 +1,679 @@
|
||||||
|
/*
|
||||||
|
* uce-dirent.h - operating system independent dirent implementation
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998-2002 Toni Ronkko
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* ``Software''), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* May 28 1998, Toni Ronkko <tronkko@messi.uku.fi>
|
||||||
|
*
|
||||||
|
* $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
|
||||||
|
*
|
||||||
|
* $Log: uce-dirent.h,v $
|
||||||
|
* Revision 1.7 2002/05/13 10:48:35 tr
|
||||||
|
* embedded some source code directly to the header so that no source
|
||||||
|
* modules need to be included in the MS Visual C project using the
|
||||||
|
* interface, removed all the dependencies to other headers of the `uce'
|
||||||
|
* library so that the header can be made public
|
||||||
|
*
|
||||||
|
* Revision 1.6 2002/04/12 16:22:04 tr
|
||||||
|
* Unified Compiling Environment (UCE) replaced `std' library
|
||||||
|
*
|
||||||
|
* Revision 1.5 2001/07/20 16:33:40 tr
|
||||||
|
* moved to `std' library and re-named defines accordingly
|
||||||
|
*
|
||||||
|
* Revision 1.4 2001/07/10 16:47:18 tronkko
|
||||||
|
* revised comments
|
||||||
|
*
|
||||||
|
* Revision 1.3 2001/01/11 13:16:43 tr
|
||||||
|
* using ``uce-machine.h'' for finding out defines such as `FREEBSD'
|
||||||
|
*
|
||||||
|
* Revision 1.2 2000/10/08 16:00:41 tr
|
||||||
|
* copy of FreeBSD man page
|
||||||
|
*
|
||||||
|
* Revision 1.1 2000/07/10 05:53:16 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
* Revision 1.2 1998/07/19 18:29:14 tr
|
||||||
|
* Added error reporting capabilities and some asserts.
|
||||||
|
*
|
||||||
|
* Revision 1.1 1998/07/04 16:27:51 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MSVC 1.0 scans automatic dependencies incorrectly when your project
|
||||||
|
* contains this very header. The problem is that MSVC cannot handle
|
||||||
|
* include directives inside #if..#endif block those are never entered.
|
||||||
|
* Since this header ought to compile in many different operating systems,
|
||||||
|
* there had to be several conditional blocks that are compiled only in
|
||||||
|
* operating systems for what they were designed for. MSVC 1.0 cannot
|
||||||
|
* handle inclusion of sys/dir.h in a part that is compiled only in Apollo
|
||||||
|
* operating system. To fix the problem you need to insert DIR.H into
|
||||||
|
* SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
|
||||||
|
* Consult manuals for more informaton about the problem.
|
||||||
|
*
|
||||||
|
* Since many UNIX systems have dirent.h we assume to have one also.
|
||||||
|
* However, if your UNIX system does not have dirent.h you can download one
|
||||||
|
* for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
|
||||||
|
* You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
|
||||||
|
* sys/dir.h and sys/ndir.h somewhere. Try defining HAVE_DIRENT_H,
|
||||||
|
* HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
|
||||||
|
* HAVE_SYS_NDIR_H according to the files found.
|
||||||
|
*/
|
||||||
|
#ifndef DIRENT_H
|
||||||
|
#define DIRENT_H
|
||||||
|
#define DIRENT_H_INCLUDED
|
||||||
|
|
||||||
|
/* find out platform */
|
||||||
|
#if defined(MSDOS) /* MS-DOS */
|
||||||
|
#elif defined(__MSDOS__) /* Turbo C/Borland */
|
||||||
|
# define MSDOS
|
||||||
|
#elif defined(__DOS__) /* Watcom */
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) /* MS-Windows */
|
||||||
|
#elif defined(__NT__) /* Watcom */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(_WIN32) /* Microsoft */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(__WIN32__) /* Borland */
|
||||||
|
# define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See what kind of dirent interface we have unless autoconf has already
|
||||||
|
* determinated that.
|
||||||
|
*/
|
||||||
|
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||||
|
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__MINGW32__) /* MinGW */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# define VOID_CLOSEDIR
|
||||||
|
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||||
|
# define HAVE_DIRECT_H
|
||||||
|
# elif defined(__apollo) /* Apollo */
|
||||||
|
# define HAVE_SYS_DIR_H
|
||||||
|
# elif defined(__hpux) /* HP-UX */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__alpha) || defined(__alpha__) /* Alpha OSF1 */
|
||||||
|
# error "not implemented"
|
||||||
|
# elif defined(__sgi) /* Silicon Graphics */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(sun) || defined(_sun) /* Sun Solaris */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__FreeBSD__) /* FreeBSD */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__linux__) /* Linux */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__GNUC__) /* GNU C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# else
|
||||||
|
# error "not implemented"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* include proper interface headers */
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
|
# include <dirent.h>
|
||||||
|
# ifdef FREEBSD
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
# else
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(HAVE_NDIR_H)
|
||||||
|
# include <ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_NDIR_H)
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIRECT_H)
|
||||||
|
# include <direct.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIR_H)
|
||||||
|
# include <dir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_DIR_H)
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# ifndef dirent
|
||||||
|
# define dirent direct
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(MSDOS) || defined(WIN32)
|
||||||
|
|
||||||
|
/* figure out type of underlaying directory interface to be used */
|
||||||
|
# if defined(WIN32)
|
||||||
|
# define DIRENT_WIN32_INTERFACE
|
||||||
|
# elif defined(MSDOS)
|
||||||
|
# define DIRENT_MSDOS_INTERFACE
|
||||||
|
# else
|
||||||
|
# error "missing native dirent interface"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** WIN32 specifics ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
# include <windows.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (MAX_PATH)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*** MS-DOS specifics ***/
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# include <dos.h>
|
||||||
|
|
||||||
|
/* Borland defines file length macros in dir.h */
|
||||||
|
# if defined(__BORLANDC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# if !defined(_find_t)
|
||||||
|
# define _find_t find_t
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Turbo C defines ffblk structure in dir.h */
|
||||||
|
# elif defined(__TURBOC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# define DIRENT_USE_FFBLK
|
||||||
|
|
||||||
|
/* MSVC */
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Watcom */
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# if defined(__OS2__) || defined(__NT__)
|
||||||
|
# define DIRENT_MAXNAMLEN (255)
|
||||||
|
# else
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||||
|
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||||
|
# endif
|
||||||
|
# if NAME_MAX < DIRENT_MAXNAMLEN
|
||||||
|
# error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||||
|
* true character array although we have it copied in the implementation
|
||||||
|
* dependent data. We could save some memory if we had declared `d_name'
|
||||||
|
* as a pointer referring the name within implementation dependent data.
|
||||||
|
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||||
|
* something other than four. Besides, directory entries are typically so
|
||||||
|
* small that it takes virtually no time to copy them from place to place.
|
||||||
|
*/
|
||||||
|
typedef struct dirent {
|
||||||
|
char d_name[NAME_MAX + 1];
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE) /*WIN32*/
|
||||||
|
WIN32_FIND_DATA data;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE) /*MSDOS*/
|
||||||
|
# if defined(DIRENT_USE_FFBLK)
|
||||||
|
struct ffblk data;
|
||||||
|
# else
|
||||||
|
struct _find_t data;
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
} dirent;
|
||||||
|
|
||||||
|
/* DIR substitute structure containing directory name. The name is
|
||||||
|
* essential for the operation of ``rewinndir'' function. */
|
||||||
|
typedef struct DIR {
|
||||||
|
char *dirname; /* directory being scanned */
|
||||||
|
dirent current; /* current entry */
|
||||||
|
int dirent_filled; /* is current un-processed? */
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
HANDLE search_handle;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# endif
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* supply prototypes for dirent functions */
|
||||||
|
static DIR *opendir(const char *dirname);
|
||||||
|
static struct dirent *readdir(DIR *dirp);
|
||||||
|
static int closedir(DIR *dirp);
|
||||||
|
static void rewinddir(DIR *dirp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implement dirent interface as static functions so that the user does not
|
||||||
|
* need to change his project in any way to use dirent function. With this
|
||||||
|
* it is sufficient to include this very header from source modules using
|
||||||
|
* dirent functions and the functions will be pulled in automatically.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* use ffblk instead of _find_t if requested */
|
||||||
|
#if defined(DIRENT_USE_FFBLK)
|
||||||
|
# define _A_ARCH (FA_ARCH)
|
||||||
|
# define _A_HIDDEN (FA_HIDDEN)
|
||||||
|
# define _A_NORMAL (0)
|
||||||
|
# define _A_RDONLY (FA_RDONLY)
|
||||||
|
# define _A_SUBDIR (FA_DIREC)
|
||||||
|
# define _A_SYSTEM (FA_SYSTEM)
|
||||||
|
# define _A_VOLID (FA_LABEL)
|
||||||
|
# define _dos_findnext(dest) findnext(dest)
|
||||||
|
# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int _initdir(DIR *p);
|
||||||
|
static const char *_getdirname(const struct dirent *dp);
|
||||||
|
static void _setdirname(struct DIR *dirp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="opendir">
|
||||||
|
* <intro>open directory stream for reading
|
||||||
|
* <syntax>DIR *opendir (const char *dirname);
|
||||||
|
*
|
||||||
|
* <desc>Open named directory stream for read and return pointer to the
|
||||||
|
* internal working area that is used for retrieving individual directory
|
||||||
|
* entries. The internal working area has no fields of your interest.
|
||||||
|
*
|
||||||
|
* <ret>Returns a pointer to the internal working area or NULL in case the
|
||||||
|
* directory stream could not be opened. Global `errno' variable will set
|
||||||
|
* in case of error as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EACESS |Permission denied.
|
||||||
|
* [EMFILE |Too many open files used by the process.
|
||||||
|
* [ENFILE |Too many open files in system.
|
||||||
|
* [ENOENT |Directory does not exist.
|
||||||
|
* [ENOMEM |Insufficient memory.
|
||||||
|
* [ENOTDIR |dirname does not refer to directory. This value is not
|
||||||
|
* reliable on MS-DOS and MS-Windows platforms. Many
|
||||||
|
* implementations return ENOENT even when the name refers to a
|
||||||
|
* file.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static DIR *opendir(const char *dirname)
|
||||||
|
{
|
||||||
|
DIR *dirp;
|
||||||
|
assert(dirname != NULL);
|
||||||
|
|
||||||
|
dirp = (DIR*)malloc(sizeof(struct DIR));
|
||||||
|
if (dirp != NULL) {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
/* allocate room for directory name */
|
||||||
|
dirp->dirname = (char*) malloc(strlen(dirname) + 1 + strlen("\\*.*"));
|
||||||
|
if (dirp->dirname == NULL) {
|
||||||
|
/* failed to duplicate directory name. errno set by malloc() */
|
||||||
|
free(dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Copy directory name while appending directory separator and "*.*".
|
||||||
|
* Directory separator is not appended if the name already ends with
|
||||||
|
* drive or directory separator. Directory separator is assumed to be
|
||||||
|
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||||
|
strcpy(dirp->dirname, dirname);
|
||||||
|
p = strchr(dirp->dirname, '\0');
|
||||||
|
if (dirp->dirname < p &&
|
||||||
|
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
||||||
|
strcpy(p++, "\\");
|
||||||
|
}
|
||||||
|
# ifdef DIRENT_WIN32_INTERFACE
|
||||||
|
strcpy(p, "*"); /*scan files with and without extension in win32*/
|
||||||
|
# else
|
||||||
|
strcpy(p, "*.*"); /*scan files with and without extension in DOS*/
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* open stream */
|
||||||
|
if (_initdir(dirp) == 0) {
|
||||||
|
/* initialization failed */
|
||||||
|
free(dirp->dirname);
|
||||||
|
free(dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="readdir">
|
||||||
|
* <intro>read a directory entry
|
||||||
|
* <syntax>struct dirent *readdir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Read individual directory entry and return pointer to a structure
|
||||||
|
* containing the name of the entry. Individual directory entries returned
|
||||||
|
* include normal files, sub-directories, pseudo-directories "." and ".."
|
||||||
|
* and also volume labels, hidden files and system files in MS-DOS and
|
||||||
|
* MS-Windows. You might want to use stat(2) function to determinate which
|
||||||
|
* one are you dealing with. Many dirent implementations already contain
|
||||||
|
* equivalent information in dirent structure but you cannot depend on
|
||||||
|
* this.
|
||||||
|
*
|
||||||
|
* The dirent structure contains several system dependent fields that
|
||||||
|
* generally have no interest to you. The only interesting one is char
|
||||||
|
* d_name[] that is also portable across different systems. The d_name
|
||||||
|
* field contains the name of the directory entry without leading path.
|
||||||
|
* While d_name is portable across different systems the actual storage
|
||||||
|
* capacity of d_name varies from system to system and there is no portable
|
||||||
|
* way to find out it at compile time as different systems define the
|
||||||
|
* capacity of d_name with different macros and some systems do not define
|
||||||
|
* capacity at all (besides actual declaration of the field). If you really
|
||||||
|
* need to find out storage capacity of d_name then you might want to try
|
||||||
|
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard although
|
||||||
|
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||||
|
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||||
|
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||||
|
* Decamps (Alain.Decamps@advalvas.be) for pointing it out to me.
|
||||||
|
*
|
||||||
|
* This all leads to the fact that it is difficult to allocate space
|
||||||
|
* for the directory names when the very same program is being compiled on
|
||||||
|
* number of operating systems. Therefore I suggest that you always
|
||||||
|
* allocate space for directory names dynamically.
|
||||||
|
*
|
||||||
|
* <ret>
|
||||||
|
* Returns a pointer to a structure containing name of the directory entry
|
||||||
|
* in `d_name' field or NULL if there was an error. In case of an error the
|
||||||
|
* global `errno' variable will set as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EBADF |dir parameter refers to an invalid directory stream. This value
|
||||||
|
* is not set reliably on all implementations.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static struct dirent *
|
||||||
|
readdir(DIR *dirp)
|
||||||
|
{
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dirp->dirent_filled != 0) {
|
||||||
|
/*
|
||||||
|
* Directory entry has already been retrieved and there is no need to
|
||||||
|
* retrieve a new one. Directory entry will be retrieved in advance
|
||||||
|
* when the user calls readdir function for the first time. This is so
|
||||||
|
* because real dirent has separate functions for opening and reading
|
||||||
|
* the stream whereas Win32 and DOS dirents open the stream
|
||||||
|
* automatically when we retrieve the first file. Therefore, we have to
|
||||||
|
* save the first file when opening the stream and later we have to
|
||||||
|
* return the saved entry when the user tries to read the first entry.
|
||||||
|
*/
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
} else {
|
||||||
|
/* fill in entry and return that */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (FindNextFile(dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||||
|
/* Last file has been processed or an error occurred */
|
||||||
|
FindClose(dirp->search_handle);
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
errno = ENOENT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findnext(&dirp->current.data) != 0) {
|
||||||
|
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
_setdirname(dirp);
|
||||||
|
assert(dirp->dirent_filled == 0);
|
||||||
|
}
|
||||||
|
return &dirp->current;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="closedir">
|
||||||
|
* <intro>close directory stream.
|
||||||
|
* <syntax>int closedir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Close directory stream opened by the `opendir' function. Close of
|
||||||
|
* directory stream invalidates the DIR structure as well as previously read
|
||||||
|
* dirent entry.
|
||||||
|
*
|
||||||
|
* <ret>The function typically returns 0 on success and -1 on failure but
|
||||||
|
* the function may be declared to return void on same systems. At least
|
||||||
|
* Borland C/C++ and some UNIX implementations use void as a return type.
|
||||||
|
* The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
|
||||||
|
* known to return nothing. The very same definition is made by the GNU
|
||||||
|
* autoconf if you happen to use it.
|
||||||
|
*
|
||||||
|
* The global `errno' variable will set to EBADF in case of error.
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
closedir(DIR *dirp)
|
||||||
|
{
|
||||||
|
int retcode = 0;
|
||||||
|
|
||||||
|
/* make sure that dirp points to legal structure */
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free directory name and search handles */
|
||||||
|
if (dirp->dirname != NULL) {
|
||||||
|
free(dirp->dirname);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose(dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
retcode = -1;
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||||
|
memset(dirp, 0, sizeof(*dirp));
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
free(dirp);
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="rewinddir">
|
||||||
|
* <intro>rewind directory stream to the beginning
|
||||||
|
* <syntax>void rewinddir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Rewind directory stream to the beginning so that the next call of
|
||||||
|
* readdir() returns the very first directory entry again. However, note
|
||||||
|
* that next call of readdir() may not return the same directory entry as it
|
||||||
|
* did in first time. The directory stream may have been affected by newly
|
||||||
|
* created files.
|
||||||
|
*
|
||||||
|
* Almost every dirent implementation ensure that rewinddir will update
|
||||||
|
* the directory stream to reflect any changes made to the directory entries
|
||||||
|
* since the previous ``opendir'' or ``rewinddir'' call. Keep an eye on
|
||||||
|
* this if your program depends on the feature. I know at least one dirent
|
||||||
|
* implementation where you are required to close and re-open the stream to
|
||||||
|
* see the changes.
|
||||||
|
*
|
||||||
|
* <ret>Returns nothing. If something went wrong while rewinding, you will
|
||||||
|
* notice it later when you try to retrieve the first directory entry.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
rewinddir(DIR *dirp)
|
||||||
|
{
|
||||||
|
/* make sure that dirp is legal */
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assert(dirp->dirname != NULL);
|
||||||
|
|
||||||
|
/* close previous stream */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose(dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* re-open previous stream */
|
||||||
|
if (_initdir(dirp) == 0) {
|
||||||
|
/* initialization failed but we cannot deal with error. User will notice
|
||||||
|
* error later when she tries to retrieve first directory enty. */
|
||||||
|
/*EMPTY*/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open native directory stream object and retrieve first file.
|
||||||
|
* Be sure to close previous stream before opening new one.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
_initdir(DIR *dirp)
|
||||||
|
{
|
||||||
|
assert(dirp != NULL);
|
||||||
|
assert(dirp->dirname != NULL);
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
/* Open stream and retrieve first file */
|
||||||
|
dirp->search_handle = FindFirstFile(dirp->dirname, &dirp->current.data);
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* something went wrong but we don't know what. GetLastError() could
|
||||||
|
* give us more information about the error, but then we should map
|
||||||
|
* the error code into errno. */
|
||||||
|
errno = ENOENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findfirst(dirp->dirname,
|
||||||
|
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||||
|
&dirp->current.data) != 0) {
|
||||||
|
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* initialize DIR and it's first entry */
|
||||||
|
_setdirname(dirp);
|
||||||
|
dirp->dirent_filled = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return implementation dependent name of the current directory entry.
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
_getdirname(const struct dirent *dp)
|
||||||
|
{
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
return dp->data.cFileName;
|
||||||
|
|
||||||
|
#elif defined(DIRENT_USE_FFBLK)
|
||||||
|
return dp->data.ff_name;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return dp->data.name;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy name of implementation dependent directory entry to the d_name field.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_setdirname(struct DIR *dirp)
|
||||||
|
{
|
||||||
|
/* make sure that d_name is long enough */
|
||||||
|
assert(strlen(_getdirname(&dirp->current)) <= NAME_MAX);
|
||||||
|
|
||||||
|
strncpy(dirp->current.d_name,
|
||||||
|
_getdirname(&dirp->current),
|
||||||
|
NAME_MAX);
|
||||||
|
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
|
||||||
|
#else
|
||||||
|
# error "missing dirent interface"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*DIRENT_H*/
|
|
@ -0,0 +1,161 @@
|
||||||
|
# Headers file are located here:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common # opj_getopt.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/jp2 # convert.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip
|
||||||
|
${FCGI_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Tool to embed metadata into JP2 file
|
||||||
|
add_executable(opj_jpip_addxml opj_jpip_addxml.c)
|
||||||
|
# Install exe
|
||||||
|
install(TARGETS opj_jpip_addxml
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_JPIP_SERVER)
|
||||||
|
set(OPJ_SERVER_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_server.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build executable
|
||||||
|
add_executable(opj_server ${OPJ_SERVER_SRCS})
|
||||||
|
target_link_libraries(opj_server ${FCGI_LIBRARIES} openjpip_server)
|
||||||
|
set_property(
|
||||||
|
TARGET opj_server
|
||||||
|
APPEND PROPERTY
|
||||||
|
COMPILE_DEFINITIONS SERVER QUIT_SIGNAL="quitJPIP"
|
||||||
|
)
|
||||||
|
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(opj_server m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Install exe
|
||||||
|
install(TARGETS opj_server
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(EXES
|
||||||
|
opj_dec_server
|
||||||
|
opj_jpip_transcode
|
||||||
|
opj_jpip_test
|
||||||
|
)
|
||||||
|
foreach(exe ${EXES})
|
||||||
|
add_executable(${exe} ${exe}.c)
|
||||||
|
target_link_libraries(${exe} openjpip)
|
||||||
|
install(TARGETS ${exe}
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Build the two java clients:
|
||||||
|
find_package(Java 1.5 COMPONENTS Development) # javac, jar
|
||||||
|
|
||||||
|
# User can override this:
|
||||||
|
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||||
|
set(JAVA_SOURCE_VERSION 1.5)
|
||||||
|
endif()
|
||||||
|
if(NOT DEFINED JAVA_TARGET_VERSION)
|
||||||
|
set(JAVA_TARGET_VERSION 1.5)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Only build the java viewer if dev is found:
|
||||||
|
if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE)
|
||||||
|
set(jflags $ENV{JFLAGS})
|
||||||
|
# search for package org.apache.xerces.parsers
|
||||||
|
find_file(APACHE_XERCES_JAR
|
||||||
|
NAMES xerces-j2.jar xercesImpl.jar
|
||||||
|
PATHS /usr/share/java/
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
mark_as_advanced(APACHE_XERCES_JAR)
|
||||||
|
|
||||||
|
# Decide to build the simple viewer or the xerces one:
|
||||||
|
if(EXISTS ${APACHE_XERCES_JAR})
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
# build dep list:
|
||||||
|
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
||||||
|
|
||||||
|
# Need some common files:
|
||||||
|
list(APPEND java2_srcs
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
||||||
|
)
|
||||||
|
|
||||||
|
# make sure target javac dir exists:
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
||||||
|
# Build java
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||||
|
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||||
|
-classpath ${APACHE_XERCES_JAR}
|
||||||
|
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
||||||
|
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||||
|
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
||||||
|
DEPENDS ${java2_srcs}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||||
|
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# name the target
|
||||||
|
add_custom_target(OPJViewerXercesJar ALL
|
||||||
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
COMMENT "building opj_jpip_viewer.jar (xerces)"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# opj_viewer (simple, no xerces)
|
||||||
|
# build dep list:
|
||||||
|
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
||||||
|
|
||||||
|
# make sure target javac dir exists:
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
||||||
|
# Build java
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||||
|
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||||
|
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
||||||
|
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
||||||
|
DEPENDS ${java1_srcs}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
||||||
|
COMMENT "javac *.java; jar cvf -> opj_jpip_viewer.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# name the target
|
||||||
|
add_custom_target(OPJViewerJar ALL
|
||||||
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
COMMENT "building opj_jpip_viewer.jar (no xerces found)"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "No java compiler found. Wont be able to build java viewer")
|
||||||
|
endif()
|
|
@ -0,0 +1,149 @@
|
||||||
|
========================================================================
|
||||||
|
OpenJPIP software 2.1 ReadMe
|
||||||
|
|
||||||
|
OpenJPEG:
|
||||||
|
http://www.openjpeg.org
|
||||||
|
|
||||||
|
Written by:
|
||||||
|
Kaori Hagihara
|
||||||
|
UCL/SST/ICTM/ELEN
|
||||||
|
February 18 2011
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
1. Introduction
|
||||||
|
2. License
|
||||||
|
3. System requirements
|
||||||
|
4. Implementing instructions
|
||||||
|
5. JP2 encoding instructions
|
||||||
|
|
||||||
|
|
||||||
|
----------
|
||||||
|
1. Introduction
|
||||||
|
----------
|
||||||
|
|
||||||
|
OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).
|
||||||
|
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
|
||||||
|
The current implementation uses some results from the 2KAN project (http://www.2kan.org).
|
||||||
|
|
||||||
|
Version 2.1 covers:
|
||||||
|
- JPT-stream (Tile) and JPP-stream (Precinct) media types
|
||||||
|
- Session, channels, cache model managements
|
||||||
|
- JPIP over HTTP, HTTP requests and TCP return
|
||||||
|
- Indexing JPEG 2000 files
|
||||||
|
- Embedding XML formatted metadata
|
||||||
|
- Region Of Interest (ROI) requests
|
||||||
|
- Access to JP2 files with their URL
|
||||||
|
|
||||||
|
----------
|
||||||
|
2. License
|
||||||
|
----------
|
||||||
|
|
||||||
|
This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.
|
||||||
|
The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||||
|
Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
|
||||||
|
----------
|
||||||
|
3. System requirements
|
||||||
|
----------
|
||||||
|
|
||||||
|
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||||
|
- libcURL library
|
||||||
|
- Java application launcher at client
|
||||||
|
<Optional>
|
||||||
|
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
|
||||||
|
|
||||||
|
We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||||
|
|
||||||
|
----------
|
||||||
|
4. Building instructions
|
||||||
|
----------
|
||||||
|
|
||||||
|
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
|
||||||
|
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
|
||||||
|
|
||||||
|
The documentation can be build this way (requires doxygen utility):
|
||||||
|
cd doc
|
||||||
|
doxygen Doxyfile
|
||||||
|
|
||||||
|
----------
|
||||||
|
5. Usage
|
||||||
|
----------
|
||||||
|
|
||||||
|
Preliminary notes :
|
||||||
|
* HTML documentation is available at http://www.openjpeg.org/jpip/doc/html
|
||||||
|
* Example image is available at http://www.openjpeg.org/jpip/data/copenhague1.zip (20 Mb !)
|
||||||
|
|
||||||
|
Webserver:
|
||||||
|
You need a webserver running with the fastcgi module enabled and correctly configured.
|
||||||
|
For Apache, add the following line to your /etc/apache2/mods-available/fastcgi.conf configuration file:
|
||||||
|
|
||||||
|
FastCGIExternalServer /var/www/myFCGI -host localhost:3000
|
||||||
|
|
||||||
|
where /var/www is your DocumentRoot.
|
||||||
|
Please refer to 'http://www.openjpeg.org/jpip/doc/ApacheFastCGITutorial.pdf' for more details.
|
||||||
|
|
||||||
|
Server:
|
||||||
|
1. Store JP2 files in the same directory as opj_server
|
||||||
|
|
||||||
|
2. Launch opj_server from the server terminal:
|
||||||
|
% spawn-fcgi -f ./opj_server -p 3000 -n
|
||||||
|
|
||||||
|
For shutting down JPIP server:
|
||||||
|
%GET http://hostname/myFCGI?quitJPIP
|
||||||
|
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
|
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
|
||||||
|
|
||||||
|
Client:
|
||||||
|
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||||
|
% ./opj_dec_server [portnumber (50000 by default)]
|
||||||
|
|
||||||
|
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||||
|
% mkdir cache
|
||||||
|
% cd cache
|
||||||
|
% ../opj_dec_server
|
||||||
|
|
||||||
|
2. Open image viewers (as many as needed)
|
||||||
|
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||||
|
( The arguments
|
||||||
|
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
|
- path/filename.jp2 is the server local path or URL of a JP2 file
|
||||||
|
- host name of opj_dec_server, localhost by default
|
||||||
|
- portnumber of opj_dec_server, 50000 by default
|
||||||
|
- request type stateless for no caching, session (default) for caching
|
||||||
|
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
||||||
|
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
||||||
|
Image viewer GUI instructions:
|
||||||
|
Scale up request: Enlarge the window
|
||||||
|
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
|
||||||
|
<If Xerces2 is installed>
|
||||||
|
% java -jar opj_viewer_xerces.jar http://hostname/myFCGI JP2_filename.jp2
|
||||||
|
Annotate image with ROI information in XML metadata: Click button "Region Of Interest"
|
||||||
|
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
|
||||||
|
|
||||||
|
3. Quit the image decoding server through the telnet, be sure all image viewers are closed
|
||||||
|
% telnet localhost 50000
|
||||||
|
quit
|
||||||
|
|
||||||
|
----------
|
||||||
|
5. JP2 encoding instructions
|
||||||
|
----------
|
||||||
|
|
||||||
|
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
|
||||||
|
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
||||||
|
|
||||||
|
options
|
||||||
|
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
||||||
|
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
||||||
|
|
||||||
|
<Option>
|
||||||
|
3. Embed metadata into JP2 file
|
||||||
|
% ./addXMLinJP2 copenhague1.jp2 copenhague1.xml
|
||||||
|
Input metadata file "copenhague1.xml" looks like:
|
||||||
|
<xmlbox>
|
||||||
|
<roi name="island" x="1890" y="1950" w="770" h="310"/>
|
||||||
|
<roi name="ship" x="750" y="330" w="100" h="60"/>
|
||||||
|
<roi name="airport" x="650" y="1800" w="650" h="800"/>
|
||||||
|
<roi name="harbor" x="4200" y="1650" w="130" h="130"/>
|
||||||
|
<irt refimg="name1.jp2" m1="0.50" m2="-0.50" m3="0" m4="0.80" m5="-0.80" m6="0" m7="500" m8="1000" m9="0"/>
|
||||||
|
</xmlbox>
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* $Id: opj_dec_server.c 54 2011-05-10 13:22:47Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief opj_dec_server is a server to decode JPT-stream and communicate locally with JPIP client, which is coded in java.
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
||||||
|
* % ./opj_dec_server [portnumber]\n
|
||||||
|
* ( portnumber=50000 by default)\n
|
||||||
|
* Keep it alive as long as image viewers are open.\n
|
||||||
|
*
|
||||||
|
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
||||||
|
* % telnet localhost 50000\n
|
||||||
|
* quit\n
|
||||||
|
* Be sure all image viewers are closed.\n
|
||||||
|
* Cache file in JPT format is stored in the working directly before it quites.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjpip.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA initialisation_win32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
dec_server_record_t *server_record;
|
||||||
|
client_t client;
|
||||||
|
int port = 50000;
|
||||||
|
int erreur;
|
||||||
|
(void)erreur;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
port = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
erreur = WSAStartup(MAKEWORD(2, 2), &initialisation_win32);
|
||||||
|
if (erreur != 0) {
|
||||||
|
fprintf(stderr, "Erreur initialisation Winsock error : %d %d\n", erreur,
|
||||||
|
WSAGetLastError());
|
||||||
|
} else {
|
||||||
|
printf("Initialisation Winsock\n");
|
||||||
|
}
|
||||||
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
|
server_record = init_dec_server(port);
|
||||||
|
|
||||||
|
while ((client = accept_connection(server_record)) != -1)
|
||||||
|
if (!handle_clientreq(client, server_record)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminate_dec_server(&server_record);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (WSACleanup() != 0) {
|
||||||
|
printf("\nError in WSACleanup : %d %d", erreur, WSAGetLastError());
|
||||||
|
} else {
|
||||||
|
printf("\nWSACleanup OK\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
/*
|
||||||
|
* $Id: addXMLinJP2.c 46 2011-02-17 14:50:55Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief addXMLinJP2 is a program to embed metadata into JP2 file
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* This program takes two arguments. \n
|
||||||
|
* -# Input/output image file in JP2 format, this JP2 file is being modified
|
||||||
|
* -# Input XML file with metadata contents\n
|
||||||
|
* % ./addXMLinJP2 image.jp2 metadata.xml\n
|
||||||
|
*
|
||||||
|
* Currently, this program does not parse XML file, and the XML file contents is directly embedded as a XML Box.\n
|
||||||
|
* The following is an example of XML file contents specifying Region Of Interests with target names.\n
|
||||||
|
* <xmlbox>\n
|
||||||
|
* <roi name="island" x="1890" y="1950" w="770" h="310"/>\n
|
||||||
|
* <roi name="ship" x="750" y="330" w="100" h="60"/>\n
|
||||||
|
* <roi name="airport" x="650" y="1800" w="650" h="800"/>\n
|
||||||
|
* <roi name="harbor" x="4200" y="1650" w="130" h="130"/>\n
|
||||||
|
* </xmlbox>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open JP2 file with the check of JP2 header
|
||||||
|
*
|
||||||
|
* @param[in] filename file name string
|
||||||
|
* @return file descriptor
|
||||||
|
*/
|
||||||
|
FILE * open_jp2file(const char filename[]);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read xml file without any format check for the moment
|
||||||
|
*
|
||||||
|
* @param[in] filename file name string
|
||||||
|
* @param[out] fsize file byte size
|
||||||
|
* @return pointer to the xml file content buffer
|
||||||
|
*/
|
||||||
|
char * read_xmlfile(const char filename[], long *fsize);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *xmldata, type[] = "xml ";
|
||||||
|
long fsize, boxsize;
|
||||||
|
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "USAGE: %s modifing.jp2 adding.xml\n", argv[0]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = open_jp2file(argv[1]);
|
||||||
|
if (!fp) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmldata = read_xmlfile(argv[2], &fsize);
|
||||||
|
if (fsize < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
boxsize = fsize + 8;
|
||||||
|
|
||||||
|
fputc((boxsize >> 24) & 0xff, fp);
|
||||||
|
fputc((boxsize >> 16) & 0xff, fp);
|
||||||
|
fputc((boxsize >> 8) & 0xff, fp);
|
||||||
|
fputc(boxsize & 0xff, fp);
|
||||||
|
fwrite(type, 4, 1, fp);
|
||||||
|
fwrite(xmldata, (size_t)fsize, 1, fp);
|
||||||
|
|
||||||
|
free(xmldata);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE * open_jp2file(const char filename[])
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
if (!(fp = fopen(filename, "a+b"))) {
|
||||||
|
fprintf(stderr, "Original JP2 %s not found\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Check resource is a JP family file. */
|
||||||
|
if (fseek(fp, 0, SEEK_SET) == -1) {
|
||||||
|
fclose(fp);
|
||||||
|
fprintf(stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (char *)malloc(12); /* size of header */
|
||||||
|
if (fread(data, 12, 1, fp) != 1) {
|
||||||
|
free(data);
|
||||||
|
fclose(fp);
|
||||||
|
fprintf(stderr, "Original JP2 %s broken (read error)\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*data || *(data + 1) || *(data + 2) ||
|
||||||
|
*(data + 3) != 12 || strncmp(data + 4, "jP \r\n\x87\n", 8)) {
|
||||||
|
free(data);
|
||||||
|
fclose(fp);
|
||||||
|
fprintf(stderr, "No JPEG 2000 Signature box in target %s\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
free(data);
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * read_xmlfile(const char filename[], long *fsize)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
/* fprintf( stderr, "open %s\n", filename);*/
|
||||||
|
if (!(fp = fopen(filename, "r"))) {
|
||||||
|
fprintf(stderr, "XML file %s not found\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fseek(fp, 0, SEEK_END) == -1) {
|
||||||
|
fprintf(stderr, "XML file %s broken (seek error)\n", filename);
|
||||||
|
fclose(fp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*fsize = ftell(fp)) == -1) {
|
||||||
|
fprintf(stderr, "XML file %s broken (seek error)\n", filename);
|
||||||
|
fclose(fp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
assert(*fsize >= 0);
|
||||||
|
|
||||||
|
if (fseek(fp, 0, SEEK_SET) == -1) {
|
||||||
|
fprintf(stderr, "XML file %s broken (seek error)\n", filename);
|
||||||
|
fclose(fp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (char *)malloc((size_t) * fsize);
|
||||||
|
|
||||||
|
if (fread(data, (size_t)*fsize, 1, fp) != 1) {
|
||||||
|
fprintf(stderr, "XML file %s broken (read error)\n", filename);
|
||||||
|
free(data);
|
||||||
|
fclose(fp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* $Id: test_index.c 46 2011-02-17 14:50:55Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief test_index is a program to test the index code format of a JP2 file
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* This program takes one argument, and print out text type index information to the terminal. \n
|
||||||
|
* -# Input JP2 file\n
|
||||||
|
* % ./test_index input.jp2\n
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include "openjpip.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
index_t *jp2idx;
|
||||||
|
if (argc < 2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fd = open(argv[1], O_RDONLY)) == -1) {
|
||||||
|
fprintf(stderr, "Error: Target %s not found\n", argv[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(jp2idx = get_index_from_JP2file(fd))) {
|
||||||
|
fprintf(stderr, "JP2 file broken\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
output_index(jp2idx);
|
||||||
|
destroy_index(&jp2idx);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} /* main */
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "openjpip.h"
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief jpip_to_jp2 is a program to convert JPT- JPP- stream to JP2 file
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* This program takes two arguments. \n
|
||||||
|
* -# Input JPT or JPP file
|
||||||
|
* -# Output JP2 file\n
|
||||||
|
* % ./jpip_to_jp2 input.jpt output.jp2
|
||||||
|
* or
|
||||||
|
* % ./jpip_to_jp2 input.jpp output.jp2
|
||||||
|
*/
|
||||||
|
static int jpip_to_jp2(char *argv[])
|
||||||
|
{
|
||||||
|
jpip_dec_param_t *dec;
|
||||||
|
|
||||||
|
dec = init_jpipdecoder(OPJ_TRUE);
|
||||||
|
|
||||||
|
if (!(fread_jpip(argv[1], dec))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
decode_jpip(dec);
|
||||||
|
|
||||||
|
if (!(fwrite_jp2k(argv[2], dec))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_TRUE, dec); */
|
||||||
|
|
||||||
|
destroy_jpipdecoder(&dec);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief jpip_to_j2k is a program to convert JPT- JPP- stream to J2K file
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* This program takes two arguments. \n
|
||||||
|
* -# Input JPT or JPP file
|
||||||
|
* -# Output J2K file\n
|
||||||
|
* % ./jpip_to_j2k input.jpt output.j2k
|
||||||
|
* or
|
||||||
|
* % ./jpip_to_j2k input.jpp output.j2k
|
||||||
|
*/
|
||||||
|
static int jpip_to_j2k(char *argv[])
|
||||||
|
{
|
||||||
|
jpip_dec_param_t *dec;
|
||||||
|
|
||||||
|
dec = init_jpipdecoder(OPJ_FALSE);
|
||||||
|
|
||||||
|
if (!(fread_jpip(argv[1], dec))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
decode_jpip(dec);
|
||||||
|
|
||||||
|
if (!(fwrite_jp2k(argv[2], dec))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_FALSE, dec); */
|
||||||
|
|
||||||
|
destroy_jpipdecoder(&dec);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *ext;
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Too few arguments:\n");
|
||||||
|
fprintf(stderr, " - input jpt or jpp file\n");
|
||||||
|
fprintf(stderr, " - output j2k file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ext = strrchr(argv[2], '.');
|
||||||
|
if (ext) {
|
||||||
|
/* strcasecmp ? */
|
||||||
|
if (strcmp(ext, ".jp2") == 0) {
|
||||||
|
return jpip_to_jp2(argv);
|
||||||
|
}
|
||||||
|
if (strcmp(ext, ".j2k") == 0) {
|
||||||
|
return jpip_to_j2k(argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Invalid file extension for output file: %s\n", argv[2]);
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* $Id: opj_server.c 53 2011-05-09 16:55:39Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* \brief opj_server is a JPIP server program, which supports HTTP connection, JPT-stream, session, channels, and cache model managements.
|
||||||
|
*
|
||||||
|
* \section req Requirements
|
||||||
|
* FastCGI development kit (http://www.fastcgi.com).
|
||||||
|
*
|
||||||
|
* \section impinst Implementing instructions
|
||||||
|
* Launch opj_server from the server terminal:\n
|
||||||
|
* % spawn-fcgi -f ./opj_server -p 3000 -n
|
||||||
|
*
|
||||||
|
* Note: JP2 files are stored in the working directory of opj_server\n
|
||||||
|
* Check README for the JP2 Encoding\n
|
||||||
|
*
|
||||||
|
* We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#include "openjpip.h"
|
||||||
|
|
||||||
|
#ifndef QUIT_SIGNAL
|
||||||
|
#define QUIT_SIGNAL "quitJPIP"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA initialisation_win32;
|
||||||
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
server_record_t *server_record;
|
||||||
|
#ifdef SERVER
|
||||||
|
char *query_string;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
int erreur = WSAStartup(MAKEWORD(2, 2), &initialisation_win32);
|
||||||
|
if (erreur != 0) {
|
||||||
|
fprintf(stderr, "Erreur initialisation Winsock error : %d %d\n", erreur,
|
||||||
|
WSAGetLastError());
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Initialisation Winsock\n");
|
||||||
|
}
|
||||||
|
#endif /*_WIN32*/
|
||||||
|
|
||||||
|
server_record = init_JPIPserver(60000, 0);
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
while (FCGI_Accept() >= 0)
|
||||||
|
#else
|
||||||
|
|
||||||
|
char query_string[128];
|
||||||
|
while (fgets(query_string, 128, stdin) && query_string[0] != '\n')
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
QR_t *qr;
|
||||||
|
OPJ_BOOL parse_status;
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
query_string = getenv("QUERY_STRING");
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
if (strcmp(query_string, QUIT_SIGNAL) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qr = parse_querystring(query_string);
|
||||||
|
|
||||||
|
parse_status = process_JPIPrequest(server_record, qr);
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
local_log(OPJ_TRUE, OPJ_TRUE, parse_status, OPJ_FALSE, qr, server_record);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (parse_status) {
|
||||||
|
send_responsedata(server_record, qr);
|
||||||
|
} else {
|
||||||
|
fprintf(FCGI_stderr, "Error: JPIP request failed\n");
|
||||||
|
fprintf(FCGI_stdout, "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
end_QRprocess(server_record, &qr);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(FCGI_stderr, "JPIP server terminated by a client request\n");
|
||||||
|
|
||||||
|
terminate_JPIPserver(&server_record);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (WSACleanup() != 0) {
|
||||||
|
fprintf(stderr, "\nError in WSACleanup : %d %d", erreur, WSAGetLastError());
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "\nWSACleanup OK\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Ant-Version: Apache Ant 1.7.0
|
||||||
|
Created-By: Kaori Hagihara
|
||||||
|
Main-Class: ImageWindow
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
|
||||||
|
public class ImageManager extends JPIPHttpClient
|
||||||
|
{
|
||||||
|
private PnmImage pnmimage;
|
||||||
|
private int origwidth;
|
||||||
|
private int origheight;
|
||||||
|
private ImgdecClient imgdecoder;
|
||||||
|
|
||||||
|
public ImageManager( String uri, String host, int port)
|
||||||
|
{
|
||||||
|
super( uri);
|
||||||
|
imgdecoder = new ImgdecClient( host, port);
|
||||||
|
pnmimage = null;
|
||||||
|
origwidth = 0;
|
||||||
|
origheight = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrigWidth(){
|
||||||
|
if( origwidth == 0){
|
||||||
|
if( cid != null || tid != null){
|
||||||
|
java.awt.Dimension dim = imgdecoder.query_imagesize( cid, tid);
|
||||||
|
if( dim != null){
|
||||||
|
origwidth = dim.width;
|
||||||
|
origheight = dim.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Neither cid or tid obtained before to get Original Image Dimension");
|
||||||
|
}
|
||||||
|
return origwidth;
|
||||||
|
}
|
||||||
|
public int getOrigHeight(){ return origheight;}
|
||||||
|
|
||||||
|
public Image getImage( String j2kfilename, int reqfw, int reqfh, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
System.err.println();
|
||||||
|
|
||||||
|
String refcid = null;
|
||||||
|
byte[] jpipstream;
|
||||||
|
|
||||||
|
// Todo: check if the cid is for the same stream type
|
||||||
|
if( reqcnew)
|
||||||
|
refcid = imgdecoder.query_cid( j2kfilename);
|
||||||
|
|
||||||
|
if( refcid == null){
|
||||||
|
String reftid = imgdecoder.query_tid( j2kfilename);
|
||||||
|
if( reftid == null)
|
||||||
|
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
else
|
||||||
|
jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
|
||||||
|
System.err.println( "decoding to PNM image");
|
||||||
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
||||||
|
System.err.println( " done");
|
||||||
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.err.println( " failed");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
|
||||||
|
{
|
||||||
|
System.err.println();
|
||||||
|
|
||||||
|
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
||||||
|
|
||||||
|
System.err.println( "decoding to PNM image");
|
||||||
|
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
||||||
|
System.err.println( " done");
|
||||||
|
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.err.println( " failed");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getXML()
|
||||||
|
{
|
||||||
|
System.err.println();
|
||||||
|
|
||||||
|
byte []xmldata = null;
|
||||||
|
byte[] jpipstream = super.requestXML();
|
||||||
|
|
||||||
|
if( jpipstream != null){
|
||||||
|
imgdecoder.send_JPIPstream( jpipstream);
|
||||||
|
|
||||||
|
xmldata = imgdecoder.get_XMLstream( cid);
|
||||||
|
}
|
||||||
|
return xmldata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeChannel()
|
||||||
|
{
|
||||||
|
if( cid != null){
|
||||||
|
imgdecoder.destroy_cid( cid);
|
||||||
|
super.closeChannel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,266 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.image.*;
|
||||||
|
import java.awt.geom.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import javax.swing.border.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ImageViewer extends JPanel
|
||||||
|
{
|
||||||
|
private ImageManager imgmanager;
|
||||||
|
private int vw, vh;
|
||||||
|
private int iw, ih;
|
||||||
|
private int selected = 0;
|
||||||
|
private Image img;
|
||||||
|
|
||||||
|
private String cmdline = new String();
|
||||||
|
private boolean fullRefresh = false;
|
||||||
|
private Point offset = new Point(0,0);
|
||||||
|
private Rectangle rect = new Rectangle();
|
||||||
|
private Rectangle roirect[] = null;
|
||||||
|
private String roiname[] = null;
|
||||||
|
|
||||||
|
public ImageViewer( String j2kfilename, ImageManager manager, boolean session, boolean jppstream, int aux)
|
||||||
|
{
|
||||||
|
String str;
|
||||||
|
MML myMML;
|
||||||
|
|
||||||
|
this.setSize( 170, 170);
|
||||||
|
Dimension asz = this.getSize();
|
||||||
|
|
||||||
|
vw = asz.width;
|
||||||
|
vh = asz.height;
|
||||||
|
|
||||||
|
setBackground(Color.black);
|
||||||
|
myMML = new MML(this);
|
||||||
|
|
||||||
|
imgmanager = manager;
|
||||||
|
|
||||||
|
img = imgmanager.getImage( j2kfilename, vw, vh, session, aux, jppstream, !jppstream);
|
||||||
|
|
||||||
|
addMouseListener(myMML);
|
||||||
|
addMouseMotionListener(myMML);
|
||||||
|
addComponentListener( new ResizeListener(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage()
|
||||||
|
{
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zoomIn()
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
double scalex = (double)vw/(double)rect.width;
|
||||||
|
double scaley = (double)vh/(double)rect.height;
|
||||||
|
|
||||||
|
int fw = (int)(imgmanager.getFw()*scalex);
|
||||||
|
int fh = (int)(imgmanager.getFh()*scaley);
|
||||||
|
int rx = (int)((imgmanager.getRx()+rect.x)*scalex);
|
||||||
|
int ry = (int)((imgmanager.getRy()+rect.y)*scaley);
|
||||||
|
|
||||||
|
img = imgmanager.getImage( fw, fh, rx, ry, vw, vh);
|
||||||
|
|
||||||
|
rect.x = rect.y = rect.width = rect.height = 0;
|
||||||
|
|
||||||
|
selected = 0;
|
||||||
|
fullRefresh = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enlarge()
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
Dimension asz = this.getSize();
|
||||||
|
|
||||||
|
vw = asz.width;
|
||||||
|
vh = asz.height;
|
||||||
|
|
||||||
|
double scalex = vw/(double)imgmanager.getRw();
|
||||||
|
double scaley = vh/(double)imgmanager.getRh();
|
||||||
|
|
||||||
|
int fw = (int)(imgmanager.getFw()*scalex);
|
||||||
|
int fh = (int)(imgmanager.getFh()*scaley);
|
||||||
|
int rx = (int)(imgmanager.getRx()*scalex);
|
||||||
|
int ry = (int)(imgmanager.getRy()*scaley);
|
||||||
|
|
||||||
|
img = imgmanager.getImage( fw, fh, rx, ry, vw, vh);
|
||||||
|
|
||||||
|
fullRefresh = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(int state)
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
if (state != selected) {
|
||||||
|
|
||||||
|
selected = state;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInsideRect(int x, int y)
|
||||||
|
{
|
||||||
|
return rect.contains(x - offset.x, y - offset.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGeom(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
rect.x = Math.min(x1,x2) - offset.x;
|
||||||
|
rect.y = Math.min(y1,y2) - offset.y;
|
||||||
|
rect.width = Math.abs(x2-x1);
|
||||||
|
rect.height = Math.abs(y2-y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void annotate( JP2XMLparser.ROIparams roi[])
|
||||||
|
// {
|
||||||
|
// int numofroi = roi.length;
|
||||||
|
|
||||||
|
// roirect = new Rectangle [numofroi];
|
||||||
|
// roiname = new String [numofroi];
|
||||||
|
|
||||||
|
// double scale_x = imgmanager.getFw()/(double)imgmanager.getOrigWidth();
|
||||||
|
// double scale_y = imgmanager.getFh()/(double)imgmanager.getOrigHeight();
|
||||||
|
// int rx = imgmanager.getRx();
|
||||||
|
// int ry = imgmanager.getRy();
|
||||||
|
// int rw = imgmanager.getRw();
|
||||||
|
// int rh = imgmanager.getRh();
|
||||||
|
|
||||||
|
// for( int i=0; i<numofroi ; i++){
|
||||||
|
// int x = (int)(roi[i].x*scale_x) - rx;
|
||||||
|
// int y = (int)(roi[i].y*scale_y) - ry;
|
||||||
|
// int w = (int)(roi[i].w*scale_x);
|
||||||
|
// int h = (int)(roi[i].h*scale_y);
|
||||||
|
// if( 0<=x && 0<=y && x+w<=rw && y+h<=rh){ // can be optimized
|
||||||
|
// roirect[i] = new Rectangle( x, y, w, h);
|
||||||
|
// roiname[i] = new String( roi[i].name);
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// roirect[i] = null;
|
||||||
|
// roiname[i] = null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// repaint();
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean hasAnnotation()
|
||||||
|
{
|
||||||
|
if( roirect == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInsideROIRect(int x, int y)
|
||||||
|
{
|
||||||
|
for( int i=0; i<roirect.length; i++)
|
||||||
|
if( roirect[i] != null)
|
||||||
|
if( roirect[i].contains(x - offset.x, y - offset.y)){
|
||||||
|
rect = roirect[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
BufferedImage bi;
|
||||||
|
Graphics2D big;
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
|
||||||
|
if (fullRefresh) {
|
||||||
|
g2.clearRect(0, 0, vw, vh);
|
||||||
|
fullRefresh = false;
|
||||||
|
}
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
||||||
|
RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
|
|
||||||
|
offset.x = 0;
|
||||||
|
offset.y = 0;
|
||||||
|
|
||||||
|
iw = img.getWidth(this);
|
||||||
|
ih = img.getHeight(this);
|
||||||
|
|
||||||
|
bi = new BufferedImage( iw, ih, BufferedImage.TYPE_INT_RGB);
|
||||||
|
big = bi.createGraphics();
|
||||||
|
|
||||||
|
big.drawImage(img, 0, 0, this);
|
||||||
|
big.setPaint(Color.red);
|
||||||
|
if ((rect.width > 0) && (rect.height > 0))
|
||||||
|
big.draw(rect);
|
||||||
|
|
||||||
|
if( roirect != null){
|
||||||
|
for( int i=0; i<roirect.length; i++)
|
||||||
|
if( roirect[i] != null){
|
||||||
|
big.draw( roirect[i]);
|
||||||
|
big.drawString( roiname[i], roirect[i].x+3, roirect[i].y+roirect[i].height*2/3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selected == 1)
|
||||||
|
shadeExt(big, 0, 0, 0, 64);
|
||||||
|
else if (selected == 2) {
|
||||||
|
shadeExt(big, 0, 0, 0, 255);
|
||||||
|
selected = 1;
|
||||||
|
}
|
||||||
|
g2.drawImage(bi, offset.x, offset.y, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shadeRect(Graphics2D g2, int r, int g, int b, int a)
|
||||||
|
{
|
||||||
|
g2.setPaint(new Color(r, g, b, a));
|
||||||
|
g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shadeExt(Graphics2D g2, int r, int g, int b, int a)
|
||||||
|
{
|
||||||
|
g2.setPaint(new Color(r, g, b, a));
|
||||||
|
g2.fillRect(0, 0, iw, rect.y); /* _N_ */
|
||||||
|
g2.fillRect(rect.x + rect.width + 1, rect.y,
|
||||||
|
iw - rect.x - rect.width - 1, rect.height + 1); /* E */
|
||||||
|
g2.fillRect(0, rect.y, rect.x, rect.height + 1); /* W */
|
||||||
|
g2.fillRect(0, rect.y + rect.height + 1,
|
||||||
|
iw, ih - rect.y - rect.height - 1); /* _S_ */
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ImageWindow extends JFrame
|
||||||
|
{
|
||||||
|
private ImageViewer imgviewer;
|
||||||
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
|
{
|
||||||
|
super( j2kfilename);
|
||||||
|
|
||||||
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BorderLayout());
|
||||||
|
panel.add( imgviewer, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
setContentPane( panel);
|
||||||
|
|
||||||
|
addWindowListener(new WindowMyAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
class WindowMyAdapter extends WindowAdapter
|
||||||
|
{
|
||||||
|
public void windowClosing(WindowEvent arg)
|
||||||
|
{
|
||||||
|
imgmanager.closeChannel();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String s[])
|
||||||
|
{
|
||||||
|
String j2kfilename, uri, host;
|
||||||
|
boolean session, jppstream;
|
||||||
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
|
if(s.length >= 2){
|
||||||
|
uri = s[0];
|
||||||
|
j2kfilename = s[1];
|
||||||
|
|
||||||
|
if( s.length > 2)
|
||||||
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
|
else
|
||||||
|
session = true;
|
||||||
|
|
||||||
|
if( s.length > 5)
|
||||||
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
|
else
|
||||||
|
jppstream = true;
|
||||||
|
|
||||||
|
if( s.length > 6){
|
||||||
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
|
aux = 2;
|
||||||
|
else
|
||||||
|
aux = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aux = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
//Display the window.
|
||||||
|
frame.pack();
|
||||||
|
frame.setSize(new Dimension(400,200));
|
||||||
|
frame.setLocation( 0, 50);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,350 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
public class ImgdecClient{
|
||||||
|
|
||||||
|
private String hostname;
|
||||||
|
private int portNo;
|
||||||
|
|
||||||
|
public ImgdecClient( String host, int port)
|
||||||
|
{
|
||||||
|
hostname = host;
|
||||||
|
portNo = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage decode_jpipstream( byte[] jpipstream, String tid, String cid, int fw, int fh)
|
||||||
|
{
|
||||||
|
if( jpipstream != null)
|
||||||
|
send_JPIPstream( jpipstream);
|
||||||
|
return get_PNMstream( cid, tid, fw, fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage decode_jpipstream( byte[] jpipstream, String j2kfilename, String tid, String cid, int fw, int fh)
|
||||||
|
{
|
||||||
|
send_JPIPstream( jpipstream, j2kfilename, tid, cid);
|
||||||
|
return get_PNMstream( cid, tid, fw, fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send_JPIPstream( byte[] jpipstream)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
|
System.err.println("Sending " + jpipstream.length + "Data Bytes to decodingServer");
|
||||||
|
|
||||||
|
os.writeBytes("JPIP-stream\n");
|
||||||
|
os.writeBytes("version 1.2\n");
|
||||||
|
os.writeBytes( jpipstream.length + "\n");
|
||||||
|
os.write( jpipstream, 0, jpipstream.length);
|
||||||
|
|
||||||
|
byte signal = is.readByte();
|
||||||
|
|
||||||
|
if( signal == 0)
|
||||||
|
System.err.println(" failed");
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send_JPIPstream( byte[] jpipstream, String j2kfilename, String tid, String cid)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
int length = 0;
|
||||||
|
|
||||||
|
if( jpipstream != null)
|
||||||
|
length = jpipstream.length;
|
||||||
|
|
||||||
|
System.err.println("Sending " + length + "Data Bytes to decodingServer");
|
||||||
|
|
||||||
|
os.writeBytes("JPIP-stream\n");
|
||||||
|
os.writeBytes("version 1.2\n");
|
||||||
|
os.writeBytes( j2kfilename + "\n");
|
||||||
|
if( tid == null)
|
||||||
|
os.writeBytes( "0\n");
|
||||||
|
else
|
||||||
|
os.writeBytes( tid + "\n");
|
||||||
|
if( cid == null)
|
||||||
|
os.writeBytes( "0\n");
|
||||||
|
else
|
||||||
|
os.writeBytes( cid + "\n");
|
||||||
|
os.writeBytes( length + "\n");
|
||||||
|
os.write( jpipstream, 0, length);
|
||||||
|
|
||||||
|
byte signal = is.readByte();
|
||||||
|
|
||||||
|
if( signal == 0)
|
||||||
|
System.err.println(" failed");
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage get_PNMstream( String cid, String tid, int fw, int fh)
|
||||||
|
{
|
||||||
|
PnmImage pnmstream = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
byte []header = new byte[7];
|
||||||
|
|
||||||
|
os.writeBytes("PNM request\n");
|
||||||
|
if( cid != null)
|
||||||
|
os.writeBytes( cid + "\n");
|
||||||
|
else
|
||||||
|
if( tid != null)
|
||||||
|
os.writeBytes( tid + "\n");
|
||||||
|
else
|
||||||
|
os.writeBytes( "0\n");
|
||||||
|
os.writeBytes( fw + "\n");
|
||||||
|
os.writeBytes( fh + "\n");
|
||||||
|
|
||||||
|
read_stream( is, header, 7);
|
||||||
|
|
||||||
|
if( header[0] == 80){
|
||||||
|
// P5: gray, P6: color
|
||||||
|
byte magicknum = header[1];
|
||||||
|
if( magicknum == 5 || magicknum == 6){
|
||||||
|
int c = magicknum==6 ? 3: 1;
|
||||||
|
int w = (header[2]&0xff)<<8 | (header[3]&0xff);
|
||||||
|
int h = (header[4]&0xff)<<8 | (header[5]&0xff);
|
||||||
|
int maxval = header[6]&0xff;
|
||||||
|
int length = w*h*c;
|
||||||
|
|
||||||
|
if( maxval == 255 && length != 0){
|
||||||
|
pnmstream = new PnmImage( c, w, h);
|
||||||
|
read_stream( is, pnmstream.get_data(), length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in get_PNMstream(), only 255 is accepted");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in get_PNMstream(), wrong magick number" + header[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in get_PNMstream(), Not starting with P");
|
||||||
|
|
||||||
|
os.close();
|
||||||
|
is.close();
|
||||||
|
imgdecSocket.close();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
return pnmstream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte [] get_XMLstream( String cid)
|
||||||
|
{
|
||||||
|
byte []xmldata = null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
byte []header = new byte[5];
|
||||||
|
|
||||||
|
os.writeBytes("XML request\n");
|
||||||
|
os.writeBytes( cid + "\n");
|
||||||
|
|
||||||
|
read_stream( is, header, 5);
|
||||||
|
|
||||||
|
if( header[0] == 88 && header[1] == 77 && header[2] == 76){
|
||||||
|
int length = (header[3]&0xff)<<8 | (header[4]&0xff);
|
||||||
|
|
||||||
|
xmldata = new byte[ length];
|
||||||
|
read_stream( is, xmldata, length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in get_XMLstream(), not starting with XML");
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
return xmldata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String query_cid( String j2kfilename)
|
||||||
|
{
|
||||||
|
int []retmsglabel = new int[3];
|
||||||
|
retmsglabel[0] = 67;
|
||||||
|
retmsglabel[1] = 73;
|
||||||
|
retmsglabel[2] = 68;
|
||||||
|
|
||||||
|
return query_id( "CID request", j2kfilename, retmsglabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String query_tid( String j2kfilename)
|
||||||
|
{
|
||||||
|
int []retmsglabel = new int[3];
|
||||||
|
retmsglabel[0] = 84;
|
||||||
|
retmsglabel[1] = 73;
|
||||||
|
retmsglabel[2] = 68;
|
||||||
|
|
||||||
|
return query_id( "TID request", j2kfilename, retmsglabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String query_id( String reqmsghead, String j2kfilename, int[] retmsglabel)
|
||||||
|
{
|
||||||
|
String id = null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
byte []header = new byte[4];
|
||||||
|
|
||||||
|
os.writeBytes( reqmsghead + "\n");
|
||||||
|
os.writeBytes( j2kfilename + "\n");
|
||||||
|
|
||||||
|
read_stream( is, header, 4);
|
||||||
|
|
||||||
|
if( header[0] == retmsglabel[0] && header[1] == retmsglabel[1] && header[2] == retmsglabel[2]){
|
||||||
|
int length = header[3]&0xff;
|
||||||
|
|
||||||
|
if( length > 0){
|
||||||
|
|
||||||
|
byte []iddata = new byte[ length];
|
||||||
|
read_stream( is, iddata, length);
|
||||||
|
id = new String( iddata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in query_id("+ reqmsghead + "), wrong to start with " + header);
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.awt.Dimension query_imagesize( String cid, String tid)
|
||||||
|
{
|
||||||
|
java.awt.Dimension dim = null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
byte []header = new byte[3];
|
||||||
|
|
||||||
|
os.writeBytes( "SIZ request\n");
|
||||||
|
if( tid == null)
|
||||||
|
os.writeBytes( "0\n");
|
||||||
|
else
|
||||||
|
os.writeBytes( tid + "\n");
|
||||||
|
if( cid == null)
|
||||||
|
os.writeBytes( "0\n");
|
||||||
|
else
|
||||||
|
os.writeBytes( cid + "\n");
|
||||||
|
|
||||||
|
read_stream( is, header, 3);
|
||||||
|
|
||||||
|
if( header[0] == 83 && header[1] == 73 && header[2] == 90){
|
||||||
|
|
||||||
|
byte []data = new byte[ 3];
|
||||||
|
read_stream( is, data, 3);
|
||||||
|
int w = (data[0]&0xff)<<16 | (data[1]&0xff)<<8 | (data[2]&0xff);
|
||||||
|
read_stream( is, data, 3);
|
||||||
|
int h = (data[0]&0xff)<<16 | (data[1]&0xff)<<8 | (data[2]&0xff);
|
||||||
|
dim = new java.awt.Dimension( w, h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("Error in query_imagesize("+ cid + ", " + tid + "), wrong to start with " + header);
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void read_stream( DataInputStream is, byte []stream, int length)
|
||||||
|
{
|
||||||
|
int remlen = length;
|
||||||
|
int off = 0;
|
||||||
|
|
||||||
|
try{
|
||||||
|
while( remlen > 0){
|
||||||
|
int redlen = is.read( stream, off, remlen);
|
||||||
|
|
||||||
|
if( redlen == -1){
|
||||||
|
System.err.println(" failed to read_stream()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
off += redlen;
|
||||||
|
remlen -= redlen;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy_cid( String cid)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
Socket imgdecSocket = new Socket( hostname, portNo);
|
||||||
|
DataOutputStream os = new DataOutputStream( imgdecSocket.getOutputStream());
|
||||||
|
DataInputStream is = new DataInputStream( imgdecSocket.getInputStream());
|
||||||
|
|
||||||
|
os.writeBytes("CID destroy\n");
|
||||||
|
os.writeBytes( cid + "\n");
|
||||||
|
|
||||||
|
byte signal = is.readByte();
|
||||||
|
|
||||||
|
if( signal == 0)
|
||||||
|
System.err.println(" failed");
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Trying to connect to unknown host: " + e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,503 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class JPIPHttpClient
|
||||||
|
{
|
||||||
|
private String comURL;
|
||||||
|
protected int fw, fh;
|
||||||
|
protected int rx, ry;
|
||||||
|
protected int rw, rh;
|
||||||
|
protected String cid;
|
||||||
|
protected String tid;
|
||||||
|
private boolean JPTstream;
|
||||||
|
private boolean JPPstream;
|
||||||
|
private boolean aux;
|
||||||
|
private boolean tcp; // true: tcp, false: udp
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
public JPIPHttpClient( String URI)
|
||||||
|
{
|
||||||
|
comURL = URI + "?";
|
||||||
|
fw = fh = -1;
|
||||||
|
rx = ry = -1;
|
||||||
|
rw = rh = -1;
|
||||||
|
cid = null;
|
||||||
|
tid = null;
|
||||||
|
JPTstream = JPPstream = aux = false;
|
||||||
|
port = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFw(){ return fw;}
|
||||||
|
public int getFh(){ return fh;}
|
||||||
|
public int getRx(){ return rx;}
|
||||||
|
public int getRy(){ return ry;}
|
||||||
|
public int getRw(){ return rw;}
|
||||||
|
public int getRh(){ return rh;}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( int reqfw, int reqfh)
|
||||||
|
{
|
||||||
|
if( cid != null)
|
||||||
|
return requestViewWindow( reqfw, reqfh, cid);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
|
||||||
|
{
|
||||||
|
if( cid != null)
|
||||||
|
return requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh, cid);
|
||||||
|
else
|
||||||
|
if( tid != null)
|
||||||
|
return requestViewWindow( null, tid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false, 0, false, false);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid)
|
||||||
|
{
|
||||||
|
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, false, 0, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh, String reqcid)
|
||||||
|
{
|
||||||
|
return requestViewWindow( null, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, false, 0, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( String target, int reqfw, int reqfh)
|
||||||
|
{
|
||||||
|
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, false, 0, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( String target, int reqfw, int reqfh, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
if( cid == null) // 1 channel allocation only
|
||||||
|
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( String target, String reqtid, int reqfw, int reqfh, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
if( cid == null) // 1 channel allocation only
|
||||||
|
return requestViewWindow( target, reqtid, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( String target, int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
|
||||||
|
{
|
||||||
|
return requestViewWindow( target, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false, 0, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestViewWindow( String target,
|
||||||
|
String reqtid,
|
||||||
|
int reqfw, int reqfh,
|
||||||
|
int reqrx, int reqry,
|
||||||
|
int reqrw, int reqrh,
|
||||||
|
String reqcid, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
if( reqtid != null)
|
||||||
|
tid = reqtid;
|
||||||
|
|
||||||
|
String urlstring = const_urlstring( target, reqtid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||||
|
return GETrequest( urlstring);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] requestXML()
|
||||||
|
{
|
||||||
|
String urlstring = comURL;
|
||||||
|
|
||||||
|
if( cid == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
urlstring = urlstring.concat( "cid=" + cid);
|
||||||
|
urlstring = urlstring.concat( "&metareq=[xml_]");
|
||||||
|
|
||||||
|
return GETrequest( urlstring);
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] GETrequest( String urlstring)
|
||||||
|
{
|
||||||
|
URL url = null;
|
||||||
|
HttpURLConnection urlconn = null;
|
||||||
|
byte[] jpipstream = null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
url = new URL( urlstring);
|
||||||
|
|
||||||
|
System.err.println("Requesting: " + url);
|
||||||
|
|
||||||
|
urlconn = (HttpURLConnection)url.openConnection();
|
||||||
|
urlconn.setRequestMethod("GET");
|
||||||
|
urlconn.setInstanceFollowRedirects(false);
|
||||||
|
urlconn.connect();
|
||||||
|
|
||||||
|
set_responseheader( urlconn);
|
||||||
|
|
||||||
|
if( !aux){
|
||||||
|
jpipstream = receive_httpchunk( urlconn);
|
||||||
|
urlconn.disconnect();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
urlconn.disconnect();
|
||||||
|
jpipstream = receive_tcpaux( comURL.substring( 7, comURL.indexOf('/', 7)), port, cid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( MalformedURLException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch ( ProtocolException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch( ClassCastException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch( NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch( UnknownServiceException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch ( IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jpipstream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_responseheader( HttpURLConnection urlconn)
|
||||||
|
{
|
||||||
|
Map<String,java.util.List<String>> headers = urlconn.getHeaderFields();
|
||||||
|
java.util.List<String> hvaluelist;
|
||||||
|
String hvalueline;
|
||||||
|
|
||||||
|
String status = headers.get(null).get(0);
|
||||||
|
|
||||||
|
System.err.println( status);
|
||||||
|
if( !status.contains("OK"))
|
||||||
|
System.err.println( headers.get("Reason"));
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("Content-type")) == null)
|
||||||
|
hvaluelist = headers.get("Content-Type");
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
System.err.println( hvalueline);
|
||||||
|
|
||||||
|
if( hvalueline.endsWith("jpt-stream"))
|
||||||
|
JPTstream = true;
|
||||||
|
else if( hvalueline.endsWith("jpp-stream"))
|
||||||
|
JPPstream = true;
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("JPIP-fsiz")) != null){
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
fw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
|
||||||
|
fh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
|
||||||
|
|
||||||
|
System.err.println("fw,fh: " + fw + "," + fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("JPIP-roff")) != null){
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
rx = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
|
||||||
|
ry = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
|
||||||
|
System.err.println("rx,ry: " + rx + "," + ry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("JPIP-rsiz")) != null){
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
rw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
|
||||||
|
rh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
|
||||||
|
System.err.println("rw,rh: " + rw + "," + rh);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("JPIP-cnew")) != null){
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
cid = hvalueline.substring( hvalueline.indexOf('=')+1, hvalueline.indexOf(','));
|
||||||
|
|
||||||
|
int idxOfcid = hvalueline.indexOf("transport")+10;
|
||||||
|
int idxOfcid2 = hvalueline.indexOf(',', idxOfcid);
|
||||||
|
String transport;
|
||||||
|
if( idxOfcid2 != -1)
|
||||||
|
transport = hvalueline.substring( idxOfcid, idxOfcid2);
|
||||||
|
else
|
||||||
|
transport = hvalueline.substring( idxOfcid);
|
||||||
|
|
||||||
|
if( transport.matches("http-tcp")){
|
||||||
|
aux = true;
|
||||||
|
tcp = true;
|
||||||
|
}
|
||||||
|
else if( transport.matches("http-udp")){
|
||||||
|
aux = true;
|
||||||
|
tcp = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aux = false;
|
||||||
|
|
||||||
|
if( aux){
|
||||||
|
idxOfcid = hvalueline.indexOf("auxport")+8;
|
||||||
|
port = Integer.valueOf( hvalueline.substring( idxOfcid)).intValue();
|
||||||
|
System.err.println("cid: " + cid + ", transport: " + transport + ", auxport: " + port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.err.println("cid: " + cid + ", transport: " + transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( hvaluelist = headers.get("JPIP-tid")) != null){
|
||||||
|
hvalueline = hvaluelist.get(0);
|
||||||
|
tid = hvalueline.substring( hvalueline.indexOf('=')+1);
|
||||||
|
System.err.println("tid: " + tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] receive_httpchunk( HttpURLConnection urlconn)
|
||||||
|
{
|
||||||
|
byte[] chunk = null;
|
||||||
|
InputStream input;
|
||||||
|
|
||||||
|
try{
|
||||||
|
input = urlconn.getInputStream();
|
||||||
|
|
||||||
|
if( input.available() > 0){
|
||||||
|
ByteArrayOutputStream tmpstream = new ByteArrayOutputStream();
|
||||||
|
byte[] buf = new byte[ 1024];
|
||||||
|
int redlen, buflen;
|
||||||
|
|
||||||
|
System.err.println("reading jpipstream...");
|
||||||
|
|
||||||
|
do{
|
||||||
|
redlen = input.read( buf);
|
||||||
|
|
||||||
|
if( redlen == -1)
|
||||||
|
break;
|
||||||
|
tmpstream.write( buf, 0, redlen);
|
||||||
|
}while( redlen > 0);
|
||||||
|
|
||||||
|
buflen = tmpstream.size();
|
||||||
|
chunk = tmpstream.toByteArray();
|
||||||
|
|
||||||
|
buf = null;
|
||||||
|
tmpstream = null;
|
||||||
|
|
||||||
|
System.err.println("jpiplen: " + buflen);
|
||||||
|
System.err.println(" succeeded");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.err.println("No new jpipstream");
|
||||||
|
}
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
catch ( IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] receive_tcpaux( String host, int port, String cid)
|
||||||
|
{
|
||||||
|
Socket jpipsocket;
|
||||||
|
DataOutputStream os;
|
||||||
|
DataInputStream is;
|
||||||
|
byte []auxheader;
|
||||||
|
byte []chunkbody = null;
|
||||||
|
byte []stream = null;
|
||||||
|
int chunkbodylen, streamlen, headlen = 8;
|
||||||
|
ByteArrayOutputStream tmpstream;
|
||||||
|
|
||||||
|
try{
|
||||||
|
jpipsocket = new Socket( host, port);
|
||||||
|
os = new DataOutputStream( jpipsocket.getOutputStream());
|
||||||
|
is = new DataInputStream( jpipsocket.getInputStream());
|
||||||
|
auxheader = new byte[headlen];
|
||||||
|
tmpstream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
os.writeBytes( cid + "\r\n");
|
||||||
|
|
||||||
|
do{
|
||||||
|
read_stream( is, auxheader, headlen);
|
||||||
|
|
||||||
|
chunkbodylen = ((auxheader[0]&0xff)<<8 | (auxheader[1]&0xff)) - headlen;
|
||||||
|
|
||||||
|
chunkbody = new byte [ chunkbodylen];
|
||||||
|
read_stream( is, chunkbody, chunkbodylen);
|
||||||
|
tmpstream.write( chunkbody, 0, chunkbodylen);
|
||||||
|
|
||||||
|
os.write( auxheader, 0, headlen);
|
||||||
|
}while( !(chunkbody[chunkbodylen-3]==0x00 && ( chunkbody[chunkbodylen-2]==0x01 || chunkbody[chunkbodylen-2]== 0x02)));
|
||||||
|
|
||||||
|
streamlen = tmpstream.size();
|
||||||
|
stream = tmpstream.toByteArray();
|
||||||
|
|
||||||
|
System.err.println("jpiplen: " + streamlen);
|
||||||
|
System.err.println(" succeeded");
|
||||||
|
|
||||||
|
chunkbody = null;
|
||||||
|
tmpstream = null;
|
||||||
|
|
||||||
|
os.close();
|
||||||
|
is.close();
|
||||||
|
|
||||||
|
jpipsocket.close();
|
||||||
|
}
|
||||||
|
catch ( IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void read_stream( InputStream is, byte []stream, int length)
|
||||||
|
{
|
||||||
|
int remlen = length;
|
||||||
|
int off = 0;
|
||||||
|
|
||||||
|
try{
|
||||||
|
while( remlen > 0){
|
||||||
|
int redlen = is.read( stream, off, remlen);
|
||||||
|
|
||||||
|
if( redlen == -1){
|
||||||
|
System.err.println(" failed to read_stream()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
off += redlen;
|
||||||
|
remlen -= redlen;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String const_urlstring( String target,
|
||||||
|
String reqtid,
|
||||||
|
int reqfw, int reqfh,
|
||||||
|
int reqrx, int reqry,
|
||||||
|
int reqrw, int reqrh,
|
||||||
|
String reqcid, boolean reqcnew, int reqaux, boolean reqJPP, boolean reqJPT)
|
||||||
|
{
|
||||||
|
String urlstring = comURL;
|
||||||
|
|
||||||
|
// C.7.3 Image Return Type
|
||||||
|
// add type=jpp-stream(;ptype=ext) or type=jpt-stream;ttype=ext
|
||||||
|
|
||||||
|
if( target != null){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "target=" + target);
|
||||||
|
}
|
||||||
|
if( reqtid != null){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "tid=" + reqtid);
|
||||||
|
}
|
||||||
|
if( reqfw != -1 && reqfh != -1){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "fsiz=" + reqfw + "," + reqfh);
|
||||||
|
}
|
||||||
|
if( reqrx != -1 && reqry != -1){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "roff=" + reqrx + "," + reqry);
|
||||||
|
}
|
||||||
|
if( reqrw != -1 && reqrh != -1){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "rsiz=" + reqrw + "," + reqrh);
|
||||||
|
}
|
||||||
|
if( reqcid != null){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "cid=" + reqcid);
|
||||||
|
}
|
||||||
|
if( reqcnew){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
if( reqaux == 1)
|
||||||
|
urlstring = urlstring.concat( "cnew=http-tcp");
|
||||||
|
else if( reqaux == 2)
|
||||||
|
urlstring = urlstring.concat( "cnew=http-udp");
|
||||||
|
else
|
||||||
|
urlstring = urlstring.concat( "cnew=http");
|
||||||
|
}
|
||||||
|
if( reqJPP && !JPTstream){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "type=jpp-stream");
|
||||||
|
}
|
||||||
|
else if( reqJPT && !JPPstream){
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
urlstring = urlstring.concat( "type=jpt-stream");
|
||||||
|
}
|
||||||
|
else{ // remove this option later
|
||||||
|
if( !urlstring.endsWith("?"))
|
||||||
|
urlstring = urlstring.concat( "&");
|
||||||
|
if( JPTstream)
|
||||||
|
urlstring = urlstring.concat( "type=jpt-stream");
|
||||||
|
else if( JPPstream)
|
||||||
|
urlstring = urlstring.concat( "type=jpp-stream");
|
||||||
|
}
|
||||||
|
|
||||||
|
return urlstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeChannel()
|
||||||
|
{
|
||||||
|
if( cid == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try{
|
||||||
|
URL url = new URL( comURL + "cclose=" + cid);
|
||||||
|
System.err.println( "closing cid: " + cid);
|
||||||
|
|
||||||
|
HttpURLConnection urlconn = (HttpURLConnection)url.openConnection();
|
||||||
|
urlconn.setRequestMethod("GET");
|
||||||
|
urlconn.setInstanceFollowRedirects(false);
|
||||||
|
urlconn.connect();
|
||||||
|
|
||||||
|
Map headers = urlconn.getHeaderFields();
|
||||||
|
|
||||||
|
urlconn.disconnect();
|
||||||
|
} catch ( MalformedURLException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch ( IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
class MML implements MouseMotionListener, MouseListener
|
||||||
|
{
|
||||||
|
public void mouseExited(MouseEvent e) {}
|
||||||
|
public void mouseEntered(MouseEvent e) {}
|
||||||
|
public void mouseClicked(MouseEvent e) {}
|
||||||
|
|
||||||
|
private ImageViewer iv;
|
||||||
|
private int x1, y1, x2, y2, zf, btn;
|
||||||
|
private boolean zoomrq;
|
||||||
|
|
||||||
|
public MML(ImageViewer imageviewer)
|
||||||
|
{
|
||||||
|
x1 = y1 = -1;
|
||||||
|
iv = imageviewer;
|
||||||
|
zoomrq = false;
|
||||||
|
zf = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isInside(int x, int y)
|
||||||
|
{
|
||||||
|
x -= iv.getX();
|
||||||
|
y -= iv.getY();
|
||||||
|
return (x >= 0) && (x < iv.getWidth())
|
||||||
|
&& (y >= 0) && (y < iv.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mousePressed(MouseEvent e)
|
||||||
|
{
|
||||||
|
btn = e.getButton();
|
||||||
|
|
||||||
|
if( iv.hasAnnotation()){
|
||||||
|
if( iv.isInsideROIRect(e.getX(), e.getY())){
|
||||||
|
iv.zoomIn();
|
||||||
|
System.out.println("annotation click");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (iv.isInsideRect(e.getX(), e.getY())) {
|
||||||
|
iv.setSelected(2);
|
||||||
|
iv.repaint();
|
||||||
|
zoomrq = true;
|
||||||
|
} else {
|
||||||
|
iv.setRGeom(0, 0, 0, 0);
|
||||||
|
iv.setSelected(0);
|
||||||
|
iv.repaint();
|
||||||
|
x1 = y1 = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseReleased(MouseEvent e)
|
||||||
|
{
|
||||||
|
if(e.getButton() == 1) {
|
||||||
|
if (zoomrq) {
|
||||||
|
iv.zoomIn();
|
||||||
|
zoomrq = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseMoved(MouseEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseDragged(MouseEvent e)
|
||||||
|
{
|
||||||
|
if (btn == 1) {
|
||||||
|
x2 = e.getX();
|
||||||
|
y2 = e.getY();
|
||||||
|
|
||||||
|
iv.setSelected(0);
|
||||||
|
zoomrq = false;
|
||||||
|
|
||||||
|
if (isInside(x2, y2)) {
|
||||||
|
if (x1 == -1) {
|
||||||
|
x1 = x2;
|
||||||
|
y1 = y2;
|
||||||
|
} else {
|
||||||
|
iv.setRGeom(x1, y1, x2, y2);
|
||||||
|
iv.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.regex.*;
|
||||||
|
|
||||||
|
public class PnmImage extends Component
|
||||||
|
{
|
||||||
|
private byte[] data = null;
|
||||||
|
private int width = 0;
|
||||||
|
private int height = 0;
|
||||||
|
private int channel = 0;
|
||||||
|
|
||||||
|
public PnmImage( int c, int w, int h)
|
||||||
|
{
|
||||||
|
channel = c;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
data = new byte [ w*h*c];
|
||||||
|
}
|
||||||
|
|
||||||
|
public PnmImage( String filename)
|
||||||
|
{
|
||||||
|
String str;
|
||||||
|
Pattern pat;
|
||||||
|
Matcher mat;
|
||||||
|
int bytes;
|
||||||
|
int r, offset = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream( new File(filename));
|
||||||
|
DataInputStream is = new DataInputStream( fis);
|
||||||
|
|
||||||
|
pat = Pattern.compile("^P([56])$");
|
||||||
|
mat = pat.matcher(str = is.readLine());
|
||||||
|
if( !mat.matches()){
|
||||||
|
System.out.println("PNM header format error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (mat.group(1)).compareTo("5") == 0)
|
||||||
|
channel = 1;
|
||||||
|
else
|
||||||
|
channel = 3;
|
||||||
|
|
||||||
|
pat = Pattern.compile("^(\\d+) (\\d+)$");
|
||||||
|
mat = pat.matcher(str = is.readLine());
|
||||||
|
if( !mat.matches()){
|
||||||
|
System.out.println("PNM header format error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
width = Integer.parseInt( mat.group(1));
|
||||||
|
height = Integer.parseInt( mat.group(2));
|
||||||
|
|
||||||
|
str = is.readLine(); // 255
|
||||||
|
|
||||||
|
bytes = width*height*channel;
|
||||||
|
data = new byte[bytes];
|
||||||
|
|
||||||
|
while( bytes > 0){
|
||||||
|
try {
|
||||||
|
r = is.read(data, offset, bytes);
|
||||||
|
if( r == -1){
|
||||||
|
System.err.println(" failed to read()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset += r;
|
||||||
|
bytes -= r;
|
||||||
|
}
|
||||||
|
catch (IOException e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
fis.close();
|
||||||
|
} catch (IOException e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte [] get_data(){ return data;}
|
||||||
|
public int get_width() { return width;}
|
||||||
|
public int get_height(){ return height;}
|
||||||
|
|
||||||
|
public Image createROIImage( int rx, int ry, int rw, int rh)
|
||||||
|
{
|
||||||
|
int []pix = new int[ rw*rh];
|
||||||
|
|
||||||
|
for( int i=0; i<rh; i++)
|
||||||
|
for( int j=0; j<rw; j++){
|
||||||
|
pix[i*rw+j] = 0xFF << 24; // transparency
|
||||||
|
if( channel == 1){
|
||||||
|
Byte lum = data[(ry+i)*width+rx+j];
|
||||||
|
short slum;
|
||||||
|
|
||||||
|
if( lum < 0)
|
||||||
|
slum = (short)(2*128+lum);
|
||||||
|
else
|
||||||
|
slum = (short)lum;
|
||||||
|
|
||||||
|
for( int c=0; c<3; c++){
|
||||||
|
pix[i*rw+j] = pix[i*rw+j] | slum << (8*c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for( int c=0; c<3; c++){
|
||||||
|
Byte lum = data[ ((ry+i)*width+rx+j)*channel+(2-c)];
|
||||||
|
short slum;
|
||||||
|
|
||||||
|
if( lum < 0)
|
||||||
|
slum = (short)(2*128+lum);
|
||||||
|
else
|
||||||
|
slum = (short)lum;
|
||||||
|
|
||||||
|
pix[i*rw+j] = pix[i*rw+j] | slum << (8*c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return createImage(new MemoryImageSource( rw, rh, pix, 0, rw));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image createScaleImage( double scale)
|
||||||
|
{
|
||||||
|
Image src = createROIImage( 0, 0, width, height);
|
||||||
|
ImageFilter replicate = new ReplicateScaleFilter( (int)(width*scale), (int)(height*scale));
|
||||||
|
ImageProducer prod = new FilteredImageSource( src.getSource(), replicate);
|
||||||
|
|
||||||
|
return createImage(prod);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.*;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
|
public class RegimViewer extends JPanel
|
||||||
|
{
|
||||||
|
private PnmImage refpnm;
|
||||||
|
private int vw, vh;
|
||||||
|
private Image refimg;
|
||||||
|
private Image jpipImg;
|
||||||
|
private double[] affine_matrix;
|
||||||
|
private AffineTransform affine;
|
||||||
|
|
||||||
|
public RegimViewer( String refname, double[] mat)
|
||||||
|
{
|
||||||
|
refpnm = new PnmImage( refname.replaceFirst("jp2", "pgm")); // decoding not realized
|
||||||
|
affine_matrix = new double[6];
|
||||||
|
|
||||||
|
affine_matrix[0] = mat[0];
|
||||||
|
affine_matrix[1] = mat[3];
|
||||||
|
affine_matrix[2] = mat[1];
|
||||||
|
affine_matrix[3] = mat[4];
|
||||||
|
affine_matrix[4] = mat[2];
|
||||||
|
affine_matrix[5] = mat[5];
|
||||||
|
|
||||||
|
affine = new AffineTransform();
|
||||||
|
|
||||||
|
for( int i=0; i<3; i++){
|
||||||
|
for( int j=0; j<3; j++)
|
||||||
|
System.out.print( mat[i*3+j] + " ");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void projection( Image jpipimg, double scale)
|
||||||
|
{
|
||||||
|
jpipImg = jpipimg;
|
||||||
|
refimg = refpnm.createScaleImage( scale);
|
||||||
|
vw = refimg.getWidth(this);
|
||||||
|
vh = refimg.getHeight(this);
|
||||||
|
this.setSize( vw, vh);
|
||||||
|
|
||||||
|
affine.setTransform( affine_matrix[0], affine_matrix[1], affine_matrix[2], affine_matrix[3], affine_matrix[4], affine_matrix[5]);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
int iw, ih;
|
||||||
|
BufferedImage bi, bi2;
|
||||||
|
Graphics2D big, big2;
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
|
||||||
|
g2.clearRect(0, 0, vw, vh);
|
||||||
|
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
||||||
|
RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
|
|
||||||
|
iw = refimg.getWidth(this);
|
||||||
|
ih = refimg.getHeight(this);
|
||||||
|
|
||||||
|
bi = new BufferedImage( iw, ih, BufferedImage.TYPE_INT_RGB);
|
||||||
|
big = bi.createGraphics();
|
||||||
|
big.drawImage(refimg, 0, 0, this);
|
||||||
|
|
||||||
|
g2.drawImage(bi, 0, 0, this);
|
||||||
|
|
||||||
|
bi2 = new BufferedImage( jpipImg.getWidth(this), jpipImg.getHeight(this), BufferedImage.TYPE_INT_RGB);
|
||||||
|
big2 = bi2.createGraphics();
|
||||||
|
big2.drawImage( jpipImg, 0, 0, this);
|
||||||
|
|
||||||
|
g2.setTransform(affine);
|
||||||
|
|
||||||
|
g2.drawImage(bi2, 0, 0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension get_imsize()
|
||||||
|
{
|
||||||
|
return (new Dimension( vw, vh));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
class ResizeListener implements ComponentListener
|
||||||
|
{
|
||||||
|
private ImageViewer iv;
|
||||||
|
private Dimension largest;
|
||||||
|
|
||||||
|
public ResizeListener( ImageViewer _iv)
|
||||||
|
{
|
||||||
|
iv = _iv;
|
||||||
|
largest = iv.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void componentHidden(ComponentEvent e) {}
|
||||||
|
|
||||||
|
public void componentMoved(ComponentEvent e) {}
|
||||||
|
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
Dimension cursize = iv.getSize();
|
||||||
|
if( largest.getWidth() < cursize.getWidth() || largest.getHeight() < cursize.getHeight()){
|
||||||
|
update_largest( cursize);
|
||||||
|
iv.enlarge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_largest( Dimension cursize)
|
||||||
|
{
|
||||||
|
if( largest.getWidth() < cursize.getWidth())
|
||||||
|
largest.setSize( cursize.getWidth(), largest.getHeight());
|
||||||
|
if( largest.getHeight() < cursize.getHeight())
|
||||||
|
largest.setSize( largest.getWidth(), cursize.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void componentShown(ComponentEvent e) {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Ant-Version: Apache Ant 1.7.0
|
||||||
|
Created-By: Kaori Hagihara
|
||||||
|
Main-Class: ImageWindow
|
||||||
|
Class-Path: @APACHE_XERCES_JAR@
|
|
@ -0,0 +1,266 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.image.*;
|
||||||
|
import java.awt.geom.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import javax.swing.border.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ImageViewer extends JPanel
|
||||||
|
{
|
||||||
|
private ImageManager imgmanager;
|
||||||
|
private int vw, vh;
|
||||||
|
private int iw, ih;
|
||||||
|
private int selected = 0;
|
||||||
|
private Image img;
|
||||||
|
|
||||||
|
private String cmdline = new String();
|
||||||
|
private boolean fullRefresh = false;
|
||||||
|
private Point offset = new Point(0,0);
|
||||||
|
private Rectangle rect = new Rectangle();
|
||||||
|
private Rectangle roirect[] = null;
|
||||||
|
private String roiname[] = null;
|
||||||
|
|
||||||
|
public ImageViewer( String j2kfilename, ImageManager manager, boolean session, boolean jppstream, int aux)
|
||||||
|
{
|
||||||
|
String str;
|
||||||
|
MML myMML;
|
||||||
|
|
||||||
|
this.setSize( 170, 170);
|
||||||
|
Dimension asz = this.getSize();
|
||||||
|
|
||||||
|
vw = asz.width;
|
||||||
|
vh = asz.height;
|
||||||
|
|
||||||
|
setBackground(Color.black);
|
||||||
|
myMML = new MML(this);
|
||||||
|
|
||||||
|
imgmanager = manager;
|
||||||
|
|
||||||
|
img = imgmanager.getImage( j2kfilename, vw, vh, session, aux, jppstream, !jppstream);
|
||||||
|
|
||||||
|
addMouseListener(myMML);
|
||||||
|
addMouseMotionListener(myMML);
|
||||||
|
addComponentListener( new ResizeListener(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage()
|
||||||
|
{
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zoomIn()
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
double scalex = (double)vw/(double)rect.width;
|
||||||
|
double scaley = (double)vh/(double)rect.height;
|
||||||
|
|
||||||
|
int fw = (int)(imgmanager.getFw()*scalex);
|
||||||
|
int fh = (int)(imgmanager.getFh()*scaley);
|
||||||
|
int rx = (int)((imgmanager.getRx()+rect.x)*scalex);
|
||||||
|
int ry = (int)((imgmanager.getRy()+rect.y)*scaley);
|
||||||
|
|
||||||
|
img = imgmanager.getImage( fw, fh, rx, ry, vw, vh);
|
||||||
|
|
||||||
|
rect.x = rect.y = rect.width = rect.height = 0;
|
||||||
|
|
||||||
|
selected = 0;
|
||||||
|
fullRefresh = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enlarge()
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
Dimension asz = this.getSize();
|
||||||
|
|
||||||
|
vw = asz.width;
|
||||||
|
vh = asz.height;
|
||||||
|
|
||||||
|
double scalex = vw/(double)imgmanager.getRw();
|
||||||
|
double scaley = vh/(double)imgmanager.getRh();
|
||||||
|
|
||||||
|
int fw = (int)(imgmanager.getFw()*scalex);
|
||||||
|
int fh = (int)(imgmanager.getFh()*scaley);
|
||||||
|
int rx = (int)(imgmanager.getRx()*scalex);
|
||||||
|
int ry = (int)(imgmanager.getRy()*scaley);
|
||||||
|
|
||||||
|
img = imgmanager.getImage( fw, fh, rx, ry, vw, vh);
|
||||||
|
|
||||||
|
fullRefresh = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(int state)
|
||||||
|
{
|
||||||
|
roirect = null;
|
||||||
|
roiname = null;
|
||||||
|
|
||||||
|
if (state != selected) {
|
||||||
|
|
||||||
|
selected = state;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInsideRect(int x, int y)
|
||||||
|
{
|
||||||
|
return rect.contains(x - offset.x, y - offset.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGeom(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
rect.x = Math.min(x1,x2) - offset.x;
|
||||||
|
rect.y = Math.min(y1,y2) - offset.y;
|
||||||
|
rect.width = Math.abs(x2-x1);
|
||||||
|
rect.height = Math.abs(y2-y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void annotate( JP2XMLparser.ROIparams roi[])
|
||||||
|
{
|
||||||
|
int numofroi = roi.length;
|
||||||
|
|
||||||
|
roirect = new Rectangle [numofroi];
|
||||||
|
roiname = new String [numofroi];
|
||||||
|
|
||||||
|
double scale_x = imgmanager.getFw()/(double)imgmanager.getOrigWidth();
|
||||||
|
double scale_y = imgmanager.getFh()/(double)imgmanager.getOrigHeight();
|
||||||
|
int rx = imgmanager.getRx();
|
||||||
|
int ry = imgmanager.getRy();
|
||||||
|
int rw = imgmanager.getRw();
|
||||||
|
int rh = imgmanager.getRh();
|
||||||
|
|
||||||
|
for( int i=0; i<numofroi ; i++){
|
||||||
|
int x = (int)(roi[i].x*scale_x) - rx;
|
||||||
|
int y = (int)(roi[i].y*scale_y) - ry;
|
||||||
|
int w = (int)(roi[i].w*scale_x);
|
||||||
|
int h = (int)(roi[i].h*scale_y);
|
||||||
|
if( 0<=x && 0<=y && x+w<=rw && y+h<=rh){ // can be optimized
|
||||||
|
roirect[i] = new Rectangle( x, y, w, h);
|
||||||
|
roiname[i] = new String( roi[i].name);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
roirect[i] = null;
|
||||||
|
roiname[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAnnotation()
|
||||||
|
{
|
||||||
|
if( roirect == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInsideROIRect(int x, int y)
|
||||||
|
{
|
||||||
|
for( int i=0; i<roirect.length; i++)
|
||||||
|
if( roirect[i] != null)
|
||||||
|
if( roirect[i].contains(x - offset.x, y - offset.y)){
|
||||||
|
rect = roirect[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
BufferedImage bi;
|
||||||
|
Graphics2D big;
|
||||||
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
|
|
||||||
|
if (fullRefresh) {
|
||||||
|
g2.clearRect(0, 0, vw, vh);
|
||||||
|
fullRefresh = false;
|
||||||
|
}
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
||||||
|
RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
|
|
||||||
|
offset.x = 0;
|
||||||
|
offset.y = 0;
|
||||||
|
|
||||||
|
iw = img.getWidth(this);
|
||||||
|
ih = img.getHeight(this);
|
||||||
|
|
||||||
|
bi = new BufferedImage( iw, ih, BufferedImage.TYPE_INT_RGB);
|
||||||
|
big = bi.createGraphics();
|
||||||
|
|
||||||
|
big.drawImage(img, 0, 0, this);
|
||||||
|
big.setPaint(Color.red);
|
||||||
|
if ((rect.width > 0) && (rect.height > 0))
|
||||||
|
big.draw(rect);
|
||||||
|
|
||||||
|
if( roirect != null){
|
||||||
|
for( int i=0; i<roirect.length; i++)
|
||||||
|
if( roirect[i] != null){
|
||||||
|
big.draw( roirect[i]);
|
||||||
|
big.drawString( roiname[i], roirect[i].x+3, roirect[i].y+roirect[i].height*2/3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selected == 1)
|
||||||
|
shadeExt(big, 0, 0, 0, 64);
|
||||||
|
else if (selected == 2) {
|
||||||
|
shadeExt(big, 0, 0, 0, 255);
|
||||||
|
selected = 1;
|
||||||
|
}
|
||||||
|
g2.drawImage(bi, offset.x, offset.y, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shadeRect(Graphics2D g2, int r, int g, int b, int a)
|
||||||
|
{
|
||||||
|
g2.setPaint(new Color(r, g, b, a));
|
||||||
|
g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shadeExt(Graphics2D g2, int r, int g, int b, int a)
|
||||||
|
{
|
||||||
|
g2.setPaint(new Color(r, g, b, a));
|
||||||
|
g2.fillRect(0, 0, iw, rect.y); /* _N_ */
|
||||||
|
g2.fillRect(rect.x + rect.width + 1, rect.y,
|
||||||
|
iw - rect.x - rect.width - 1, rect.height + 1); /* E */
|
||||||
|
g2.fillRect(0, rect.y, rect.x, rect.height + 1); /* W */
|
||||||
|
g2.fillRect(0, rect.y + rect.height + 1,
|
||||||
|
iw, ih - rect.y - rect.height - 1); /* _S_ */
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class ImageWindow extends JFrame
|
||||||
|
{
|
||||||
|
private ImageViewer imgviewer;
|
||||||
|
private OptionPanel optpanel;
|
||||||
|
private ImageManager imgmanager;
|
||||||
|
|
||||||
|
public ImageWindow( String uri, String j2kfilename, String host, int port, boolean session, boolean jppstream, int aux)
|
||||||
|
{
|
||||||
|
super( j2kfilename);
|
||||||
|
|
||||||
|
imgmanager = new ImageManager( uri, host, port);
|
||||||
|
|
||||||
|
imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream, aux);
|
||||||
|
imgviewer.setOpaque(true); //content panes must be opaque
|
||||||
|
|
||||||
|
optpanel = new OptionPanel( imgmanager, imgviewer);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BorderLayout());
|
||||||
|
panel.add( imgviewer, BorderLayout.CENTER);
|
||||||
|
panel.add( optpanel, BorderLayout.EAST);
|
||||||
|
|
||||||
|
setContentPane( panel);
|
||||||
|
|
||||||
|
addWindowListener(new WindowMyAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
class WindowMyAdapter extends WindowAdapter
|
||||||
|
{
|
||||||
|
public void windowClosing(WindowEvent arg)
|
||||||
|
{
|
||||||
|
imgmanager.closeChannel();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String s[])
|
||||||
|
{
|
||||||
|
String j2kfilename, uri, host;
|
||||||
|
boolean session, jppstream;
|
||||||
|
int port, aux; // 0: none, 1: tcp, 2: udp
|
||||||
|
|
||||||
|
if(s.length >= 2){
|
||||||
|
uri = s[0];
|
||||||
|
j2kfilename = s[1];
|
||||||
|
|
||||||
|
if( s.length > 2)
|
||||||
|
host = s[2];
|
||||||
|
else
|
||||||
|
host = "localhost";
|
||||||
|
|
||||||
|
if( s.length > 3)
|
||||||
|
port = Integer.valueOf( s[3]).intValue();
|
||||||
|
else
|
||||||
|
port = 50000;
|
||||||
|
|
||||||
|
if( s.length > 4)
|
||||||
|
session = !s[4].equalsIgnoreCase( "stateless");
|
||||||
|
else
|
||||||
|
session = true;
|
||||||
|
|
||||||
|
if( s.length > 5)
|
||||||
|
jppstream = !s[5].equalsIgnoreCase( "JPT");
|
||||||
|
else
|
||||||
|
jppstream = true;
|
||||||
|
|
||||||
|
if( s.length > 6){
|
||||||
|
if( s[6].equalsIgnoreCase("udp"))
|
||||||
|
aux = 2;
|
||||||
|
else
|
||||||
|
aux = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aux = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [hostname] [portnumber] [stateless/session] [JPT/JPP] [tcp/udp]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImageWindow frame = new ImageWindow( uri, j2kfilename, host, port, session, jppstream, aux);
|
||||||
|
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
//Display the window.
|
||||||
|
frame.pack();
|
||||||
|
frame.setSize(new Dimension(400,200));
|
||||||
|
frame.setLocation( 0, 50);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.SAXParseException;
|
||||||
|
import org.xml.sax.ErrorHandler;
|
||||||
|
import org.apache.xerces.parsers.DOMParser;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class JP2XMLparser
|
||||||
|
{
|
||||||
|
Document document;
|
||||||
|
|
||||||
|
public static class ROIparams{
|
||||||
|
public String name = null;
|
||||||
|
public int x = 0;
|
||||||
|
public int y = 0;
|
||||||
|
public int w = 0;
|
||||||
|
public int h = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class IRTparams{
|
||||||
|
public String refimg = null;
|
||||||
|
public double []mat = { 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
|
||||||
|
}
|
||||||
|
|
||||||
|
public JP2XMLparser( byte[] buf)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
InputSource source = new InputSource( new ByteArrayInputStream( buf));
|
||||||
|
DOMParser parser = new DOMParser();
|
||||||
|
parser.setErrorHandler(new MyHandler());
|
||||||
|
parser.parse( source);
|
||||||
|
document = parser.getDocument();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ROIparams [] getROIparams()
|
||||||
|
{
|
||||||
|
ROIparams roi[];
|
||||||
|
NodeList elements = document.getElementsByTagName("roi");
|
||||||
|
int elementCount = elements.getLength();
|
||||||
|
|
||||||
|
roi = new ROIparams [elementCount];
|
||||||
|
|
||||||
|
for( int i = 0; i < elementCount; i++) {
|
||||||
|
Element element = (Element)elements.item(i);
|
||||||
|
|
||||||
|
roi[i] = new ROIparams();
|
||||||
|
roi[i].name = element.getAttribute( "name");
|
||||||
|
roi[i].x = Integer.parseInt( element.getAttribute( "x")) ;
|
||||||
|
roi[i].y = Integer.parseInt( element.getAttribute( "y")) ;
|
||||||
|
roi[i].w = Integer.parseInt( element.getAttribute( "w")) ;
|
||||||
|
roi[i].h = Integer.parseInt( element.getAttribute( "h")) ;
|
||||||
|
}
|
||||||
|
return roi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRTparams getIRTparams()
|
||||||
|
{
|
||||||
|
IRTparams irt = new IRTparams();
|
||||||
|
NodeList elements = document.getElementsByTagName("irt");
|
||||||
|
int elementCount = elements.getLength();
|
||||||
|
|
||||||
|
Element element = (Element)elements.item(0);
|
||||||
|
irt.refimg = element.getAttribute( "refimg");
|
||||||
|
for( int i=1; i<=9; i++)
|
||||||
|
irt.mat[i-1] = Double.parseDouble( element.getAttribute("m" + i));
|
||||||
|
|
||||||
|
return irt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyHandler implements ErrorHandler {
|
||||||
|
public void warning(SAXParseException e) {
|
||||||
|
System.out.println("Warning: line" + e.getLineNumber());
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
public void error(SAXParseException e) {
|
||||||
|
System.out.println("Error: line" + e.getLineNumber());
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
public void fatalError(SAXParseException e) {
|
||||||
|
System.out.println("Critical error: line" + e.getLineNumber());
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class OptionPanel extends JPanel implements ActionListener
|
||||||
|
{
|
||||||
|
private JButton roibutton;
|
||||||
|
private JButton imregbutton;
|
||||||
|
private ImageManager imgmanager;
|
||||||
|
private ImageViewer iv;
|
||||||
|
private JP2XMLparser xmlparser;
|
||||||
|
private JFrame regimwindow;
|
||||||
|
private RegimViewer regimgviewer;
|
||||||
|
|
||||||
|
public OptionPanel( ImageManager manager, ImageViewer imgviewer)
|
||||||
|
{
|
||||||
|
this.setLayout(new BoxLayout( this, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
roibutton = new JButton("Region Of Interest");
|
||||||
|
imregbutton = new JButton("Image Registration");
|
||||||
|
|
||||||
|
roibutton.setAlignmentX( Component.CENTER_ALIGNMENT);
|
||||||
|
imregbutton.setAlignmentX( Component.CENTER_ALIGNMENT);
|
||||||
|
|
||||||
|
add( roibutton);
|
||||||
|
add( imregbutton);
|
||||||
|
roibutton.addActionListener(this);
|
||||||
|
imregbutton.addActionListener(this);
|
||||||
|
|
||||||
|
imgmanager = manager;
|
||||||
|
iv = imgviewer;
|
||||||
|
xmlparser = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
if( xmlparser == null){
|
||||||
|
byte []xmldata = imgmanager.getXML();
|
||||||
|
if( xmldata != null)
|
||||||
|
xmlparser = new JP2XMLparser( xmldata);
|
||||||
|
}
|
||||||
|
if( e.getSource() == roibutton){
|
||||||
|
if( xmlparser != null){
|
||||||
|
JP2XMLparser.ROIparams roi[] = xmlparser.getROIparams();
|
||||||
|
iv.annotate( roi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( e.getSource() == imregbutton){
|
||||||
|
if( xmlparser != null){
|
||||||
|
if( regimwindow == null){
|
||||||
|
JP2XMLparser.IRTparams irt = xmlparser.getIRTparams();
|
||||||
|
|
||||||
|
regimgviewer = new RegimViewer( irt.refimg, irt.mat);
|
||||||
|
regimgviewer.setOpaque(false);
|
||||||
|
|
||||||
|
regimwindow = new JFrame("Registered Image");
|
||||||
|
regimwindow.getContentPane().add("Center", regimgviewer);
|
||||||
|
regimwindow.pack();
|
||||||
|
regimwindow.setLocation( 500, 50);
|
||||||
|
regimwindow.setVisible(true);
|
||||||
|
}
|
||||||
|
regimgviewer.projection( iv.getImage(), (double)imgmanager.getRw()/(double)imgmanager.getOrigWidth());
|
||||||
|
regimwindow.setSize( regimgviewer.get_imsize());
|
||||||
|
regimwindow.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
# jpwl apps
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
set(common_SRCS
|
||||||
|
convert.c
|
||||||
|
index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openmj2
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DOPJ_EXPORTS)
|
||||||
|
else()
|
||||||
|
add_definitions(-DOPJ_STATIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DOPJ_USE_LEGACY)
|
||||||
|
foreach(exe decompress compress)
|
||||||
|
set(jpwl_exe opj_jpwl_${exe})
|
||||||
|
set(jp2_exe opj_${exe})
|
||||||
|
add_executable(${jpwl_exe}
|
||||||
|
#../jp2/${jp2_exe}.c
|
||||||
|
${jpwl_exe}.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
set_property(
|
||||||
|
TARGET ${jpwl_exe}
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${jpwl_exe} openjpwl
|
||||||
|
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
# To support universal exe:
|
||||||
|
if(ZLIB_FOUND AND APPLE)
|
||||||
|
target_link_libraries(${jpwl_exe} z)
|
||||||
|
else(ZLIB_FOUND AND APPLE)
|
||||||
|
target_link_libraries(${jpwl_exe} ${Z_LIBNAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(${jpwl_exe} m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS ${jpwl_exe}
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
endforeach()
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
#ifndef __J2K_CONVERT_H
|
||||||
|
#define __J2K_CONVERT_H
|
||||||
|
|
||||||
|
/**@name RAW image encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_cparameters {
|
||||||
|
/** width of the raw image */
|
||||||
|
int rawWidth;
|
||||||
|
/** height of the raw image */
|
||||||
|
int rawHeight;
|
||||||
|
/** components of the raw image */
|
||||||
|
int rawComp;
|
||||||
|
/** bit depth of the raw image */
|
||||||
|
int rawBitDepth;
|
||||||
|
/** signed/unsigned raw image */
|
||||||
|
opj_bool rawSigned;
|
||||||
|
/*@}*/
|
||||||
|
} raw_cparameters_t;
|
||||||
|
|
||||||
|
/* TGA conversion */
|
||||||
|
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotga(opj_image_t * image, const char *outfile);
|
||||||
|
|
||||||
|
/* BMP conversion */
|
||||||
|
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
/* TIFF conversion*/
|
||||||
|
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotif(opj_image_t *image, const char *outfile);
|
||||||
|
/**
|
||||||
|
Load a single image component encoded in PGX file format
|
||||||
|
@param filename Name of the PGX file to load
|
||||||
|
@param parameters *List ?*
|
||||||
|
@return Returns a greyscale image if successful, returns NULL otherwise
|
||||||
|
*/
|
||||||
|
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopgx(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopnm(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
/* RAW conversion */
|
||||||
|
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||||
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters,
|
||||||
|
raw_cparameters_t *raw_cp);
|
||||||
|
|
||||||
|
/* PNG conversion*/
|
||||||
|
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
||||||
|
extern opj_image_t* pngtoimage(const char *filename,
|
||||||
|
opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
#endif /* __J2K_CONVERT_H */
|
||||||
|
|
|
@ -0,0 +1,454 @@
|
||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. 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.
|
||||||
|
*
|
||||||
|
* 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 OWNER 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a structured index to a file
|
||||||
|
@param cstr_info Codestream information
|
||||||
|
@param index Index filename
|
||||||
|
@return Returns 0 if successful, returns 1 otherwise
|
||||||
|
*/
|
||||||
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
|
||||||
|
{
|
||||||
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
|
FILE *stream = NULL;
|
||||||
|
double total_disto = 0;
|
||||||
|
/* UniPG>> */
|
||||||
|
int tilepartno;
|
||||||
|
char disto_on, numpix_on;
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
|
if (!cstr_info) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream = fopen(index, "w");
|
||||||
|
if (!stream) {
|
||||||
|
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].distotile) {
|
||||||
|
disto_on = 1;
|
||||||
|
} else {
|
||||||
|
disto_on = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].numpix) {
|
||||||
|
numpix_on = 1;
|
||||||
|
} else {
|
||||||
|
numpix_on = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->prog);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||||
|
|
||||||
|
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||||
|
fprintf(stream, "[%d,%d] ",
|
||||||
|
(1 << cstr_info->tile[0].pdx[resno]),
|
||||||
|
(1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||||
|
|
||||||
|
fprintf(stream, "\nINFO ON TILES\n");
|
||||||
|
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
if (numpix_on) {
|
||||||
|
fprintf(stream, " nbpix");
|
||||||
|
}
|
||||||
|
if (disto_on && numpix_on) {
|
||||||
|
fprintf(stream, " disto/nbpix");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||||
|
cstr_info->tile[tileno].tileno,
|
||||||
|
cstr_info->tile[tileno].start_pos,
|
||||||
|
cstr_info->tile[tileno].end_header,
|
||||||
|
cstr_info->tile[tileno].end_pos,
|
||||||
|
cstr_info->tile[tileno].num_tps);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %9e", cstr_info->tile[tileno].distotile);
|
||||||
|
}
|
||||||
|
if (numpix_on) {
|
||||||
|
fprintf(stream, " %9d", cstr_info->tile[tileno].numpix);
|
||||||
|
}
|
||||||
|
if (disto_on && numpix_on) {
|
||||||
|
fprintf(stream, " %9e", cstr_info->tile[tileno].distotile /
|
||||||
|
cstr_info->tile[tileno].numpix);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
int start_pos, end_ph_pos, end_pos;
|
||||||
|
double disto = 0;
|
||||||
|
int max_numdecompos = 0;
|
||||||
|
pack_nb = 0;
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
if (max_numdecompos < cstr_info->numdecompos[compno]) {
|
||||||
|
max_numdecompos = cstr_info->numdecompos[compno];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||||
|
fprintf(stream,
|
||||||
|
"part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||||
|
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||||
|
tilepartno, tileno,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||||
|
fprintf(stream,
|
||||||
|
"LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||||
|
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* LRCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||||
|
fprintf(stream,
|
||||||
|
"RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* RLCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < numprec; precno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (resno > cstr_info->numdecompos[compno]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* resno */
|
||||||
|
} /* RPCL */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec) {
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (precno >= numprec) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* compno */
|
||||||
|
} /* precno */
|
||||||
|
} /* PCRL */
|
||||||
|
|
||||||
|
else { /* CPRL */
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec) {
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream,
|
||||||
|
"CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor((float)tileno /
|
||||||
|
(float)cstr_info->tw) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] *
|
||||||
|
cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow(2, cstr_info->tile[tileno].pdx[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int pcy = (int) pow(2, cstr_info->tile[tileno].pdy[resno] +
|
||||||
|
cstr_info->numdecompos[compno] - resno);
|
||||||
|
int precno_x = precno - (int) floor((float)precno / (float)pcnx) * pcnx;
|
||||||
|
int precno_y = (int) floor((float)precno / (float)pcnx);
|
||||||
|
if (precno >= numprec) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = y0; y < y1; y++) {
|
||||||
|
if (precno_y * pcy == y) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x * pcx == x) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
}
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* CPRL */
|
||||||
|
} /* tileno */
|
||||||
|
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||||
|
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||||
|
}
|
||||||
|
/* UniPG>> */
|
||||||
|
/* print the markers' list */
|
||||||
|
if (cstr_info->marknum) {
|
||||||
|
fprintf(stream, "\nMARKER LIST\n");
|
||||||
|
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||||
|
fprintf(stream, "type\tstart_pos length\n");
|
||||||
|
for (x = 0; x < cstr_info->marknum; x++) {
|
||||||
|
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type,
|
||||||
|
cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* <<UniPG */
|
||||||
|
fclose(stream);
|
||||||
|
|
||||||
|
fprintf(stderr, "Generated index file %s\n", index);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue