Compare commits
284 Commits
codingstyl
...
version.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9586bc669c | ||
|
|
78dc93512b | ||
|
|
6778ef6a25 | ||
|
|
20eb15b760 | ||
|
|
8c71728242 | ||
|
|
4140dfdea8 | ||
|
|
259f629a46 | ||
|
|
c302efcf86 | ||
|
|
e0b5b08f9a | ||
|
|
dac95eff3a | ||
|
|
4f4de7070e | ||
|
|
78d1820881 | ||
|
|
de73cfeec1 | ||
|
|
49044ae2a8 | ||
|
|
6e0162a8a6 | ||
|
|
910af7edec | ||
|
|
69cd4f9211 | ||
|
|
6fc2b56847 | ||
|
|
773bd89130 | ||
|
|
5d356d6fcb | ||
|
|
a2f90ab2cb | ||
|
|
a05a9aa4ed | ||
|
|
af2be2d456 | ||
|
|
96dba34ddc | ||
|
|
6aad1208b2 | ||
|
|
d2be8c5d21 | ||
|
|
b42f76cb7f | ||
|
|
07163be7ed | ||
|
|
4e672cc1e9 | ||
|
|
ced9a50367 | ||
|
|
a1683bd7c2 | ||
|
|
f968a70e22 | ||
|
|
2fe6bac6eb | ||
|
|
15243144c4 | ||
|
|
c0c69d1c36 | ||
|
|
d9d62a77ee | ||
|
|
15488c94d2 | ||
|
|
75175b715c | ||
|
|
46831582b2 | ||
|
|
e55d5e29e0 | ||
|
|
c02f145cd1 | ||
|
|
6280b5ad8d | ||
|
|
7720188fa7 | ||
|
|
20f9f96719 | ||
|
|
4776f48477 | ||
|
|
c2f32bb485 | ||
|
|
bba708462d | ||
|
|
4935eaf773 | ||
|
|
bad9a71e77 | ||
|
|
a74a41b932 | ||
|
|
6b5bbc2645 | ||
|
|
8b5f815925 | ||
|
|
abce31e706 | ||
|
|
8062f74deb | ||
|
|
b8fecbbc99 | ||
|
|
cd8896968d | ||
|
|
b94bc0dbe2 | ||
|
|
083d4c2361 | ||
|
|
6c5a066b20 | ||
|
|
835bf5357f | ||
|
|
8a279881d4 | ||
|
|
6da56bb11a | ||
|
|
8cd13f3a55 | ||
|
|
eeca4a220c | ||
|
|
e17dcf58c9 | ||
|
|
39ac7c479f | ||
|
|
401e9cbb5c | ||
|
|
5dbf771bb9 | ||
|
|
ce9d5083ef | ||
|
|
baa7e32f9c | ||
|
|
097496a9f0 | ||
|
|
6b649f3bf6 | ||
|
|
65f8ae765e | ||
|
|
3aba3e203b | ||
|
|
95cf10e979 | ||
|
|
3a643798bd | ||
|
|
875591f664 | ||
|
|
4e8aea6b5a | ||
|
|
5379ec5715 | ||
|
|
b431cb0a41 | ||
|
|
dfbab28b4d | ||
|
|
3819c1b5f4 | ||
|
|
b09cd38b08 | ||
|
|
da453218a4 | ||
|
|
e0795464c1 | ||
|
|
fab8de59d3 | ||
|
|
dcf78f14f6 | ||
|
|
d1a1653f2a | ||
|
|
5a817eba3d | ||
|
|
ce5bbefff0 | ||
|
|
a5d96e54b9 | ||
|
|
2dddf54f8b | ||
|
|
992409c00c | ||
|
|
ee9c46d350 | ||
|
|
87a1081f7c | ||
|
|
83332e13ad | ||
|
|
675f34fabd | ||
|
|
0c7b21c46f | ||
|
|
590ba6d460 | ||
|
|
6f314ae48e | ||
|
|
24ab49a363 | ||
|
|
ecb36f02c8 | ||
|
|
8c9fd1b351 | ||
|
|
dd999a2840 | ||
|
|
b3b2ee0925 | ||
|
|
58cfcaff9f | ||
|
|
c1c2d24b16 | ||
|
|
cefa643823 | ||
|
|
64e37e2a66 | ||
|
|
545680cdb4 | ||
|
|
23cab09e07 | ||
|
|
8336ace29a | ||
|
|
a794ee233d | ||
|
|
a39e4a2a82 | ||
|
|
b267239603 | ||
|
|
54e4e8f809 | ||
|
|
8fc06de0c5 | ||
|
|
9a5ab44e35 | ||
|
|
4d76145884 | ||
|
|
bdf1343f62 | ||
|
|
52f5452d4d | ||
|
|
a9b7c7b0b4 | ||
|
|
07521a5dc2 | ||
|
|
d1bb3ed1f2 | ||
|
|
6c6cd79820 | ||
|
|
7b6ae8810d | ||
|
|
699f172e6c | ||
|
|
5fbf79e730 | ||
|
|
aa28216f9b | ||
|
|
e449cb706f | ||
|
|
a85c5151ce | ||
|
|
ed58a22d2e | ||
|
|
3408787101 | ||
|
|
948dfd50c0 | ||
|
|
46da9f2294 | ||
|
|
995b145f09 | ||
|
|
451a41064e | ||
|
|
c6b02b10fe | ||
|
|
36b66a8796 | ||
|
|
f1e441596e | ||
|
|
d5fa5605c4 | ||
|
|
427b2427d4 | ||
|
|
09522e65af | ||
|
|
19cfaac52e | ||
|
|
21c38214ef | ||
|
|
577fdbc8a5 | ||
|
|
f93aed8031 | ||
|
|
326c58b4e1 | ||
|
|
ec0c69af7a | ||
|
|
21509a3955 | ||
|
|
5b2ca9caf6 | ||
|
|
529006f136 | ||
|
|
7d96e7c1c0 | ||
|
|
e2948acd92 | ||
|
|
6dc8635e28 | ||
|
|
7d0a419c87 | ||
|
|
0ea0e8b915 | ||
|
|
8e53bad7fb | ||
|
|
9c51a37dbf | ||
|
|
aa00142949 | ||
|
|
87b05f2885 | ||
|
|
baf01b98fd | ||
|
|
6dd7da0e05 | ||
|
|
4949b593be | ||
|
|
0ed7aa7c1b | ||
|
|
02b906f6ad | ||
|
|
6a03e3a438 | ||
|
|
ec33653961 | ||
|
|
133426ddfe | ||
|
|
aab317eb8c | ||
|
|
f3f86e1eb7 | ||
|
|
040c9a68b6 | ||
|
|
2b746a71cb | ||
|
|
ba01e855a3 | ||
|
|
d3c1a49246 | ||
|
|
85bbc6def8 | ||
|
|
5bd5d894eb | ||
|
|
452403d393 | ||
|
|
fc268dff90 | ||
|
|
180dd26df1 | ||
|
|
d27bc19d71 | ||
|
|
b7b72bbf97 | ||
|
|
e1340fe087 | ||
|
|
32e80bc4a7 | ||
|
|
8d18c77a7d | ||
|
|
f492f0a3d6 | ||
|
|
6b43ba091e | ||
|
|
5dfadb2eb1 | ||
|
|
30944454de | ||
|
|
0e7529c272 | ||
|
|
c9986d1b78 | ||
|
|
4bc00a40ca | ||
|
|
80f69364b0 | ||
|
|
2e3900780d | ||
|
|
d530d35024 | ||
|
|
e96f7a5f50 | ||
|
|
79ce6ccce5 | ||
|
|
b7e489c901 | ||
|
|
dbd60c1469 | ||
|
|
007409e2af | ||
|
|
b82b6cbd05 | ||
|
|
f26b96dd5c | ||
|
|
7e6c287d78 | ||
|
|
6b1e9d1b4e | ||
|
|
d88dfc3472 | ||
|
|
64f08e216b | ||
|
|
c9ae2a5fbc | ||
|
|
51ae8b7926 | ||
|
|
3280dc344f | ||
|
|
0b7e0166a7 | ||
|
|
5fe8eed4da | ||
|
|
9d4d3b2cd0 | ||
|
|
02d9f43802 | ||
|
|
00b479cb79 | ||
|
|
6219ad32b0 | ||
|
|
a3a161660a | ||
|
|
2643f79069 | ||
|
|
fba8f701c4 | ||
|
|
4bcd3a1e42 | ||
|
|
594148ae83 | ||
|
|
2a2f169b27 | ||
|
|
e576aa9f06 | ||
|
|
c469e1339f | ||
|
|
abf9809c22 | ||
|
|
3ebdd674d8 | ||
|
|
a13abdaf65 | ||
|
|
72867bc692 | ||
|
|
b081ff2813 | ||
|
|
9d1bd03be4 | ||
|
|
82e539d333 | ||
|
|
548a49bb7f | ||
|
|
dc9a8b03aa | ||
|
|
c6e0b71633 | ||
|
|
0c350f4908 | ||
|
|
01749cb8a2 | ||
|
|
49f1a5ff54 | ||
|
|
ff1f022d47 | ||
|
|
3459199eba | ||
|
|
544e8c9de0 | ||
|
|
735b40989d | ||
|
|
09f2926cd5 | ||
|
|
238b767917 | ||
|
|
49a0f0db8f | ||
|
|
6a1530e4b1 | ||
|
|
8d8841c84f | ||
|
|
1dc6eddf1c | ||
|
|
c1510793e3 | ||
|
|
d728868263 | ||
|
|
8a2af121a4 | ||
|
|
9e60c2f8e9 | ||
|
|
d35f647aaa | ||
|
|
adbccc2e56 | ||
|
|
642d09f5cb | ||
|
|
d1cb786dd8 | ||
|
|
182e4b1882 | ||
|
|
73106fe839 | ||
|
|
40b4ecfaec | ||
|
|
fb82b6d7d9 | ||
|
|
5d6ac5ea72 | ||
|
|
3d06f03072 | ||
|
|
5213675ba8 | ||
|
|
9a89e2f162 | ||
|
|
e89eb575ac | ||
|
|
d15f01b6e3 | ||
|
|
9ec5e8cf9a | ||
|
|
4c9acc22b8 | ||
|
|
6adb5f5070 | ||
|
|
d1d662768d | ||
|
|
4091882dfb | ||
|
|
61e0ed6a96 | ||
|
|
9c7899372b | ||
|
|
a098921d34 | ||
|
|
8ed4cb1a1e | ||
|
|
721904bc26 | ||
|
|
2724f85cad | ||
|
|
40b989ce00 | ||
|
|
3e1d8d6aef | ||
|
|
fda0cada0e | ||
|
|
a58987d082 | ||
|
|
0f101066f2 | ||
|
|
cbe26cbb88 | ||
|
|
f753a1c36c | ||
|
|
c0ea54e518 | ||
|
|
c85e1a10cf |
63
.travis.yml
@@ -1,63 +0,0 @@
|
|||||||
language: c
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: osx
|
|
||||||
compiler: clang
|
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
|
||||||
- os: linux
|
|
||||||
compiler: gcc
|
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
|
||||||
- os: linux
|
|
||||||
compiler: gcc
|
|
||||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-multilib
|
|
||||||
- os: linux
|
|
||||||
compiler: gcc
|
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug
|
|
||||||
- os: linux
|
|
||||||
compiler: clang
|
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
|
||||||
- os: linux
|
|
||||||
compiler: x86_64-w64-mingw32-gcc
|
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-mingw-w64-base
|
|
||||||
- binutils-mingw-w64-x86-64
|
|
||||||
- gcc-mingw-w64-x86-64
|
|
||||||
- gcc-mingw-w64
|
|
||||||
- os: linux
|
|
||||||
compiler: x86_64-w64-mingw32-gcc
|
|
||||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-mingw-w64-base
|
|
||||||
- binutils-mingw-w64-i686
|
|
||||||
- gcc-mingw-w64-i686
|
|
||||||
- gcc-mingw-w64
|
|
||||||
- os: linux
|
|
||||||
compiler: gcc-4.8
|
|
||||||
env: OPJ_CI_ABI_CHECK=1
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- gcc-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
|
|
||||||
4
AUTHORS
@@ -3,10 +3,8 @@ See also the files THANKS and CHANGES
|
|||||||
|
|
||||||
David Janssens designed and implemented the first version of OpenJPEG.
|
David Janssens designed and implemented the first version of OpenJPEG.
|
||||||
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
||||||
Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
|
Jerome Fimes implemented the alpha version of OpenJPEG v2.
|
||||||
Giuseppe Baruffa added the JPWL functionalities.
|
Giuseppe Baruffa added the JPWL functionalities.
|
||||||
Micka<EFBFBD>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,
|
Yannick Verschueren,
|
||||||
Herve Drolon,
|
Herve Drolon,
|
||||||
Francois-Olivier Devaux,
|
Francois-Olivier Devaux,
|
||||||
|
|||||||
198
CHANGES
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
2012-10-01 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2028] CMakeLists.txt: [1.5] Start opj 1.5.2
|
||||||
|
* [r2029] libopenjpeg/jp2.c: [1.5] jp2_read_boxhdr() can trigger
|
||||||
|
random pointer memory access
|
||||||
|
|
||||||
|
Fixes issue 155
|
||||||
|
|
||||||
|
2012-10-02 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2031] libopenjpeg/Makefile.am, libopenjpeg/jpwl/Makefile.am:
|
||||||
|
[1.5] int main() in t1_generate_luts.c breaks mplayer
|
||||||
|
|
||||||
|
Fixes issue 152
|
||||||
|
* [r2032] libopenjpeg/j2k.c: [1.5] division by zero in j2k_read_siz
|
||||||
|
|
||||||
|
Fixes issue 169
|
||||||
|
* [r2033] libopenjpeg/j2k.c: [1.5] missing range check in
|
||||||
|
j2k_read_coc et al.
|
||||||
|
|
||||||
|
Fixes issue 166
|
||||||
|
* [r2035] libopenjpeg/CMakeLists.txt: [1.5] Build small internal
|
||||||
|
tools to generate t1_luts.h
|
||||||
|
|
||||||
|
2012-10-22 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2107] CMakeLists.txt, applications/JavaOpenJPEG/CMakeLists.txt:
|
||||||
|
[1.5] Fix Java binding issues.
|
||||||
|
|
||||||
|
Properly link to math lib on UNIX
|
||||||
|
Make JNI install location a user configuration
|
||||||
|
Remove SONAME property from the java module
|
||||||
|
|
||||||
|
2012-12-07 Rex Dieter
|
||||||
|
|
||||||
|
* [r2260] doc/Doxyfile.dox, doc/Doxyfile.dox.cmake.in: backport
|
||||||
|
r2259
|
||||||
|
|
||||||
|
Doxyfile: HTML_TIMESTAMP = NO
|
||||||
|
|
||||||
|
helps when comparing the output of multiple runs,
|
||||||
|
and distros will appreciate avoiding multilib conflicts.
|
||||||
|
|
||||||
|
2012-12-18 Mickaël Savinaud
|
||||||
|
|
||||||
|
* [r2265] applications/codec/convert.c: [1.5] improve the bmp read
|
||||||
|
function for RGB8 case (thanks Winfried). Update issue 203
|
||||||
|
|
||||||
|
2013-02-27 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2299] libopenjpeg/opj_includes.h: [1.5] Rework #ifdef checks.
|
||||||
|
We should check for _M_IX86 instead of not(_M_X64). Thanks to
|
||||||
|
Misha Ulyutin for report on ML
|
||||||
|
|
||||||
|
2013-03-14 Mickaël Savinaud
|
||||||
|
|
||||||
|
* [r2305] configure.ac: [b1.5.x] update the micro version into the
|
||||||
|
configure file (thanks to winfried)
|
||||||
|
|
||||||
|
2013-07-11 Antonin Descampe
|
||||||
|
|
||||||
|
* [r2345] tests/conformance/CMakeLists.txt: tests : reactivated
|
||||||
|
conformance tests in openjpeg 1.5 branch to enable comparison
|
||||||
|
with trunk
|
||||||
|
|
||||||
|
2013-09-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2346] libopenjpeg/image.c: [1.5] Import patch suggested in bug
|
||||||
|
#241
|
||||||
|
|
||||||
|
2014-02-24 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2390] libopenjpeg/bio.c: [1.5] Remove some simple warnings
|
||||||
|
* [r2391] CMake/CTestCustom.cmake.in: [1.5] Do not report warning
|
||||||
|
on third party lib
|
||||||
|
|
||||||
|
2014-02-25 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2420] tests/nonregression/CMakeLists.txt,
|
||||||
|
tests/nonregression/checkmd5refs.cmake,
|
||||||
|
tests/nonregression/md5refs.txt,
|
||||||
|
tests/nonregression/test_suite.ctest.in: [1.5] Import md5 checker
|
||||||
|
from trunk back onto 1.5 branch
|
||||||
|
* [r2423] libopenjpeg/j2k.c: [1.5] Remove addition from r1702 this
|
||||||
|
introduced a regression as seen in issue 205
|
||||||
|
|
||||||
|
Fixes issue 205
|
||||||
|
|
||||||
|
2014-02-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2437] tests/CMakeLists.txt, tests/conformance/CMakeLists.txt,
|
||||||
|
tests/nonregression/CMakeLists.txt, tests/unit/CMakeLists.txt:
|
||||||
|
[1.5] Use new add_test signature to handle cross compilation and
|
||||||
|
execution using wine
|
||||||
|
* [r2438] applications/codec/convert.c,
|
||||||
|
applications/codec/image_to_j2k.c, applications/codec/j2k_dump.c,
|
||||||
|
applications/codec/j2k_to_image.c, libopenjpeg/jp2.c,
|
||||||
|
libopenjpeg/tcd.c: [1.5] Import first patch (fixes.patch) from
|
||||||
|
issue 249 to fix leaks on error condition.
|
||||||
|
|
||||||
|
Update issue 249
|
||||||
|
* [r2439] applications/codec/image_to_j2k.c,
|
||||||
|
applications/codec/j2k_to_image.c: [1.5] Declare functions static
|
||||||
|
to track unused ones.
|
||||||
|
|
||||||
|
2014-03-04 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2564] CMakeLists.txt: [1.5] Use improved find_path syntax to
|
||||||
|
help cross-compilation setup find openjpeg data root
|
||||||
|
|
||||||
|
2014-03-12 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2696] applications/codec/convert.c, tests/unit/testempty2.c:
|
||||||
|
[1.5] Fix remainings warnings on 1.5 branch
|
||||||
|
* [r2697] applications/jpip/libopenjpip/msgqueue_manager.c: [1.5]
|
||||||
|
Prevent buffer overflow in openjpip code
|
||||||
|
|
||||||
|
2014-03-17 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2750] applications/common/opj_getopt.c: [1.5] Update BSD-4
|
||||||
|
copyright into a BSD-3 copyright
|
||||||
|
Update issue 300
|
||||||
|
* [r2752] libopenjpeg/jp2.c, libopenjpeg/t1_generate_luts.c: [1.5]
|
||||||
|
Remove simple warning about C++ style comments
|
||||||
|
* [r2753] applications/codec/convert.c,
|
||||||
|
applications/common/color.c, libopenjpeg/j2k.c,
|
||||||
|
libopenjpeg/jp2.c, libopenjpeg/t1_generate_luts.c,
|
||||||
|
libopenjpeg/tcd.c: [1.5] Remove another set of simple warnings
|
||||||
|
|
||||||
|
2014-03-18 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2757] libopenjpeg/cio.c, libopenjpeg/j2k.c, libopenjpeg/jp2.c,
|
||||||
|
libopenjpeg/t2.c, libopenjpeg/tcd.c,
|
||||||
|
tests/nonregression/test_suite.ctest.in: [1.5] Import portion of
|
||||||
|
patch from issue 297
|
||||||
|
Run test suite on new datasets
|
||||||
|
Update issue 297
|
||||||
|
* [r2758] libopenjpeg/jp2.c, libopenjpeg/tcd.c: [1.5] Import patch
|
||||||
|
from trunk to make test passes. Affects:
|
||||||
|
NR-DEC-2977.pdf.asan.67.2198.jp2-52-decode &
|
||||||
|
NR-DEC-4149.pdf.SIGSEGV.cf7.3501.jp2-50-decode
|
||||||
|
* [r2759] libopenjpeg/j2k.c: [1.5] Check the number of tiles
|
||||||
|
* [r2760] libopenjpeg/tcd.c: [1.5] Rework r2758 the conditions were
|
||||||
|
not quite right. Update checks.
|
||||||
|
* [r2762] applications/codec/convert.c: [1.5] Fix issues with big
|
||||||
|
endian handling
|
||||||
|
Fixes issue 302
|
||||||
|
* [r2765] applications/jpip/util/CMakeLists.txt: [1.5] Add a way
|
||||||
|
for user to override source/target java version
|
||||||
|
Update issue 303
|
||||||
|
* [r2768] CMakeLists.txt, applications/codec/CMakeLists.txt,
|
||||||
|
applications/common/opj_getopt.c,
|
||||||
|
applications/common/opj_getopt.h, opj_config.h.cmake.in,
|
||||||
|
tests/CMakeLists.txt: [1.5] Create a new cmake option to choose
|
||||||
|
between convienient copy of getopt and system installed one
|
||||||
|
Udapte issue 301
|
||||||
|
* [r2769] applications/codec/image_to_j2k.c,
|
||||||
|
applications/codec/j2k_dump.c, applications/codec/j2k_to_image.c,
|
||||||
|
applications/common/opj_getopt.h: [1.5] Rework r2768 in fact
|
||||||
|
getopt_long is slightly different on GNU. Adapt signature to
|
||||||
|
handle BSD signature and GNU one.
|
||||||
|
Update issue 301
|
||||||
|
|
||||||
|
2014-03-24 Rex Dieter
|
||||||
|
|
||||||
|
* [r2780] configure.ac: Calling AC_CANONICAL_SYSTEM implies
|
||||||
|
AC_CANONICAL_TARGET, which
|
||||||
|
gives incorrect results when cross compiling. Calling only
|
||||||
|
AC_CANONICAL_HOST is enough.
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
* [r2781] doc/Makefile.am: Install jpwl man pages only if jpwl is
|
||||||
|
enabled
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
* [r2782] m4/opj_check_lib.m4: Improve check for standard libs
|
||||||
|
|
||||||
|
Previously, with <lib>_LIBS and <lib>_CFLAGS undefined,
|
||||||
|
the most basic compile command "$CC conftest.c -l<lib>" was not
|
||||||
|
tested.
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
|
||||||
|
2014-03-25 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2800] applications/codec/Makefile.am,
|
||||||
|
applications/jpip/libopenjpip/CMakeLists.txt: [1.5] Import patch
|
||||||
|
from bug tracker
|
||||||
|
Thanks to winfried
|
||||||
|
Fixes issue 304
|
||||||
|
|
||||||
|
2014-03-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2807] configure.ac: [1.5] Fix big endian checking with
|
||||||
|
autotools
|
||||||
|
Thanks to winfried for patch
|
||||||
|
Fixes issue 302
|
||||||
|
|
||||||
@@ -8,11 +8,11 @@
|
|||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||||
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||||
|
|
||||||
set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||||
|
|
||||||
# Exclude files from the Testing directories
|
# Exclude files from the Testing directories
|
||||||
@@ -22,15 +22,12 @@ set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
|||||||
".*/thirdparty/.*"
|
".*/thirdparty/.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CTEST_CUSTOM_WARNING_EXCEPTION
|
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||||
|
|
||||||
# Suppress warning caused by intentional messages about deprecation
|
# Suppress warning caused by intentional messages about deprecation
|
||||||
".*warning,.* is deprecated"
|
".*warning,.* is deprecated"
|
||||||
# java also warns about deprecated API
|
# supress warnings caused by 3rd party libs:
|
||||||
".*java.*deprecation"
|
|
||||||
".*deprecation.*"
|
|
||||||
# suppress warnings caused by 3rd party libs:
|
|
||||||
".*thirdparty.*"
|
".*thirdparty.*"
|
||||||
"libtiff.*has no symbols"
|
"libtiff.*has no symbols"
|
||||||
"libpng.*has no symbols"
|
"libpng.*has no symbols"
|
||||||
20
CMake/FindFCGI.cmake
Normal file
@@ -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(FCGI_FOUND)
|
||||||
|
SET(FCGI_LIBRARIES)
|
||||||
|
SET(FCGI_INCLUDE_DIRS)
|
||||||
|
ENDIF(FCGI_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#
|
#
|
||||||
# this module looks for KAKADU
|
# this module looks for KAKADu
|
||||||
# http://www.kakadusoftware.com/
|
# http://www.kakadusoftware.com/
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
# Copyright (c) 2006-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
#
|
#
|
||||||
# Redistribution and use is allowed according to the terms of the New
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
# BSD license.
|
# BSD license.
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
#
|
#
|
||||||
|
|
||||||
find_program(KDU_EXPAND_EXECUTABLE
|
FIND_PROGRAM(KDU_EXPAND_EXECUTABLE
|
||||||
kdu_expand
|
kdu_expand
|
||||||
)
|
)
|
||||||
|
|
||||||
find_program(KDU_COMPRESS_EXECUTABLE
|
MARK_AS_ADVANCED(
|
||||||
kdu_compress
|
|
||||||
)
|
|
||||||
|
|
||||||
mark_as_advanced(
|
|
||||||
KDU_EXPAND_EXECUTABLE
|
KDU_EXPAND_EXECUTABLE
|
||||||
KDU_COMPRESS_EXECUTABLE
|
|
||||||
)
|
)
|
||||||
@@ -12,20 +12,20 @@
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
find_path(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
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)
|
SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||||
|
|
||||||
find_library(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||||
|
|
||||||
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
||||||
|
|
||||||
if(LCMS_FOUND)
|
IF(LCMS_FOUND)
|
||||||
set( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||||
set( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||||
endif()
|
ENDIF(LCMS_FOUND)
|
||||||
@@ -12,20 +12,20 @@
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
find_path(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
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)
|
SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||||
|
|
||||||
find_library(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||||
|
|
||||||
mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
||||||
|
|
||||||
if(LCMS2_FOUND)
|
IF(LCMS2_FOUND)
|
||||||
set( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||||
set( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||||
endif()
|
ENDIF(LCMS2_FOUND)
|
||||||
@@ -7,7 +7,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|||||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||||
endif()
|
endif()
|
||||||
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
||||||
endif()
|
endif(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||||
|
|
||||||
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
||||||
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
||||||
@@ -28,45 +28,43 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|||||||
|
|
||||||
# Make this explicit here, rather than accepting the CPack default value,
|
# Make this explicit here, rather than accepting the CPack default value,
|
||||||
# so we can refer to it:
|
# so we can refer to it:
|
||||||
set(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||||
|
|
||||||
if(NOT DEFINED CPACK_SYSTEM_NAME)
|
IF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
# make sure package is not Cygwin-unknown, for Cygwin just
|
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||||
# cygwin is good for the system name
|
# cygwin is good for the system name
|
||||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
set(CPACK_SYSTEM_NAME Cygwin)
|
SET(CPACK_SYSTEM_NAME Cygwin)
|
||||||
else()
|
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||||
endif()
|
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
endif()
|
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
if(CMAKE_CL_64)
|
IF(CMAKE_CL_64)
|
||||||
set(CPACK_SYSTEM_NAME win64-x64)
|
SET(CPACK_SYSTEM_NAME win64-x64)
|
||||||
else()
|
ELSE(CMAKE_CL_64)
|
||||||
set(CPACK_SYSTEM_NAME win32-x86)
|
SET(CPACK_SYSTEM_NAME win32-x86)
|
||||||
endif()
|
ENDIF(CMAKE_CL_64)
|
||||||
endif()
|
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
|
||||||
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||||
# default to source package - system, on cygwin system is not
|
# default to source package - system, on cygwin system is not
|
||||||
# needed
|
# needed
|
||||||
if(CYGWIN)
|
IF(CYGWIN)
|
||||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||||
else()
|
ELSE(CYGWIN)
|
||||||
set(CPACK_PACKAGE_FILE_NAME
|
SET(CPACK_PACKAGE_FILE_NAME
|
||||||
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||||
endif()
|
ENDIF(CYGWIN)
|
||||||
endif()
|
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
|
||||||
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
if(APPLE)
|
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||||
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
SET(CPACK_BUNDLE_PLIST
|
||||||
set(CPACK_BUNDLE_PLIST
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
#include(BundleUtilities)
|
||||||
#include(BundleUtilities)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||||
54
CMake/OpenJPEGConfig.cmake.in
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# 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)
|
||||||
|
# The following is inspired from:
|
||||||
|
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||||||
|
# However the following is difficult to handle:
|
||||||
|
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
|
||||||
|
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
|
||||||
|
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
# This is an install tree
|
||||||
|
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||||
|
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||||
|
|
||||||
|
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
# This is a build tree
|
||||||
|
SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||||
|
|
||||||
|
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
|
||||||
|
else(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
message(FATAL_ERROR "ooops")
|
||||||
|
endif(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
endif(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
|
||||||
|
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||||
|
|
||||||
|
# Backward compatible part:
|
||||||
|
SET(OPENJPEG_FOUND TRUE)
|
||||||
|
|
||||||
388
CMakeLists.txt
@@ -6,41 +6,37 @@
|
|||||||
# you will eventually like to prefix the library to avoid linking confusion
|
# 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
|
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||||
# e.g.:
|
# e.g.:
|
||||||
# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||||
cmake_minimum_required(VERSION 2.8.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
|
|
||||||
if(COMMAND CMAKE_POLICY)
|
IF(COMMAND CMAKE_POLICY)
|
||||||
cmake_policy(SET CMP0003 NEW)
|
CMAKE_POLICY(SET CMP0003 NEW)
|
||||||
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
ENDIF(COMMAND CMAKE_POLICY)
|
||||||
cmake_policy(SET CMP0042 NEW)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT OPENJPEG_NAMESPACE)
|
IF(NOT OPENJPEG_NAMESPACE)
|
||||||
set(OPENJPEG_NAMESPACE "OPENJPEG")
|
SET(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||||
set(OPENJPEG_STANDALONE 1)
|
SET(OPENJPEG_STANDALONE 1)
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_NAMESPACE)
|
||||||
# In all cases:
|
# In all cases:
|
||||||
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||||
set(OPENJPEG_LIBRARY_NAME openjp2)
|
|
||||||
|
|
||||||
project(${OPENJPEG_NAMESPACE} C)
|
PROJECT(${OPENJPEG_NAMESPACE} C)
|
||||||
|
|
||||||
# Do full dependency headers.
|
# Do full dependency headers.
|
||||||
include_regular_expression("^.*$")
|
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
set(OPENJPEG_VERSION_MAJOR 2)
|
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||||
set(OPENJPEG_VERSION_MINOR 1)
|
SET(OPENJPEG_VERSION_MINOR 5)
|
||||||
set(OPENJPEG_VERSION_BUILD 0)
|
SET(OPENJPEG_VERSION_BUILD 2)
|
||||||
set(OPENJPEG_VERSION
|
SET(OPENJPEG_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
set(PACKAGE_VERSION
|
SET(PACKAGE_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
|
||||||
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
# 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
|
# two numerorations, one for the openjpeg version and one for openjpeg soversion
|
||||||
# version | soversion
|
# version | soversion
|
||||||
# 1.0 | 0
|
# 1.0 | 0
|
||||||
# 1.1 | 1
|
# 1.1 | 1
|
||||||
@@ -50,34 +46,32 @@ set(PACKAGE_VERSION
|
|||||||
# 1.5 | 5
|
# 1.5 | 5
|
||||||
# 1.5.1 | 5
|
# 1.5.1 | 5
|
||||||
# 2.0 | 6
|
# 2.0 | 6
|
||||||
# 2.0.1 | 6
|
|
||||||
# 2.1 | 7
|
|
||||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
# 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:
|
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||||
if(NOT OPENJPEG_SOVERSION)
|
if(NOT OPENJPEG_SOVERSION)
|
||||||
SET(OPENJPEG_SOVERSION 7)
|
SET(OPENJPEG_SOVERSION 5)
|
||||||
endif(NOT OPENJPEG_SOVERSION)
|
endif(NOT OPENJPEG_SOVERSION)
|
||||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
SOVERSION "${OPENJPEG_SOVERSION}"
|
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Path to additional CMake modules
|
# Path to additional CMake modules
|
||||||
set(CMAKE_MODULE_PATH
|
SET(CMAKE_MODULE_PATH
|
||||||
${CMAKE_SOURCE_DIR}/cmake
|
${CMAKE_SOURCE_DIR}/CMake
|
||||||
${CMAKE_MODULE_PATH})
|
${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||||
# warnings
|
# warnings
|
||||||
if(WIN32)
|
IF(WIN32)
|
||||||
if(NOT BORLAND)
|
IF(NOT BORLAND)
|
||||||
if(NOT CYGWIN)
|
IF(NOT CYGWIN)
|
||||||
if(NOT MINGW)
|
IF(NOT MINGW)
|
||||||
if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
add_definitions(
|
ADD_DEFINITIONS(
|
||||||
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||||
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||||
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||||
@@ -89,50 +83,58 @@ if(WIN32)
|
|||||||
-D_CRT_VCCLRIT_NO_DEPRECATE
|
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||||
-D_SCL_SECURE_NO_DEPRECATE
|
-D_SCL_SECURE_NO_DEPRECATE
|
||||||
)
|
)
|
||||||
endif()
|
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
endif()
|
ENDIF(NOT MINGW)
|
||||||
endif()
|
ENDIF(NOT CYGWIN)
|
||||||
endif()
|
ENDIF(NOT BORLAND)
|
||||||
endif()
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Install directories
|
# 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)
|
STRING(TOLOWER ${PROJECT_NAME} projectname)
|
||||||
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
SET(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_BIN_DIR)
|
IF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
set(OPENJPEG_INSTALL_BIN_DIR "bin")
|
SET(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_LIB_DIR)
|
IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
set(OPENJPEG_INSTALL_LIB_DIR "lib")
|
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
# The following will compute the amount of parent dir to go
|
||||||
set(OPENJPEG_INSTALL_SHARE_DIR "share")
|
# from include to lib. it works nicely with
|
||||||
endif()
|
# OPENJPEG_INSTALL_LIB_DIR=lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=/lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
|
||||||
|
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
set(relative_parent "..")
|
||||||
|
foreach( elem ${relative_to_lib})
|
||||||
|
set( relative_parent "${relative_parent}/.." )
|
||||||
|
endforeach()
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_DATA_DIR)
|
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
|
|
||||||
if(BUILD_DOC)
|
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
endif()
|
|
||||||
|
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@@ -142,243 +144,163 @@ if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
# We could install *.cmake files in share/ however those files contains
|
# We could install *.cmake files in share/ however those files contains
|
||||||
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
# 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)
|
# 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}")
|
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
|
|
||||||
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:
|
# Big endian test:
|
||||||
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||||
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Setup file for setting custom ctest vars
|
# Setup file for setting custom ctest vars
|
||||||
configure_file(
|
CONFIGURE_FILE(
|
||||||
${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
|
||||||
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# OpenJPEG build configuration options.
|
# OpenJPEG build configuration options.
|
||||||
option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||||
set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
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.")
|
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)
|
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# configure name mangling to allow multiple libraries to coexist
|
# configure name mangling to allow multiple libraries to coexist
|
||||||
# peacefully
|
# peacefully
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||||
@ONLY)
|
@ONLY)
|
||||||
endif()
|
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# pkgconfig support
|
||||||
|
IF(UNIX)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||||
|
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
\"libopenjpeg1.pc\"
|
||||||
|
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Compiler specific flags:
|
# Compiler specific flags:
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
# For all builds, make sure openjpeg is std99 compliant:
|
# 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.
|
# 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:
|
# 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(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
endif()
|
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# opj_config.h generation (1/2)
|
# opj_config.h generation (1/2)
|
||||||
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
# 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("strings.h" HAVE_STRINGS_H)
|
||||||
|
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
||||||
|
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
||||||
|
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||||
|
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
|
||||||
|
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
|
||||||
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_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
|
# Build Library
|
||||||
if(BUILD_JPIP_SERVER)
|
INCLUDE_DIRECTORIES(BEFORE ${OPENJPEG_BINARY_DIR})
|
||||||
find_package(CURL REQUIRED)
|
ADD_SUBDIRECTORY(libopenjpeg)
|
||||||
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)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Build Applications
|
# Build Applications
|
||||||
option(BUILD_CODEC "Build the CODEC executables" ON)
|
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
|
||||||
option(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||||
option(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||||
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
OPTION(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||||
if(BUILD_JPIP)
|
IF(BUILD_JPIP)
|
||||||
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
OPTION(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||||
endif()
|
ENDIF(BUILD_JPIP)
|
||||||
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||||
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||||
option(BUILD_JP3D "Build the JP3D comp" OFF)
|
OPTION(USE_SYSTEM_GETOPT "Prefer system installed getopt()" OFF)
|
||||||
mark_as_advanced(BUILD_VIEWER)
|
MARK_AS_ADVANCED(USE_SYSTEM_GETOPT)
|
||||||
mark_as_advanced(BUILD_JAVA)
|
MARK_AS_ADVANCED(BUILD_VIEWER)
|
||||||
mark_as_advanced(BUILD_JP3D)
|
MARK_AS_ADVANCED(BUILD_JAVA)
|
||||||
|
|
||||||
if(BUILD_CODEC OR BUILD_MJ2)
|
IF(BUILD_CODEC OR BUILD_MJ2)
|
||||||
# OFF: It will only build 3rd party libs if they are not found on the system
|
# 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
|
# ON: 3rd party libs will ALWAYS be build, and used
|
||||||
option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
||||||
add_subdirectory(thirdparty)
|
ADD_SUBDIRECTORY(thirdparty)
|
||||||
add_subdirectory(src/bin)
|
ADD_SUBDIRECTORY(applications)
|
||||||
endif ()
|
ENDIF (BUILD_CODEC OR BUILD_MJ2)
|
||||||
add_subdirectory(wrapping)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# opj_config.h generation (2/2)
|
# opj_config.h generation (2/2)
|
||||||
configure_file(
|
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
|
"${OPENJPEG_BINARY_DIR}/opj_config.h"
|
||||||
${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
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# build documentation in doc subdir:
|
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||||
if(BUILD_DOC)
|
OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||||
add_subdirectory(doc)
|
IF(BUILD_DOC)
|
||||||
endif()
|
ADD_SUBDIRECTORY(doc)
|
||||||
|
ENDIF(BUILD_DOC)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Buld Testing
|
# Buld Testing
|
||||||
option(BUILD_TESTING "Build the tests." OFF)
|
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||||
if(BUILD_TESTING)
|
IF(BUILD_TESTING)
|
||||||
if(BUILD_CODEC)
|
IF(BUILD_CODEC)
|
||||||
enable_testing()
|
ENABLE_TESTING()
|
||||||
include(CTest)
|
INCLUDE(CTest)
|
||||||
|
|
||||||
# Search openjpeg data needed for the tests
|
# Search openjpeg data needed for the tests
|
||||||
# They could be found via git on the OpenJPEG GitHub code project
|
# They could be found via svn on the OpenJPEG google code project
|
||||||
# git clone https://github.com/uclouvain/openjpeg-data.git
|
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||||
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
||||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||||
|
${CMAKE_SOURCE_DIR}/../../data
|
||||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add repository where to find tests
|
# Add repository where to find tests
|
||||||
add_subdirectory(tests)
|
ADD_SUBDIRECTORY(tests)
|
||||||
|
|
||||||
else()
|
ELSE(BUILD_CODEC)
|
||||||
message(FATAL_ERROR "You need build codec to run the tests")
|
message(FATAL_ERROR "You need build codec to run the tests")
|
||||||
endif()
|
ENDIF(BUILD_CODEC)
|
||||||
endif()
|
ENDIF(BUILD_TESTING)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# install all targets referenced as OPENJPEGTargets
|
# install all targets referenced as OPENJPEGTargets
|
||||||
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
INSTALL(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||||
configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
|
||||||
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# install CHANGES and LICENSE
|
# install CHANGES and LICENSE
|
||||||
if(BUILD_DOC)
|
IF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
INSTALL(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
ENDIF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
endif()
|
INSTALL(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
|
||||||
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||||
endif()
|
|
||||||
|
|
||||||
include (cmake/OpenJPEGCPack.cmake)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# pkgconfig support
|
|
||||||
# enabled by default on Unix, disabled by default on other platforms
|
|
||||||
if(UNIX)
|
|
||||||
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()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
|
|||||||
75
INSTALL
@@ -2,10 +2,63 @@
|
|||||||
How to build and install openjpeg binaries
|
How to build and install openjpeg binaries
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
UNIX/LINUX/MacOSX/Windows systems
|
UNIX/LINUX similar systems
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Using cmake (see www.cmake.org)
|
1) Using autotools
|
||||||
|
|
||||||
|
It is highly recommended that pkg-config is installed. If needed, you have to
|
||||||
|
properly set the environment variable PKG_CONFIG_PATH so that the .pc files
|
||||||
|
are found.
|
||||||
|
|
||||||
|
To build from top-level directory, you can simply type:
|
||||||
|
./bootstrap.sh
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
To keep all build files in a separate directory, you can type instead:
|
||||||
|
./bootstrap.sh
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
../configure
|
||||||
|
make
|
||||||
|
|
||||||
|
To install:
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
To clean:
|
||||||
|
make clean
|
||||||
|
make distclean
|
||||||
|
|
||||||
|
To build doc (requires 'doxygen' to be found on your system):
|
||||||
|
(this will create an html directory in TOP_LEVEL/doc)
|
||||||
|
make doc
|
||||||
|
|
||||||
|
Main './configure' options (type './configure --help' for more details)
|
||||||
|
'--enable-mj2'
|
||||||
|
'--enable-jpwl'
|
||||||
|
'--enable-jpip'
|
||||||
|
'--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed')
|
||||||
|
'--enable-debug' (default : disabled)
|
||||||
|
|
||||||
|
You can also specify your own CFLAGS and LDFLAGS with (for example):
|
||||||
|
CFLAGS="-O3 -pipe" LDFLAGS="-Wl,-s" ./configure
|
||||||
|
|
||||||
|
The (optional) dependencies of some binaries are libpng, libtiff, libcms 1 or 2
|
||||||
|
and FastCGI. Only libtiff and FastCGI have no .pc file. There should be some
|
||||||
|
automatic detection if they are installed in /usr, /usr/local or /opt/local.
|
||||||
|
Otherwise, you can tune their detection (as well as for libpng and libcms1 or 2
|
||||||
|
too) with the environment variables:
|
||||||
|
|
||||||
|
TIFF_CFLAGS
|
||||||
|
TIFF_LIBS
|
||||||
|
FCGI_CFLAGS
|
||||||
|
FCGI_LIBS
|
||||||
|
|
||||||
|
See './configure --help' output for more details.
|
||||||
|
|
||||||
|
|
||||||
|
2) Using cmake (see www.cmake.org)
|
||||||
|
|
||||||
Type:
|
Type:
|
||||||
cmake .
|
cmake .
|
||||||
@@ -31,20 +84,14 @@ Main available cmake flags:
|
|||||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
* 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.
|
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||||
* To build the documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
|
|
||||||
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||||
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||||
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
||||||
** To build the JPIP server: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
|
|
||||||
* To build the JP3D library and utilities: '-DBUILD_JP3D:bool=on' (default: 'OFF') (experimental)
|
|
||||||
* To build the Java binding: '-DBUILD_JAVA:bool=on' (default: 'OFF') (experimental).
|
|
||||||
** to choose which java implementation, you can set your JAVA_HOME env var.
|
|
||||||
* To build the wxWidgets/C++ viewer: 'BUILD_VIEWER:BOOL=ON' (default OFF) (experimental)
|
|
||||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
* 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'
|
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
||||||
make
|
make
|
||||||
make Experimental
|
make Experimental
|
||||||
Note : JPEG2000 test files are available with 'git clone https://github.com/uclouvain/openjpeg-data.git'.
|
Note : JPEG2000 test files are available with 'svn checkout http://openjpeg.googlecode.com/svn/data' (about 70 Mo).
|
||||||
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
||||||
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
||||||
been checked out of course).
|
been checked out of course).
|
||||||
@@ -52,7 +99,7 @@ Main available cmake flags:
|
|||||||
MACOSX
|
MACOSX
|
||||||
------
|
------
|
||||||
|
|
||||||
The same building procedures as above work for MACOSX.
|
The same building procedures as above (autotools and cmake) work for MACOSX.
|
||||||
The xcode project file can also be used.
|
The xcode project file can also be used.
|
||||||
|
|
||||||
If it does not work, try adding the following flag to the cmake command :
|
If it does not work, try adding the following flag to the cmake command :
|
||||||
@@ -61,9 +108,7 @@ If it does not work, try adding the following flag to the cmake command :
|
|||||||
WINDOWS
|
WINDOWS
|
||||||
-------
|
-------
|
||||||
|
|
||||||
You can use cmake to generate project files for the IDE you are using (VS2010, NMake, etc).
|
If you're using cygwin or MinGW+MSYS, the same procedures as for Unix can be used.
|
||||||
|
|
||||||
|
Otherwise you can use cmake to generate project files for the IDE you are using (VC2010, etc).
|
||||||
Type 'cmake --help' for available generators on your platform.
|
Type 'cmake --help' for available generators on your platform.
|
||||||
|
|
||||||
Make sure to build the third party libs (png, zlib ...):
|
|
||||||
|
|
||||||
'-DBUILD_THIRDPARTY:BOOL=ON'
|
|
||||||
|
|||||||
14
LICENSE
@@ -1,19 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* BSD License, included below. This software may be subject to other third
|
* Copyright (c) 2002-2012, Professor Benoit Macq
|
||||||
* party and contributor rights, including patent rights, and no such rights
|
* Copyright (c) 2003-2012, Antonin Descampe
|
||||||
* 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) 2003-2009, Francois-Olivier Devaux
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
* 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.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
75
Makefile.am
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpip-server=yes --enable-jpwl=yes --enable-mj2=yes
|
||||||
|
|
||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpeg applications doc
|
||||||
|
|
||||||
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
|
pkgconfig_DATA = libopenjpeg1.pc
|
||||||
|
|
||||||
|
if WANT_JPWL
|
||||||
|
pkgconfig_DATA += libopenjpeg-jpwl.pc
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
MAINTAINERCLEANFILES = \
|
||||||
|
Makefile.in \
|
||||||
|
aclocal.m4 \
|
||||||
|
config.guess \
|
||||||
|
opj_config.h.in \
|
||||||
|
opj_config.h.in~ \
|
||||||
|
config.sub \
|
||||||
|
configure \
|
||||||
|
depcomp \
|
||||||
|
install-sh \
|
||||||
|
ltmain.sh \
|
||||||
|
missing
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMake/CTestCustom.cmake.in \
|
||||||
|
CMake/FindFCGI.cmake \
|
||||||
|
CMake/FindLCMS2.cmake \
|
||||||
|
CMake/FindLCMS.cmake \
|
||||||
|
CMake/OpenJPEGConfig.cmake.in \
|
||||||
|
CMakeLists.txt \
|
||||||
|
CTestConfig.cmake \
|
||||||
|
AUTHORS \
|
||||||
|
CHANGES \
|
||||||
|
INSTALL \
|
||||||
|
LICENSE \
|
||||||
|
NEWS \
|
||||||
|
README \
|
||||||
|
THANKS \
|
||||||
|
bootstrap.sh \
|
||||||
|
libopenjpeg1.pc.cmake \
|
||||||
|
libopenjpeg1.pc.in \
|
||||||
|
libopenjpeg-jpwl.pc.in \
|
||||||
|
opj_config.h.cmake.in \
|
||||||
|
m4/opj_check_lib.m4 \
|
||||||
|
m4/opj_doxygen.m4 \
|
||||||
|
m4/pkg.m4
|
||||||
|
|
||||||
|
.PHONY: doc
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
doc:
|
||||||
|
@echo "entering doc/"
|
||||||
|
@cd doc && make doc
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
if HAVE_WIN32
|
||||||
|
$(LN_S) -f libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
|
else
|
||||||
|
$(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
|
endif
|
||||||
|
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.pc" >> $(top_builddir)/report.txt
|
||||||
|
if WANT_JPWL
|
||||||
|
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg-jpwl.pc" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
@cat $(top_builddir)/report.txt
|
||||||
|
@rm $(top_builddir)/report.txt
|
||||||
|
|
||||||
|
uninstall-hook:
|
||||||
|
rm -f $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
62
NEWS
@@ -2,60 +2,24 @@
|
|||||||
OpenJPEG NEWS - user visible changes
|
OpenJPEG NEWS - user visible changes
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.X.X
|
Changes from OpenJPEG 1.5.2 to OpenJPEG 1.5.1
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
Security:
|
||||||
|
|
||||||
|
* Fixes: CVE-2013-4289 CVE-2013-4290
|
||||||
|
* Fixes: CVE-2013-1447 CVE-2013-6045 CVE-2013-6052 CVE-2013-6054 CVE-2013-6053 CVE-2013-6887
|
||||||
|
|
||||||
New Features:
|
New Features:
|
||||||
|
|
||||||
* Digital Cinema profiles have been fixed and updated
|
* Compile Java with source/target specific java version
|
||||||
* New option to disable MCT if needed
|
* Do not set SONAME for Java module, fix linking (missing math lib)
|
||||||
* extended RAW support: it is now possible to input raw images
|
* Support some BMP/RGB8 files
|
||||||
with subsampled color components (422, 420, etc)
|
* Fix compilation on ARM
|
||||||
* New way to deal with profiles
|
|
||||||
|
|
||||||
API/ABI modifications: (see abi_compat_report in dev-utils/scripts)
|
|
||||||
|
|
||||||
* 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:
|
Misc:
|
||||||
|
|
||||||
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
* Remove BSD-4 license from getopt copy, since upstream switched to BSD-3
|
||||||
and will soon become official reference software at the
|
* Support compilation against system installed getopt
|
||||||
JPEG committee.
|
* Fix Big Endian checking (autotools)
|
||||||
* Huge amount of bug fixes. See CHANGES for details.
|
|
||||||
|
|
||||||
|
|
||||||
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0
|
|
||||||
----------------------------------------------
|
|
||||||
|
|
||||||
New Features:
|
|
||||||
|
|
||||||
* streaming capabilities
|
|
||||||
* merge JP3D
|
|
||||||
|
|
||||||
API modifications:
|
|
||||||
|
|
||||||
* Use a 64bits capable API
|
|
||||||
|
|
||||||
Misc:
|
|
||||||
|
|
||||||
* removed autotools build system
|
|
||||||
* folders hierarchies reorganisation
|
|
||||||
* Huge amount of bug fixes. See CHANGES for details.
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
|
|||||||
25
README
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
OPENJPEG LIBRARY and APPLICATIONS
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Details on folders hierarchy:
|
||||||
|
|
||||||
|
* libopenjpeg: contains the sources of the openjpeg library
|
||||||
|
* jpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||||
|
* applications: contains all applications that use the openjpeg library
|
||||||
|
* common: common files to all applications
|
||||||
|
* codec: a basic codec
|
||||||
|
* mj2: motion jpeg 2000 executables
|
||||||
|
* JavaOpenJPEG: java jni to use openjpeg in a java program
|
||||||
|
* jpip: complete client-server architecture for remote browsing of jpeg 2000 images. See corresponding README for more details.
|
||||||
|
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||||
|
* 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 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||||
|
* CMake: cmake related files
|
||||||
|
* m4: autotools related files
|
||||||
|
|
||||||
|
see LICENSE for license and copyright information.
|
||||||
|
see INSTALL for installation procedures.
|
||||||
|
see NEWS for user visible changes in successive releases.
|
||||||
|
see CHANGES for per-revision changes.
|
||||||
79
README.md
@@ -1,79 +0,0 @@
|
|||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
See [LICENSE][link-license] for license and copyright information.
|
|
||||||
|
|
||||||
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL) for installation procedures.
|
|
||||||
|
|
||||||
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS) for user visible changes in successive releases.
|
|
||||||
|
|
||||||
## API/ABI
|
|
||||||
|
|
||||||
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"
|
|
||||||
48
THANKS
@@ -4,32 +4,30 @@ Many people have contributed to OpenJPEG by reporting problems, suggesting vario
|
|||||||
or submitting actual code. Here is a list of these people. Help me keep
|
or submitting actual code. Here is a list of these people. Help me keep
|
||||||
it complete and exempt of errors.
|
it complete and exempt of errors.
|
||||||
|
|
||||||
Giuseppe Baruffa
|
Mathieu Malaterre
|
||||||
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
|
|
||||||
Sebastien Lugan
|
|
||||||
Benoit Macq
|
|
||||||
Arnaud Maye
|
|
||||||
Julien Malik
|
|
||||||
Vincent Nicolas
|
|
||||||
Glenn Pearson
|
|
||||||
Dzonatas Sol
|
|
||||||
Winfried Szukalski
|
Winfried Szukalski
|
||||||
Vincent Torri
|
Vincent Torri
|
||||||
|
Bob Friesenhahn
|
||||||
|
Callum Lerwick
|
||||||
|
Dzonatas Sol
|
||||||
|
Mickaël Savinaud
|
||||||
|
Julien Malik
|
||||||
|
Jerôme Fimes
|
||||||
|
Herve Drolon
|
||||||
Yannick Verschueren
|
Yannick Verschueren
|
||||||
|
Sebastien Lugan
|
||||||
|
Kaori Hagihara
|
||||||
Peter Wimmer
|
Peter Wimmer
|
||||||
|
Francois-Olivier Devaux
|
||||||
|
Antonin Descampe
|
||||||
|
David Janssens
|
||||||
|
Pr. Benoit Macq
|
||||||
|
Luis Ibanez
|
||||||
|
Ben Boeckel
|
||||||
|
Vincent Nicolas
|
||||||
|
Glenn Pearson
|
||||||
|
Giuseppe Baruffa
|
||||||
|
Arnaud Maye
|
||||||
|
Rex Dieter
|
||||||
|
David Burken
|
||||||
|
Parvatha Elangovan
|
||||||
|
|||||||
22
applications/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Build the each application if it needed
|
||||||
|
|
||||||
|
IF(BUILD_CODEC)
|
||||||
|
ADD_SUBDIRECTORY(codec)
|
||||||
|
ENDIF(BUILD_CODEC)
|
||||||
|
|
||||||
|
IF(BUILD_MJ2)
|
||||||
|
ADD_SUBDIRECTORY(mj2)
|
||||||
|
ENDIF(BUILD_MJ2)
|
||||||
|
|
||||||
|
# Client & Server:
|
||||||
|
IF(BUILD_JPIP)
|
||||||
|
ADD_SUBDIRECTORY(jpip)
|
||||||
|
ENDIF(BUILD_JPIP)
|
||||||
|
|
||||||
|
IF(BUILD_VIEWER)
|
||||||
|
ADD_SUBDIRECTORY(OPJViewer)
|
||||||
|
ENDIF(BUILD_VIEWER)
|
||||||
|
|
||||||
|
IF(BUILD_JAVA)
|
||||||
|
ADD_SUBDIRECTORY(JavaOpenJPEG)
|
||||||
|
ENDIF(BUILD_JAVA)
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
#JavaOpenJPEG/CMakeLists.txt
|
#JavaOpenJPEG/CMakeLists.txt
|
||||||
|
|
||||||
# First thing define the common source:
|
# First thing define the common source:
|
||||||
set(openjpegjni_SRCS
|
SET(openjpegjni_SRCS
|
||||||
JavaOpenJPEGDecoder.c
|
JavaOpenJPEGDecoder.c
|
||||||
JavaOpenJPEG.c
|
JavaOpenJPEG.c
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
${OPENJPEG_SOURCE_DIR}/applications/codec/index.c
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/jp2/convert.c
|
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
|
||||||
index.c
|
#${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# JNI binding:
|
# JNI binding:
|
||||||
@@ -15,10 +16,9 @@ include_directories(${JNI_INCLUDE_DIRS})
|
|||||||
|
|
||||||
# required header file:
|
# required header file:
|
||||||
include_directories(
|
include_directories(
|
||||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
${OPENJPEG_SOURCE_DIR}/src/lib/openmj2
|
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
${OPENJPEG_SOURCE_DIR}/applications/codec
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/jp2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(openjpegjni MODULE
|
add_library(openjpegjni MODULE
|
||||||
@@ -27,24 +27,19 @@ add_library(openjpegjni MODULE
|
|||||||
# Java module should not have a SONAME:
|
# Java module should not have a SONAME:
|
||||||
set_property(TARGET openjpegjni PROPERTY NO_SONAME 1)
|
set_property(TARGET openjpegjni PROPERTY NO_SONAME 1)
|
||||||
|
|
||||||
# FIXME (need to use old API):
|
TARGET_LINK_LIBRARIES(openjpegjni ${OPENJPEG_LIBRARY_NAME})
|
||||||
if(BUILD_MJ2)
|
|
||||||
target_link_libraries(openjpegjni openmj2)
|
|
||||||
endif()
|
|
||||||
target_link_libraries(openjpegjni
|
|
||||||
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} ${Z_LIBNAME}
|
|
||||||
)
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(openjpegjni m)
|
target_link_libraries(openjpegjni m)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS openjpegjni
|
INSTALL(TARGETS openjpegjni
|
||||||
EXPORT OpenJPEGTargets
|
EXPORT OpenJPEGTargets
|
||||||
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
||||||
)
|
)
|
||||||
|
|
||||||
# build jar:
|
# build jar:
|
||||||
find_package(Java 1.5 REQUIRED) # javac, jar
|
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||||
|
|
||||||
# build dep list:
|
# build dep list:
|
||||||
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
||||||
@@ -52,7 +47,7 @@ file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
|||||||
# make sure target javac dir exists:
|
# make sure target javac dir exists:
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
|
||||||
# Build java
|
# Build java
|
||||||
add_custom_command(
|
ADD_CUSTOM_COMMAND(
|
||||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
||||||
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
|
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||||
@@ -63,11 +58,11 @@ add_custom_command(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# name the target
|
# name the target
|
||||||
add_custom_target(OpenJPEGJavaJar ALL
|
ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
|
||||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
COMMENT "building openjpeg.jar"
|
COMMENT "building openjpeg.jar"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
)
|
)
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
|
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
|
||||||
@@ -38,7 +37,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_includes.h"
|
|
||||||
#include "opj_getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
@@ -91,7 +89,7 @@ typedef struct img_folder{
|
|||||||
float *rates;
|
float *rates;
|
||||||
}img_fol_t;
|
}img_fol_t;
|
||||||
|
|
||||||
static void encode_help_display() {
|
void encode_help_display() {
|
||||||
fprintf(stdout,"HELP\n----\n\n");
|
fprintf(stdout,"HELP\n----\n\n");
|
||||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
@@ -206,7 +204,7 @@ static void encode_help_display() {
|
|||||||
fprintf(stdout," Indicate multiple modes by adding their values. \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," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-TP : divide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
|
fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
@@ -331,7 +329,7 @@ static void encode_help_display() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||||
if(strncmp(progression, "LRCP", 4) == 0) {
|
if(strncmp(progression, "LRCP", 4) == 0) {
|
||||||
return LRCP;
|
return LRCP;
|
||||||
}
|
}
|
||||||
@@ -351,6 +349,19 @@ static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
|||||||
return PROG_UNKNOWN;
|
return PROG_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <summary>
|
||||||
|
* Get logarithm of an integer and round downwards.
|
||||||
|
* </summary>
|
||||||
|
*/
|
||||||
|
int int_floorlog2(int a) {
|
||||||
|
int l;
|
||||||
|
for (l=0; a>1; l++) {
|
||||||
|
a>>=1;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
||||||
POC[0].tile = 1;
|
POC[0].tile = 1;
|
||||||
POC[0].resno0 = 0;
|
POC[0].resno0 = 0;
|
||||||
@@ -369,7 +380,7 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_parameters(opj_cparameters_t *parameters){
|
void cinema_parameters(opj_cparameters_t *parameters){
|
||||||
parameters->tile_size_on = OPJ_FALSE;
|
parameters->tile_size_on = OPJ_FALSE;
|
||||||
parameters->cp_tdx=1;
|
parameters->cp_tdx=1;
|
||||||
parameters->cp_tdy=1;
|
parameters->cp_tdy=1;
|
||||||
@@ -402,7 +413,7 @@ static void cinema_parameters(opj_cparameters_t *parameters){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
||||||
int i;
|
int i;
|
||||||
float temp_rate;
|
float temp_rate;
|
||||||
opj_poc_t *POC = NULL;
|
opj_poc_t *POC = NULL;
|
||||||
@@ -484,7 +495,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
|
|||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------ */
|
||||||
static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, char *indexfilename) {
|
img_fol_t *img_fol, char *indexfilename) {
|
||||||
int i, j,totlen;
|
int i, j,totlen;
|
||||||
opj_option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
@@ -502,7 +513,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:"
|
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:J"
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
"W:"
|
"W:"
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
@@ -617,7 +628,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
parameters->tcp_numlayers = numlayers;
|
parameters->tcp_numlayers = numlayers;
|
||||||
numresolution = parameters->numresolution;
|
numresolution = parameters->numresolution;
|
||||||
matrix_width = numresolution * 3;
|
matrix_width = numresolution * 3;
|
||||||
parameters->cp_matrice = (int *) opj_malloc(numlayers * matrix_width * sizeof(int));
|
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||||
|
if(parameters->cp_matrice == NULL) return 1;
|
||||||
|
|
||||||
s = s + 2;
|
s = s + 2;
|
||||||
|
|
||||||
for (i = 0; i < numlayers; i++) {
|
for (i = 0; i < numlayers; i++) {
|
||||||
@@ -845,7 +858,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(parameters->cp_comment == NULL) return 1;
|
||||||
|
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, opj_optarg);
|
strcpy(parameters->cp_comment, opj_optarg);
|
||||||
}
|
}
|
||||||
@@ -874,7 +890,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(img_fol->imgdirpath == NULL) return 1;
|
||||||
|
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
@@ -1236,6 +1255,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'J': /* jpip on */
|
||||||
|
{
|
||||||
|
parameters->jpip_on = OPJ_TRUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
@@ -1325,7 +1348,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
start position in the codestream
|
start position in the codestream
|
||||||
end position of this packet
|
end position of this packet
|
||||||
*/
|
*/
|
||||||
static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer_size) {
|
char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer_size) {
|
||||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
char* buffer = NULL;
|
char* buffer = NULL;
|
||||||
int buffer_pos = 0;
|
int buffer_pos = 0;
|
||||||
@@ -1334,11 +1357,11 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
prec_max = 0;
|
prec_max = 0;
|
||||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
for (resno = 0; resno < cstr_info->numdecompos[0] + 1; resno++) {
|
for (resno = 0; resno < cstr_info->numdecompos[0] + 1; resno++) {
|
||||||
prec_max = int_max(prec_max,cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]);
|
prec_max = max(prec_max,cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the size of the index buffer, in number of bytes*/
|
/* Compute the size of the index buffer, in number of bytes*/
|
||||||
*buffer_size =
|
*buffer_size =
|
||||||
1 /* version */
|
1 /* version */
|
||||||
+ (10 /* image_w until decomposition */
|
+ (10 /* image_w until decomposition */
|
||||||
@@ -1347,18 +1370,18 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
||||||
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
||||||
) * sizeof(int);
|
) * sizeof(int);
|
||||||
/*printf("C: index buffer size = %d bytes\n", *buffer_size);*/
|
/*printf("C: index buffer size = %d bytes\n", *buffer_size); */
|
||||||
buffer = (char*) opj_malloc(*buffer_size);
|
buffer = (char*) malloc(*buffer_size);
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
/*opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size);*/
|
/* opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size); */
|
||||||
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 1; /* Version stored on a byte*/
|
buffer[0] = 1; /* Version stored on a byte */
|
||||||
buffer++;
|
buffer++;
|
||||||
/* Remaining informations are stored on a int.*/
|
/* Remaining informations are stored on a int. */
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
||||||
@@ -1583,7 +1606,7 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
} /* tileno */
|
} /* tileno */
|
||||||
|
|
||||||
if (buffer_pos > *buffer_size) {
|
if (buffer_pos > *buffer_size) {
|
||||||
/*opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);*/
|
/* opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size); */
|
||||||
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1597,7 +1620,7 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
------------ Get the image byte[] from the Java object -------------------*/
|
------------ Get the image byte[] from the Java object -------------------*/
|
||||||
|
|
||||||
static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj, jclass cls) {
|
opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj, jclass cls) {
|
||||||
int i,max,shift,w,h,depth;
|
int i,max,shift,w,h,depth;
|
||||||
opj_image_t * img = NULL;
|
opj_image_t * img = NULL;
|
||||||
int compno, numcomps;
|
int compno, numcomps;
|
||||||
@@ -1616,7 +1639,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
jint *jiBody;
|
jint *jiBody;
|
||||||
jboolean isCopy;
|
jboolean isCopy;
|
||||||
|
|
||||||
/* Image width, height and depth*/
|
/* Image width, height and depth */
|
||||||
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
w = ji;
|
w = ji;
|
||||||
@@ -1629,7 +1652,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
depth = ji;
|
depth = ji;
|
||||||
|
|
||||||
/* Read the image*/
|
/* Read the image */
|
||||||
if (depth <=16) {
|
if (depth <=16) {
|
||||||
numcomps = 1;
|
numcomps = 1;
|
||||||
color_space = CLRSPC_GRAY;
|
color_space = CLRSPC_GRAY;
|
||||||
@@ -1644,8 +1667,10 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
cmptparm[0].y0 = parameters->image_offset_y0;
|
cmptparm[0].y0 = parameters->image_offset_y0;
|
||||||
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
||||||
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
||||||
/* Java types are always signed but we use them as unsigned types (shift of the negative part of
|
/* Java types are always signed but we use them as unsigned types
|
||||||
the pixels of the images in Telemis before entering the encoder).*/
|
* (shift of the negative part of the pixels of the images in
|
||||||
|
* Telemis before entering the encoder).
|
||||||
|
*/
|
||||||
cmptparm[0].sgnd = 0;
|
cmptparm[0].sgnd = 0;
|
||||||
if (depth<=16)
|
if (depth<=16)
|
||||||
cmptparm[0].prec=depth;
|
cmptparm[0].prec=depth;
|
||||||
@@ -1691,12 +1716,12 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
comp = &image->comps[compno];
|
comp = &image->comps[compno];
|
||||||
max = -100000;
|
max = -100000;
|
||||||
if (depth == 8) {
|
if (depth == 8) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image8", "[B"); /* byteArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image8", "[B");/* byteArray []*/
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jba);
|
len = (*env)->GetArrayLength(env, jba);
|
||||||
|
|
||||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
||||||
/*printf("C: before transferring 8 bpp image\n");*/
|
/* printf("C: before transfering 8 bpp image\n"); */
|
||||||
if (comp->sgnd) {
|
if (comp->sgnd) {
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = (char) jbBody[i];
|
comp->data[i] = (char) jbBody[i];
|
||||||
@@ -1710,13 +1735,14 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||||
} else if(depth == 16) {
|
} else if(depth == 16) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image16", "[S"); /* shortArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image16", "[S");/*shortArray []*/
|
||||||
jsa = (*env)->GetObjectField(env, obj, fid);
|
jsa = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jsa);
|
len = (*env)->GetArrayLength(env, jsa);
|
||||||
|
|
||||||
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
||||||
/*printf("C: before transferring 16 bpp image\n");*/
|
/*printf("C: before transfering 16 bpp image\n"); */
|
||||||
if (comp->sgnd) { /* Special behaviour to deal with signed elements ??*/
|
if (comp->sgnd) {
|
||||||
|
/* Special behaviour to deal with signed elements ?? */
|
||||||
comp->data[i] = (short) jsBody[i];
|
comp->data[i] = (short) jsBody[i];
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1729,14 +1755,15 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
||||||
} else if (depth == 24) {
|
} else if (depth == 24) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I"); /* intArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");/* intArray []*/
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jia);
|
len = (*env)->GetArrayLength(env, jia);
|
||||||
shift = compno*8;
|
shift = compno*8;
|
||||||
|
|
||||||
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
||||||
/*printf("C: before transferring 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/
|
/*printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/
|
||||||
if (comp->sgnd) { /* Special behaviour to deal with signed elements ?? XXXXX*/
|
if (comp->sgnd) {
|
||||||
|
/* Special behaviour to deal with signed elements ?? XXXXX */
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1751,7 +1778,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
comp->bpp = int_floorlog2(max)+1;
|
comp->bpp = int_floorlog2(max)+1;
|
||||||
comp->prec = comp->bpp;
|
comp->prec = comp->bpp;
|
||||||
/*printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);*/
|
/*printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);*/
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@@ -1761,7 +1788,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
opj_bool bSuccess;
|
opj_bool bSuccess;
|
||||||
opj_cparameters_t parameters; /* compression parameters */
|
opj_cparameters_t parameters; /* compression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
@@ -1769,12 +1796,12 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
opj_image_t *image = NULL;
|
opj_image_t *image = NULL;
|
||||||
int i,j,num_images;
|
int i,j,num_images;
|
||||||
int imageno;
|
int imageno;
|
||||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
char* compressed_index = NULL;
|
int* compressed_index = NULL;
|
||||||
int compressed_index_size=-1;
|
int compressed_index_size=-1;
|
||||||
/* ==> Access variables to the Java member variables*/
|
/* ==> Access variables to the Java member variables */
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -1783,18 +1810,20 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
jbyteArray jba;
|
jbyteArray jba;
|
||||||
jbyte *jbBody;
|
jbyte *jbBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
/* <== access variable to the Java member variables.*/
|
/* <== access variable to the Java member variables. */
|
||||||
|
jlong retval = -1;
|
||||||
/* For the encoding and storage into the file*/
|
/* For the encoding and storage into the file */
|
||||||
opj_cinfo_t* cinfo;
|
opj_cinfo_t* cinfo;
|
||||||
int codestream_length;
|
int codestream_length = -1;
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
||||||
/* JNI reference to the calling class*/
|
/* JNI reference to the calling class */
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
/* Pointers to be able to call a Java method for all the info and error messages*/
|
/* Pointers to be able to call a Java method
|
||||||
|
* for all the info and error messages
|
||||||
|
*/
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
@@ -1802,12 +1831,15 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
|
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = opj_malloc(argc*sizeof(char*));
|
argv = (const char **)malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; /* The program name: useless*/
|
|
||||||
|
if(argv == NULL) return -1;
|
||||||
|
|
||||||
|
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
argv[i] = (char*)(*env)->GetStringUTFChars(env, object, &isCopy);
|
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*printf("C: ");
|
/*printf("C: ");
|
||||||
@@ -1827,23 +1859,21 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
/* set encoding parameters to default values */
|
/* set encoding parameters to default values */
|
||||||
opj_set_default_encoder_parameters(¶meters);
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
parameters.cod_format = J2K_CFMT;
|
parameters.cod_format = J2K_CFMT;
|
||||||
/*parameters.index_on = 1;*/
|
/* parameters.index_on = 1; */
|
||||||
|
|
||||||
/* Initialize indexfilename and img_fol */
|
/* Initialize indexfilename and img_fol */
|
||||||
*indexfilename = 0;
|
*indexfilename = 0;
|
||||||
memset(&img_fol,0,sizeof(img_fol_t));
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
j = parse_cmdline_encoder(argc, (char *const*)argv, ¶meters,&img_fol, indexfilename);
|
||||||
/* Release the Java arguments array*/
|
|
||||||
for (i=1; i<argc; i++)
|
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the Java arguments array*/
|
/* Release the Java arguments array */
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env,
|
||||||
|
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
|
if(j == 1) goto fin; /* failure */
|
||||||
|
|
||||||
if (parameters.cp_cinema){
|
if (parameters.cp_cinema){
|
||||||
cinema_parameters(¶meters);
|
cinema_parameters(¶meters);
|
||||||
@@ -1857,10 +1887,16 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
const char *version = opj_version();
|
const char *version = opj_version();
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+11);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
|
||||||
|
|
||||||
|
if(parameters.cp_comment == NULL) goto fin;
|
||||||
|
|
||||||
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
||||||
#else
|
#else
|
||||||
parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+1);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
|
||||||
|
|
||||||
|
if(parameters.cp_comment == NULL) goto fin;
|
||||||
|
|
||||||
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
||||||
#endif
|
#endif
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
@@ -1877,10 +1913,10 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
image = loadImage(¶meters, env, obj, cls);
|
image = loadImage(¶meters, env, obj, cls);
|
||||||
/*printf("C: after load image: image = %d\n", image);*/
|
/* printf("C: after load image: image = %d\n", image); */
|
||||||
if (!image) {
|
if (!image) {
|
||||||
fprintf(stderr, "Unable to load image\n");
|
fprintf(stderr, "Unable to load image\n");
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decide if MCT should be used */
|
/* Decide if MCT should be used */
|
||||||
@@ -1914,7 +1950,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
codestream_length = cio_tell(cio);
|
codestream_length = cio_tell(cio);
|
||||||
|
|
||||||
@@ -1926,7 +1962,8 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compressed_index = create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
compressed_index = (int*)
|
||||||
|
create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
||||||
/* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
|
/* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
|
||||||
jba = (*env)->NewByteArray(env, compressed_index_size+1);
|
jba = (*env)->NewByteArray(env, compressed_index_size+1);
|
||||||
@@ -1934,21 +1971,21 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
memcpy(jbBody, compressed_index, compressed_index_size);
|
memcpy(jbBody, compressed_index, compressed_index_size);
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||||
(*env)->SetObjectField(env, obj, fid, jba);
|
(*env)->SetObjectField(env, obj, fid, jba);
|
||||||
opj_free(compressed_index);
|
free(compressed_index);
|
||||||
|
|
||||||
/* write the generated codestream to disk ? */
|
/* write the generated codestream to disk ? */
|
||||||
if (parameters.outfile[0]!='\0') {
|
if (parameters.outfile[0]!='\0') {
|
||||||
f = fopen(parameters.outfile, "wb");
|
f = fopen(parameters.outfile, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
|
fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
|
||||||
return -1;
|
goto fin;
|
||||||
}
|
}
|
||||||
fwrite(cio->buffer, 1, codestream_length, f);
|
fwrite(cio->buffer, 1, codestream_length, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
|
fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
|
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
|
||||||
@@ -1967,8 +2004,13 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free user parameters structure */
|
/* free user parameters structure */
|
||||||
if(parameters.cp_comment) opj_free(parameters.cp_comment);
|
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||||
if(parameters.cp_matrice) opj_free(parameters.cp_matrice);
|
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||||
|
|
||||||
return codestream_length;
|
retval = codestream_length;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
free(argv);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
|
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
|
||||||
@@ -38,7 +37,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_includes.h"
|
|
||||||
#include "opj_getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
@@ -205,7 +203,7 @@ int get_file_format(char *filename) {
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
int parse_cmdline_decoder(int argc, char * const argv[], opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen;
|
int totlen;
|
||||||
opj_option_t long_option[]={
|
opj_option_t long_option[]={
|
||||||
@@ -340,7 +338,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
|
||||||
|
if(img_fol->imgdirpath == NULL) return 1;
|
||||||
|
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
@@ -428,7 +429,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}/* parse_cmdline_decoder() */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -490,12 +491,13 @@ void info_callback(const char *msg, void *client_data) {
|
|||||||
(*env)->DeleteLocalRef(env, jbuffer);
|
(*env)->DeleteLocalRef(env, jbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FAILS -1
|
||||||
|
#define OK 0
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||||
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
@@ -510,7 +512,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
int w,h;
|
int w,h;
|
||||||
long min_value, max_value;
|
long min_value, max_value;
|
||||||
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
||||||
/* ==> Access variables to the Java member variables*/
|
/* ==> Access variables to the Java member variables */
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -523,8 +525,9 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
jshort *jsBody, *ptrSBody;
|
jshort *jsBody, *ptrSBody;
|
||||||
jint *jiBody, *ptrIBody;
|
jint *jiBody, *ptrIBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
/* <=== access variable to Java member variables */
|
/* <=== access variable to Java member variables */
|
||||||
int *ptr, *ptr1, *ptr2; /* <== To transfer the decoded image to Java*/
|
int *ptr, *ptr1, *ptr2;/* <== To transfer the decoded image to Java */
|
||||||
|
jint retval = FAILS;
|
||||||
|
|
||||||
/* configure the event callbacks */
|
/* configure the event callbacks */
|
||||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
@@ -532,24 +535,30 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
event_mgr.warning_handler = warning_callback;
|
event_mgr.warning_handler = warning_callback;
|
||||||
event_mgr.info_handler = info_callback;
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
/* JNI reference to the calling class*/
|
/* JNI reference to the calling class */
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
/* Pointers to be able to call a Java method for all the info and error messages*/
|
/* Pointers to be able to call a Java method
|
||||||
|
* for all the info and error messages
|
||||||
|
*/
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
/* Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.*/
|
/* Get the String[] containing the parameters */
|
||||||
|
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = opj_malloc(argc*sizeof(char*));
|
argv = (const char **)malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; /* The program name: useless*/
|
|
||||||
|
if(argv == NULL) return FAILS;
|
||||||
|
|
||||||
|
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
argv[i] = (char*)(*env)->GetStringUTFChars(env, object, &isCopy);
|
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*printf("C: decoder params = ");
|
/*printf("C: decoder params = ");
|
||||||
@@ -563,19 +572,18 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
parameters.decod_format = J2K_CFMT;
|
parameters.decod_format = J2K_CFMT;
|
||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
j = parse_cmdline_decoder(argc, (char * const*)argv, ¶meters,&img_fol);
|
||||||
/* Release the Java arguments array*/
|
|
||||||
for (i=1; i<argc; i++)
|
/* Release the Java arguments array */
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* Release the Java arguments array*/
|
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env,
|
||||||
|
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
|
if(j == 1) goto fin; /* failure */
|
||||||
|
|
||||||
num_images=1;
|
num_images=1;
|
||||||
|
|
||||||
/* Get additional information from the Java object variables*/
|
/* Get additional information from the Java object variables */
|
||||||
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
||||||
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
||||||
|
|
||||||
@@ -589,22 +597,25 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
Implemented for debug purpose. */
|
Implemented for debug purpose. */
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
if (parameters.infile && parameters.infile[0]!='\0') {
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
/*printf("C: opening [%s]\n", parameters.infile);*/
|
/* printf("C: opening [%s]\n", parameters.infile); */
|
||||||
fsrc = fopen(parameters.infile, "rb");
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
if (!fsrc) {
|
if (!fsrc) {
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
fseek(fsrc, 0, SEEK_END);
|
fseek(fsrc, 0, SEEK_END);
|
||||||
file_length = ftell(fsrc);
|
file_length = ftell(fsrc);
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
src = (unsigned char *) opj_malloc(file_length);
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
|
||||||
|
if(src == NULL) goto fin;
|
||||||
|
|
||||||
fread(src, 1, file_length, fsrc);
|
fread(src, 1, file_length, fsrc);
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
/*printf("C: %d bytes read from file\n",file_length);*/
|
/* printf("C: %d bytes read from file\n",file_length); */
|
||||||
} else {
|
} else {
|
||||||
/* Preparing the transfer of the codestream from Java to C*/
|
/* Preparing the transfer of the codestream from Java to C */
|
||||||
/*printf("C: before transferring codestream\n");*/
|
/* printf("C: before transfering codestream\n"); */
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
file_length = (*env)->GetArrayLength(env, jba);
|
file_length = (*env)->GetArrayLength(env, jba);
|
||||||
@@ -638,7 +649,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -668,7 +679,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -699,7 +710,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
return 1;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
@@ -714,7 +725,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
/* free the memory containing the code-stream */
|
/* free the memory containing the code-stream */
|
||||||
if (parameters.infile && parameters.infile[0]!='\0') {
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
opj_free(src);
|
free(src);
|
||||||
} else {
|
} else {
|
||||||
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
||||||
}
|
}
|
||||||
@@ -754,17 +765,21 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========= Return the image to the Java structure ===============*/
|
/* ========= Return the image to the Java structure =============== */
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
printf("C: checking thresholds\n");
|
printf("C: checking thresholds\n");
|
||||||
#endif
|
#endif
|
||||||
/* First compute the real with and height, in function of the resolutions decoded.*/
|
/* First compute the real with and height,
|
||||||
/*wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;*/
|
* in function of the resolutions decoded.
|
||||||
/*hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;*/
|
*/
|
||||||
|
/*---
|
||||||
|
wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
---*/
|
||||||
w = image->comps[0].w;
|
w = image->comps[0].w;
|
||||||
h = image->comps[0].h;
|
h = image->comps[0].h;
|
||||||
|
|
||||||
if (image->numcomps==3) { /* 3 components color image*/
|
if (image->numcomps==3) { /* 3 components color image */
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
ptr1 = image->comps[1].data;
|
ptr1 = image->comps[1].data;
|
||||||
ptr2 = image->comps[2].data;
|
ptr2 = image->comps[2].data;
|
||||||
@@ -777,12 +792,12 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Get the pointer to the Java structure where the data must be copied*/
|
/* Get the pointer to the Java structure where the data must be copied */
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
||||||
ptrIBody = jiBody;
|
ptrIBody = jiBody;
|
||||||
printf("C: transferring image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
|
printf("C: transfering image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
|
||||||
|
|
||||||
for (i=0; i<w*h; i++) {
|
for (i=0; i<w*h; i++) {
|
||||||
tempUC = (unsigned char)(ptr[i]);
|
tempUC = (unsigned char)(ptr[i]);
|
||||||
@@ -806,9 +821,9 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
}
|
}
|
||||||
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
||||||
|
|
||||||
} else { /* 1 component 8 or 16 bpp image*/
|
} else { /* 1 component 8 or 16 bpp image */
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
printf("C: before transferring a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
||||||
if (image->comps[0].prec<=8) {
|
if (image->comps[0].prec<=8) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image8", "[B");
|
fid = (*env)->GetFieldID(env, cls,"image8", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
@@ -823,7 +838,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*printf("C: transferring %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);*/
|
/* printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody); */
|
||||||
for (i=0; i<w*h; i++) {
|
for (i=0; i<w*h; i++) {
|
||||||
tempUC = (unsigned char) (ptr[i]);
|
tempUC = (unsigned char) (ptr[i]);
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
@@ -835,7 +850,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
*(ptrBBody++) = tempUC;
|
*(ptrBBody++) = tempUC;
|
||||||
}
|
}
|
||||||
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
||||||
printf("C: image8 transferred to Java\n");
|
printf("C: image8 transfered to Java\n");
|
||||||
} else {
|
} else {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image16", "[S");
|
fid = (*env)->GetFieldID(env, cls,"image16", "[S");
|
||||||
jsa = (*env)->GetObjectField(env, obj, fid);
|
jsa = (*env)->GetObjectField(env, obj, fid);
|
||||||
@@ -851,7 +866,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
}
|
}
|
||||||
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
|
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
|
||||||
#endif
|
#endif
|
||||||
printf("C: transferring %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
printf("C: transfering %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
||||||
for (i=0; i<w*h; i++) {
|
for (i=0; i<w*h; i++) {
|
||||||
tempS = (short) (ptr[i]);
|
tempS = (short) (ptr[i]);
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
@@ -879,7 +894,12 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1; /* OK */
|
retval = OK;
|
||||||
}
|
|
||||||
/*end main*/
|
fin:
|
||||||
|
free(argv);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
/* end main MAIN */
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
19
applications/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = codec
|
||||||
|
|
||||||
|
if WANT_MJ2
|
||||||
|
SUBDIRS += mj2
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WANT_JPIP_CODE
|
||||||
|
SUBDIRS += jpip
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
common/color.c \
|
||||||
|
common/color.h \
|
||||||
|
common/format_defs.h \
|
||||||
|
common/opj_getopt.c \
|
||||||
|
common/opj_getopt.h
|
||||||
@@ -1,21 +1,17 @@
|
|||||||
project(viewer CXX)
|
PROJECT(viewer CXX)
|
||||||
|
|
||||||
find_package(wxWidgets REQUIRED)
|
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||||
include(${wxWidgets_USE_FILE})
|
INCLUDE(${wxWidgets_USE_FILE})
|
||||||
|
|
||||||
include_directories(
|
INCLUDE_DIRECTORIES(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||||
${OPENJPEG_SOURCE_DIR}/src/lib
|
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin
|
|
||||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
|
||||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# original flags:
|
# original flags:
|
||||||
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
||||||
add_definitions(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
ADD_DEFINITIONS(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
||||||
set(OPJV_SRCS
|
SET(OPJV_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
||||||
@@ -23,7 +19,7 @@ set(OPJV_SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/jp2/index.c
|
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
|
||||||
)
|
)
|
||||||
add_executable(opjviewer ${OPJV_SRCS})
|
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
|
||||||
target_link_libraries(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
||||||
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -889,7 +884,7 @@ void OPJMarkerTree::OnSelChanged(wxTreeEvent& event)
|
|||||||
|
|
||||||
m_peektextCtrl->WriteText(text);
|
m_peektextCtrl->WriteText(text);
|
||||||
|
|
||||||
delete [] buffer;
|
delete buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void LogKeyEvent(const wxChar *name, const wxKeyEvent& event)
|
/*void LogKeyEvent(const wxChar *name, const wxKeyEvent& event)
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -106,7 +101,7 @@
|
|||||||
#include "wx/toolbar.h"
|
#include "wx/toolbar.h"
|
||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
|
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
//#include "imagj2k.h"
|
//#include "imagj2k.h"
|
||||||
//#include "imagjp2.h"
|
//#include "imagjp2.h"
|
||||||
@@ -180,83 +175,73 @@ class OPJChildFrame;
|
|||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
class OPJViewerApp: public wxApp
|
class OPJViewerApp: public wxApp
|
||||||
{
|
{
|
||||||
// public methods and variables
|
// public methods and variables
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// class constructor
|
// class constructor
|
||||||
OPJViewerApp()
|
OPJViewerApp() { m_showImages = true; m_showButtons = false; }
|
||||||
{
|
|
||||||
m_showImages = true;
|
|
||||||
m_showButtons = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// other methods
|
// other methods
|
||||||
bool OnInit(void);
|
bool OnInit(void);
|
||||||
int OnExit(void);
|
int OnExit(void);
|
||||||
void SetShowImages(bool show)
|
void SetShowImages(bool show) { m_showImages = show; }
|
||||||
{
|
bool ShowImages() const { return m_showImages; }
|
||||||
m_showImages = show;
|
void ShowCmdLine(const wxCmdLineParser& parser);
|
||||||
}
|
|
||||||
bool ShowImages() const
|
|
||||||
{
|
|
||||||
return m_showImages;
|
|
||||||
}
|
|
||||||
void ShowCmdLine(const wxCmdLineParser& parser);
|
|
||||||
|
|
||||||
// all the threads currently alive - as soon as the thread terminates, it's
|
// all the threads currently alive - as soon as the thread terminates, it's
|
||||||
// removed from the array
|
// removed from the array
|
||||||
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
|
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
|
||||||
|
|
||||||
// crit section protects access to all of the arrays below
|
// crit section protects access to all of the arrays below
|
||||||
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
|
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
|
||||||
|
|
||||||
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
|
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
|
||||||
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
|
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
|
||||||
|
|
||||||
// the last exiting thread should post to m_semAllDone if this is true
|
// the last exiting thread should post to m_semAllDone if this is true
|
||||||
// (protected by the same m_critsect)
|
// (protected by the same m_critsect)
|
||||||
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
|
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
|
||||||
|
|
||||||
// the list of all filenames written in the command line
|
// the list of all filenames written in the command line
|
||||||
wxArrayString m_filelist;
|
wxArrayString m_filelist;
|
||||||
|
|
||||||
// displaying engine parameters
|
// displaying engine parameters
|
||||||
int m_resizemethod;
|
int m_resizemethod;
|
||||||
|
|
||||||
// decoding engine parameters
|
// decoding engine parameters
|
||||||
bool m_enabledeco, m_enableparse;
|
bool m_enabledeco, m_enableparse;
|
||||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
bool m_enablejpwl, m_enablejpwle;
|
bool m_enablejpwl, m_enablejpwle;
|
||||||
int m_expcomps, m_maxtiles;
|
int m_expcomps, m_maxtiles;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
int m_framewidth, m_frameheight;
|
int m_framewidth, m_frameheight;
|
||||||
|
|
||||||
// encoding engine parameters
|
// encoding engine parameters
|
||||||
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
||||||
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
|
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
|
||||||
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
|
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
|
||||||
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
|
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
|
||||||
bool m_enablesegmark, m_enablepoc;
|
bool m_enablesegmark, m_enablepoc;
|
||||||
bool m_enablequality;
|
bool m_enablequality;
|
||||||
int m_resolutions, m_progression;
|
int m_resolutions, m_progression;
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
|
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
|
||||||
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
|
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
|
||||||
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
|
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
|
||||||
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
|
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
|
|
||||||
// some layout settings
|
// some layout settings
|
||||||
bool m_showtoolbar, m_showbrowser, m_showpeeker;
|
bool m_showtoolbar, m_showbrowser, m_showpeeker;
|
||||||
int m_browserwidth, m_peekerheight;
|
int m_browserwidth, m_peekerheight;
|
||||||
|
|
||||||
// application configuration
|
// application configuration
|
||||||
wxConfig *OPJconfig;
|
wxConfig *OPJconfig;
|
||||||
|
|
||||||
// private methods and variables
|
// private methods and variables
|
||||||
private:
|
private:
|
||||||
bool m_showImages, m_showButtons;
|
bool m_showImages, m_showButtons;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,38 +252,37 @@ DECLARE_APP(OPJViewerApp)
|
|||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
class OPJCanvas: public wxScrolledWindow
|
class OPJCanvas: public wxScrolledWindow
|
||||||
{
|
{
|
||||||
// public methods and variables
|
// public methods and variables
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// class constructor
|
// class constructor
|
||||||
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
virtual void OnDraw(wxDC& dc);
|
virtual void OnDraw(wxDC& dc);
|
||||||
void OnEvent(wxMouseEvent& event);
|
void OnEvent(wxMouseEvent& event);
|
||||||
void WriteText(const wxString& text)
|
void WriteText(const wxString& text) {
|
||||||
{
|
#ifndef __WXGTK__
|
||||||
#ifndef __WXGTK__
|
wxMutexGuiEnter();
|
||||||
wxMutexGuiEnter();
|
|
||||||
#endif //__WXGTK__
|
#endif //__WXGTK__
|
||||||
wxLogMessage(text);
|
wxLogMessage(text);
|
||||||
#ifndef __WXGTK__
|
#ifndef __WXGTK__
|
||||||
wxMutexGuiLeave();
|
wxMutexGuiLeave();
|
||||||
#endif //__WXGTK__
|
#endif //__WXGTK__
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnThreadSignal(wxCommandEvent& event);
|
void OnThreadSignal(wxCommandEvent& event);
|
||||||
|
|
||||||
OPJDecoThread *CreateDecoThread(void);
|
OPJDecoThread *CreateDecoThread(void);
|
||||||
OPJEncoThread *CreateEncoThread(void);
|
OPJEncoThread *CreateEncoThread(void);
|
||||||
|
|
||||||
|
|
||||||
OPJChildFrame *m_childframe;
|
OPJChildFrame *m_childframe;
|
||||||
|
|
||||||
wxBitmap m_image, m_image100;
|
wxBitmap m_image, m_image100;
|
||||||
wxFileName m_fname, m_savename;
|
wxFileName m_fname, m_savename;
|
||||||
long m_zooml;
|
long m_zooml;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
@@ -306,38 +290,29 @@ public:
|
|||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
class OPJMarkerData : public wxTreeItemData
|
class OPJMarkerData : public wxTreeItemData
|
||||||
{
|
{
|
||||||
// public methods and variables
|
// public methods and variables
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// class constructor
|
// class constructor
|
||||||
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname)
|
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
|
||||||
{
|
|
||||||
m_start = start;
|
|
||||||
m_length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowInfo(wxTreeCtrl *tree);
|
void ShowInfo(wxTreeCtrl *tree);
|
||||||
const wxChar *GetDesc1() const
|
const wxChar *GetDesc1() const { return m_desc.c_str(); }
|
||||||
{
|
const wxChar *GetDesc2() const { return m_filestring.c_str(); }
|
||||||
return m_desc.c_str();
|
wxFileOffset m_start, m_length;
|
||||||
}
|
wxString m_desc;
|
||||||
const wxChar *GetDesc2() const
|
|
||||||
{
|
|
||||||
return m_filestring.c_str();
|
|
||||||
}
|
|
||||||
wxFileOffset m_start, m_length;
|
|
||||||
wxString m_desc;
|
|
||||||
|
|
||||||
// private methods and variables
|
// private methods and variables
|
||||||
private:
|
private:
|
||||||
wxString m_filestring;
|
wxString m_filestring;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class OPJMarkerTree : public wxTreeCtrl
|
class OPJMarkerTree : public wxTreeCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
TreeCtrlIcon_File,
|
TreeCtrlIcon_File,
|
||||||
TreeCtrlIcon_FileSelected,
|
TreeCtrlIcon_FileSelected,
|
||||||
TreeCtrlIcon_Folder,
|
TreeCtrlIcon_Folder,
|
||||||
@@ -347,20 +322,15 @@ public:
|
|||||||
|
|
||||||
OPJMarkerTree() { };
|
OPJMarkerTree() { };
|
||||||
OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
|
OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
|
||||||
const wxPoint& pos, const wxSize& size,
|
const wxPoint& pos, const wxSize& size,
|
||||||
long style);
|
long style);
|
||||||
virtual ~OPJMarkerTree() {};
|
virtual ~OPJMarkerTree(){};
|
||||||
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
||||||
void WriteText(const wxString& text)
|
void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
|
||||||
{
|
|
||||||
wxMutexGuiEnter();
|
|
||||||
wxLogMessage(text);
|
|
||||||
wxMutexGuiLeave();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFileName m_fname;
|
wxFileName m_fname;
|
||||||
wxTextCtrl *m_peektextCtrl;
|
wxTextCtrl *m_peektextCtrl;
|
||||||
OPJChildFrame *m_childframe;
|
OPJChildFrame *m_childframe;
|
||||||
|
|
||||||
/*void OnBeginDrag(wxTreeEvent& event);
|
/*void OnBeginDrag(wxTreeEvent& event);
|
||||||
void OnBeginRDrag(wxTreeEvent& event);
|
void OnBeginRDrag(wxTreeEvent& event);
|
||||||
@@ -397,15 +367,9 @@ public:
|
|||||||
/*void DoToggleIcon(const wxTreeItemId& item);*/
|
/*void DoToggleIcon(const wxTreeItemId& item);*/
|
||||||
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
|
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
|
||||||
|
|
||||||
int ImageSize(void) const
|
int ImageSize(void) const { return m_imageSize; }
|
||||||
{
|
|
||||||
return m_imageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetLastItem(wxTreeItemId id)
|
void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
|
||||||
{
|
|
||||||
m_lastItem = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
|
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
|
||||||
@@ -447,12 +411,12 @@ WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChild
|
|||||||
// Define a new frame
|
// Define a new frame
|
||||||
class OPJFrame: public wxMDIParentFrame
|
class OPJFrame: public wxMDIParentFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
|
|
||||||
~OPJFrame(void);
|
~OPJFrame(void);
|
||||||
void OnSize(wxSizeEvent& WXUNUSED(event));
|
void OnSize(wxSizeEvent& WXUNUSED(event));
|
||||||
void OnAbout(wxCommandEvent& WXUNUSED(event));
|
void OnAbout(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnFileOpen(wxCommandEvent& WXUNUSED(event));
|
void OnFileOpen(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
|
void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
|
||||||
@@ -460,43 +424,43 @@ public:
|
|||||||
void OnQuit(wxCommandEvent& WXUNUSED(event));
|
void OnQuit(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnClose(wxCommandEvent& WXUNUSED(event));
|
void OnClose(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnZoom(wxCommandEvent& WXUNUSED(event));
|
void OnZoom(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnFit(wxCommandEvent& event);
|
void OnFit(wxCommandEvent& event);
|
||||||
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
|
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
|
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
|
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnReload(wxCommandEvent& event);
|
void OnReload(wxCommandEvent& event);
|
||||||
void OnPrevFrame(wxCommandEvent& event);
|
void OnPrevFrame(wxCommandEvent& event);
|
||||||
void OnHomeFrame(wxCommandEvent& event);
|
void OnHomeFrame(wxCommandEvent& event);
|
||||||
void OnNextFrame(wxCommandEvent& event);
|
void OnNextFrame(wxCommandEvent& event);
|
||||||
void OnLessLayers(wxCommandEvent& event);
|
void OnLessLayers(wxCommandEvent& event);
|
||||||
void OnAllLayers(wxCommandEvent& event);
|
void OnAllLayers(wxCommandEvent& event);
|
||||||
void OnMoreLayers(wxCommandEvent& event);
|
void OnMoreLayers(wxCommandEvent& event);
|
||||||
void OnLessRes(wxCommandEvent& event);
|
void OnLessRes(wxCommandEvent& event);
|
||||||
void OnFullRes(wxCommandEvent& event);
|
void OnFullRes(wxCommandEvent& event);
|
||||||
void OnMoreRes(wxCommandEvent& event);
|
void OnMoreRes(wxCommandEvent& event);
|
||||||
void OnPrevComp(wxCommandEvent& event);
|
void OnPrevComp(wxCommandEvent& event);
|
||||||
void OnAllComps(wxCommandEvent& event);
|
void OnAllComps(wxCommandEvent& event);
|
||||||
void OnNextComp(wxCommandEvent& event);
|
void OnNextComp(wxCommandEvent& event);
|
||||||
void OnSetsEnco(wxCommandEvent& event);
|
void OnSetsEnco(wxCommandEvent& event);
|
||||||
void OnSetsDeco(wxCommandEvent& event);
|
void OnSetsDeco(wxCommandEvent& event);
|
||||||
void OnSashDrag(wxSashEvent& event);
|
void OnSashDrag(wxSashEvent& event);
|
||||||
void OpenFiles(wxArrayString paths, wxArrayString filenames);
|
void OpenFiles(wxArrayString paths, wxArrayString filenames);
|
||||||
void SaveFile(wxArrayString paths, wxArrayString filenames);
|
void SaveFile(wxArrayString paths, wxArrayString filenames);
|
||||||
void OnNotebook(wxNotebookEvent& event);
|
void OnNotebook(wxNotebookEvent& event);
|
||||||
void Rescale(int scale, OPJChildFrame *child);
|
void Rescale(int scale, OPJChildFrame *child);
|
||||||
void OnThreadLogmsg(wxCommandEvent& event);
|
void OnThreadLogmsg(wxCommandEvent& event);
|
||||||
|
|
||||||
OPJMarkerTreeHash m_treehash;
|
OPJMarkerTreeHash m_treehash;
|
||||||
OPJChildFrameHash m_childhash;
|
OPJChildFrameHash m_childhash;
|
||||||
wxSashLayoutWindow* markerTreeWindow;
|
wxSashLayoutWindow* markerTreeWindow;
|
||||||
wxSashLayoutWindow* loggingWindow;
|
wxSashLayoutWindow* loggingWindow;
|
||||||
wxToolBar* tool_bar;
|
wxToolBar* tool_bar;
|
||||||
void Resize(int number);
|
void Resize(int number);
|
||||||
wxNotebook *m_bookCtrl;
|
wxNotebook *m_bookCtrl;
|
||||||
wxNotebook *m_bookCtrlbottom;
|
wxNotebook *m_bookCtrlbottom;
|
||||||
wxTextCtrl *m_textCtrlbrowse;
|
wxTextCtrl *m_textCtrlbrowse;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TogStyle(int id, long flag);
|
void TogStyle(int id, long flag);
|
||||||
|
|
||||||
void DoSort(bool reverse = false);
|
void DoSort(bool reverse = false);
|
||||||
@@ -510,69 +474,70 @@ protected:
|
|||||||
wxSashLayoutWindow* m_topWindow;
|
wxSashLayoutWindow* m_topWindow;
|
||||||
wxSashLayoutWindow* m_leftWindow2;
|
wxSashLayoutWindow* m_leftWindow2;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
class OPJChildFrame: public wxMDIChildFrame
|
class OPJChildFrame: public wxMDIChildFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPJCanvas *m_canvas;
|
OPJCanvas *m_canvas;
|
||||||
OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
~OPJChildFrame(void);
|
~OPJChildFrame(void);
|
||||||
void OnActivate(wxActivateEvent& event);
|
void OnActivate(wxActivateEvent& event);
|
||||||
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
||||||
void OnClose(wxCloseEvent& event);
|
void OnClose(wxCloseEvent& event);
|
||||||
void OnGotFocus(wxFocusEvent& event);
|
void OnGotFocus(wxFocusEvent& event);
|
||||||
void OnLostFocus(wxFocusEvent& event);
|
void OnLostFocus(wxFocusEvent& event);
|
||||||
OPJFrame *m_frame;
|
OPJFrame *m_frame;
|
||||||
wxFileName m_fname;
|
wxFileName m_fname;
|
||||||
int m_winnumber;
|
int m_winnumber;
|
||||||
|
|
||||||
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// frame and main menu ids
|
// frame and main menu ids
|
||||||
enum {
|
enum {
|
||||||
OPJFRAME_FILEEXIT = wxID_EXIT,
|
OPJFRAME_FILEEXIT = wxID_EXIT,
|
||||||
OPJFRAME_HELPABOUT = wxID_ABOUT,
|
OPJFRAME_HELPABOUT = wxID_ABOUT,
|
||||||
OPJFRAME_FILEOPEN,
|
OPJFRAME_FILEOPEN,
|
||||||
OPJFRAME_MEMORYOPEN,
|
OPJFRAME_MEMORYOPEN,
|
||||||
OPJFRAME_FILESAVEAS,
|
OPJFRAME_FILESAVEAS,
|
||||||
OPJFRAME_FILETOGGLEB,
|
OPJFRAME_FILETOGGLEB,
|
||||||
OPJFRAME_FILETOGGLEP,
|
OPJFRAME_FILETOGGLEP,
|
||||||
OPJFRAME_FILETOGGLET,
|
OPJFRAME_FILETOGGLET,
|
||||||
OPJFRAME_VIEWZOOM,
|
OPJFRAME_VIEWZOOM,
|
||||||
OPJFRAME_VIEWFIT,
|
OPJFRAME_VIEWFIT,
|
||||||
OPJFRAME_VIEWRELOAD,
|
OPJFRAME_VIEWRELOAD,
|
||||||
OPJFRAME_VIEWPREVFRAME,
|
OPJFRAME_VIEWPREVFRAME,
|
||||||
OPJFRAME_VIEWHOMEFRAME,
|
OPJFRAME_VIEWHOMEFRAME,
|
||||||
OPJFRAME_VIEWNEXTFRAME,
|
OPJFRAME_VIEWNEXTFRAME,
|
||||||
OPJFRAME_VIEWLESSLAYERS,
|
OPJFRAME_VIEWLESSLAYERS,
|
||||||
OPJFRAME_VIEWALLLAYERS,
|
OPJFRAME_VIEWALLLAYERS,
|
||||||
OPJFRAME_VIEWMORELAYERS,
|
OPJFRAME_VIEWMORELAYERS,
|
||||||
OPJFRAME_VIEWLESSRES,
|
OPJFRAME_VIEWLESSRES,
|
||||||
OPJFRAME_VIEWFULLRES,
|
OPJFRAME_VIEWFULLRES,
|
||||||
OPJFRAME_VIEWMORERES,
|
OPJFRAME_VIEWMORERES,
|
||||||
OPJFRAME_VIEWPREVCOMP,
|
OPJFRAME_VIEWPREVCOMP,
|
||||||
OPJFRAME_VIEWALLCOMPS,
|
OPJFRAME_VIEWALLCOMPS,
|
||||||
OPJFRAME_VIEWNEXTCOMP,
|
OPJFRAME_VIEWNEXTCOMP,
|
||||||
OPJFRAME_FILECLOSE,
|
OPJFRAME_FILECLOSE,
|
||||||
OPJFRAME_SETSENCO,
|
OPJFRAME_SETSENCO,
|
||||||
OPJFRAME_SETSDECO,
|
OPJFRAME_SETSDECO,
|
||||||
|
|
||||||
OPJFRAME_BROWSEWIN = 10000,
|
OPJFRAME_BROWSEWIN = 10000,
|
||||||
OPJFRAME_LOGWIN,
|
OPJFRAME_LOGWIN,
|
||||||
OPJFRAME_TOOLBAR,
|
OPJFRAME_TOOLBAR,
|
||||||
|
|
||||||
OPJFRAME_THREADLOGMSG,
|
OPJFRAME_THREADLOGMSG,
|
||||||
OPJCANVAS_THREADSIGNAL
|
OPJCANVAS_THREADSIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// menu and control ids
|
// menu and control ids
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
TreeTest_Quit = wxID_EXIT,
|
TreeTest_Quit = wxID_EXIT,
|
||||||
TreeTest_About = wxID_ABOUT,
|
TreeTest_About = wxID_ABOUT,
|
||||||
TreeTest_TogButtons = wxID_HIGHEST,
|
TreeTest_TogButtons = wxID_HIGHEST,
|
||||||
@@ -617,8 +582,8 @@ enum {
|
|||||||
TreeTest_Unselect,
|
TreeTest_Unselect,
|
||||||
TreeTest_SelectRoot,
|
TreeTest_SelectRoot,
|
||||||
TreeTest_Ctrl = 1000,
|
TreeTest_Ctrl = 1000,
|
||||||
BOTTOM_NOTEBOOK_ID,
|
BOTTOM_NOTEBOOK_ID,
|
||||||
LEFT_NOTEBOOK_ID
|
LEFT_NOTEBOOK_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
class OPJEncoThread : public wxThread
|
class OPJEncoThread : public wxThread
|
||||||
@@ -675,19 +640,19 @@ public:
|
|||||||
|
|
||||||
// write something to the text control
|
// write something to the text control
|
||||||
void WriteText(const wxString& text);
|
void WriteText(const wxString& text);
|
||||||
void LoadFile(wxFileName fname);
|
void LoadFile(wxFileName fname);
|
||||||
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
||||||
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
||||||
|
|
||||||
unsigned m_count;
|
unsigned m_count;
|
||||||
OPJMarkerTree *m_tree;
|
OPJMarkerTree *m_tree;
|
||||||
wxTreeItemId m_parentid;
|
wxTreeItemId m_parentid;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||||
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -696,10 +661,7 @@ private:
|
|||||||
class OPJDnDFile: public wxFileDropTarget
|
class OPJDnDFile: public wxFileDropTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPJDnDFile(OPJFrame *pOwner)
|
OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
|
||||||
{
|
|
||||||
m_pOwner = pOwner;
|
|
||||||
}
|
|
||||||
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -711,137 +673,137 @@ private:
|
|||||||
// Property sheet dialog: encoder
|
// Property sheet dialog: encoder
|
||||||
class OPJEncoderDialog: public wxPropertySheetDialog
|
class OPJEncoderDialog: public wxPropertySheetDialog
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(OPJEncoderDialog)
|
DECLARE_CLASS(OPJEncoderDialog)
|
||||||
public:
|
public:
|
||||||
OPJEncoderDialog(wxWindow* parent, int dialogType);
|
OPJEncoderDialog(wxWindow* parent, int dialogType);
|
||||||
~OPJEncoderDialog();
|
~OPJEncoderDialog();
|
||||||
|
|
||||||
wxBookCtrlBase* m_settingsNotebook;
|
wxBookCtrlBase* m_settingsNotebook;
|
||||||
|
|
||||||
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||||
wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
|
||||||
wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
|
||||||
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
|
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
|
||||||
void OnEnableComm(wxCommandEvent& event);
|
void OnEnableComm(wxCommandEvent& event);
|
||||||
void OnEnableIdx(wxCommandEvent& event);
|
void OnEnableIdx(wxCommandEvent& event);
|
||||||
void OnEnablePoc(wxCommandEvent& event);
|
void OnEnablePoc(wxCommandEvent& event);
|
||||||
void OnRadioQualityRate(wxCommandEvent& event);
|
void OnRadioQualityRate(wxCommandEvent& event);
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
void OnEnableJPWL(wxCommandEvent& event);
|
void OnEnableJPWL(wxCommandEvent& event);
|
||||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||||
/*wxCheckBox *m_enablejpwlCheck;*/
|
/*wxCheckBox *m_enablejpwlCheck;*/
|
||||||
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
|
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
|
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
void OnHprotSelect(wxCommandEvent& event);
|
void OnHprotSelect(wxCommandEvent& event);
|
||||||
void OnPprotSelect(wxCommandEvent& event);
|
void OnPprotSelect(wxCommandEvent& event);
|
||||||
void OnSensiSelect(wxCommandEvent& event);
|
void OnSensiSelect(wxCommandEvent& event);
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
|
|
||||||
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
|
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
|
||||||
wxRadioButton *m_rateRadio, *m_qualityRadio;
|
wxRadioButton *m_rateRadio, *m_qualityRadio;
|
||||||
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
|
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
|
||||||
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
|
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
|
||||||
wxRadioBox *progressionBox;
|
wxRadioBox *progressionBox;
|
||||||
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
|
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
|
||||||
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
|
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
|
||||||
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
|
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
|
||||||
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
|
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
|
||||||
wxSpinCtrl *m_resolutionsCtrl;
|
wxSpinCtrl *m_resolutionsCtrl;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPJENCO_ENABLEJPWL = 100,
|
OPJENCO_ENABLEJPWL = 100,
|
||||||
OPJENCO_RATEFACTOR,
|
OPJENCO_RATEFACTOR,
|
||||||
OPJENCO_RATERADIO,
|
OPJENCO_RATERADIO,
|
||||||
OPJENCO_QUALITYFACTOR,
|
OPJENCO_QUALITYFACTOR,
|
||||||
OPJENCO_QUALITYRADIO,
|
OPJENCO_QUALITYRADIO,
|
||||||
OPJENCO_RESNUMBER,
|
OPJENCO_RESNUMBER,
|
||||||
OPJENCO_CODEBLOCKSIZE,
|
OPJENCO_CODEBLOCKSIZE,
|
||||||
OPJENCO_PRECINCTSIZE,
|
OPJENCO_PRECINCTSIZE,
|
||||||
OPJENCO_TILESIZE,
|
OPJENCO_TILESIZE,
|
||||||
OPJENCO_PROGRESSION,
|
OPJENCO_PROGRESSION,
|
||||||
OPJENCO_SUBSAMPLING,
|
OPJENCO_SUBSAMPLING,
|
||||||
OPJENCO_ENABLESOP,
|
OPJENCO_ENABLESOP,
|
||||||
OPJENCO_ENABLEEPH,
|
OPJENCO_ENABLEEPH,
|
||||||
OPJENCO_ENABLEBYPASS,
|
OPJENCO_ENABLEBYPASS,
|
||||||
OPJENCO_ENABLERESET,
|
OPJENCO_ENABLERESET,
|
||||||
OPJENCO_ENABLERESTART,
|
OPJENCO_ENABLERESTART,
|
||||||
OPJENCO_ENABLEVSC,
|
OPJENCO_ENABLEVSC,
|
||||||
OPJENCO_ENABLEERTERM,
|
OPJENCO_ENABLEERTERM,
|
||||||
OPJENCO_ENABLESEGMARK,
|
OPJENCO_ENABLESEGMARK,
|
||||||
OPJENCO_ENABLEPOC,
|
OPJENCO_ENABLEPOC,
|
||||||
OPJENCO_ROICOMP,
|
OPJENCO_ROICOMP,
|
||||||
OPJENCO_ROISHIFT,
|
OPJENCO_ROISHIFT,
|
||||||
OPJENCO_IMORIG,
|
OPJENCO_IMORIG,
|
||||||
OPJENCO_TILORIG,
|
OPJENCO_TILORIG,
|
||||||
OPJENCO_ENABLEMCT,
|
OPJENCO_ENABLEMCT,
|
||||||
OPJENCO_ENABLEIRREV,
|
OPJENCO_ENABLEIRREV,
|
||||||
OPJENCO_ENABLEINDEX,
|
OPJENCO_ENABLEINDEX,
|
||||||
OPJENCO_INDEXNAME,
|
OPJENCO_INDEXNAME,
|
||||||
OPJENCO_POCSPEC,
|
OPJENCO_POCSPEC,
|
||||||
OPJENCO_ENABLECOMM,
|
OPJENCO_ENABLECOMM,
|
||||||
OPJENCO_COMMENTTEXT,
|
OPJENCO_COMMENTTEXT,
|
||||||
OPJENCO_HPROT,
|
OPJENCO_HPROT,
|
||||||
OPJENCO_HTILE,
|
OPJENCO_HTILE,
|
||||||
OPJENCO_PPROT,
|
OPJENCO_PPROT,
|
||||||
OPJENCO_PTILE,
|
OPJENCO_PTILE,
|
||||||
OPJENCO_PPACK,
|
OPJENCO_PPACK,
|
||||||
OPJENCO_SENSI,
|
OPJENCO_SENSI,
|
||||||
OPJENCO_STILE
|
OPJENCO_STILE
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Property sheet dialog: decoder
|
// Property sheet dialog: decoder
|
||||||
class OPJDecoderDialog: public wxPropertySheetDialog
|
class OPJDecoderDialog: public wxPropertySheetDialog
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(OPJDecoderDialog)
|
DECLARE_CLASS(OPJDecoderDialog)
|
||||||
public:
|
public:
|
||||||
OPJDecoderDialog(wxWindow* parent, int dialogType);
|
OPJDecoderDialog(wxWindow* parent, int dialogType);
|
||||||
~OPJDecoderDialog();
|
~OPJDecoderDialog();
|
||||||
|
|
||||||
wxBookCtrlBase* m_settingsNotebook;
|
wxBookCtrlBase* m_settingsNotebook;
|
||||||
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
||||||
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
||||||
wxRadioBox* m_resizeBox;
|
wxRadioBox* m_resizeBox;
|
||||||
|
|
||||||
void OnEnableDeco(wxCommandEvent& event);
|
void OnEnableDeco(wxCommandEvent& event);
|
||||||
|
|
||||||
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||||
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
|
||||||
wxPanel* CreatePart3SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart3SettingsPage(wxWindow* parent);
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
void OnEnableJPWL(wxCommandEvent& event);
|
void OnEnableJPWL(wxCommandEvent& event);
|
||||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||||
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
||||||
wxCheckBox *m_enablejpwlCheck;
|
wxCheckBox *m_enablejpwlCheck;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
wxSpinCtrl *m_framenumCtrl;
|
wxSpinCtrl *m_framenumCtrl;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPJDECO_RESMETHOD = 100,
|
OPJDECO_RESMETHOD = 100,
|
||||||
OPJDECO_REDUCEFACTOR,
|
OPJDECO_REDUCEFACTOR,
|
||||||
OPJDECO_QUALITYLAYERS,
|
OPJDECO_QUALITYLAYERS,
|
||||||
OPJDECO_NUMCOMPS,
|
OPJDECO_NUMCOMPS,
|
||||||
OPJDECO_ENABLEDECO,
|
OPJDECO_ENABLEDECO,
|
||||||
OPJDECO_ENABLEPARSE,
|
OPJDECO_ENABLEPARSE,
|
||||||
OPJDECO_ENABLEJPWL,
|
OPJDECO_ENABLEJPWL,
|
||||||
OPJDECO_EXPCOMPS,
|
OPJDECO_EXPCOMPS,
|
||||||
OPJDECO_MAXTILES,
|
OPJDECO_MAXTILES,
|
||||||
OPJDECO_FRAMENUM
|
OPJDECO_FRAMENUM
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__OPJ_VIEWER_H__
|
#endif //__OPJ_VIEWER_H__
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
54
applications/OPJViewer/source/about_htm.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
wxString htmlaboutpage = wxT(
|
||||||
|
"<html>"
|
||||||
|
"<body bgcolor=#FFFFFF>"
|
||||||
|
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||||
|
"<tr>"
|
||||||
|
"<td rowspan=3 valign=top align=center width=70>"
|
||||||
|
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||||
|
"</td>"
|
||||||
|
"<td align=center>"
|
||||||
|
"<font size=+0 color=#000000><b>"
|
||||||
|
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||||
|
"</b></font><br>"
|
||||||
|
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||||
|
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr height=3 valign=center>"
|
||||||
|
"<td valign=center bgcolor=#cc3300></td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td align=justify>"
|
||||||
|
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||||
|
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||||
|
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||||
|
"<font size=-2 color=red>* Build: ")
|
||||||
|
#include "build.h"
|
||||||
|
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||||
|
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||||
|
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||||
|
#endif // USE_JPWL
|
||||||
|
#ifdef USE_JPSEC
|
||||||
|
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||||
|
#endif // USE_JPSEC
|
||||||
|
wxT(")</font><br>")
|
||||||
|
#ifdef USE_MXF
|
||||||
|
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||||
|
#endif // USE_MXF
|
||||||
|
wxT("</td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td colspan=2>"
|
||||||
|
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||||
|
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>"
|
||||||
|
"</table>"
|
||||||
|
"</body>"
|
||||||
|
"</html>"
|
||||||
|
);
|
||||||
1
applications/OPJViewer/source/build.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
wxT("491")
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -56,7 +51,7 @@
|
|||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -49,8 +44,8 @@
|
|||||||
#if wxUSE_LIBOPENJPEG
|
#if wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
#include "jp2/index.h"
|
#include "codec/index.h"
|
||||||
|
|
||||||
#define wxBITMAP_TYPE_JPEG2000 50
|
#define wxBITMAP_TYPE_JPEG2000 50
|
||||||
|
|
||||||
@@ -64,105 +59,105 @@ public:
|
|||||||
m_type = wxBITMAP_TYPE_JPEG2000;
|
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||||
m_mime = wxT("image/mj2");
|
m_mime = wxT("image/mj2");
|
||||||
|
|
||||||
/* decoding */
|
/* decoding */
|
||||||
m_reducefactor = 0;
|
m_reducefactor = 0;
|
||||||
m_qualitylayers = 0;
|
m_qualitylayers = 0;
|
||||||
m_components = 0;
|
m_components = 0;
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
m_enablejpwl = true;
|
m_enablejpwl = true;
|
||||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
|
|
||||||
/* encoding */
|
/* encoding */
|
||||||
m_subsampling = wxT("1,1");
|
m_subsampling = wxT("1,1");
|
||||||
m_origin = wxT("0,0");
|
m_origin = wxT("0,0");
|
||||||
m_rates = wxT("20,10,5");
|
m_rates = wxT("20,10,5");
|
||||||
m_quality = wxT("30,35,40");
|
m_quality = wxT("30,35,40");
|
||||||
m_enablequality = false;
|
m_enablequality = false;
|
||||||
m_multicomp = false;
|
m_multicomp = false;
|
||||||
m_irreversible = false;
|
m_irreversible = false;
|
||||||
m_resolutions = 6;
|
m_resolutions = 6;
|
||||||
m_progression = 0;
|
m_progression = 0;
|
||||||
m_cbsize = wxT("32,32");
|
m_cbsize = wxT("32,32");
|
||||||
m_prsize = wxT("[128,128],[128,128]");
|
m_prsize = wxT("[128,128],[128,128]");
|
||||||
m_tsize = wxT("");
|
m_tsize = wxT("");
|
||||||
m_torigin = wxT("0,0");
|
m_torigin = wxT("0,0");
|
||||||
/*m_progression
|
/*m_progression
|
||||||
m_resilience*/
|
m_resilience*/
|
||||||
m_enablesop = false;
|
m_enablesop = false;
|
||||||
m_enableeph = false;
|
m_enableeph = false;
|
||||||
m_enablereset = false;
|
m_enablereset = false;
|
||||||
m_enablesegmark = false;
|
m_enablesegmark = false;
|
||||||
m_enablevsc = false;
|
m_enablevsc = false;
|
||||||
m_enablerestart = false;
|
m_enablerestart = false;
|
||||||
m_enableerterm = false;
|
m_enableerterm = false;
|
||||||
m_enablebypass = false;
|
m_enablebypass = false;
|
||||||
/*m_roicompo
|
/*m_roicompo
|
||||||
m_roiup
|
m_roiup
|
||||||
m_indexfname*/
|
m_indexfname*/
|
||||||
m_enableidx = false;
|
m_enableidx = false;
|
||||||
m_index = wxT("index.txt");
|
m_index = wxT("index.txt");
|
||||||
m_enablepoc = false;
|
m_enablepoc = false;
|
||||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||||
m_enablecomm = true;
|
m_enablecomm = true;
|
||||||
|
|
||||||
#if defined __WXMSW__
|
#if defined __WXMSW__
|
||||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||||
#elif defined __WXGTK__
|
#elif defined __WXGTK__
|
||||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||||
#else
|
#else
|
||||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||||
#else
|
#else
|
||||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// decoding engine parameters
|
// decoding engine parameters
|
||||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
bool m_enablejpwl;
|
bool m_enablejpwl;
|
||||||
int m_expcomps, m_maxtiles;
|
int m_expcomps, m_maxtiles;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
|
|
||||||
// encoding engine parameters
|
// encoding engine parameters
|
||||||
wxString m_subsampling;
|
wxString m_subsampling;
|
||||||
wxString m_origin;
|
wxString m_origin;
|
||||||
wxString m_rates;
|
wxString m_rates;
|
||||||
wxString m_quality;
|
wxString m_quality;
|
||||||
bool m_enablequality;
|
bool m_enablequality;
|
||||||
bool m_multicomp;
|
bool m_multicomp;
|
||||||
bool m_irreversible;
|
bool m_irreversible;
|
||||||
int m_resolutions;
|
int m_resolutions;
|
||||||
int m_progression;
|
int m_progression;
|
||||||
wxString m_cbsize;
|
wxString m_cbsize;
|
||||||
wxString m_prsize;
|
wxString m_prsize;
|
||||||
wxString m_tsize;
|
wxString m_tsize;
|
||||||
wxString m_torigin;
|
wxString m_torigin;
|
||||||
/*m_progression
|
/*m_progression
|
||||||
m_resilience*/
|
m_resilience*/
|
||||||
bool m_enablesop;
|
bool m_enablesop;
|
||||||
bool m_enableeph;
|
bool m_enableeph;
|
||||||
bool m_enablebypass;
|
bool m_enablebypass;
|
||||||
bool m_enableerterm;
|
bool m_enableerterm;
|
||||||
bool m_enablerestart;
|
bool m_enablerestart;
|
||||||
bool m_enablereset;
|
bool m_enablereset;
|
||||||
bool m_enablesegmark;
|
bool m_enablesegmark;
|
||||||
bool m_enablevsc;
|
bool m_enablevsc;
|
||||||
/*m_roicompo
|
/*m_roicompo
|
||||||
m_roiup
|
m_roiup
|
||||||
m_indexfname*/
|
m_indexfname*/
|
||||||
bool m_enableidx;
|
bool m_enableidx;
|
||||||
wxString m_index;
|
wxString m_index;
|
||||||
bool m_enablecomm;
|
bool m_enablecomm;
|
||||||
wxString m_comment;
|
wxString m_comment;
|
||||||
bool m_enablepoc;
|
bool m_enablepoc;
|
||||||
wxString m_poc;
|
wxString m_poc;
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||||
@@ -172,7 +167,7 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||||
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -66,23 +61,23 @@ public:
|
|||||||
m_type = wxBITMAP_TYPE_MXF;
|
m_type = wxBITMAP_TYPE_MXF;
|
||||||
m_mime = wxT("image/mxf");
|
m_mime = wxT("image/mxf");
|
||||||
|
|
||||||
m_reducefactor = 0;
|
m_reducefactor = 0;
|
||||||
m_qualitylayers = 0;
|
m_qualitylayers = 0;
|
||||||
m_components = 0;
|
m_components = 0;
|
||||||
m_filename = wxT("");
|
m_filename = wxT("");
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
m_enablejpwl = true;
|
m_enablejpwl = true;
|
||||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
}
|
}
|
||||||
|
|
||||||
// decoding engine parameters
|
// decoding engine parameters
|
||||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
wxFileName m_filename;
|
wxFileName m_filename;
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
bool m_enablejpwl;
|
bool m_enablejpwl;
|
||||||
int m_expcomps, m_maxtiles;
|
int m_expcomps, m_maxtiles;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
Copyright (c) 2002-2014, Professor Benoit Macq
|
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
Copyright (c) 2001-2003, David Janssens
|
Copyright (c) 2001-2003, David Janssens
|
||||||
Copyright (c) 2002-2003, Yannick Verschueren
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
@@ -8,4 +8,4 @@ Anybody. As the OpenJPEG library is released under the BSD license, anybody can
|
|||||||
|
|
||||||
Who is developing the library ?
|
Who is developing the library ?
|
||||||
===============================
|
===============================
|
||||||
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Université Catholique de Louvain (UCL). The JPWL module is developed and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Université Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* 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) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
117
applications/codec/CMakeLists.txt
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
SET(common_SRCS
|
||||||
|
convert.c
|
||||||
|
index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
)
|
||||||
|
if(NOT USE_SYSTEM_GETOPT)
|
||||||
|
list(APPEND common_SRCS
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||||
|
ELSE(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||||
|
ENDIF(BUILD_SHARED_LIBS)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
|
||||||
|
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
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(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
# 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 OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDFOREACH(exe)
|
||||||
|
|
||||||
|
# Install man pages
|
||||||
|
INSTALL(
|
||||||
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/image_to_j2k.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_dump.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_to_image.1
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||||
|
#
|
||||||
|
|
||||||
|
IF(BUILD_JPWL)
|
||||||
|
ADD_EXECUTABLE(JPWL_j2k_to_image
|
||||||
|
j2k_to_image.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_j2k_to_image
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
# To support universal exe:
|
||||||
|
IF(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image z)
|
||||||
|
ELSe(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${Z_LIBNAME})
|
||||||
|
ENDIF(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(JPWL_image_to_j2k
|
||||||
|
image_to_j2k.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_image_to_j2k
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
# To support universal exe:
|
||||||
|
IF(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k z)
|
||||||
|
ELSe(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${Z_LIBNAME})
|
||||||
|
ENDIF(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDIF(BUILD_JPWL)
|
||||||
118
applications/codec/Makefile.am
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump
|
||||||
|
|
||||||
|
if WANT_JPWL
|
||||||
|
bin_PROGRAMS += JPWL_j2k_to_image JPWL_image_to_j2k
|
||||||
|
endif
|
||||||
|
|
||||||
|
j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
j2k_to_image_CFLAGS =
|
||||||
|
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
j2k_to_image.c \
|
||||||
|
../common/color.h
|
||||||
|
|
||||||
|
image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@
|
||||||
|
image_to_j2k_CFLAGS =
|
||||||
|
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
image_to_j2k_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
image_to_j2k.c \
|
||||||
|
convert.h \
|
||||||
|
../common/format_defs.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
j2k_dump_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg
|
||||||
|
j2k_dump_CFLAGS =
|
||||||
|
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
|
j2k_dump_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
j2k_dump.c \
|
||||||
|
../common/opj_getopt.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
JPWL_j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
JPWL_j2k_to_image_CFLAGS =
|
||||||
|
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
JPWL_j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
j2k_to_image.c
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@
|
||||||
|
JPWL_image_to_j2k_CFLAGS =
|
||||||
|
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
image_to_j2k.c
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
windirent.h
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_dump$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
if WANT_JPWL
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
8
applications/codec/README
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Simple codec compilation
|
||||||
|
------------------------
|
||||||
|
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
|
||||||
|
|
||||||
|
gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
|
You should add '-L..' to those lines if you did not use the 'install' target when building the library.
|
||||||
3607
applications/codec/convert.c
Normal file
@@ -1,15 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* BSD License, included below. This software may be subject to other third
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* 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) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -40,17 +34,17 @@
|
|||||||
/**@name RAW image encoding parameters */
|
/**@name RAW image encoding parameters */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
typedef struct raw_cparameters {
|
typedef struct raw_cparameters {
|
||||||
/** width of the raw image */
|
/** width of the raw image */
|
||||||
int rawWidth;
|
int rawWidth;
|
||||||
/** height of the raw image */
|
/** height of the raw image */
|
||||||
int rawHeight;
|
int rawHeight;
|
||||||
/** components of the raw image */
|
/** components of the raw image */
|
||||||
int rawComp;
|
int rawComp;
|
||||||
/** bit depth of the raw image */
|
/** bit depth of the raw image */
|
||||||
int rawBitDepth;
|
int rawBitDepth;
|
||||||
/** signed/unsigned raw image */
|
/** signed/unsigned raw image */
|
||||||
opj_bool rawSigned;
|
opj_bool rawSigned;
|
||||||
/*@}*/
|
/*@}*/
|
||||||
} raw_cparameters_t;
|
} raw_cparameters_t;
|
||||||
|
|
||||||
/* TGA conversion */
|
/* TGA conversion */
|
||||||
1819
applications/codec/image_to_j2k.c
Normal file
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
684
applications/codec/j2k_dump.c
Normal file
@@ -0,0 +1,684 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
#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 "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "j2k.h"
|
||||||
|
#include "jp2.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#include "format_defs.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;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
void decode_help_display(void) {
|
||||||
|
fprintf(stdout,"HELP for j2k_dump\n----\n\n");
|
||||||
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"+ JPWL "
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
"decoder:\n");
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -ImgDir \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,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_file_format(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 };
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
|
/*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);
|
||||||
|
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen, c;
|
||||||
|
opj_option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
{0,0,0,0} /* GNU getopt_long requirement */
|
||||||
|
};
|
||||||
|
const char optlist[] = "i:o:h";
|
||||||
|
|
||||||
|
OPJ_ARG_NOT_USED(indexfilename);
|
||||||
|
|
||||||
|
totlen=sizeof(long_option)-1;
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
do {
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||||
|
#else
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
|
#endif
|
||||||
|
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 J2K_CFMT:
|
||||||
|
case JP2_CFMT:
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'o': /* output file */
|
||||||
|
{
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
|
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! Valid format 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, "Example: %s -i image.j2k\n",argv[0]);
|
||||||
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
|
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) {
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
img_fol_t img_fol;
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
FILE *fsrc = NULL, *fout = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int num_images;
|
||||||
|
int i,imageno;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* Initialize indexfilename and img_fol */
|
||||||
|
*indexfilename = 0;
|
||||||
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if(dirptr){
|
||||||
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||||
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
|
if(!dirptr->filename_buf){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<num_images;i++){
|
||||||
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (num_images==0){
|
||||||
|
fprintf(stdout,"Folder is empty\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
num_images=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
if (parameters.outfile[0] != 0)
|
||||||
|
{
|
||||||
|
fout = fopen(parameters.outfile,"w");
|
||||||
|
if (!fout)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fout = stdout;
|
||||||
|
|
||||||
|
/*Encoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++)
|
||||||
|
{
|
||||||
|
image = NULL;
|
||||||
|
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 */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "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);
|
||||||
|
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||||
|
{
|
||||||
|
free(src);
|
||||||
|
fclose(fsrc);
|
||||||
|
fclose(fout);
|
||||||
|
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
switch(parameters.decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG-2000 codestream */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
j2k_dump_image(fout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JP2_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000 compressed image data */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JP2);
|
||||||
|
|
||||||
|
/* 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 the current image and 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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
if(image->icc_profile_buf)
|
||||||
|
{
|
||||||
|
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||||
|
}
|
||||||
|
j2k_dump_image(fout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(fout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JPT_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000, JPIP */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JPT);
|
||||||
|
|
||||||
|
/* 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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free codestream information structure */
|
||||||
|
if (*indexfilename)
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fout);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||||
|
int compno;
|
||||||
|
fprintf(fd, "image {\n");
|
||||||
|
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||||
|
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_image_comp_t *comp = &img->comps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||||
|
fprintf(fd, " prec=%d\n", comp->prec);
|
||||||
|
/*fprintf(fd, " bpp=%d\n", comp->bpp);*/
|
||||||
|
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||||
|
int tileno, compno, layno, bandno, resno, numbands;
|
||||||
|
fprintf(fd, "coding parameters {\n");
|
||||||
|
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||||
|
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||||
|
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||||
|
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||||
|
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||||
|
fprintf(fd, " tile %d {\n", tileno);
|
||||||
|
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||||
|
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||||
|
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||||
|
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||||
|
fprintf(fd, " rates=");
|
||||||
|
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||||
|
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||||
|
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||||
|
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||||
|
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||||
|
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||||
|
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||||
|
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||||
|
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||||
|
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||||
|
fprintf(fd, " stepsizes=");
|
||||||
|
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||||
|
for (bandno = 0; bandno < numbands; bandno++) {
|
||||||
|
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||||
|
tccp->stepsizes[bandno].expn);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
|
||||||
|
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||||
|
fprintf(fd, " prcw=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
fprintf(fd, " prch=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
861
applications/codec/j2k_to_image.c
Normal file
@@ -0,0 +1,861 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, 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
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
#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 "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
#include <lcms2.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
#include <lcms.h>
|
||||||
|
#endif
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
#include "format_defs.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;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
static void decode_help_display(void) {
|
||||||
|
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
||||||
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"+ JPWL "
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
"decoder:\n");
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -ImgDir \n");
|
||||||
|
fprintf(stdout," Image file Directory path \n");
|
||||||
|
fprintf(stdout," -OutFor \n");
|
||||||
|
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
|
||||||
|
fprintf(stdout," Need to specify only format without filename <BMP> \n");
|
||||||
|
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\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 <decompressed file>\n");
|
||||||
|
fprintf(stdout," REQUIRED\n");
|
||||||
|
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA files\n");
|
||||||
|
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
|
||||||
|
fprintf(stdout," filename is given, there will be as many output files as there are\n");
|
||||||
|
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
|
||||||
|
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
|
||||||
|
fprintf(stdout," is given and there are more than one component, only the first component\n");
|
||||||
|
fprintf(stdout," will be written to the file.\n");
|
||||||
|
fprintf(stdout," -r <reduce factor>\n");
|
||||||
|
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
|
||||||
|
fprintf(stdout," image 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," -x \n");
|
||||||
|
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
fprintf(stdout," -W <options>\n");
|
||||||
|
fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
|
||||||
|
fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
|
||||||
|
fprintf(stdout," c, c=numcomps\n");
|
||||||
|
fprintf(stdout," numcomps is the number of expected components in the codestream\n");
|
||||||
|
fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
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(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 };
|
||||||
|
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);
|
||||||
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
|
/*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);
|
||||||
|
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen, c;
|
||||||
|
opj_option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
|
{0,0,0,0} /* GNU getopt_long requirement */
|
||||||
|
};
|
||||||
|
|
||||||
|
const char optlist[] = "i:o:r:l:x:"
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"W:"
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
"h" ;
|
||||||
|
totlen=sizeof(long_option) - 1;
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
do {
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||||
|
#else
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
|
#endif
|
||||||
|
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 J2K_CFMT:
|
||||||
|
case JP2_CFMT:
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'o': /* output file */
|
||||||
|
{
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
parameters->cod_format = get_file_format(outfile);
|
||||||
|
switch(parameters->cod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
case PXM_DFMT:
|
||||||
|
case BMP_DFMT:
|
||||||
|
case TIF_DFMT:
|
||||||
|
case RAW_DFMT:
|
||||||
|
case TGA_DFMT:
|
||||||
|
case PNG_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'O': /* output format */
|
||||||
|
{
|
||||||
|
char outformat[50];
|
||||||
|
char *of = opj_optarg;
|
||||||
|
sprintf(outformat,".%s",of);
|
||||||
|
img_fol->set_out_format = 1;
|
||||||
|
parameters->cod_format = get_file_format(outformat);
|
||||||
|
switch(parameters->cod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
img_fol->out_format = "pgx";
|
||||||
|
break;
|
||||||
|
case PXM_DFMT:
|
||||||
|
img_fol->out_format = "ppm";
|
||||||
|
break;
|
||||||
|
case BMP_DFMT:
|
||||||
|
img_fol->out_format = "bmp";
|
||||||
|
break;
|
||||||
|
case TIF_DFMT:
|
||||||
|
img_fol->out_format = "tif";
|
||||||
|
break;
|
||||||
|
case RAW_DFMT:
|
||||||
|
img_fol->out_format = "raw";
|
||||||
|
break;
|
||||||
|
case TGA_DFMT:
|
||||||
|
img_fol->out_format = "raw";
|
||||||
|
break;
|
||||||
|
case PNG_DFMT:
|
||||||
|
img_fol->out_format = "png";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
case 'r': /* reduce option */
|
||||||
|
{
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
case 'l': /* layering option */
|
||||||
|
{
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'x': /* Creation of index file */
|
||||||
|
{
|
||||||
|
char *index = opj_optarg;
|
||||||
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
|
||||||
|
case 'W': /* activate JPWL correction */
|
||||||
|
{
|
||||||
|
char *token = NULL;
|
||||||
|
|
||||||
|
token = strtok(opj_optarg, ",");
|
||||||
|
while(token != NULL) {
|
||||||
|
|
||||||
|
/* search expected number of components */
|
||||||
|
if (*token == 'c') {
|
||||||
|
|
||||||
|
static int compno;
|
||||||
|
|
||||||
|
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
|
||||||
|
|
||||||
|
if(sscanf(token, "c=%d", &compno) == 1) {
|
||||||
|
/* Specified */
|
||||||
|
if ((compno < 1) || (compno > 256)) {
|
||||||
|
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->jpwl_exp_comps = compno;
|
||||||
|
|
||||||
|
} else if (!strcmp(token, "c")) {
|
||||||
|
/* default */
|
||||||
|
parameters->jpwl_exp_comps = compno; /* auto for default size */
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search maximum number of tiles */
|
||||||
|
if (*token == 't') {
|
||||||
|
|
||||||
|
static int tileno;
|
||||||
|
|
||||||
|
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
|
||||||
|
|
||||||
|
if(sscanf(token, "t=%d", &tileno) == 1) {
|
||||||
|
/* Specified */
|
||||||
|
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
|
||||||
|
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->jpwl_max_tiles = tileno;
|
||||||
|
|
||||||
|
} else if (!strcmp(token, "t")) {
|
||||||
|
/* default */
|
||||||
|
parameters->jpwl_max_tiles = tileno; /* auto for default size */
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* next token or bust */
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
};
|
||||||
|
parameters->jpwl_correct = OPJ_TRUE;
|
||||||
|
fprintf(stdout, "JPWL correction capability activated\n");
|
||||||
|
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
|
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! Valid format 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) || (parameters->outfile[0] == 0)) {
|
||||||
|
fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
|
||||||
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
static 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
|
||||||
|
*/
|
||||||
|
static 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
|
||||||
|
*/
|
||||||
|
static void info_callback(const char *msg, void *client_data) {
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
img_fol_t img_fol;
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
FILE *fsrc = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int num_images;
|
||||||
|
int i,imageno;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* Initialize indexfilename and img_fol */
|
||||||
|
*indexfilename = 0;
|
||||||
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if(dirptr){
|
||||||
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||||
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
|
if(!dirptr->filename_buf){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<num_images;i++){
|
||||||
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (num_images==0){
|
||||||
|
fprintf(stdout,"Folder is empty\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
num_images=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Encoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++) {
|
||||||
|
image = NULL;
|
||||||
|
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 */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "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);
|
||||||
|
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||||
|
{
|
||||||
|
free(src);
|
||||||
|
fclose(fsrc);
|
||||||
|
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
switch(parameters.decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG-2000 codestream */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JP2_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000 compressed image data */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JP2);
|
||||||
|
|
||||||
|
/* 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 the current image and 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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JPT_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000, JPIP */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JPT);
|
||||||
|
|
||||||
|
/* 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 image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
if(image->color_space == CLRSPC_SYCC)
|
||||||
|
{
|
||||||
|
color_sycc_to_rgb(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image->icc_profile_buf)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||||
|
color_apply_icc_profile(image);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free(image->icc_profile_buf);
|
||||||
|
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create output image */
|
||||||
|
/* ------------------- */
|
||||||
|
switch (parameters.cod_format) {
|
||||||
|
case PXM_DFMT: /* PNM PGM PPM */
|
||||||
|
if (imagetopnm(image, parameters.outfile)) {
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PGX_DFMT: /* PGX */
|
||||||
|
if(imagetopgx(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BMP_DFMT: /* BMP */
|
||||||
|
if(imagetobmp(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_LIBTIFF
|
||||||
|
case TIF_DFMT: /* TIFF */
|
||||||
|
if(imagetotif(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* HAVE_LIBTIFF */
|
||||||
|
case RAW_DFMT: /* RAW */
|
||||||
|
if(imagetoraw(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TGA_DFMT: /* TGA */
|
||||||
|
if(imagetotga(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_LIBPNG
|
||||||
|
case PNG_DFMT: /* PNG */
|
||||||
|
if(imagetopng(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* HAVE_LIBPNG */
|
||||||
|
/* Can happen if output file is TIFF or PNG
|
||||||
|
* and HAVE_LIBTIF or HAVE_LIBPNG is undefined
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free codestream information structure */
|
||||||
|
if (*indexfilename)
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*end main*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* uce-dirent.h - operating system independent dirent implementation
|
* uce-dirent.h - operating system independent dirent implementation
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998-2002 Toni Ronkko
|
* Copyright (C) 1998-2002 Toni Ronkko
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
* ``Software''), to deal in the Software without restriction, including
|
* ``Software''), to deal in the Software without restriction, including
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
* the following conditions:
|
* the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included
|
* The above copyright notice and this permission notice shall be included
|
||||||
* in all copies or substantial portions of the Software.
|
* in all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
* 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
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* May 28 1998, Toni Ronkko <tronkko@messi.uku.fi>
|
* May 28 1998, Toni Ronkko <tronkko@messi.uku.fi>
|
||||||
*
|
*
|
||||||
* $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
|
* $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
* Revision 1.1 1998/07/04 16:27:51 tr
|
* Revision 1.1 1998/07/04 16:27:51 tr
|
||||||
* Initial revision
|
* Initial revision
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* MSVC 1.0 scans automatic dependencies incorrectly when your project
|
* MSVC 1.0 scans automatic dependencies incorrectly when your project
|
||||||
* contains this very header. The problem is that MSVC cannot handle
|
* contains this very header. The problem is that MSVC cannot handle
|
||||||
* include directives inside #if..#endif block those are never entered.
|
* include directives inside #if..#endif block those are never entered.
|
||||||
@@ -106,14 +106,14 @@
|
|||||||
*/
|
*/
|
||||||
#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(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++ */
|
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||||
/* no dirent.h */
|
/* no dirent.h */
|
||||||
# elif defined(__MINGW32__) /* MinGW */
|
# elif defined(__MINGW32__) /* MinGW */
|
||||||
/* no dirent.h */
|
/* no dirent.h */
|
||||||
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
# define VOID_CLOSEDIR
|
# define VOID_CLOSEDIR
|
||||||
# elif defined(__TURBOC__) /* Borland Turbo C */
|
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||||
/* no dirent.h */
|
/* no dirent.h */
|
||||||
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||||
# define HAVE_DIRECT_H
|
# define HAVE_DIRECT_H
|
||||||
# elif defined(__apollo) /* Apollo */
|
# elif defined(__apollo) /* Apollo */
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
|
|
||||||
#elif defined(MSDOS) || defined(WIN32)
|
#elif defined(MSDOS) || defined(WIN32)
|
||||||
|
|
||||||
/* figure out type of underlaying directory interface to be used */
|
/* figure out type of underlaying directory interface to be used */
|
||||||
# if defined(WIN32)
|
# if defined(WIN32)
|
||||||
# define DIRENT_WIN32_INTERFACE
|
# define DIRENT_WIN32_INTERFACE
|
||||||
# elif defined(MSDOS)
|
# elif defined(MSDOS)
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
# error "missing native dirent interface"
|
# error "missing native dirent interface"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/*** WIN32 specifics ***/
|
/*** WIN32 specifics ***/
|
||||||
# if defined(DIRENT_WIN32_INTERFACE)
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# if !defined(DIRENT_MAXNAMLEN)
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
@@ -189,11 +189,11 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
/*** MS-DOS specifics ***/
|
/*** MS-DOS specifics ***/
|
||||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
# include <dos.h>
|
# include <dos.h>
|
||||||
|
|
||||||
/* Borland defines file length macros in dir.h */
|
/* Borland defines file length macros in dir.h */
|
||||||
# if defined(__BORLANDC__)
|
# if defined(__BORLANDC__)
|
||||||
# include <dir.h>
|
# include <dir.h>
|
||||||
# if !defined(DIRENT_MAXNAMLEN)
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
# define _find_t find_t
|
# define _find_t find_t
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Turbo C defines ffblk structure in dir.h */
|
/* Turbo C defines ffblk structure in dir.h */
|
||||||
# elif defined(__TURBOC__)
|
# elif defined(__TURBOC__)
|
||||||
# include <dir.h>
|
# include <dir.h>
|
||||||
# if !defined(DIRENT_MAXNAMLEN)
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
@@ -211,13 +211,13 @@
|
|||||||
# endif
|
# endif
|
||||||
# define DIRENT_USE_FFBLK
|
# define DIRENT_USE_FFBLK
|
||||||
|
|
||||||
/* MSVC */
|
/* MSVC */
|
||||||
# elif defined(_MSC_VER)
|
# elif defined(_MSC_VER)
|
||||||
# if !defined(DIRENT_MAXNAMLEN)
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
# define DIRENT_MAXNAMLEN (12)
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Watcom */
|
/* Watcom */
|
||||||
# elif defined(__WATCOMC__)
|
# elif defined(__WATCOMC__)
|
||||||
# if !defined(DIRENT_MAXNAMLEN)
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
# if defined(__OS2__) || defined(__NT__)
|
# if defined(__OS2__) || defined(__NT__)
|
||||||
@@ -230,7 +230,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||||
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||||
# define NAME_MAX DIRENT_MAXNAMLEN
|
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||||
# endif
|
# endif
|
||||||
@@ -239,16 +239,16 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||||
* true character array although we have it copied in the implementation
|
* true character array although we have it copied in the implementation
|
||||||
* dependent data. We could save some memory if we had declared `d_name'
|
* dependent data. We could save some memory if we had declared `d_name'
|
||||||
* as a pointer referring the name within implementation dependent data.
|
* as a pointer refering the name within implementation dependent data.
|
||||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
* 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
|
* something other than four. Besides, directory entries are typically so
|
||||||
* small that it takes virtually no time to copy them from place to place.
|
* small that it takes virtually no time to copy them from place to place.
|
||||||
*/
|
*/
|
||||||
typedef struct dirent {
|
typedef struct dirent {
|
||||||
char d_name[NAME_MAX + 1];
|
char d_name[NAME_MAX + 1];
|
||||||
|
|
||||||
/*** Operating system specific part ***/
|
/*** Operating system specific part ***/
|
||||||
@@ -261,21 +261,21 @@ typedef struct dirent {
|
|||||||
struct _find_t data;
|
struct _find_t data;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
} dirent;
|
} dirent;
|
||||||
|
|
||||||
/* DIR substitute structure containing directory name. The name is
|
/* DIR substitute structure containing directory name. The name is
|
||||||
* essential for the operation of ``rewinndir'' function. */
|
* essential for the operation of ``rewinndir'' function. */
|
||||||
typedef struct DIR {
|
typedef struct DIR {
|
||||||
char *dirname; /* directory being scanned */
|
char *dirname; /* directory being scanned */
|
||||||
dirent current; /* current entry */
|
dirent current; /* current entry */
|
||||||
int dirent_filled; /* is current un-processed? */
|
int dirent_filled; /* is current un-processed? */
|
||||||
|
|
||||||
/*** Operating system specific part ***/
|
/*** Operating system specific part ***/
|
||||||
# if defined(DIRENT_WIN32_INTERFACE)
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
HANDLE search_handle;
|
HANDLE search_handle;
|
||||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
# endif
|
# endif
|
||||||
} DIR;
|
} DIR;
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -325,7 +325,7 @@ static void _setdirname (struct DIR *dirp);
|
|||||||
* internal working area that is used for retrieving individual directory
|
* internal working area that is used for retrieving individual directory
|
||||||
* entries. The internal working area has no fields of your interest.
|
* 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
|
* <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
|
* directory stream could not be opened. Global `errno' variable will set
|
||||||
* in case of error as follows:
|
* in case of error as follows:
|
||||||
*
|
*
|
||||||
@@ -344,45 +344,46 @@ static void _setdirname (struct DIR *dirp);
|
|||||||
*/
|
*/
|
||||||
static DIR *opendir(const char *dirname)
|
static DIR *opendir(const char *dirname)
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
assert (dirname != NULL);
|
assert (dirname != NULL);
|
||||||
|
|
||||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||||
if (dirp != NULL) {
|
if (dirp != NULL) {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* allocate room for directory name */
|
/* allocate room for directory name */
|
||||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||||
if (dirp->dirname == NULL) {
|
if (dirp->dirname == NULL) {
|
||||||
/* failed to duplicate directory name. errno set by malloc() */
|
/* failed to duplicate directory name. errno set by malloc() */
|
||||||
free (dirp);
|
free (dirp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Copy directory name while appending directory separator and "*.*".
|
/* Copy directory name while appending directory separator and "*.*".
|
||||||
* Directory separator is not appended if the name already ends with
|
* Directory separator is not appended if the name already ends with
|
||||||
* drive or directory separator. Directory separator is assumed to be
|
* drive or directory separator. Directory separator is assumed to be
|
||||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||||
strcpy (dirp->dirname, dirname);
|
strcpy (dirp->dirname, dirname);
|
||||||
p = strchr (dirp->dirname, '\0');
|
p = strchr (dirp->dirname, '\0');
|
||||||
if (dirp->dirname < p &&
|
if (dirp->dirname < p &&
|
||||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
|
||||||
strcpy (p++, "\\");
|
{
|
||||||
}
|
strcpy (p++, "\\");
|
||||||
|
}
|
||||||
# ifdef DIRENT_WIN32_INTERFACE
|
# ifdef DIRENT_WIN32_INTERFACE
|
||||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||||
# else
|
# else
|
||||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* open stream */
|
/* open stream */
|
||||||
if (_initdir (dirp) == 0) {
|
if (_initdir (dirp) == 0) {
|
||||||
/* initialization failed */
|
/* initialization failed */
|
||||||
free (dirp->dirname);
|
free (dirp->dirname);
|
||||||
free (dirp);
|
free (dirp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return dirp;
|
}
|
||||||
|
return dirp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,7 +411,7 @@ static DIR *opendir(const char *dirname)
|
|||||||
* capacity of d_name with different macros and some systems do not define
|
* 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
|
* 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
|
* 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
|
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
|
||||||
* there are many MS-DOS and MS-Windows implementations those do not define
|
* 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
|
* 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
|
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||||
@@ -435,55 +436,55 @@ static DIR *opendir(const char *dirname)
|
|||||||
static struct dirent *
|
static struct dirent *
|
||||||
readdir (DIR *dirp)
|
readdir (DIR *dirp)
|
||||||
{
|
{
|
||||||
assert(dirp != NULL);
|
assert(dirp != NULL);
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DIRENT_WIN32_INTERFACE)
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dirp->dirent_filled != 0) {
|
if (dirp->dirent_filled != 0) {
|
||||||
/*
|
/*
|
||||||
* Directory entry has already been retrieved and there is no need to
|
* Directory entry has already been retrieved and there is no need to
|
||||||
* retrieve a new one. Directory entry will be retrieved in advance
|
* retrieve a new one. Directory entry will be retrieved in advance
|
||||||
* when the user calls readdir function for the first time. This is so
|
* when the user calls readdir function for the first time. This is so
|
||||||
* because real dirent has separate functions for opening and reading
|
* because real dirent has separate functions for opening and reading
|
||||||
* the stream whereas Win32 and DOS dirents open the stream
|
* the stream whereas Win32 and DOS dirents open the stream
|
||||||
* automatically when we retrieve the first file. Therefore, we have to
|
* automatically when we retrieve the first file. Therefore, we have to
|
||||||
* save the first file when opening the stream and later 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.
|
* return the saved entry when the user tries to read the first entry.
|
||||||
*/
|
*/
|
||||||
dirp->dirent_filled = 0;
|
dirp->dirent_filled = 0;
|
||||||
} else {
|
} else {
|
||||||
/* fill in entry and return that */
|
/* fill in entry and return that */
|
||||||
#if defined(DIRENT_WIN32_INTERFACE)
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||||
/* Last file has been processed or an error occurred */
|
/* Last file has been processed or an error occured */
|
||||||
FindClose (dirp->search_handle);
|
FindClose (dirp->search_handle);
|
||||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||||
* more entries could be retrieved. */
|
* more entries could be retrieved. */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
_setdirname (dirp);
|
_setdirname (dirp);
|
||||||
assert (dirp->dirent_filled == 0);
|
assert (dirp->dirent_filled == 0);
|
||||||
}
|
}
|
||||||
return &dirp->current;
|
return &dirp->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -508,37 +509,37 @@ readdir (DIR *dirp)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
closedir (DIR *dirp)
|
closedir (DIR *dirp)
|
||||||
{
|
{
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
/* make sure that dirp points to legal structure */
|
/* make sure that dirp points to legal structure */
|
||||||
assert (dirp != NULL);
|
assert (dirp != NULL);
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free directory name and search handles */
|
/* free directory name and search handles */
|
||||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||||
|
|
||||||
#if defined(DIRENT_WIN32_INTERFACE)
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
if (FindClose (dirp->search_handle) == FALSE) {
|
if (FindClose (dirp->search_handle) == FALSE) {
|
||||||
/* Unknown error */
|
/* Unknown error */
|
||||||
retcode = -1;
|
retcode = -1;
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||||
memset (dirp, 0, sizeof (*dirp));
|
memset (dirp, 0, sizeof (*dirp));
|
||||||
# if defined(DIRENT_WIN32_INTERFACE)
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
free (dirp);
|
free (dirp);
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -565,31 +566,31 @@ closedir (DIR *dirp)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rewinddir (DIR *dirp)
|
rewinddir (DIR *dirp)
|
||||||
{
|
{
|
||||||
/* make sure that dirp is legal */
|
/* make sure that dirp is legal */
|
||||||
assert (dirp != NULL);
|
assert (dirp != NULL);
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert (dirp->dirname != NULL);
|
assert (dirp->dirname != NULL);
|
||||||
|
|
||||||
/* close previous stream */
|
/* close previous stream */
|
||||||
#if defined(DIRENT_WIN32_INTERFACE)
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
if (FindClose (dirp->search_handle) == FALSE) {
|
if (FindClose (dirp->search_handle) == FALSE) {
|
||||||
/* Unknown error */
|
/* Unknown error */
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* re-open previous stream */
|
/* re-open previous stream */
|
||||||
if (_initdir (dirp) == 0) {
|
if (_initdir (dirp) == 0) {
|
||||||
/* initialization failed but we cannot deal with error. User will notice
|
/* initialization failed but we cannot deal with error. User will notice
|
||||||
* error later when she tries to retrieve first directory enty. */
|
* error later when she tries to retrieve first directory enty. */
|
||||||
/*EMPTY*/;
|
/*EMPTY*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -599,36 +600,37 @@ rewinddir (DIR *dirp)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_initdir (DIR *dirp)
|
_initdir (DIR *dirp)
|
||||||
{
|
{
|
||||||
assert (dirp != NULL);
|
assert (dirp != NULL);
|
||||||
assert (dirp->dirname != NULL);
|
assert (dirp->dirname != NULL);
|
||||||
dirp->dirent_filled = 0;
|
dirp->dirent_filled = 0;
|
||||||
|
|
||||||
# if defined(DIRENT_WIN32_INTERFACE)
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
/* Open stream and retrieve first file */
|
/* Open stream and retrieve first file */
|
||||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
/* something went wrong but we don't know what. GetLastError() could
|
/* something went wrong but we don't know what. GetLastError() could
|
||||||
* give us more information about the error, but then we should map
|
* give us more information about the error, but then we should map
|
||||||
* the error code into errno. */
|
* the error code into errno. */
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
if (_dos_findfirst (dirp->dirname,
|
if (_dos_findfirst (dirp->dirname,
|
||||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||||
&dirp->current.data) != 0) {
|
&dirp->current.data) != 0)
|
||||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
{
|
||||||
* more entries could be retrieved. */
|
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||||
return 0;
|
* more entries could be retrieved. */
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* initialize DIR and it's first entry */
|
/* initialize DIR and it's first entry */
|
||||||
_setdirname (dirp);
|
_setdirname (dirp);
|
||||||
dirp->dirent_filled = 1;
|
dirp->dirent_filled = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -639,14 +641,14 @@ static const char *
|
|||||||
_getdirname (const struct dirent *dp)
|
_getdirname (const struct dirent *dp)
|
||||||
{
|
{
|
||||||
#if defined(DIRENT_WIN32_INTERFACE)
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
return dp->data.cFileName;
|
return dp->data.cFileName;
|
||||||
|
|
||||||
#elif defined(DIRENT_USE_FFBLK)
|
#elif defined(DIRENT_USE_FFBLK)
|
||||||
return dp->data.ff_name;
|
return dp->data.ff_name;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
return dp->data.name;
|
return dp->data.name;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -654,17 +656,16 @@ _getdirname (const struct dirent *dp)
|
|||||||
* Copy name of implementation dependent directory entry to the d_name field.
|
* Copy name of implementation dependent directory entry to the d_name field.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_setdirname (struct DIR *dirp)
|
_setdirname (struct DIR *dirp) {
|
||||||
{
|
/* make sure that d_name is long enough */
|
||||||
/* make sure that d_name is long enough */
|
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
|
||||||
|
strncpy (dirp->current.d_name,
|
||||||
strncpy (dirp->current.d_name,
|
_getdirname (&dirp->current),
|
||||||
_getdirname (&dirp->current),
|
NAME_MAX);
|
||||||
NAME_MAX);
|
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
468
applications/common/color.c
Normal file
@@ -0,0 +1,468 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, 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
|
||||||
|
* 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 "openjpeg.h"
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
#include <lcms2.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
#include <lcms.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*--------------------------------------------------------
|
||||||
|
Matrix f<>r sYCC, Amendment 1 to IEC 61966-2-1
|
||||||
|
|
||||||
|
Y : 0.299 0.587 0.114 :R
|
||||||
|
Cb: -0.1687 -0.3312 0.5 :G
|
||||||
|
Cr: 0.5 -0.4187 -0.0812 :B
|
||||||
|
|
||||||
|
Inverse:
|
||||||
|
|
||||||
|
R: 1 -3.68213e-05 1.40199 :Y
|
||||||
|
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||||
|
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||||
|
|
||||||
|
-----------------------------------------------------------*/
|
||||||
|
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||||
|
int *out_r, int *out_g, int *out_b)
|
||||||
|
{
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
cb -= offset; cr -= offset;
|
||||||
|
r = y + (int)(1.402 * (float)cr);
|
||||||
|
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
|
||||||
|
|
||||||
|
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
|
||||||
|
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
|
||||||
|
|
||||||
|
b = y + (int)(1.772 * (float)cb);
|
||||||
|
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sycc444_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b;
|
||||||
|
const int *y, *cb, *cr;
|
||||||
|
int maxw, maxh, max, i, offset, upb;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
}/* sycc444_to_rgb() */
|
||||||
|
|
||||||
|
static void sycc422_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b;
|
||||||
|
const int *y, *cb, *cr;
|
||||||
|
int maxw, maxh, max, offset, upb;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i=0; i < maxh; ++i)
|
||||||
|
{
|
||||||
|
for(j=0; j < maxw; j += 2)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||||
|
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||||
|
img->comps[1].dx = img->comps[0].dx;
|
||||||
|
img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[0].dy;
|
||||||
|
img->comps[2].dy = img->comps[0].dy;
|
||||||
|
|
||||||
|
}/* sycc422_to_rgb() */
|
||||||
|
|
||||||
|
static void sycc420_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||||
|
const int *y, *cb, *cr, *ny;
|
||||||
|
int maxw, maxh, max, offset, upb;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i=0; i < maxh; i += 2)
|
||||||
|
{
|
||||||
|
ny = y + maxw;
|
||||||
|
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||||
|
|
||||||
|
for(j=0; j < maxw; j += 2)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||||
|
|
||||||
|
++ny; ++nr; ++ng; ++nb;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||||
|
|
||||||
|
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||||
|
}
|
||||||
|
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||||
|
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||||
|
img->comps[1].dx = img->comps[0].dx;
|
||||||
|
img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[0].dy;
|
||||||
|
img->comps[2].dy = img->comps[0].dy;
|
||||||
|
|
||||||
|
}/* sycc420_to_rgb() */
|
||||||
|
|
||||||
|
void color_sycc_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
if(img->numcomps < 3)
|
||||||
|
{
|
||||||
|
img->color_space = CLRSPC_GRAY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 2)
|
||||||
|
&& (img->comps[2].dx == 2)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 2)
|
||||||
|
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||||
|
{
|
||||||
|
sycc420_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 2)
|
||||||
|
&& (img->comps[2].dx == 2)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 1)
|
||||||
|
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||||
|
{
|
||||||
|
sycc422_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 1)
|
||||||
|
&& (img->comps[2].dx == 1)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 1)
|
||||||
|
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||||
|
{
|
||||||
|
sycc444_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n",
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
img->color_space = CLRSPC_SRGB;
|
||||||
|
|
||||||
|
}/* color_sycc_to_rgb() */
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
/* Bob Friesenhahn proposed:*/
|
||||||
|
#define cmsSigXYZData icSigXYZData
|
||||||
|
#define cmsSigLabData icSigLabData
|
||||||
|
#define cmsSigCmykData icSigCmykData
|
||||||
|
#define cmsSigYCbCrData icSigYCbCrData
|
||||||
|
#define cmsSigLuvData icSigLuvData
|
||||||
|
#define cmsSigGrayData icSigGrayData
|
||||||
|
#define cmsSigRgbData icSigRgbData
|
||||||
|
#define cmsUInt32Number DWORD
|
||||||
|
|
||||||
|
#define cmsColorSpaceSignature icColorSpaceSignature
|
||||||
|
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
|
void color_apply_icc_profile(opj_image_t *image)
|
||||||
|
{
|
||||||
|
cmsHPROFILE in_prof, out_prof;
|
||||||
|
cmsHTRANSFORM transform;
|
||||||
|
cmsColorSpaceSignature in_space, out_space;
|
||||||
|
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||||
|
int *r, *g, *b;
|
||||||
|
int prec, i, max, max_w, max_h;
|
||||||
|
OPJ_COLOR_SPACE oldspace;
|
||||||
|
|
||||||
|
in_prof =
|
||||||
|
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||||
|
|
||||||
|
if(in_prof == NULL) return;
|
||||||
|
|
||||||
|
in_space = cmsGetPCS(in_prof);
|
||||||
|
(void)in_space;
|
||||||
|
out_space = cmsGetColorSpace(in_prof);
|
||||||
|
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||||
|
|
||||||
|
|
||||||
|
max_w = image->comps[0].w; max_h = image->comps[0].h;
|
||||||
|
prec = image->comps[0].prec;
|
||||||
|
(void)prec;
|
||||||
|
oldspace = image->color_space;
|
||||||
|
|
||||||
|
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_RGB_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_GRAY_8;
|
||||||
|
out_type = TYPE_RGB_8;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_YCbCr_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||||
|
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||||
|
__FILE__,__LINE__,out_space,
|
||||||
|
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||||
|
(out_space>>8) & 0xff, out_space & 0xff);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||||
|
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||||
|
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||||
|
|
||||||
|
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||||
|
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||||
|
" type: in(%u) out:(%u)\n",
|
||||||
|
intent,
|
||||||
|
in_space,
|
||||||
|
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||||
|
(in_space>>8) & 0xff, in_space & 0xff,
|
||||||
|
|
||||||
|
out_space,
|
||||||
|
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||||
|
(out_space>>8) & 0xff, out_space & 0xff,
|
||||||
|
|
||||||
|
in_type,out_type
|
||||||
|
);
|
||||||
|
#endif /* DEBUG_PROFILE */
|
||||||
|
|
||||||
|
transform = cmsCreateTransform(in_prof, in_type,
|
||||||
|
out_prof, out_type, intent, 0);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(transform == NULL)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||||
|
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||||
|
#endif
|
||||||
|
image->color_space = oldspace;
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image->numcomps > 2)/* RGB, RGBA */
|
||||||
|
{
|
||||||
|
unsigned short *inbuf, *outbuf, *in, *out;
|
||||||
|
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned short);
|
||||||
|
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned short)*r++;
|
||||||
|
*in++ = (unsigned short)*g++;
|
||||||
|
*in++ = (unsigned short)*b++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++;
|
||||||
|
*g++ = (int)*out++;
|
||||||
|
*b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
free(inbuf); free(outbuf);
|
||||||
|
}
|
||||||
|
else /* GRAY, GRAYA */
|
||||||
|
{
|
||||||
|
unsigned char *in, *inbuf, *out, *outbuf;
|
||||||
|
|
||||||
|
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned char);
|
||||||
|
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
|
||||||
|
image->comps = (opj_image_comp_t*)
|
||||||
|
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||||
|
|
||||||
|
if(image->numcomps == 2)
|
||||||
|
image->comps[3] = image->comps[1];
|
||||||
|
|
||||||
|
image->comps[1] = image->comps[0];
|
||||||
|
image->comps[2] = image->comps[0];
|
||||||
|
|
||||||
|
image->comps[1].data = (int*)calloc(max, sizeof(int));
|
||||||
|
image->comps[2].data = (int*)calloc(max, sizeof(int));
|
||||||
|
|
||||||
|
image->numcomps += 2;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned char)*r++;
|
||||||
|
}
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
free(inbuf); free(outbuf);
|
||||||
|
|
||||||
|
}/* if(image->numcomps */
|
||||||
|
|
||||||
|
cmsDeleteTransform(transform);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
}/* color_apply_icc_profile() */
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBLCMS2 || HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
@@ -1,15 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* BSD License, included below. This software may be subject to other third
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* 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) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -40,8 +34,5 @@
|
|||||||
|
|
||||||
extern void color_sycc_to_rgb(opj_image_t *img);
|
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||||
extern void color_apply_icc_profile(opj_image_t *image);
|
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_ */
|
#endif /* _OPJ_COLOR_H_ */
|
||||||
@@ -1,15 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* BSD License, included below. This software may be subject to other third
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* 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) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -47,9 +41,8 @@
|
|||||||
#define BMP_DFMT 12
|
#define BMP_DFMT 12
|
||||||
#define YUV_DFMT 13
|
#define YUV_DFMT 13
|
||||||
#define TIF_DFMT 14
|
#define TIF_DFMT 14
|
||||||
#define RAW_DFMT 15 /* MSB / Big Endian */
|
#define RAW_DFMT 15
|
||||||
#define TGA_DFMT 16
|
#define TGA_DFMT 16
|
||||||
#define PNG_DFMT 17
|
#define PNG_DFMT 17
|
||||||
#define RAWL_DFMT 18 /* LSB / Little Endian */
|
|
||||||
|
|
||||||
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||||
254
applications/common/opj_getopt.c
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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 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 */
|
||||||
|
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;
|
||||||
|
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=argv[opj_optind]+1;
|
||||||
|
const opj_option_t* o;
|
||||||
|
o=longopts;
|
||||||
|
len=sizeof(longopts[0]);
|
||||||
|
|
||||||
|
if (param > 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);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!opj_optarg) { /* missing argument */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
|
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*/
|
||||||
51
applications/common/opj_getopt.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#define opj_opterr opterr
|
||||||
|
#define opj_optind optind
|
||||||
|
#define opj_optopt optopt
|
||||||
|
#define opj_optreset optreset
|
||||||
|
#define opj_optarg optarg
|
||||||
|
|
||||||
|
typedef struct option opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG no_argument
|
||||||
|
#define REQ_ARG required_argument
|
||||||
|
#define OPT_ARG optional_argument
|
||||||
|
|
||||||
|
#define opj_getopt getopt
|
||||||
|
#define opj_getopt_long getopt_long
|
||||||
|
|
||||||
|
#else
|
||||||
|
#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 reset_options_reading(void);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
||||||
|
#endif /* USE_SYSTEM_GETOPT */
|
||||||
127
applications/jpip/CHANGES
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
What's New for OpenJPIP
|
||||||
|
|
||||||
|
* : fixed
|
||||||
|
- : removed
|
||||||
|
! : changed
|
||||||
|
+ : added
|
||||||
|
|
||||||
|
Feburary 28, 2012
|
||||||
|
+ [kaori] enabled the opj_server to reply the first query consisting with len request from kakadu client
|
||||||
|
|
||||||
|
February 9, 2012
|
||||||
|
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||||
|
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||||
|
|
||||||
|
January 26, 2012
|
||||||
|
! [kaori] unapplied auxtrans_manager to the local mode
|
||||||
|
|
||||||
|
December 24, 2011
|
||||||
|
* [kaori] additional modification for the warning
|
||||||
|
|
||||||
|
December 22, 2011
|
||||||
|
* [kaori] fixed auxtrans_manager to enable MAC
|
||||||
|
* [kaori] warnings due to disregarding return value are removed
|
||||||
|
|
||||||
|
November 30, 2011
|
||||||
|
+ [kaori] TCP return (http-tcp) implemented
|
||||||
|
|
||||||
|
November 16, 2011
|
||||||
|
* [kaori] fixed Region of Interest option, and memory leak of opj_dec_server
|
||||||
|
+ [kaori] new feature to target JP2 files from www (libcurl required)
|
||||||
|
* [kaori] fixed opj_server execusion error (instant terminating) with autotool, cmake still need to be fixed
|
||||||
|
|
||||||
|
November 8, 2011
|
||||||
|
! [kaori] updated main page of doxygen
|
||||||
|
|
||||||
|
November 3, 2011
|
||||||
|
* [kaori] solved memory leak of opj_server
|
||||||
|
! [kaori] removed redundant defines
|
||||||
|
|
||||||
|
November 2, 2011
|
||||||
|
* [antonin] additional patches for autotools and cmake
|
||||||
|
|
||||||
|
October 26, 2011
|
||||||
|
* [kaori] additional patches for autotool are applied
|
||||||
|
|
||||||
|
October 25, 2011
|
||||||
|
* [kaori] patches for cmake and autotool are applied
|
||||||
|
* [kaori] fixed client viewer to be compatible with server response header both Content-type and Content-Type
|
||||||
|
|
||||||
|
October 20, 2011
|
||||||
|
+ [added] API style in openJPIP library
|
||||||
|
! [kaori] rearranged directories, applications are all under util/ directory, currently only 'make -f Makefile.nix' works
|
||||||
|
|
||||||
|
October 18, 2011
|
||||||
|
! [kaori] rearranged opj_server, opj_dec_server directory
|
||||||
|
|
||||||
|
October 14, 2011
|
||||||
|
+ [kaori] enable all progression orders
|
||||||
|
|
||||||
|
October 12, 2011
|
||||||
|
+ [kaori] enable layers requests; restricting the number of codesream quality layers
|
||||||
|
|
||||||
|
October 11, 2011
|
||||||
|
+ [antonin] enable JPT-stream request from client viewer option (credit to kaori)
|
||||||
|
|
||||||
|
October 10, 2011
|
||||||
|
- [antonin] removed obsolete indexer utility (credit to kaori)
|
||||||
|
+ [antonin] enabled JPP-stream (credit to kaori)
|
||||||
|
|
||||||
|
September 16, 2011
|
||||||
|
+ [kaori] enabled stateless requests from the opj_viewers
|
||||||
|
|
||||||
|
Septempber 1, 2011
|
||||||
|
* [kaori] changed terminating status of opj_server in debug/non-server mode
|
||||||
|
|
||||||
|
August 27, 2011
|
||||||
|
* [antonin] fixed missing include directory in opj_client/opj_dec_server/CMakeLists.txt
|
||||||
|
|
||||||
|
August 26, 2011
|
||||||
|
* [antonin] fixed cmake and autotools files to reflect recent indexer changes in JPIP
|
||||||
|
! [kaori] indexer using the latest openjpeg library
|
||||||
|
* [antonin] fixed cmake and autotools files to reflect recent changes in JPIP
|
||||||
|
! [kaori] fixed Makefile.nix to load openjpeg library from this archive
|
||||||
|
|
||||||
|
August 25, 2011
|
||||||
|
+ [kaori] added tid request support to JPIP client
|
||||||
|
+ [kaori] added quit JPIP server request
|
||||||
|
|
||||||
|
August 24, 2011
|
||||||
|
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||||
|
+ [kaori] added tid request support to JPIP server
|
||||||
|
|
||||||
|
August 16, 2011
|
||||||
|
* [antonin] fixed cmake support for openjpip
|
||||||
|
|
||||||
|
August 12, 2011
|
||||||
|
+ [antonin] added cmake support to openjpip
|
||||||
|
|
||||||
|
July 6, 2011
|
||||||
|
* [antonin] JPIP : fixed autotools to work with recent name changes
|
||||||
|
|
||||||
|
July 5, 2011
|
||||||
|
! [kaori] changed parameter, file names, message names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||||
|
|
||||||
|
May 26, 2011
|
||||||
|
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||||
|
|
||||||
|
May 23, 2011
|
||||||
|
+ [antonin] added autotools for the 'tools' directory
|
||||||
|
+ [antonin] added autotools as a build method for jpip (credit to Vincent Torri)
|
||||||
|
|
||||||
|
May 10, 2011
|
||||||
|
! [kaori] opj_viewer removed the xml functions (for users without Xersus2)
|
||||||
|
+ [kaori] renamed opj_viewer to opj_viewer_xerces ( needs Xersus2)
|
||||||
|
! [kaori] Modification of opj_dec_server to be portable to windows
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [antonin] OpenJPIP: small bug fixes to compile on win platform
|
||||||
|
|
||||||
|
May 8, 2011
|
||||||
|
* [antonin] OpenJPIP: fixed several bugs in opj_server (removal of strsep function, duplication of query string) + some changes to compile opj_server under windows (replacement of strcasecmp(), bzero()).
|
||||||
|
|
||||||
|
April 14, 2011
|
||||||
|
+ [antonin] initial commit of OpenJPIP 1.0, a JPIP client-server architecture based on OpenJPEG (see README file in jpip directory for more details)
|
||||||
16
applications/jpip/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# 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(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
ENDIF(BUILD_JPIP_SERVER)
|
||||||
|
|
||||||
|
# JPIP library:
|
||||||
|
ADD_SUBDIRECTORY(libopenjpip)
|
||||||
|
|
||||||
|
# JPIP binaries:
|
||||||
|
ADD_SUBDIRECTORY(util)
|
||||||
|
|
||||||
3
applications/jpip/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpip util
|
||||||
1514
applications/jpip/doc/Doxyfile
Normal file
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -1,17 +1,13 @@
|
|||||||
include_regular_expression("^.*$")
|
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||||
|
|
||||||
add_definitions(-DUSE_JPIP)
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
include_directories(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
|
||||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
|
||||||
${FCGI_INCLUDE_DIRS}
|
${FCGI_INCLUDE_DIRS}
|
||||||
${CURL_INCLUDE_DIRS}
|
${CURL_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Defines the source code for the library
|
# Defines the source code for the library
|
||||||
set(OPENJPIP_SRCS
|
SET(OPENJPIP_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/boxheader_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/boxheader_manager.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/codestream_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/codestream_manager.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/imgreg_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/imgreg_manager.c
|
||||||
@@ -38,11 +34,11 @@ set(OPENJPIP_SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SERVER_SRCS
|
SET(SERVER_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/auxtrans_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/auxtrans_manager.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LOCAL_SRCS
|
SET(LOCAL_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
|
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
|
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
|
||||||
@@ -51,40 +47,26 @@ set(LOCAL_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Build the library
|
# Build the library
|
||||||
if(WIN32)
|
ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
|
||||||
if(BUILD_SHARED_LIBS)
|
TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME})
|
||||||
add_definitions(-DOPJ_EXPORTS)
|
IF(WIN32)
|
||||||
else()
|
|
||||||
add_definitions(-DOPJ_STATIC)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
add_library(openjpip ${OPENJPIP_SRCS} ${LOCAL_SRCS})
|
|
||||||
set_target_properties(openjpip
|
|
||||||
PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
|
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
|
|
||||||
target_compile_options(openjpip PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
|
|
||||||
endif()
|
|
||||||
target_link_libraries(openjpip ${OPENJPEG_LIBRARY_NAME})
|
|
||||||
if(WIN32)
|
|
||||||
# add Winsock on windows+mingw
|
# add Winsock on windows+mingw
|
||||||
target_link_libraries(openjpip ws2_32)
|
TARGET_LINK_LIBRARIES(openjpip_local ws2_32)
|
||||||
endif()
|
ENDIF(WIN32)
|
||||||
|
|
||||||
# Install library
|
# Install library
|
||||||
install(TARGETS openjpip
|
INSTALL(TARGETS openjpip_local
|
||||||
EXPORT OpenJPEGTargets
|
EXPORT OpenJPEGTargets
|
||||||
RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
|
||||||
ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_JPIP_SERVER)
|
IF(BUILD_JPIP_SERVER)
|
||||||
add_library(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
||||||
target_link_libraries(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
set_target_properties(openjpip_server
|
SET_TARGET_PROPERTIES(openjpip_server
|
||||||
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
||||||
install(TARGETS openjpip_server
|
INSTALL(TARGETS openjpip_server
|
||||||
EXPORT OpenJPEGTargets
|
EXPORT OpenJPEGTargets
|
||||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
)
|
)
|
||||||
endif()
|
ENDIF(BUILD_JPIP_SERVER)
|
||||||
151
applications/jpip/libopenjpip/Makefile.am
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
|
||||||
|
includes_HEADERS =
|
||||||
|
|
||||||
|
lib_LTLIBRARIES =
|
||||||
|
|
||||||
|
if WANT_JPIP
|
||||||
|
lib_LTLIBRARIES += libopenjpip_local.la
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WANT_JPIP_SERVER
|
||||||
|
lib_LTLIBRARIES += libopenjpip_server.la
|
||||||
|
endif
|
||||||
|
|
||||||
|
JPIP_SRC = \
|
||||||
|
openjpip.c \
|
||||||
|
query_parser.c \
|
||||||
|
channel_manager.c \
|
||||||
|
session_manager.c \
|
||||||
|
jpip_parser.c \
|
||||||
|
boxheader_manager.c \
|
||||||
|
codestream_manager.c \
|
||||||
|
imgreg_manager.c \
|
||||||
|
marker_manager.c \
|
||||||
|
msgqueue_manager.c \
|
||||||
|
box_manager.c \
|
||||||
|
faixbox_manager.c \
|
||||||
|
index_manager.c \
|
||||||
|
metadata_manager.c \
|
||||||
|
placeholder_manager.c \
|
||||||
|
byte_manager.c \
|
||||||
|
ihdrbox_manager.c \
|
||||||
|
manfbox_manager.c \
|
||||||
|
mhixbox_manager.c \
|
||||||
|
target_manager.c \
|
||||||
|
cachemodel_manager.c \
|
||||||
|
j2kheader_manager.c \
|
||||||
|
jp2k_encoder.c \
|
||||||
|
sock_manager.c \
|
||||||
|
openjpip.h \
|
||||||
|
bool.h \
|
||||||
|
boxheader_manager.h \
|
||||||
|
box_manager.h \
|
||||||
|
byte_manager.h \
|
||||||
|
codestream_manager.h \
|
||||||
|
faixbox_manager.h \
|
||||||
|
ihdrbox_manager.h \
|
||||||
|
imgreg_manager.h \
|
||||||
|
index_manager.h \
|
||||||
|
manfbox_manager.h \
|
||||||
|
marker_manager.h \
|
||||||
|
metadata_manager.h \
|
||||||
|
mhixbox_manager.h \
|
||||||
|
msgqueue_manager.h \
|
||||||
|
placeholder_manager.h \
|
||||||
|
target_manager.h \
|
||||||
|
cachemodel_manager.h \
|
||||||
|
j2kheader_manager.h \
|
||||||
|
jp2k_encoder.h \
|
||||||
|
query_parser.h \
|
||||||
|
channel_manager.h \
|
||||||
|
session_manager.h \
|
||||||
|
jpip_parser.h \
|
||||||
|
jp2k_decoder.h \
|
||||||
|
sock_manager.h
|
||||||
|
|
||||||
|
SERVER_SRC = auxtrans_manager.c \
|
||||||
|
auxtrans_manager.h
|
||||||
|
|
||||||
|
LOCAL_SRC = jp2k_decoder.c \
|
||||||
|
imgsock_manager.c \
|
||||||
|
jpipstream_manager.c \
|
||||||
|
cache_manager.c \
|
||||||
|
dec_clientmsg_handler.c \
|
||||||
|
imgsock_manager.h \
|
||||||
|
jpipstream_manager.h \
|
||||||
|
cache_manager.h \
|
||||||
|
dec_clientmsg_handler.h
|
||||||
|
|
||||||
|
libopenjpip_server_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||||
|
@FCGI_CFLAGS@ \
|
||||||
|
@LIBCURL_CFLAGS@ \
|
||||||
|
-DSERVER
|
||||||
|
libopenjpip_server_la_CFLAGS = @THREAD_CFLAGS@
|
||||||
|
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ @LIBCURL_LIBS@ @THREAD_LIBS@ -lm
|
||||||
|
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_server_la_SOURCES = $(JPIP_SRC) $(SERVER_SRC)
|
||||||
|
|
||||||
|
libopenjpip_local_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||||
|
@LIBCURL_CFLAGS@
|
||||||
|
libopenjpip_local_la_CFLAGS =
|
||||||
|
libopenjpip_local_la_LIBADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
|
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
if WANT_JPIP_SERVER
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
|
||||||
|
if BUILD_SHARED
|
||||||
|
@( $(call solist_s) ) >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
if BUILD_STATIC
|
||||||
|
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if WANT_JPIP
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
|
||||||
|
if BUILD_SHARED
|
||||||
|
@( $(call solist_c) ) >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
if BUILD_STATIC
|
||||||
|
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
solist_s = $(foreach f, $(dll_s) $(so_s), echo -e ' $(SO_PREFIX)\t$(base_s)/$(f)' ;)
|
||||||
|
get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)
|
||||||
|
base_s = $(call get_tok_s,libdir)
|
||||||
|
so_s = $(call get_tok_s,library_names)
|
||||||
|
a_s = $(call get_tok_s,old_library)
|
||||||
|
|
||||||
|
solist_c = $(foreach f, $(dll_c) $(so_c), echo -e ' $(SO_PREFIX)\t$(base_c)/$(f)' ;)
|
||||||
|
get_tok_c = $(shell grep -E "^$(1)=" libopenjpip_local.la | cut -d "'" -f 2)
|
||||||
|
base_c = $(call get_tok_c,libdir)
|
||||||
|
so_c = $(call get_tok_c,library_names)
|
||||||
|
a_c = $(call get_tok_c,old_library)
|
||||||
|
|
||||||
|
if HAVE_WIN32
|
||||||
|
SO_PREFIX = (DLL)
|
||||||
|
dll_s = $(call get_tok_s,dlname)
|
||||||
|
dll_c = $(call get_tok_c,dlname)
|
||||||
|
else
|
||||||
|
if HAVE_DARWIN
|
||||||
|
SO_PREFIX = (DY)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
else
|
||||||
|
SO_PREFIX = (SO)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
endif
|
||||||
|
endif
|
||||||
267
applications/jpip/libopenjpip/auxtrans_manager.c
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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 <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "auxtrans_manager.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <process.h>
|
||||||
|
#else
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||||
|
{
|
||||||
|
auxtrans_param_t auxtrans;
|
||||||
|
|
||||||
|
auxtrans.tcpauxport = tcp_auxport;
|
||||||
|
auxtrans.udpauxport = udp_auxport;
|
||||||
|
|
||||||
|
if( 49152 <= tcp_auxport && tcp_auxport <= 65535)
|
||||||
|
auxtrans.tcplistensock = open_listeningsocket( tcp_auxport);
|
||||||
|
else
|
||||||
|
auxtrans.tcplistensock = -1;
|
||||||
|
|
||||||
|
auxtrans.udplistensock = -1;
|
||||||
|
/* open listening socket for udp later */
|
||||||
|
|
||||||
|
return auxtrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
void close_aux_transport( auxtrans_param_t auxtrans)
|
||||||
|
{
|
||||||
|
if( auxtrans.tcplistensock != -1)
|
||||||
|
if( close_socket( auxtrans.tcplistensock) != 0)
|
||||||
|
perror("close");
|
||||||
|
|
||||||
|
if( auxtrans.udplistensock != -1)
|
||||||
|
if( close_socket( auxtrans.udplistensock) != 0)
|
||||||
|
perror("close");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!< auxiliary response parameters */
|
||||||
|
typedef struct aux_response_param{
|
||||||
|
char *cid; /*!< channel ID */
|
||||||
|
unsigned char *data; /*!< sending data */
|
||||||
|
int datalen; /*!< length of data */
|
||||||
|
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||||
|
SOCKET listensock; /*!< listeing socket */
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE hTh; /*!< thread handle */
|
||||||
|
#endif
|
||||||
|
} aux_response_param_t;
|
||||||
|
|
||||||
|
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame);
|
||||||
|
|
||||||
|
void delete_auxresponse( aux_response_param_t **auxresponse);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned __stdcall aux_streaming( void *arg);
|
||||||
|
#else
|
||||||
|
void * aux_streaming( void *arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||||
|
{
|
||||||
|
aux_response_param_t *auxresponse;
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned int threadId;
|
||||||
|
#else
|
||||||
|
pthread_t thread;
|
||||||
|
int status;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( istcp){
|
||||||
|
if( auxtrans.tcplistensock == -1){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), tcp listening socket no open\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId);
|
||||||
|
if( auxresponse->hTh == 0)
|
||||||
|
fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh));
|
||||||
|
#else
|
||||||
|
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
|
||||||
|
if( status != 0)
|
||||||
|
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||||
|
{
|
||||||
|
aux_response_param_t *auxresponse;
|
||||||
|
|
||||||
|
auxresponse = (aux_response_param_t *)malloc( sizeof(aux_response_param_t));
|
||||||
|
|
||||||
|
auxresponse->cid = strdup( cid);
|
||||||
|
auxresponse->data = data;
|
||||||
|
auxresponse->datalen = datalen;
|
||||||
|
auxresponse->maxlenPerFrame = maxlenPerFrame;
|
||||||
|
auxresponse->listensock = istcp ? auxtrans.tcplistensock : auxtrans.udplistensock;
|
||||||
|
|
||||||
|
return auxresponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_auxresponse( aux_response_param_t **auxresponse)
|
||||||
|
{
|
||||||
|
free( (*auxresponse)->cid);
|
||||||
|
free( (*auxresponse)->data);
|
||||||
|
free( *auxresponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify cid sent from client
|
||||||
|
*
|
||||||
|
* @param [in] connected_socket file descriptor of the connected socket
|
||||||
|
* @param [in] refcid refenrece channel ID
|
||||||
|
* @param [in] fp file pointer for log of aux stream
|
||||||
|
* @return true if identified, false otherwise
|
||||||
|
*/
|
||||||
|
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp);
|
||||||
|
|
||||||
|
bool recv_ack( SOCKET connected_socket, void *data);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned __stdcall aux_streaming( void *arg)
|
||||||
|
#else
|
||||||
|
void * aux_streaming( void *arg)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
SOCKET connected_socket;
|
||||||
|
unsigned char *chunk, *ptr;
|
||||||
|
int maxLenOfBody, remlen, chunklen;
|
||||||
|
const int headlen = 8;
|
||||||
|
|
||||||
|
aux_response_param_t *auxresponse = (aux_response_param_t *)arg;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
CloseHandle( auxresponse->hTh);
|
||||||
|
#else
|
||||||
|
pthread_detach( pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame);
|
||||||
|
maxLenOfBody = auxresponse->maxlenPerFrame - headlen;
|
||||||
|
remlen = auxresponse->datalen;
|
||||||
|
|
||||||
|
while((connected_socket = accept_socket( auxresponse->listensock)) != -1){
|
||||||
|
if( identify_cid( connected_socket, auxresponse->cid, FCGI_stderr)){
|
||||||
|
ptr = auxresponse->data;
|
||||||
|
while( 0 < remlen){
|
||||||
|
memset( chunk, 0, auxresponse->maxlenPerFrame);
|
||||||
|
|
||||||
|
chunklen = remlen<maxLenOfBody?remlen:maxLenOfBody;
|
||||||
|
chunklen += headlen;
|
||||||
|
|
||||||
|
chunk[0] = (chunklen >> 8) & 0xff;
|
||||||
|
chunk[1] = chunklen & 0xff;
|
||||||
|
|
||||||
|
memcpy( chunk+headlen, ptr, chunklen-headlen);
|
||||||
|
|
||||||
|
do{
|
||||||
|
send_stream( connected_socket, chunk, chunklen);
|
||||||
|
}while( !recv_ack( connected_socket, chunk));
|
||||||
|
|
||||||
|
remlen -= maxLenOfBody;
|
||||||
|
ptr += maxLenOfBody;
|
||||||
|
}
|
||||||
|
if( close_socket( connected_socket) != 0)
|
||||||
|
perror("close");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free( chunk);
|
||||||
|
|
||||||
|
delete_auxresponse( &auxresponse);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
_endthreadex(0);
|
||||||
|
#else
|
||||||
|
pthread_exit(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp)
|
||||||
|
{
|
||||||
|
char *cid;
|
||||||
|
bool succeed;
|
||||||
|
|
||||||
|
if(!(cid = receive_string( connected_socket))){
|
||||||
|
fprintf( fp, "Error: error in identify_cid(), while receiving cid from client\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
succeed = false;
|
||||||
|
if( strncmp( refcid, cid, strlen( refcid)) == 0)
|
||||||
|
succeed = true;
|
||||||
|
|
||||||
|
free( cid);
|
||||||
|
|
||||||
|
return succeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool recv_ack( SOCKET connected_socket, void *data)
|
||||||
|
{
|
||||||
|
char *header;
|
||||||
|
bool succeed;
|
||||||
|
|
||||||
|
header = receive_stream( connected_socket, 8);
|
||||||
|
|
||||||
|
if( memcmp( header, data, 8) != 0)
|
||||||
|
succeed = false;
|
||||||
|
else
|
||||||
|
succeed = true;
|
||||||
|
|
||||||
|
free( header);
|
||||||
|
|
||||||
|
return succeed;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -32,21 +32,20 @@
|
|||||||
# define AUXTRANS_MANAGER_H_
|
# define AUXTRANS_MANAGER_H_
|
||||||
|
|
||||||
#include "sock_manager.h"
|
#include "sock_manager.h"
|
||||||
#include "opj_includes.h"
|
|
||||||
|
|
||||||
/** auxiliary transport setting parameters*/
|
/** auxiliary transport setting parameters*/
|
||||||
typedef struct auxtrans_param {
|
typedef struct auxtrans_param{
|
||||||
int tcpauxport; /**< tcp port*/
|
int tcpauxport; /**< tcp port*/
|
||||||
int udpauxport; /**< udp port*/
|
int udpauxport; /**< udp port*/
|
||||||
SOCKET tcplistensock; /**< listenning socket for aux tcp (-1 if not open)*/
|
SOCKET tcplistensock; /**< listenning socket for aux tcp (-1 if not open)*/
|
||||||
SOCKET udplistensock; /**< listenning socket for aux udp (-1 if not open)*/
|
SOCKET udplistensock; /**< listenning socket for aux udp (-1 if not open)*/
|
||||||
} auxtrans_param_t;
|
} auxtrans_param_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize auxiliary transport server of JPIP server
|
* Initialize auxiliary transport server of JPIP server
|
||||||
*
|
*
|
||||||
* @param[in] tcp_auxport opening tcp auxiliary port ( 0 not to open, valid No. 49152-65535)
|
* @param[in] tcp_auxport opening tcp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||||
* @param[in] udp_auxport opening udp auxiliary port ( 0 not to open, valid No. 49152-65535)
|
* @param[in] udp_auxport opening udp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||||
* @return intialized transport parameters
|
* @return intialized transport parameters
|
||||||
*/
|
*/
|
||||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport);
|
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport);
|
||||||
@@ -68,6 +67,6 @@ void close_aux_transport( auxtrans_param_t auxtrans);
|
|||||||
* @param[in] length length of data
|
* @param[in] length length of data
|
||||||
* @param[in] maxlenPerFrame maximum data length to send per frame
|
* @param[in] maxlenPerFrame maximum data length to send per frame
|
||||||
*/
|
*/
|
||||||
void send_responsedata_on_aux( OPJ_BOOL istcp, auxtrans_param_t auxtrans, const char cid[], void *data, OPJ_SIZE_T length, OPJ_SIZE_T maxlenPerFrame);
|
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int length, int maxlenPerFrame);
|
||||||
|
|
||||||
#endif /* !AUXTRANS_MANAGER_H_ */
|
#endif /* !AUXTRANS_MANAGER_H_ */
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
* $Id$
|
||||||
* 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) 2012, Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -28,21 +27,26 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#ifndef OPJ_INTTYPES_H
|
|
||||||
#define OPJ_INTTYPES_H
|
|
||||||
|
|
||||||
#include "opj_config_private.h"
|
#ifndef BOOL_H_
|
||||||
#ifdef OPJ_HAVE_INTTYPES_H
|
# define BOOL_H_
|
||||||
#include <inttypes.h>
|
|
||||||
#else
|
#ifndef false
|
||||||
#if defined(_WIN32)
|
#define false 0
|
||||||
#define PRId64 "I64d"
|
|
||||||
#define PRIi64 "I64i"
|
|
||||||
#define PRIu64 "I64u"
|
|
||||||
#define PRIx64 "I64x"
|
|
||||||
#else
|
|
||||||
#error unsupported platform
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* OPJ_INTTYPES_H */
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef true
|
||||||
|
#define true (!false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (!FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef char bool;
|
||||||
|
|
||||||
|
#endif /* !BOOL_H_ */
|
||||||
415
applications/jpip/libopenjpip/box_manager.c
Normal file
@@ -0,0 +1,415 @@
|
|||||||
|
/*
|
||||||
|
* $Id: box_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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 <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include "box_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
boxlist_param_t * gene_boxlist()
|
||||||
|
{
|
||||||
|
boxlist_param_t *boxlist;
|
||||||
|
|
||||||
|
boxlist = (boxlist_param_t *)malloc( sizeof(boxlist_param_t));
|
||||||
|
|
||||||
|
boxlist->first = NULL;
|
||||||
|
boxlist->last = NULL;
|
||||||
|
|
||||||
|
return boxlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
|
||||||
|
{
|
||||||
|
boxlist_param_t *boxlist;
|
||||||
|
box_param_t *box;
|
||||||
|
int pos;
|
||||||
|
|
||||||
|
boxlist = NULL;
|
||||||
|
pos = offset;
|
||||||
|
do{
|
||||||
|
if(!(box = gene_boxbyOffset( fd, pos)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += box->length;
|
||||||
|
|
||||||
|
if( !boxlist)
|
||||||
|
boxlist = gene_boxlist();
|
||||||
|
insert_box_into_list( box, boxlist);
|
||||||
|
}while( pos < (int)(offset+length));
|
||||||
|
|
||||||
|
return boxlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
/* box type constraint*/
|
||||||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
|
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||||
|
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||||
|
free( data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
Byte_t *data2;
|
||||||
|
headlen = 16;
|
||||||
|
/* read XLBox*/
|
||||||
|
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
||||||
|
boxlen = big8(data2);
|
||||||
|
free(data2);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
|
free( data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
box->fd = fd;
|
||||||
|
box->offset = offset;
|
||||||
|
box->headlen = headlen;
|
||||||
|
box->length = boxlen;
|
||||||
|
strncpy( box->type, boxtype, 4);
|
||||||
|
box->next = NULL;
|
||||||
|
free( data);
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||||
|
{
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4( stream);
|
||||||
|
boxtype = (char *)( stream+4);
|
||||||
|
|
||||||
|
/* box type constraint*/
|
||||||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
|
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||||
|
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
headlen = 16;
|
||||||
|
boxlen = big8( stream+8); /* read XLBox*/
|
||||||
|
}
|
||||||
|
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
box->fd = -1;
|
||||||
|
box->offset = offset;
|
||||||
|
box->headlen = headlen;
|
||||||
|
box->length = boxlen;
|
||||||
|
strncpy( box->type, boxtype, 4);
|
||||||
|
box->next = NULL;
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
|
{
|
||||||
|
Byte8_t pos;
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|
||||||
|
if( length==0){ /* set the max length*/
|
||||||
|
if( (length = get_filesize( fd) - offset) <= 0)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = offset;
|
||||||
|
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
if((data = fetch_bytes( fd, pos, 8))){
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
Byte_t *data2;
|
||||||
|
headlen = 16;
|
||||||
|
/* read XLBox*/
|
||||||
|
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
||||||
|
boxlen = big8(data2);
|
||||||
|
free(data2);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||||
|
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
foundbox->fd = fd;
|
||||||
|
foundbox->offset = pos;
|
||||||
|
foundbox->headlen = headlen;
|
||||||
|
foundbox->length = boxlen;
|
||||||
|
strncpy( foundbox->type, TBox, 4);
|
||||||
|
foundbox->next = NULL;
|
||||||
|
free( data);
|
||||||
|
return foundbox;
|
||||||
|
}
|
||||||
|
free( data);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pos+= boxlen;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
|
{
|
||||||
|
Byte8_t pos;
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|
||||||
|
if( length<=0){ /* set the max length*/
|
||||||
|
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = offset;
|
||||||
|
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
data = stream + pos;
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
/* read XLBox*/
|
||||||
|
headlen = 16;
|
||||||
|
boxlen = big8( data+8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||||
|
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
foundbox->fd = -1;
|
||||||
|
foundbox->offset = pos;
|
||||||
|
foundbox->headlen = headlen;
|
||||||
|
foundbox->length = boxlen;
|
||||||
|
strncpy( foundbox->type, TBox, 4);
|
||||||
|
foundbox->next = NULL;
|
||||||
|
return foundbox;
|
||||||
|
}
|
||||||
|
pos+= boxlen;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||||
|
{
|
||||||
|
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[])
|
||||||
|
{
|
||||||
|
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_DBoxoff( box_param_t *box)
|
||||||
|
{
|
||||||
|
return box->offset+box->headlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_DBoxlen( box_param_t *box)
|
||||||
|
{
|
||||||
|
return box->length-box->headlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t * fetch_headbytes( box_param_t *box)
|
||||||
|
{
|
||||||
|
return fetch_bytes( box->fd, box->offset, box->headlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size)
|
||||||
|
{
|
||||||
|
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * search_box( const char type[], boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
foundbox = boxlist->first;
|
||||||
|
|
||||||
|
while( foundbox != NULL){
|
||||||
|
|
||||||
|
if( strncmp( type, foundbox->type, 4) == 0)
|
||||||
|
return foundbox;
|
||||||
|
|
||||||
|
foundbox = foundbox->next;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", type);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_box( box_param_t *box)
|
||||||
|
{
|
||||||
|
fprintf( logstream, "box info:\n"
|
||||||
|
"\t type: %.4s\n"
|
||||||
|
"\t offset: %lld %#llx\n"
|
||||||
|
"\t header length: %d\n"
|
||||||
|
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allbox( boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *ptr;
|
||||||
|
|
||||||
|
if( !boxlist)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ptr = boxlist->first;
|
||||||
|
if( !ptr)
|
||||||
|
fprintf( logstream, "no box\n");
|
||||||
|
|
||||||
|
fprintf( logstream, "all box info: \n");
|
||||||
|
while( ptr != NULL){
|
||||||
|
print_box( ptr);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *ptr;
|
||||||
|
|
||||||
|
if( *box == boxlist->first)
|
||||||
|
boxlist->first = (*box)->next;
|
||||||
|
else{
|
||||||
|
ptr = boxlist->first;
|
||||||
|
while( ptr->next != *box){
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
ptr->next = (*box)->next;
|
||||||
|
|
||||||
|
if( *box == boxlist->last)
|
||||||
|
boxlist->last = ptr;
|
||||||
|
}
|
||||||
|
free( *box);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
box = search_box( type, boxlist);
|
||||||
|
delete_box_in_list( &box, boxlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_boxlist( boxlist_param_t **boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *boxPtr, *boxNext;
|
||||||
|
|
||||||
|
if(!(*boxlist))
|
||||||
|
return;
|
||||||
|
|
||||||
|
boxPtr = (*boxlist)->first;
|
||||||
|
while( boxPtr != NULL){
|
||||||
|
boxNext=boxPtr->next;
|
||||||
|
free( boxPtr);
|
||||||
|
boxPtr=boxNext;
|
||||||
|
}
|
||||||
|
free( *boxlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
if( boxlist->first)
|
||||||
|
boxlist->last->next = box;
|
||||||
|
else
|
||||||
|
boxlist->first = box;
|
||||||
|
boxlist->last = box;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: box_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -34,20 +34,20 @@
|
|||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
|
|
||||||
/** box parameters*/
|
/** box parameters*/
|
||||||
typedef struct box_param {
|
typedef struct box_param{
|
||||||
int fd; /**< file descriptor*/
|
int fd; /**< file descriptor*/
|
||||||
OPJ_OFF_T offset; /**< byte position of the whole Box (LBox) in the file*/
|
Byte8_t offset; /**< byte position of the whole Box (LBox) in the file*/
|
||||||
Byte_t headlen; /**< header length 8 or 16*/
|
Byte_t headlen; /**< header length 8 or 16*/
|
||||||
Byte8_t length; /**< length of the whole Box*/
|
Byte8_t length; /**< length of the whole Box*/
|
||||||
char type[4]; /**< type of information in the DBox*/
|
char type[4]; /**< type of information in the DBox*/
|
||||||
struct box_param *next; /**< pointer to the next box*/
|
struct box_param *next; /**< pointer to the next box*/
|
||||||
} box_param_t;
|
} box_param_t;
|
||||||
|
|
||||||
|
|
||||||
/** Box list parameters*/
|
/** Box list parameters*/
|
||||||
typedef struct boxlist_param {
|
typedef struct boxlist_param{
|
||||||
box_param_t *first; /**< first box pointer of the list*/
|
box_param_t *first; /**< first box pointer of the list*/
|
||||||
box_param_t *last; /**< last box pointer of the list*/
|
box_param_t *last; /**< last box pointer of the list*/
|
||||||
} boxlist_param_t;
|
} boxlist_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ typedef struct boxlist_param {
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated box list
|
* @return pointer to the generated box list
|
||||||
*/
|
*/
|
||||||
boxlist_param_t * gene_boxlist(void);
|
boxlist_param_t * gene_boxlist();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get box structure of JP2 file
|
* get box structure of JP2 file
|
||||||
@@ -66,7 +66,7 @@ boxlist_param_t * gene_boxlist(void);
|
|||||||
* @param[in] length length of the decomposing region
|
* @param[in] length length of the decomposing region
|
||||||
* @return pointer to the generated boxlist
|
* @return pointer to the generated boxlist
|
||||||
*/
|
*/
|
||||||
boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length);
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length)
|
|||||||
* @param[in] offset Box offset
|
* @param[in] offset Box offset
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset);
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,29 +86,29 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset Box offset of the whole stream
|
* @param[in] offset Box offset of the whole stream
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset);
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from JP2 file
|
* generate(search) box from JP2 file
|
||||||
*
|
*
|
||||||
* @param[in] fd file discriptor of the JP2 file
|
* @param[in] fd file discriptor of the JP2 file
|
||||||
* @param[in] offset start Byte position of the search
|
* @param[in] offset start Byte position of the search
|
||||||
* @param[in] length Byte length of the search, if 0, size to the end of file
|
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from code stream
|
* generate(search) box from code stream
|
||||||
*
|
*
|
||||||
* @param[in] stream code stream ( from the first byte)
|
* @param[in] stream code stream ( from the first byte)
|
||||||
* @param[in] offset start Byte position of the search
|
* @param[in] offset start Byte position of the search
|
||||||
* @param[in] length Byte length of the search, if 0, size to the end of file
|
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate child box from JP2 file at the given offset
|
* generate child box from JP2 file at the given offset
|
||||||
@@ -117,7 +117,7 @@ box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE
|
|||||||
* @param[in] offset offset from DBox first byte of superbox
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset);
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from JP2 file
|
* generate(search) box from JP2 file
|
||||||
@@ -127,7 +127,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset);
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, const char TBox[]);
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get DBox offset
|
* get DBox offset
|
||||||
@@ -135,7 +135,7 @@ box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, cons
|
|||||||
* @param[in] box box pointer
|
* @param[in] box box pointer
|
||||||
* @return DBox offset (byte position) in the file
|
* @return DBox offset (byte position) in the file
|
||||||
*/
|
*/
|
||||||
OPJ_OFF_T get_DBoxoff( box_param_t *box);
|
Byte8_t get_DBoxoff( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,7 +144,7 @@ OPJ_OFF_T get_DBoxoff( box_param_t *box);
|
|||||||
* @param[in] box box pointer
|
* @param[in] box box pointer
|
||||||
* @return DBox length ( content length)
|
* @return DBox length ( content length)
|
||||||
*/
|
*/
|
||||||
OPJ_SIZE_T get_DBoxlen( box_param_t *box);
|
Byte8_t get_DBoxlen( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +164,7 @@ Byte_t * fetch_headbytes( box_param_t *box);
|
|||||||
* @param[in] size Byte length
|
* @param[in] size Byte length
|
||||||
* @return pointer to the fetched data
|
* @return pointer to the fetched data
|
||||||
*/
|
*/
|
||||||
Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
||||||
@@ -173,7 +173,7 @@ Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset);
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
||||||
@@ -182,7 +182,7 @@ Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
||||||
@@ -191,7 +191,7 @@ Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
||||||
@@ -200,7 +200,7 @@ Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +242,7 @@ void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
|
|||||||
* @param[in,out] type box type
|
* @param[in,out] type box type
|
||||||
* @param[in] boxlist box list pointer
|
* @param[in] boxlist box list pointer
|
||||||
*/
|
*/
|
||||||
void delete_box_in_list_by_type( const char type[], boxlist_param_t *boxlist);
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: boxheader_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "boxheader_manager.h"
|
#include "boxheader_manager.h"
|
||||||
#include "opj_inttypes.h"
|
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
#include "fcgi_stdio.h"
|
#include "fcgi_stdio.h"
|
||||||
@@ -45,40 +44,40 @@
|
|||||||
#endif /*SERVER*/
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset)
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||||
{
|
{
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen;
|
||||||
Byte_t headlen;
|
Byte_t headlen;
|
||||||
char *boxtype;
|
char *boxtype;
|
||||||
boxheader_param_t *boxheader;
|
boxheader_param_t *boxheader;
|
||||||
|
|
||||||
boxlen = fetch_4bytebigendian( fd, offset);
|
boxlen = fetch_4bytebigendian( fd, offset);
|
||||||
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
|
|
||||||
|
if( boxlen == 1){ /* read XLBox */
|
||||||
|
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||||
|
headlen = 16;
|
||||||
|
}
|
||||||
|
|
||||||
if( boxlen == 1) { /* read XLBox */
|
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
||||||
boxlen = fetch_8bytebigendian( fd, offset+8);
|
boxheader->headlen = headlen;
|
||||||
headlen = 16;
|
boxheader->length = boxlen;
|
||||||
}
|
strncpy( boxheader->type, boxtype, 4);
|
||||||
|
boxheader->next = NULL;
|
||||||
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
|
||||||
boxheader->headlen = headlen;
|
free( boxtype);
|
||||||
boxheader->length = boxlen;
|
return boxheader;
|
||||||
strncpy( boxheader->type, boxtype, 4);
|
|
||||||
boxheader->next = NULL;
|
|
||||||
|
|
||||||
free( boxtype);
|
|
||||||
return boxheader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, OPJ_OFF_T offset)
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset)
|
||||||
{
|
{
|
||||||
return gene_boxheader( superbox->fd, get_DBoxoff(superbox)+offset);
|
return gene_boxheader( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_boxheader( boxheader_param_t *boxheader)
|
void print_boxheader( boxheader_param_t *boxheader)
|
||||||
{
|
{
|
||||||
fprintf( logstream, "boxheader info:\n"
|
fprintf( logstream, "boxheader info:\n"
|
||||||
"\t type: %.4s\n"
|
"\t type: %.4s\n"
|
||||||
"\t length:%" PRId64 " %#" PRIx64 "\n", boxheader->type, boxheader->length, boxheader->length);
|
"\t length:%lld %#llx\n", boxheader->type, boxheader->length, boxheader->length);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: boxheader_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -31,16 +31,15 @@
|
|||||||
#ifndef BOXHEADER_MANAGER_H_
|
#ifndef BOXHEADER_MANAGER_H_
|
||||||
# define BOXHEADER_MANAGER_H_
|
# define BOXHEADER_MANAGER_H_
|
||||||
|
|
||||||
#include "openjpeg.h"
|
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
#include "box_manager.h"
|
#include "box_manager.h"
|
||||||
|
|
||||||
/** box header parameters*/
|
/** box header parameters*/
|
||||||
typedef struct boxheader_param {
|
typedef struct boxheader_param{
|
||||||
Byte_t headlen; /**< header length 8 or 16*/
|
Byte_t headlen; /**< header length 8 or 16*/
|
||||||
Byte8_t length; /**< length of the reference Box*/
|
Byte8_t length; /**< length of the reference Box*/
|
||||||
char type[4]; /**< type of information in the DBox*/
|
char type[4]; /**< type of information in the DBox*/
|
||||||
struct boxheader_param *next; /**< pointer to the next header box*/
|
struct boxheader_param *next; /**< pointer to the next header box*/
|
||||||
} boxheader_param_t;
|
} boxheader_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ typedef struct boxheader_param {
|
|||||||
* @param[in] offset Box offset
|
* @param[in] offset Box offset
|
||||||
* @return pointer to the structure of generate box header parameters
|
* @return pointer to the structure of generate box header parameters
|
||||||
*/
|
*/
|
||||||
boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset);
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a child box header at the given offset
|
* generate a child box header at the given offset
|
||||||
@@ -60,7 +59,7 @@ boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset offset from DBox first byte of superbox
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
* @return pointer to the structure of generate box header parameters
|
* @return pointer to the structure of generate box header parameters
|
||||||
*/
|
*/
|
||||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, OPJ_OFF_T offset);
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print box header parameters
|
* print box header parameters
|
||||||
172
applications/jpip/libopenjpip/byte_manager.c
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* $Id: byte_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "byte_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
|
Byte_t * fetch_bytes( int fd, long offset, int size)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
|
||||||
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (Byte_t *)malloc( size);
|
||||||
|
|
||||||
|
if( read( fd, data, size) != size){
|
||||||
|
free( data);
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t fetch_1byte( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t code;
|
||||||
|
|
||||||
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( read( fd, &code, 1) != 1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte2_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big2(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte4_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big4(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big8(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Byte2_t big2( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t big4( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((((((Byte4_t) buf[0]) << 8) + ((Byte4_t) buf[1])) << 8)
|
||||||
|
+ ((Byte4_t) buf[2])) << 8) + ((Byte4_t) buf[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t big8( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((Byte8_t) big4 (buf)) << 32)
|
||||||
|
+ ((Byte8_t) big4 (buf + 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void modify_4Bytecode( Byte4_t code, Byte_t *stream)
|
||||||
|
{
|
||||||
|
*stream = (Byte_t) ((Byte4_t)(code & 0xff000000) >> 24);
|
||||||
|
*(stream+1) = (Byte_t) ((Byte4_t)(code & 0x00ff0000) >> 16);
|
||||||
|
*(stream+2) = (Byte_t) ((Byte4_t)(code & 0x0000ff00) >> 8);
|
||||||
|
*(stream+3) = (Byte_t) (code & 0x000000ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_filesize( int fd)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if( fstat( fd, &sb) == -1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in get_filesize( %d)\n", fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (Byte8_t)sb.st_size;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: byte_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -31,13 +31,28 @@
|
|||||||
#ifndef BYTE_MANAGER_H_
|
#ifndef BYTE_MANAGER_H_
|
||||||
#define BYTE_MANAGER_H_
|
#define BYTE_MANAGER_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include "opj_config.h"
|
||||||
#include "openjpeg.h"
|
#ifdef HAVE_STDINT_H
|
||||||
#include "opj_stdint.h"
|
#include <stdint.h>
|
||||||
typedef uint8_t Byte_t;
|
typedef uint8_t Byte_t;
|
||||||
typedef uint16_t Byte2_t;
|
typedef uint16_t Byte2_t;
|
||||||
typedef uint32_t Byte4_t;
|
typedef uint32_t Byte4_t;
|
||||||
typedef uint64_t Byte8_t;
|
typedef uint64_t Byte8_t;
|
||||||
|
#else
|
||||||
|
#if defined(_WIN32)
|
||||||
|
/** 1Byte parameter type*/
|
||||||
|
typedef unsigned __int8 Byte_t;
|
||||||
|
/** 2Byte parameter type*/
|
||||||
|
typedef unsigned __int16 Byte2_t;
|
||||||
|
/** 4Byte parameter type*/
|
||||||
|
typedef unsigned __int32 Byte4_t;
|
||||||
|
/** 8Byte parameter type*/
|
||||||
|
typedef unsigned __int64 Byte8_t;
|
||||||
|
#else
|
||||||
|
#error unsupported platform
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch bytes of data in file stream
|
* fetch bytes of data in file stream
|
||||||
@@ -47,7 +62,7 @@ typedef uint64_t Byte8_t;
|
|||||||
* @param[in] size Byte length
|
* @param[in] size Byte length
|
||||||
* @return pointer to the fetched data
|
* @return pointer to the fetched data
|
||||||
*/
|
*/
|
||||||
Byte_t * fetch_bytes( int fd, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
Byte_t * fetch_bytes( int fd, long offset, int size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,7 +72,7 @@ Byte_t * fetch_bytes( int fd, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte_t fetch_1byte( int fd, OPJ_OFF_T offset);
|
Byte_t fetch_1byte( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 2-byte big endian Byte codes in file stream
|
* fetch a 2-byte big endian Byte codes in file stream
|
||||||
@@ -66,7 +81,7 @@ Byte_t fetch_1byte( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte2_t fetch_2bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 4-byte big endian Byte codes in file stream
|
* fetch a 4-byte big endian Byte codes in file stream
|
||||||
@@ -75,7 +90,7 @@ Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte4_t fetch_4bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 8-byte big endian Byte codes in file stream
|
* fetch a 8-byte big endian Byte codes in file stream
|
||||||
@@ -84,7 +99,7 @@ Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte8_t fetch_8bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte8_t fetch_8bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +128,7 @@ Byte8_t big8( Byte_t *buf);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* modify 4Byte code in a codestream
|
* modify 4Byte code in a codestream
|
||||||
*
|
*
|
||||||
* @param[in] code code value
|
* @param[in] code code value
|
||||||
* @param[out] stream modifying codestream
|
* @param[out] stream modifying codestream
|
||||||
*/
|
*/
|
||||||
@@ -125,6 +140,6 @@ void modify_4Bytecode( Byte4_t code, Byte_t *stream);
|
|||||||
* @param[in] fd file discriptor
|
* @param[in] fd file discriptor
|
||||||
* @return file size
|
* @return file size
|
||||||
*/
|
*/
|
||||||
OPJ_OFF_T get_filesize( int fd);
|
Byte8_t get_filesize( int fd);
|
||||||
|
|
||||||
#endif /* !BYTE_MANAGER_H_ */
|
#endif /* !BYTE_MANAGER_H_ */
|
||||||
275
applications/jpip/libopenjpip/cache_manager.c
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
* $Id: cache_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "cache_manager.h"
|
||||||
|
|
||||||
|
cachelist_param_t * gene_cachelist()
|
||||||
|
{
|
||||||
|
cachelist_param_t *cachelist;
|
||||||
|
|
||||||
|
cachelist = (cachelist_param_t *)malloc( sizeof(cachelist_param_t));
|
||||||
|
|
||||||
|
cachelist->first = NULL;
|
||||||
|
cachelist->last = NULL;
|
||||||
|
|
||||||
|
return cachelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachelist(cachelist_param_t **cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *cachePtr, *cacheNext;
|
||||||
|
|
||||||
|
cachePtr = (*cachelist)->first;
|
||||||
|
while( cachePtr != NULL){
|
||||||
|
cacheNext=cachePtr->next;
|
||||||
|
delete_cache( &cachePtr);
|
||||||
|
cachePtr=cacheNext;
|
||||||
|
}
|
||||||
|
free( *cachelist);
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
|
||||||
|
{
|
||||||
|
cache_param_t *cache;
|
||||||
|
|
||||||
|
cache = (cache_param_t *)malloc( sizeof(cache_param_t));
|
||||||
|
cache->filename = strdup( targetname);
|
||||||
|
cache->tid = strdup( tid);
|
||||||
|
cache->csn = csn;
|
||||||
|
cache->cid = (char **)malloc( sizeof(char *));
|
||||||
|
*cache->cid = strdup( cid);
|
||||||
|
cache->numOfcid = 1;
|
||||||
|
#if 1
|
||||||
|
cache->metadatalist = NULL;
|
||||||
|
#else
|
||||||
|
cache->metadatalist = gene_metadatalist();
|
||||||
|
#endif
|
||||||
|
cache->ihdrbox = NULL;
|
||||||
|
cache->next = NULL;
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cache( cache_param_t **cache)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
free( (*cache)->filename);
|
||||||
|
free( (*cache)->tid);
|
||||||
|
|
||||||
|
delete_metadatalist( &(*cache)->metadatalist);
|
||||||
|
|
||||||
|
if((*cache)->ihdrbox)
|
||||||
|
free((*cache)->ihdrbox);
|
||||||
|
for( i=0; i<(*cache)->numOfcid; i++)
|
||||||
|
free( (*cache)->cid[i]);
|
||||||
|
free( (*cache)->cid);
|
||||||
|
free( *cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
if( cachelist->first)
|
||||||
|
cachelist->last->next = cache;
|
||||||
|
else
|
||||||
|
cachelist->first = cache;
|
||||||
|
cachelist->last = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
if( !targetname)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
|
||||||
|
if( strcmp( targetname, foundcache->filename) == 0)
|
||||||
|
return foundcache;
|
||||||
|
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
|
||||||
|
if( csn == foundcache->csn)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if( !cid)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
for( i=0; i<foundcache->numOfcid; i++)
|
||||||
|
if( strcmp( cid, foundcache->cid[i]) == 0)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
if( !tid)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
if( strcmp( tid, foundcache->tid) == 0)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_cachecid( char *cid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
if( !cid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( (cache->cid = realloc( cache->cid, (cache->numOfcid+1)*sizeof(char *))) == NULL){
|
||||||
|
fprintf( stderr, "failed to add new cid to cache table in add_cachecid()\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache->cid[ cache->numOfcid] = strdup( cid);
|
||||||
|
|
||||||
|
cache->numOfcid ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_cachetid( char *tid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
if( !tid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( tid[0] != '0' && strcmp( tid, cache->tid) !=0){
|
||||||
|
fprintf( stderr, "tid is updated to %s for %s\n", tid, cache->filename);
|
||||||
|
free( cache->tid);
|
||||||
|
cache->tid = strdup( tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_cidInCache( char *cid, cache_param_t *cache);
|
||||||
|
|
||||||
|
void remove_cachecid( char *cid, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *cache;
|
||||||
|
|
||||||
|
cache = search_cacheBycid( cid, cachelist);
|
||||||
|
remove_cidInCache( cid, cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_cidInCache( char *cid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
int idx = -1;
|
||||||
|
char **tmp;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for( i=0; i<cache->numOfcid; i++)
|
||||||
|
if( strcmp( cid, cache->cid[i]) == 0){
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( idx == -1){
|
||||||
|
fprintf( stderr, "cid: %s not found\n", cid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = cache->cid;
|
||||||
|
|
||||||
|
cache->cid = (char **)malloc( (cache->numOfcid-1)*sizeof(char *));
|
||||||
|
|
||||||
|
for( i=0, j=0; i<cache->numOfcid; i++){
|
||||||
|
if( i != idx){
|
||||||
|
cache->cid[j] = strdup( tmp[i]);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
free( tmp[i]);
|
||||||
|
}
|
||||||
|
free( tmp);
|
||||||
|
|
||||||
|
cache->numOfcid --;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_cache( cache_param_t *cache)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
fprintf( stdout,"cache\n");
|
||||||
|
fprintf( stdout,"\t filename: %s\n", cache->filename);
|
||||||
|
fprintf( stdout,"\t tid: %s\n", cache->tid);
|
||||||
|
fprintf( stdout,"\t csn: %d\n", cache->csn);
|
||||||
|
fprintf( stdout,"\t cid:");
|
||||||
|
|
||||||
|
for( i=0; i<cache->numOfcid; i++)
|
||||||
|
fprintf( stdout," %s", cache->cid[i]);
|
||||||
|
fprintf( stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allcache( cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *ptr;
|
||||||
|
|
||||||
|
fprintf( stdout,"cache list\n");
|
||||||
|
|
||||||
|
ptr = cachelist->first;
|
||||||
|
while( ptr != NULL){
|
||||||
|
print_cache( ptr);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: cache_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -35,21 +35,21 @@
|
|||||||
#include "ihdrbox_manager.h"
|
#include "ihdrbox_manager.h"
|
||||||
|
|
||||||
/** cache parameters*/
|
/** cache parameters*/
|
||||||
typedef struct cache_param {
|
typedef struct cache_param{
|
||||||
char *filename; /**< file name*/
|
char *filename; /**< file name*/
|
||||||
char *tid; /**< taregt identifier*/
|
char *tid; /**< taregt identifier*/
|
||||||
int csn; /**< codestream number*/
|
int csn; /**< codestream number*/
|
||||||
char **cid; /**< dynamic array of channel identifiers*/
|
char **cid; /**< dynamic array of channel identifiers*/
|
||||||
int numOfcid; /**< number of cids*/
|
int numOfcid; /**< number of cids*/
|
||||||
metadatalist_param_t *metadatalist; /**< metadata-bin list*/
|
metadatalist_param_t *metadatalist; /**< metadata-bin list*/
|
||||||
ihdrbox_param_t *ihdrbox; /**< ihdrbox*/
|
ihdrbox_param_t *ihdrbox; /**< ihdrbox*/
|
||||||
struct cache_param *next; /**< pointer to the next cache*/
|
struct cache_param *next; /**< pointer to the next cache*/
|
||||||
} cache_param_t;
|
} cache_param_t;
|
||||||
|
|
||||||
/**< cache list parameters*/
|
/**< cache list parameters*/
|
||||||
typedef struct cachelist_param {
|
typedef struct cachelist_param{
|
||||||
cache_param_t *first; /**< first cache pointer of the list*/
|
cache_param_t *first; /**< first cache pointer of the list*/
|
||||||
cache_param_t *last; /**< last cache pointer of the list*/
|
cache_param_t *last; /**< last cache pointer of the list*/
|
||||||
} cachelist_param_t;
|
} cachelist_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ typedef struct cachelist_param {
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated cache list
|
* @return pointer to the generated cache list
|
||||||
*/
|
*/
|
||||||
cachelist_param_t * gene_cachelist(void);
|
cachelist_param_t * gene_cachelist();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete cache list
|
* delete cache list
|
||||||
@@ -76,7 +76,7 @@ void delete_cachelist(cachelist_param_t **cachelist);
|
|||||||
* @param[in] cid channel identifier
|
* @param[in] cid channel identifier
|
||||||
* @return pointer to the generated cache
|
* @return pointer to the generated cache
|
||||||
*/
|
*/
|
||||||
cache_param_t * gene_cache( const char *targetname, int csn, char *tid, char *cid);
|
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete a cache
|
* delete a cache
|
||||||
@@ -101,7 +101,7 @@ void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist)
|
|||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
* @return found cache pointer
|
* @return found cache pointer
|
||||||
*/
|
*/
|
||||||
cache_param_t * search_cache( const char targetname[], cachelist_param_t *cachelist);
|
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +121,7 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
|
|||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
* @return found cache pointer
|
* @return found cache pointer
|
||||||
*/
|
*/
|
||||||
cache_param_t * search_cacheBycid( const char cid[], cachelist_param_t *cachelist);
|
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +131,7 @@ cache_param_t * search_cacheBycid( const char cid[], cachelist_param_t *cachelis
|
|||||||
* @param[in] cachelist cache list pointer
|
* @param[in] cachelist cache list pointer
|
||||||
* @return found cache pointer
|
* @return found cache pointer
|
||||||
*/
|
*/
|
||||||
cache_param_t * search_cacheBytid( const char tid[], cachelist_param_t *cachelist);
|
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add cid into a cache
|
* add cid into a cache
|
||||||
@@ -139,7 +139,7 @@ cache_param_t * search_cacheBytid( const char tid[], cachelist_param_t *cachelis
|
|||||||
* @param[in] cid channel identifier
|
* @param[in] cid channel identifier
|
||||||
* @param[in] cache cache pointer
|
* @param[in] cache cache pointer
|
||||||
*/
|
*/
|
||||||
void add_cachecid( const char *cid, cache_param_t *cache);
|
void add_cachecid( char *cid, cache_param_t *cache);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +148,7 @@ void add_cachecid( const char *cid, cache_param_t *cache);
|
|||||||
* @param[in] tid target identifier
|
* @param[in] tid target identifier
|
||||||
* @param[in] cache cache pointer
|
* @param[in] cache cache pointer
|
||||||
*/
|
*/
|
||||||
void update_cachetid( const char *tid, cache_param_t *cache);
|
void update_cachetid( char *tid, cache_param_t *cache);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +157,7 @@ void update_cachetid( const char *tid, cache_param_t *cache);
|
|||||||
* @param[in] cid channel identifier
|
* @param[in] cid channel identifier
|
||||||
* @param[in] cachelist cachelist pointer
|
* @param[in] cachelist cachelist pointer
|
||||||
*/
|
*/
|
||||||
void remove_cachecid( const char *cid, cachelist_param_t *cachelist);
|
void remove_cachecid( char *cid, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
235
applications/jpip/libopenjpip/cachemodel_manager.c
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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 <stdlib.h>
|
||||||
|
#include "cachemodel_manager.h"
|
||||||
|
#include "faixbox_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
|
cachemodellist_param_t * gene_cachemodellist(void)
|
||||||
|
{
|
||||||
|
cachemodellist_param_t *cachemodellist;
|
||||||
|
|
||||||
|
cachemodellist = (cachemodellist_param_t *)malloc( sizeof(cachemodellist_param_t));
|
||||||
|
|
||||||
|
cachemodellist->first = NULL;
|
||||||
|
cachemodellist->last = NULL;
|
||||||
|
|
||||||
|
return cachemodellist;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
|
faixbox_param_t *tilepart;
|
||||||
|
faixbox_param_t *precpacket;
|
||||||
|
size_t numOfelem;
|
||||||
|
Byte8_t numOftiles;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
|
||||||
|
|
||||||
|
refer_target( target, &cachemodel->target);
|
||||||
|
|
||||||
|
if( reqJPP){
|
||||||
|
if( target->jppstream)
|
||||||
|
cachemodel->jppstream = true;
|
||||||
|
else
|
||||||
|
cachemodel->jppstream = false;
|
||||||
|
} else{ /* reqJPT */
|
||||||
|
if( target->jptstream)
|
||||||
|
cachemodel->jppstream = false;
|
||||||
|
else
|
||||||
|
cachemodel->jppstream = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel->mhead_model = false;
|
||||||
|
|
||||||
|
tilepart = target->codeidx->tilepart;
|
||||||
|
numOftiles = get_m( tilepart);
|
||||||
|
numOfelem = get_nmax( tilepart)*numOftiles;
|
||||||
|
cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
|
||||||
|
cachemodel->th_model = (bool *)calloc( 1, numOftiles*sizeof(bool));
|
||||||
|
cachemodel->pp_model = (bool **)malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
|
||||||
|
for( i=0; i<target->codeidx->SIZ.Csiz; i++){
|
||||||
|
precpacket = target->codeidx->precpacket[i];
|
||||||
|
cachemodel->pp_model[i] = (bool *)calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
|
||||||
|
}
|
||||||
|
cachemodel->next = NULL;
|
||||||
|
|
||||||
|
if( cachemodellist){
|
||||||
|
if( cachemodellist->first) /* there are one or more entries */
|
||||||
|
cachemodellist->last->next = cachemodel;
|
||||||
|
else /* first entry */
|
||||||
|
cachemodellist->first = cachemodel;
|
||||||
|
cachemodellist->last = cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel generated\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||||
|
{
|
||||||
|
target_param_t *target;
|
||||||
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: Is this large enough ? */
|
||||||
|
|
||||||
|
target = cachemodel.target;
|
||||||
|
|
||||||
|
fprintf( logstream, "target: %s\n", target->targetname);
|
||||||
|
fprintf( logstream, "\t main header model: %d\n", cachemodel.mhead_model);
|
||||||
|
|
||||||
|
fprintf( logstream, "\t tile part model:\n");
|
||||||
|
TPnum = get_nmax( target->codeidx->tilepart);
|
||||||
|
|
||||||
|
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++){
|
||||||
|
for( j=0; j<target->codeidx->SIZ.XTnum; j++){
|
||||||
|
for( k=0; k<TPnum; k++)
|
||||||
|
fprintf( logstream, "%d", cachemodel.tp_model[n++]);
|
||||||
|
fprintf( logstream, " ");
|
||||||
|
}
|
||||||
|
fprintf( logstream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||||
|
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||||
|
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
|
||||||
|
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||||
|
fprintf( logstream, "\t compo.%llud: ", j);
|
||||||
|
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||||
|
for( k=0; k<Pmax; k++)
|
||||||
|
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||||
|
fprintf( logstream, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = cachemodellist->first;
|
||||||
|
|
||||||
|
while( foundcachemodel != NULL){
|
||||||
|
|
||||||
|
if( foundcachemodel->target == target)
|
||||||
|
return foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = foundcachemodel->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodellist( cachemodellist_param_t **cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodelPtr, *cachemodelNext;
|
||||||
|
|
||||||
|
cachemodelPtr = (*cachemodellist)->first;
|
||||||
|
while( cachemodelPtr != NULL){
|
||||||
|
cachemodelNext=cachemodelPtr->next;
|
||||||
|
delete_cachemodel( &cachemodelPtr);
|
||||||
|
cachemodelPtr=cachemodelNext;
|
||||||
|
}
|
||||||
|
free(*cachemodellist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
unrefer_target( (*cachemodel)->target);
|
||||||
|
|
||||||
|
free( (*cachemodel)->tp_model);
|
||||||
|
free( (*cachemodel)->th_model);
|
||||||
|
|
||||||
|
for( i=0; i<(*cachemodel)->target->codeidx->SIZ.Csiz; i++)
|
||||||
|
free( (*cachemodel)->pp_model[i]);
|
||||||
|
free( (*cachemodel)->pp_model);
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel deleted\n");
|
||||||
|
#endif
|
||||||
|
free( *cachemodel);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_allsent( cachemodel_param_t cachemodel)
|
||||||
|
{
|
||||||
|
target_param_t *target;
|
||||||
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: is this large enough ? */
|
||||||
|
|
||||||
|
target = cachemodel.target;
|
||||||
|
|
||||||
|
if( !cachemodel.mhead_model)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TPnum = get_nmax( target->codeidx->tilepart);
|
||||||
|
|
||||||
|
if( cachemodel.jppstream){
|
||||||
|
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||||
|
if( !cachemodel.th_model[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||||
|
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||||
|
for( k=0; k<Pmax; k++)
|
||||||
|
if( !cachemodel.pp_model[j][i*Pmax+k])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
|
||||||
|
for( j=0; j<target->codeidx->SIZ.XTnum; j++)
|
||||||
|
for( k=0; k<TPnum; k++)
|
||||||
|
if( !cachemodel.tp_model[n++])
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -31,23 +31,24 @@
|
|||||||
#ifndef CACHEMODEL_MANAGER_H_
|
#ifndef CACHEMODEL_MANAGER_H_
|
||||||
# define CACHEMODEL_MANAGER_H_
|
# define CACHEMODEL_MANAGER_H_
|
||||||
|
|
||||||
|
#include "bool.h"
|
||||||
#include "target_manager.h"
|
#include "target_manager.h"
|
||||||
|
|
||||||
/** Cache model parameters*/
|
/** Cache model parameters*/
|
||||||
typedef struct cachemodel_param {
|
typedef struct cachemodel_param{
|
||||||
target_param_t *target; /**< reference pointer to the target*/
|
target_param_t *target; /**< reference pointer to the target*/
|
||||||
OPJ_BOOL jppstream; /**< return type, true: JPP-stream, false: JPT-stream*/
|
bool jppstream; /**< return type, true: JPP-stream, false: JPT-stream*/
|
||||||
OPJ_BOOL mhead_model; /**< main header model, if sent, 1, else 0*/
|
bool mhead_model; /**< main header model, if sent, 1, else 0*/
|
||||||
OPJ_BOOL *tp_model; /**< dynamic array pointer of tile part model, if sent, 1, else 0*/
|
bool *tp_model; /**< dynamic array pointer of tile part model, if sent, 1, else 0*/
|
||||||
OPJ_BOOL *th_model; /**< dynamic array pointer of tile header model*/
|
bool *th_model; /**< dynamic array pointer of tile header model*/
|
||||||
OPJ_BOOL **pp_model; /**< dynamic array pointer of precint packet model*/
|
bool **pp_model; /**< dynamic array pointer of precint packet model*/
|
||||||
struct cachemodel_param *next; /**< pointer to the next cache model*/
|
struct cachemodel_param *next; /**< pointer to the next cache model*/
|
||||||
} cachemodel_param_t;
|
} cachemodel_param_t;
|
||||||
|
|
||||||
/** Cache model list parameters*/
|
/** Cache model list parameters*/
|
||||||
typedef struct cachemodellist_param {
|
typedef struct cachemodellist_param{
|
||||||
cachemodel_param_t *first; /**< first cache model pointer of the list*/
|
cachemodel_param_t *first; /**< first cache model pointer of the list*/
|
||||||
cachemodel_param_t *last; /**< last cache model pointer of the list*/
|
cachemodel_param_t *last; /**< last cache model pointer of the list*/
|
||||||
} cachemodellist_param_t;
|
} cachemodellist_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ cachemodellist_param_t * gene_cachemodellist(void);
|
|||||||
* @param[in] reqJPP if JPP-stream is desired true, JPT-stream false
|
* @param[in] reqJPP if JPP-stream is desired true, JPT-stream false
|
||||||
* @return pointer to the generated cache model
|
* @return pointer to the generated cache model
|
||||||
*/
|
*/
|
||||||
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, OPJ_BOOL reqJPP);
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +81,7 @@ void print_cachemodel( cachemodel_param_t cachemodel);
|
|||||||
/**
|
/**
|
||||||
* search a cache model of a target
|
* search a cache model of a target
|
||||||
*
|
*
|
||||||
* @param[in] target referring target
|
* @param[in] target refering target
|
||||||
* @param[in] cachemodellist cache model list
|
* @param[in] cachemodellist cache model list
|
||||||
* @return found cache model pointer
|
* @return found cache model pointer
|
||||||
*/
|
*/
|
||||||
@@ -93,7 +94,7 @@ cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_p
|
|||||||
* @param[in] cachemodel cache model
|
* @param[in] cachemodel cache model
|
||||||
* @return true if sent all, false otherwise
|
* @return true if sent all, false otherwise
|
||||||
*/
|
*/
|
||||||
OPJ_BOOL is_allsent( cachemodel_param_t cachemodel);
|
bool is_allsent( cachemodel_param_t cachemodel);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
180
applications/jpip/libopenjpip/channel_manager.c
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* $Id: channel_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, 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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "channel_manager.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define snprintf _snprintf /* Visual Studio */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
channellist_param_t * gene_channellist(void)
|
||||||
|
{
|
||||||
|
channellist_param_t *channellist;
|
||||||
|
|
||||||
|
channellist = (channellist_param_t *)malloc( sizeof(channellist_param_t));
|
||||||
|
|
||||||
|
channellist->first = NULL;
|
||||||
|
channellist->last = NULL;
|
||||||
|
|
||||||
|
return channellist;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *channel;
|
||||||
|
char transport[4][10] = { "non", "http", "http-tcp", "http-udp"};
|
||||||
|
|
||||||
|
if( !cachemodel){
|
||||||
|
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||||
|
channel->cachemodel = cachemodel;
|
||||||
|
|
||||||
|
/* set channel ID and get present time */
|
||||||
|
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||||
|
|
||||||
|
channel->aux = query_param.cnew;
|
||||||
|
|
||||||
|
/* only tcp implemented for now */
|
||||||
|
if( channel->aux == udp)
|
||||||
|
channel->aux = tcp;
|
||||||
|
|
||||||
|
channel->next=NULL;
|
||||||
|
|
||||||
|
set_channel_variable_param( query_param, channel);
|
||||||
|
|
||||||
|
if( channellist->first != NULL)
|
||||||
|
channellist->last->next = channel;
|
||||||
|
else
|
||||||
|
channellist->first = channel;
|
||||||
|
channellist->last = channel;
|
||||||
|
|
||||||
|
fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid);
|
||||||
|
fprintf( FCGI_stdout, ",transport=%s", transport[channel->aux]);
|
||||||
|
|
||||||
|
if( channel->aux == tcp || channel->aux == udp)
|
||||||
|
fprintf( FCGI_stdout, ",auxport=%d", channel->aux==tcp ? auxtrans.tcpauxport : auxtrans.udpauxport);
|
||||||
|
|
||||||
|
fprintf( FCGI_stdout, "\r\n");
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||||
|
{
|
||||||
|
/* set roi information */
|
||||||
|
(void)query_param;
|
||||||
|
(void)channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void delete_channel( channel_param_t **channel, channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *ptr;
|
||||||
|
|
||||||
|
if( *channel == channellist->first)
|
||||||
|
channellist->first = (*channel)->next;
|
||||||
|
else{
|
||||||
|
ptr = channellist->first;
|
||||||
|
while( ptr->next != *channel){
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->next = (*channel)->next;
|
||||||
|
|
||||||
|
if( *channel == channellist->last)
|
||||||
|
channellist->last = ptr;
|
||||||
|
}
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: channel: %s deleted\n", (*channel)->cid);
|
||||||
|
#endif
|
||||||
|
free(*channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_channellist( channellist_param_t **channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *channelPtr, *channelNext;
|
||||||
|
|
||||||
|
channelPtr = (*channellist)->first;
|
||||||
|
while( channelPtr != NULL){
|
||||||
|
channelNext=channelPtr->next;
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: channel %s deleted!\n", channelPtr->cid);
|
||||||
|
#endif
|
||||||
|
free(channelPtr);
|
||||||
|
channelPtr=channelNext;
|
||||||
|
}
|
||||||
|
free( *channellist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allchannel( channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *ptr;
|
||||||
|
|
||||||
|
ptr = channellist->first;
|
||||||
|
while( ptr != NULL){
|
||||||
|
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->cachemodel->target->targetname);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_param_t * search_channel( char cid[], channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *foundchannel;
|
||||||
|
|
||||||
|
foundchannel = channellist->first;
|
||||||
|
|
||||||
|
while( foundchannel != NULL){
|
||||||
|
|
||||||
|
if( strcmp( cid, foundchannel->cid) == 0)
|
||||||
|
return foundchannel;
|
||||||
|
|
||||||
|
foundchannel = foundchannel->next;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stdout, "Status: 503\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: Channel %s not found in this session\r\n", cid);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: channel_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -40,20 +40,20 @@
|
|||||||
#define MAX_LENOFCID 30
|
#define MAX_LENOFCID 30
|
||||||
|
|
||||||
/** Channel parameters*/
|
/** Channel parameters*/
|
||||||
typedef struct channel_param {
|
typedef struct channel_param{
|
||||||
cachemodel_param_t *cachemodel; /**< reference pointer to the cache model*/
|
cachemodel_param_t *cachemodel; /**< reference pointer to the cache model*/
|
||||||
char cid[MAX_LENOFCID]; /**< channel identifier*/
|
char cid[MAX_LENOFCID]; /**< channel identifier*/
|
||||||
cnew_transport_t aux; /**< auxiliary transport*/
|
cnew_transport_t aux; /**< auxiliary transport*/
|
||||||
/* - a record of the client's capabilities and preferences to the extent that the server queues requests*/
|
/* - a record of the client's capabilities and preferences to the extent that the server queues requests*/
|
||||||
time_t start_tm; /**< starting time*/
|
time_t start_tm; /**< starting time*/
|
||||||
struct channel_param *next; /**< pointer to the next channel*/
|
struct channel_param *next; /**< pointer to the next channel*/
|
||||||
} channel_param_t;
|
} channel_param_t;
|
||||||
|
|
||||||
|
|
||||||
/** Channel list parameters*/
|
/** Channel list parameters*/
|
||||||
typedef struct channellist_param {
|
typedef struct channellist_param{
|
||||||
channel_param_t *first; /**< first channel pointer of the list*/
|
channel_param_t *first; /**< first channel pointer of the list*/
|
||||||
channel_param_t *last; /**< last channel pointer of the list*/
|
channel_param_t *last; /**< last channel pointer of the list*/
|
||||||
} channellist_param_t;
|
} channellist_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -116,5 +116,5 @@ void print_allchannel( channellist_param_t *channellist);
|
|||||||
* @param[in] channellist channel list pointer
|
* @param[in] channellist channel list pointer
|
||||||
* @return found channel pointer
|
* @return found channel pointer
|
||||||
*/
|
*/
|
||||||
channel_param_t * search_channel( const char cid[], channellist_param_t *channellist);
|
channel_param_t * search_channel( char cid[], channellist_param_t *channellist);
|
||||||
#endif /* !CHANNEL_MANAGER_H_ */
|
#endif /* !CHANNEL_MANAGER_H_ */
|
||||||