Compare commits

...

154 Commits

Author SHA1 Message Date
Antonin Descampe
7d97b181d3 update OpenJPEGCPack.cmake with correct package names 2012-02-07 22:10:09 +00:00
Antonin Descampe
d9b74ea6a8 [tag1.5] add CHANGES to the 1.5 tagged version 2012-02-07 10:45:12 +00:00
Antonin Descampe
166b42eb54 New tag for openjpeg-1.5 release 2012-02-07 10:37:49 +00:00
Antonin Descampe
948dfd50c0 [1.5] delete CHANGES file as it will now be automatically generated when releasing the code 2012-02-07 10:34:38 +00:00
Antonin Descampe
46da9f2294 [1.5] revert build documentation behaviour in cmake 2012-02-07 08:08:58 +00:00
Antonin Descampe
995b145f09 [1.5] fixes documentation generation with doxygen 2012-02-06 22:51:07 +00:00
Mathieu Malaterre
451a41064e Make opj 1.5 use port 50000, which is not compatible with trunk. But compatible with itself. 2012-02-06 15:32:59 +00:00
Mathieu Malaterre
c6b02b10fe Re-build the jar files from the source code. 2012-02-06 15:00:04 +00:00
Mathieu Malaterre
36b66a8796 For some reason rev 1103 change the default port number, which breaks openjpip documentation. Revert back to port 5000 2012-02-06 14:11:01 +00:00
Mathieu Malaterre
f1e441596e Fix doc generation 2012-02-06 09:50:16 +00:00
Antonin Descampe
d5fa5605c4 [1.5] update version in configure.ac and NEWS, README, LICENSE files 2012-02-06 09:38:59 +00:00
Mathieu Malaterre
427b2427d4 revert (svn merge -c -1368 ). It does break compilation on windows 2012-02-01 21:45:12 +00:00
Vincent Torri
09522e65af revert commit 1357, it could break linkage 2012-01-31 18:10:20 +00:00
Mathieu Malaterre
19cfaac52e c-string are not writable 2012-01-30 10:33:07 +00:00
Mathieu Malaterre
21c38214ef Fix doc target in cmake 2012-01-30 10:20:22 +00:00
Mathieu Malaterre
577fdbc8a5 Fix for strncasecmp 2012-01-30 09:56:56 +00:00
Mathieu Malaterre
f93aed8031 Fix compilation with close and such 2012-01-30 09:55:05 +00:00
Mathieu Malaterre
326c58b4e1 Remove unistd.h from win32 compilation 2012-01-30 09:51:32 +00:00
Mathieu Malaterre
ec0c69af7a Another fix for snprintf 2012-01-30 09:48:48 +00:00
Mathieu Malaterre
21509a3955 isblank is C99, not isspace 2012-01-30 09:46:36 +00:00
Mathieu Malaterre
5b2ca9caf6 isblank is C99, not isspace 2012-01-30 09:43:10 +00:00
Mathieu Malaterre
529006f136 strncasecmp is C99 2012-01-30 09:37:39 +00:00
Mathieu Malaterre
7d96e7c1c0 declarations after statement (C90) 2012-01-30 09:34:48 +00:00
Mathieu Malaterre
e2948acd92 As explained in the documentation cant be included multiple times. 2012-01-30 09:32:32 +00:00
Mathieu Malaterre
6dc8635e28 Fix snprintf for M$ compilers 2012-01-30 09:29:48 +00:00
Mathieu Malaterre
7d0a419c87 fix declarations 2012-01-30 09:27:35 +00:00
Mathieu Malaterre
0ea0e8b915 declarations after statement (C90) 2012-01-30 09:22:25 +00:00
Mathieu Malaterre
8e53bad7fb Another pass at getting this code to compile on windows 2012-01-30 09:17:57 +00:00
Mathieu Malaterre
9c51a37dbf track all declarations after statement for C90 compilers (VS2005) 2012-01-30 09:08:45 +00:00
Mathieu Malaterre
aa00142949 Fix compilation of C code. Remove warnings. 2012-01-30 08:57:26 +00:00
Mathieu Malaterre
87b05f2885 Fix a couple of warnings 2012-01-30 08:54:42 +00:00
Mathieu Malaterre
baf01b98fd trying to track issue with msgqueue_manager on win32. Use C-style comments 2012-01-30 08:44:05 +00:00
Mathieu Malaterre
6dd7da0e05 Remove unistd.h include 2012-01-30 08:22:24 +00:00
Mathieu Malaterre
4949b593be Remove include of unistd.h. non-existant on win32 2012-01-30 08:17:43 +00:00
Mathieu Malaterre
0ed7aa7c1b missing ws2_32 linking 2012-01-28 15:32:28 +00:00
Vincent Torri
02b906f6ad [1.5] Add zlib check when checking libpng 2012-01-28 10:46:42 +00:00
Vincent Torri
6a03e3a438 [1.5] missing change in a previous commit, no need for an entry in CHANGES 2012-01-27 17:55:06 +00:00
Antonin Descampe
ec33653961 [1.5] fix configure.ac to comply with recent change of PThread dependency 2012-01-26 16:02:08 +00:00
Antonin Descampe
133426ddfe [1.5] remove pthread dependency from jpip client utilities 2012-01-26 15:02:58 +00:00
Vincent Torri
aab317eb8c fix libopenjpip link on Windows 2012-01-25 20:56:07 +00:00
Vincent Torri
f3f86e1eb7 follow latest JPIP changes in the autotools side (pthread dependency, conditional compilation of JPIP server and client) 2012-01-25 19:52:18 +00:00
Antonin Descampe
040c9a68b6 [1.5] remove pthread dependency in JPIP client and tweak thirdparty stuff 2012-01-25 16:30:03 +00:00
Mathieu Malaterre
2b746a71cb Refactor code to split jpip client code from server side. 2012-01-25 09:42:00 +00:00
Antonin Descampe
ba01e855a3 [1.5] fix issue #104 2012-01-23 08:22:23 +00:00
Mathieu Malaterre
d3c1a49246 Remove icns, not required for cpack PackageManager. 2012-01-20 16:14:06 +00:00
Mathieu Malaterre
85bbc6def8 Make r1330 more robust. Display more info. 2012-01-20 14:48:07 +00:00
Mathieu Malaterre
5bd5d894eb Fix: MSVR-11-117 - Vulnerability Report. 2012-01-20 14:43:49 +00:00
Mathieu Malaterre
452403d393 Build conditionally the java binding 2012-01-20 14:08:59 +00:00
Mathieu Malaterre
fc268dff90 remove warnings about const string 2012-01-20 11:20:51 +00:00
Mathieu Malaterre
180dd26df1 Prefer share location over lib one. 2012-01-20 11:05:11 +00:00
Mathieu Malaterre
d27bc19d71 Remove warnings related to 3rd party lib 2012-01-20 10:59:10 +00:00
Mathieu Malaterre
b7b72bbf97 BUG: 4 Apply patch from stefan. 2012-01-11 19:14:50 +00:00
Mathieu Malaterre
e1340fe087 BUG: 26 Fix issue with memory consumption. 2012-01-11 19:03:22 +00:00
Mathieu Malaterre
32e80bc4a7 Fixing the PackageMaker generator 2012-01-11 16:18:26 +00:00
Mathieu Malaterre
8d18c77a7d Add the fno-common flag to work around an issue with ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option 2012-01-11 13:54:11 +00:00
Mathieu Malaterre
f492f0a3d6 Redo the BUILD_THIRDPARTY properly. Remove openjpeg.h symlink. 2012-01-11 13:17:15 +00:00
Mathieu Malaterre
6b43ba091e Fix full path to icns file 2012-01-11 12:46:23 +00:00
Antonin Descampe
5dfadb2eb1 add opj_logo.icns for trunk and 1.5 2012-01-11 12:19:18 +00:00
Mathieu Malaterre
30944454de Add missing plist file 2012-01-11 11:38:39 +00:00
Mathieu Malaterre
0e7529c272 Start playing with bundle generator 2012-01-11 10:18:07 +00:00
Mathieu Malaterre
c9986d1b78 Adding explicitely the new test 2012-01-11 09:04:44 +00:00
Vincent Torri
4bc00a40ca ignore++ 2012-01-01 09:08:01 +00:00
Mathieu Malaterre
80f69364b0 Fix for static libs 2011-12-28 20:10:44 +00:00
Mathieu Malaterre
2e3900780d Install lib in /lib and dll in /bin 2011-12-28 20:09:14 +00:00
Mathieu Malaterre
d530d35024 Do not warn for VCExpress build 2011-12-28 18:07:22 +00:00
Mathieu Malaterre
e96f7a5f50 Remove proprietary stuff from Sun. 2011-12-28 14:43:41 +00:00
Mathieu Malaterre
79ce6ccce5 remove symbolink links 2011-12-28 14:41:41 +00:00
Mathieu Malaterre
b7e489c901 Remove binary jar from source dist. 2011-12-28 14:37:03 +00:00
Mathieu Malaterre
dbd60c1469 Add a dummy test for JPIP 2011-12-27 18:00:04 +00:00
Kaori Hagihara
007409e2af [1.5][JPIP] additional modification for the warning 2011-12-24 13:21:25 +00:00
Mathieu Malaterre
b82b6cbd05 Apply another patch from Kaori, about return value from write/fwrite. Thanks 2011-12-23 08:30:36 +00:00
Mathieu Malaterre
f26b96dd5c Apply patch from Kaori. Thanks. 2011-12-23 08:29:09 +00:00
Mathieu Malaterre
7e6c287d78 Another round of universal fixes 2011-12-21 15:21:53 +00:00
Mathieu Malaterre
6b1e9d1b4e Attempt to fix building of universal exe 2011-12-21 15:19:46 +00:00
Mathieu Malaterre
d88dfc3472 Need to include this file back 2011-12-21 14:46:37 +00:00
Mathieu Malaterre
64f08e216b Remove old module which does not support universal binary 2011-12-21 14:43:16 +00:00
Mathieu Malaterre
c9ae2a5fbc hopefully fix a warning on VS2008 compiler 2011-12-21 10:24:59 +00:00
Mathieu Malaterre
51ae8b7926 minor doc tweak 2011-12-21 10:19:36 +00:00
Mathieu Malaterre
3280dc344f Make sure to append the compile def 2011-12-21 09:53:08 +00:00
Mathieu Malaterre
0b7e0166a7 pc files are for UNIX. 2011-12-21 09:33:51 +00:00
Mathieu Malaterre
5fe8eed4da Remove old visual studio files 2011-12-21 09:30:55 +00:00
Mathieu Malaterre
9d4d3b2cd0 Remove exe bit 2011-12-20 18:38:08 +00:00
Mathieu Malaterre
02d9f43802 Reactivate the opjviewer in cmake 2011-12-20 18:33:45 +00:00
Mathieu Malaterre
00b479cb79 Fix test NR-ENC-Bretagne2.ppm-4-encode on linux. 2011-12-20 17:49:12 +00:00
Mathieu Malaterre
6219ad32b0 Import patch from winfried on mailing list: patch for mj2.c in branch 2011-12-20 17:14:55 +00:00
Mathieu Malaterre
a3a161660a Fix strange line, as reported by lockalsash (gmail.com) 2011-12-20 17:10:30 +00:00
Mathieu Malaterre
2643f79069 Another set of change to remove warnings about c style comments 2011-12-16 11:26:26 +00:00
Mathieu Malaterre
fba8f701c4 Import change from trunk to be able to generate dists. 2011-12-16 11:00:30 +00:00
Mathieu Malaterre
4bcd3a1e42 Fix a warning on MacOSX 2011-12-16 10:44:53 +00:00
Mathieu Malaterre
594148ae83 Hide a warning. Since 1.5 is not large file safe (>32bits) this should be ok 2011-12-16 10:43:10 +00:00
Mathieu Malaterre
2a2f169b27 Remove warning about unused args 2011-12-16 10:40:14 +00:00
Mathieu Malaterre
e576aa9f06 Reorder static inline when extension is found (GNU) 2011-12-16 10:38:18 +00:00
Mathieu Malaterre
c469e1339f Remove some simple warnings about comments 2011-12-16 10:29:30 +00:00
Mathieu Malaterre
abf9809c22 Remove warning about GNU void* extension 2011-12-16 10:18:12 +00:00
Mathieu Malaterre
3ebdd674d8 Fix warning about no newline at end of file 2011-12-16 10:05:06 +00:00
Mathieu Malaterre
a13abdaf65 Sync with trunk 2011-12-12 09:42:44 +00:00
Mathieu Malaterre
72867bc692 Fix a bunch of warnings reported by gcc (unused results from fwrite) 2011-12-12 08:55:44 +00:00
Mathieu Malaterre
b081ff2813 Missing part of import of rev 1148. 2011-12-09 09:22:27 +00:00
Mathieu Malaterre
9d1bd03be4 Import rev 1148 from trunk. 2011-12-08 11:06:53 +00:00
Mathieu Malaterre
82e539d333 Remove more warnings 2011-12-08 09:25:25 +00:00
Mathieu Malaterre
548a49bb7f Remove warnings seen on the dashboard 2011-12-08 09:09:59 +00:00
Mickael Savinaud
dc9a8b03aa [1.5] deactivate tests about class0 files with number of components greater to 1 2011-12-07 08:59:35 +00:00
Kaori Hagihara
c6e0b71633 [1.5][JPIP] TCP return (http-tcp) implemented 2011-11-30 14:54:41 +00:00
Vincent Torri
0c350f4908 fix compilation of libopenjpip (libcurl dependency) with CMake. Credit to Winfried. 2011-11-19 07:16:14 +00:00
Kaori Hagihara
01749cb8a2 [1.5][JPIP] fixed opj_server execusion error (instant terminating) with autotool, cmake still need to be fixed 2011-11-16 20:03:09 +00:00
Vincent Torri
49f1a5ff54 [1.5] libcurl dep, fix 'distcheck' rule. 2011-11-16 19:20:50 +00:00
Kaori Hagihara
ff1f022d47 [1.5][JPIP] new feature to target JP2 files from www (libcurl required) 2011-11-16 16:54:53 +00:00
Kaori Hagihara
3459199eba [1.5][JPIP] added get_filesize() 2011-11-16 16:13:11 +00:00
Kaori Hagihara
544e8c9de0 [1.5][JPIP] fixed Region of Interest option, and memory leak of opj_dec_server 2011-11-16 15:43:01 +00:00
Kaori Hagihara
735b40989d [1.5][JPIP] backport r1042 to branch 1.5 2011-11-08 10:21:24 +00:00
Antonin Descampe
09f2926cd5 [1.5][JPIP] backport r1037 to branch 1.5 2011-11-06 22:03:12 +00:00
Antonin Descampe
238b767917 [1.5] backport r1017, r1030:1032 from trunk + additional fix for cmake and autotools 2011-11-02 00:49:20 +00:00
Antonin Descampe
49a0f0db8f [1.5] backport revisions 996, 997, 1000, 1008-1012 from trunk (JPIP modifications) 2011-11-01 23:28:07 +00:00
Mickael Savinaud
6a1530e4b1 [1.5] remove one obvious memory leak from test functions 2011-10-21 08:57:00 +00:00
Mickael Savinaud
8d8841c84f [1.5] remove obvious memory leak from applications 2011-10-20 16:36:45 +00:00
Mickael Savinaud
1dc6eddf1c backport rev 1013-1014 from trunk 2011-10-19 15:45:03 +00:00
Antonin Descampe
c1510793e3 [1.5] backport r987:990 to branch 1.5 2011-10-11 07:24:58 +00:00
Antonin Descampe
d728868263 [1.5][JPIP]removed obsolete indexer utility 2011-10-10 09:58:37 +00:00
Antonin Descampe
8a2af121a4 [1.5] enabled JPP stream in JPIP (result of GSoC program) 2011-10-10 09:50:18 +00:00
Antonin Descampe
9e60c2f8e9 [1.5] backport r909, r922-925 to branch 1.5 (terminating status of opj_server in debug/non-server mode and stateless requests) 2011-10-10 07:03:28 +00:00
Vincent Torri
d35f647aaa [1.5] add missing file in tarball, no need to change CHANGES 2011-10-10 06:42:27 +00:00
Vincent Torri
adbccc2e56 [1.5] Fix 'distcheck' rule 2011-10-10 06:02:31 +00:00
Mickael Savinaud
642d09f5cb [1.5] enhance non regression test suite generation (and some test names). It is based on a file as encoder previously 2011-10-07 13:00:18 +00:00
Mickael Savinaud
d1cb786dd8 [1.5] add tests about jp2 conformance 2011-10-07 12:45:10 +00:00
Mickael Savinaud
182e4b1882 [1.5] rename opj_configh.cmake.in to opj_config.h.cmake.in and update CMakeLists.txt to be more clear 2011-10-07 12:40:36 +00:00
Mickael Savinaud
73106fe839 [1.5] enhance some new JPIP files with opj_config inclusion and using of opj_free/opj_calloc functions (credit to Julien Malik) 2011-10-06 09:36:22 +00:00
Mickael Savinaud
40b4ecfaec [1.5] enhance html documentation generation with cmake and add a openjpeg mainpage to this doc 2011-10-06 09:04:42 +00:00
Vincent Torri
fb82b6d7d9 [1.5] fix output when --disable-shared or --disable-static is
passed to configure. Minor fix for jpwl compilation.
2011-10-01 04:55:00 +00:00
Antonin Descampe
5d6ac5ea72 BRANCH-1.5: fixed autotools for new indexer option 2011-09-09 18:53:01 +00:00
Antonin Descampe
3d06f03072 BRANCH-1.5:added a new indexer functionality to the library. With the new -jpip option at encoding, the user can now generate a JP2 file including an XML box with the index used when browsing the image with JPIP 2011-09-09 14:52:42 +00:00
Mickael Savinaud
5213675ba8 correct nightly crash on all platform linked to merge operation and missing opj_getopt command 2011-09-02 09:00:58 +00:00
Antonin Descampe
9a89e2f162 backport r898 to r907 in openjpeg-1.5 branch 2011-09-01 12:08:10 +00:00
Antonin Descampe
e89eb575ac backport r895 to openjpeg-1.5 branch 2011-08-27 15:54:52 +00:00
Antonin Descampe
d15f01b6e3 backport r882:893 to openjpeg-1.5 branch 2011-08-27 12:53:38 +00:00
Antonin Descampe
9ec5e8cf9a updated INSTALL files, fixed a bug in CMakeLists.txt that prevented finding the data directory 2011-08-22 10:42:32 +00:00
Antonin Descampe
4c9acc22b8 INSTALL and THANKS files update 2011-08-22 09:59:03 +00:00
Antonin Descampe
6adb5f5070 added NEWS, AUTHORS and THANKS files. Cosmetic changes in autotools files 2011-08-16 13:23:36 +00:00
Antonin Descampe
d1d662768d removed obsolete testing directory and *.nix files 2011-08-16 09:28:37 +00:00
Antonin Descampe
4091882dfb backport r870 to branch openjpeg-1.5 2011-08-16 08:54:54 +00:00
Antonin Descampe
61e0ed6a96 backport r868 to openjpeg-1.5 branch 2011-08-15 13:25:58 +00:00
Antonin Descampe
9c7899372b backport r866 to branch openjpeg-1.5 2011-08-15 13:00:06 +00:00
Antonin Descampe
a098921d34 added cmake support to openjpip 2011-08-12 14:59:28 +00:00
Mickael Savinaud
8ed4cb1a1e Fixed issue #76 (openjpeg-1.5) 2011-08-11 14:27:08 +00:00
Antonin Descampe
721904bc26 minor bug fix in configure.ac (credit to Vincent Torri) 2011-08-11 12:22:31 +00:00
Mickael Savinaud
2724f85cad backport rev[824-834] and rev[837-859] into the openjpeg-1.5 branch 2011-08-11 10:18:02 +00:00
Antonin Descampe
40b989ce00 removed xcode project files (cmake and autotools are now the only supported build methods) 2011-08-09 15:42:42 +00:00
Vincent Torri
3e1d8d6aef Fixed issue #74. 2011-07-23 08:47:24 +00:00
Vincent Torri
fda0cada0e Added libpng 1.5 detection. Dropped libpng 1.0.* explicit detection (we are in 2011 !). Patch by Winfried. 2011-07-23 08:32:09 +00:00
Vincent Torri
a58987d082 put comments after the creation of the branch 2011-07-13 16:39:14 +00:00
Vincent Torri
0f101066f2 * added 'libopenjpeg-jpwl.pc.in'
* fixed substitution in libopenjpeg1.pc.in
 * increase micro version to 99. When released, set minor to 5 and micro to 0
 * added -lm to the linker for libopenjpeg and to the .pc file
 * removed useless LCMS flags from Makefile.am for libopenjpeg
2011-07-13 16:29:22 +00:00
Antonin Descampe
cbe26cbb88 [openjpeg-1.5] JPIP : updated opj_viewer* jar files 2011-07-13 10:52:24 +00:00
Antonin Descampe
f753a1c36c updated CHNAGES files after branch renaming 2011-07-11 17:43:08 +00:00
Antonin Descampe
c0ea54e518 branch opj-v1-branch renamed to openjpeg-1.5 2011-07-11 17:40:09 +00:00
Antonin Descampe
c85e1a10cf opj-v1-branch created 2011-07-10 18:36:17 +00:00
261 changed files with 12349 additions and 18276 deletions

13
AUTHORS Normal file
View File

@ -0,0 +1,13 @@
Authors of OpenJPEG
See also the files THANKS and CHANGES
David Janssens designed and implemented the first version of OpenJPEG.
Kaori Hagihara designed and implemented the first version of OpenJPIP.
Jerome Fimes implemented the alpha version of OpenJPEG v2.
Giuseppe Baruffa added the JPWL functionalities.
Yannick Verschueren,
Herve Drolon,
Francois-Olivier Devaux,
Antonin Descampe
improved the libraries and utilities.

2191
CHANGES

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,3 @@
#
# Note that the ITK/CMakeLists.txt file configures this file
#
# CMake/CTestCustom.cmake.in
#
# to this file
#
# ${ITK_BINARY_DIR}/CTestCustom.cmake
#
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# #
# For further details regarding this file, # For further details regarding this file,
@ -17,20 +8,25 @@
# #
#---------------------------------------------------------------------- #----------------------------------------------------------------------
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50) SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000) SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
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
".*/tests/.*" ".*/tests/.*"
".*/Testing/.*"
) # Exclude files from the ThirdParty Utilities directories
".*/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"
) # supress warnings caused by 3rd party libs:
".*/thirdparty/.*"
)

View File

@ -1,15 +0,0 @@
# Check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
IF(UNIX) #I am pretty sure only *nix sys have this anyway
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
# Seems like we need the contrary:
IF(CMAKE_HAVE_GETOPT_H)
SET(DONT_HAVE_GETOPT 0)
ENDIF(CMAKE_HAVE_GETOPT_H)
ENDIF(UNIX)
IF(DONT_HAVE_GETOPT)
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
ENDIF(DONT_HAVE_GETOPT)

20
CMake/FindFCGI.cmake Normal file
View 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_DIRS FCGI_LIBRARIES)

19
CMake/FindKAKADU.cmake Normal file
View File

@ -0,0 +1,19 @@
#
# this module looks for KAKADu
# http://www.kakadusoftware.com/
#
#
# Copyright (c) 2006-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
FIND_PROGRAM(KDU_EXPAND_EXECUTABLE
kdu_expand
)
MARK_AS_ADVANCED(
KDU_EXPAND_EXECUTABLE
)

20
CMake/FindPTHREAD.cmake Normal file
View File

@ -0,0 +1,20 @@
# Look for the header file.
FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h)
# Look for the library.
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
# Handle the QUIETLY and REQUIRED arguments and set PTHREAD_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTHREAD DEFAULT_MSG PTHREAD_LIBRARY PTHREAD_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PTHREAD_FOUND)
SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
ELSE(PTHREAD_FOUND)
SET(PTHREAD_LIBRARIES)
SET(PTHREAD_INCLUDE_DIRS)
ENDIF(PTHREAD_FOUND)
MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIRS PTHREAD_LIBRARIES)

View File

@ -0,0 +1,9 @@
# JPIP test driver
#message(STATUS "${D_URL}")
file(DOWNLOAD
"${D_URL}"
"${D_FILE}"
LOG log
EXPECTED_MD5 "${EXPECTED_MD5}"
)
message(STATUS "LOG: ${log}")

70
CMake/OpenJPEGCPack.cmake Normal file
View File

@ -0,0 +1,70 @@
# package bundler
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
set(CMAKE_INSTALL_MFC_LIBRARIES 0)
set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
endif(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
)
# For PackageMaker on MacOSX it is important to have a file extension:
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${OPENJPEG_VERSION_BUILD}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
# Make this explicit here, rather than accepting the CPack default value,
# so we can refer to it:
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
IF(NOT DEFINED CPACK_SYSTEM_NAME)
# make sure package is not Cygwin-unknown, for Cygwin just
# cygwin is good for the system name
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
SET(CPACK_SYSTEM_NAME Cygwin)
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
IF(CMAKE_CL_64)
SET(CPACK_SYSTEM_NAME win64-x64)
ELSE(CMAKE_CL_64)
SET(CPACK_SYSTEM_NAME win32-x86)
ENDIF(CMAKE_CL_64)
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
# default to source package - system, on cygwin system is not
# needed
IF(CYGWIN)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
ELSE(CYGWIN)
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
ENDIF(CYGWIN)
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
SET(CPACK_BUNDLE_PLIST
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
#include(BundleUtilities)
include(CPack)
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")

View File

@ -28,7 +28,7 @@ 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 1) SET(OPENJPEG_VERSION_MAJOR 1)
SET(OPENJPEG_VERSION_MINOR 4) SET(OPENJPEG_VERSION_MINOR 5)
SET(OPENJPEG_VERSION_BUILD 0) SET(OPENJPEG_VERSION_BUILD 0)
SET(OPENJPEG_VERSION SET(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}") "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
@ -39,12 +39,13 @@ SET(OPENJPEG_LIBRARY_PROPERTIES
SOVERSION "${OPENJPEG_VERSION_MAJOR}" SOVERSION "${OPENJPEG_VERSION_MAJOR}"
) )
# --------------------------------------------------------------------------
# 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)
@ -85,8 +86,12 @@ IF(NOT OPENJPEG_INSTALL_LIB_DIR)
SET(OPENJPEG_INSTALL_LIB_DIR "lib") SET(OPENJPEG_INSTALL_LIB_DIR "lib")
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR) ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
IF(NOT OPENJPEG_INSTALL_DATA_DIR) IF(NOT OPENJPEG_INSTALL_DATA_DIR)
SET(OPENJPEG_INSTALL_DATA_DIR "share/${OPENJPEG_INSTALL_SUBDIR}") SET(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR) ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR) IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
@ -102,17 +107,13 @@ IF(NOT OPENJPEG_INSTALL_DOC_DIR)
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR) ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR) IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR} SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
CACHE INTERNAL "")
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR) ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Test for some required system information. # Big endian test:
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake) INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
#-----------------------------------------------------------------------------
# Test for getopt being available in this system
INCLUDE (${OPENJPEG_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Setup file for setting custom ctest vars # Setup file for setting custom ctest vars
@ -136,15 +137,20 @@ 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 IMMEDIATE) @ONLY)
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in) ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# pkgconfig support # pkgconfig support
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY) IF(UNIX)
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig ) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
INSTALL( CODE ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
"EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink \"libopenjpeg1.pc\" \"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")") INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig )
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
\"libopenjpeg1.pc\"
\"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")")
ENDIF(UNIX)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Compiler specific flags: # Compiler specific flags:
@ -157,51 +163,17 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# opj_config.h generation (1/2) # opj_config.h generation (1/2)
FIND_FILE(HAVE_STRINGS_H_FOUND strings.h) INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
IF(NOT HAVE_STRINGS_H_FOUND STREQUAL "HAVE_STRINGS_H_FOUND-NOTFOUND") CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
FIND_FILE(HAVE_STRINGS_H strings.h) CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
SET(HAS_STRINGS_H 1) CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
ENDIF() CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
FIND_FILE(HAVE_INTTYPES_H_FOUND inttypes.h) CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
IF(NOT HAVE_INTTYPES_H_FOUND STREQUAL "HAVE_INTTYPES_H_FOUND-NOTFOUND") CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
FIND_FILE(HAVE_INTTYPES_H inttypes.h) CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
SET(HAS_INTTYPES_H 1) CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
ENDIF() CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
FIND_FILE(HAVE_MEMORY_H_FOUND memory.h)
IF(NOT HAVE_MEMORY_H_FOUND STREQUAL "HAVE_MEMORY_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_MEMORY_H memory.h)
SET(HAS_MEMORY_H 1)
ENDIF()
FIND_FILE(HAVE_STDINT_H_FOUND stdint.h)
IF(NOT HAVE_STDINT_H_FOUND STREQUAL "HAVE_STDINT_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_STDINT_H stdint.h)
SET(HAS_STDINT_H 1)
ENDIF()
FIND_FILE(HAVE_STDLIB_H_FOUND stdlib.h)
IF(NOT HAVE_STDLIB_H_FOUND STREQUAL "HAVE_STDLIB_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_STDLIB_H stdlib.h)
SET(HAS_STDLIB_H 1)
ENDIF()
FIND_FILE(HAVE_STRING_H_FOUND string.h)
IF(NOT HAVE_STRING_H_FOUND STREQUAL "HAVE_STRING_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_STRING_H string.h)
SET(HAS_STRING_H 1)
ENDIF()
FIND_FILE(HAVE_SYS_STAT_H_FOUND sys/stat.h)
IF(NOT HAVE_SYS_STAT_H_FOUND STREQUAL "HAVE_SYS_STAT_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_SYS_STAT_H sys/stat.h)
SET(HAS_SYS_STAT_H 1)
ENDIF()
FIND_FILE(HAVE_SYS_TYPES_H_FOUND sys/types.h)
IF(NOT HAVE_SYS_TYPES_H_FOUND STREQUAL "HAVE_SYS_TYPES_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_SYS_TYPES_H sys/types.h)
SET(HAS_SYS_TYPES_H 1)
ENDIF()
FIND_FILE(HAVE_UNISTD_H_FOUND unistd.h)
IF(NOT HAVE_UNISTD_H_FOUND STREQUAL "HAVE_UNISTD_H_FOUND-NOTFOUND")
FIND_FILE(HAVE_UNISTD_H unistd.h)
SET(HAS_UNISTD_H 1)
ENDIF()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Build Library # Build Library
@ -212,8 +184,19 @@ ADD_SUBDIRECTORY(libopenjpeg)
# 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_JPIP "Build the JPIP library and executables." OFF)
IF(BUILD_JPIP)
OPTION(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
ENDIF(BUILD_JPIP)
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
MARK_AS_ADVANCED(BUILD_VIEWER)
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
# 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(applications) ADD_SUBDIRECTORY(applications)
@ -221,18 +204,17 @@ ENDIF (BUILD_CODEC OR BUILD_MJ2)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# opj_config.h generation (2/2) # opj_config.h generation (2/2)
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in" CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
"${OPENJPEG_BINARY_DIR}/opj_config.h" "${OPENJPEG_BINARY_DIR}/opj_config.h"
@ONLY @ONLY
) )
#-----------------------------------------------------------------------------
# Build JPWL-flavoured library and executables
OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found) # Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
ADD_SUBDIRECTORY(doc) OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
IF(BUILD_DOC)
ADD_SUBDIRECTORY(doc)
ENDIF(BUILD_DOC)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Buld Testing # Buld Testing
@ -242,18 +224,18 @@ IF(BUILD_TESTING)
ENABLE_TESTING() ENABLE_TESTING()
INCLUDE(CTest) INCLUDE(CTest)
# Add repository where to find tests
ADD_SUBDIRECTORY(tests)
# Search openjpeg data needed for the tests # Search openjpeg data needed for the tests
# They could be found via svn on the OpenJPEG google code project # They could be found via svn on the OpenJPEG google code project
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo) # 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}/../opj-data) PATHS
$ENV{OPJ_DATA_ROOT}
SET (REF_DECODER_BIN_PATH "NOT-FOUND" CACHE PATH "Single directory where find the reference encoder binaries to enable encoding test suite.") ${CMAKE_SOURCE_DIR}/../data
MARK_AS_ADVANCED(REF_DECODER_BIN_PATH) )
# Add repository where to find tests
ADD_SUBDIRECTORY(tests)
ELSE(BUILD_CODEC) 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(BUILD_CODEC) ENDIF(BUILD_CODEC)
@ -276,3 +258,5 @@ INSTALL(
FILES CHANGES FILES CHANGES
LICENSE LICENSE
DESTINATION ${OPENJPEG_INSTALL_DOC_DIR}) DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
INCLUDE (CMake/OpenJPEGCPack.cmake)

43
INSTALL
View File

@ -5,7 +5,11 @@ How to build and install openjpeg binaries
UNIX/LINUX similar systems UNIX/LINUX similar systems
-------------------------- --------------------------
1) Using configure tools 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: To build from top-level directory, you can simply type:
./bootstrap.sh ./bootstrap.sh
@ -33,12 +37,26 @@ To build doc (requires 'doxygen' to be found on your system):
Main './configure' options (type './configure --help' for more details) Main './configure' options (type './configure --help' for more details)
'--enable-mj2' '--enable-mj2'
'--enable-jpwl' '--enable-jpwl'
'--enable-jpip'
'--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed') '--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed')
'--enable-debug' (default : disabled) '--enable-debug' (default : disabled)
You can also specify your own CFLAGS and LDFLAGS with (for example): You can also specify your own CFLAGS and LDFLAGS with (for example):
CFLAGS="-O3 -pipe" LDFLAGS="-Wl,-s" ./configure 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) 2) Using cmake (see www.cmake.org)
@ -67,24 +85,15 @@ Main available cmake flags:
* 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 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 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 -DJPEG2000_CONFORMANCE_DATA_ROOT:PATH=/path/to/your/JPEG2000/test/files 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 here : http://www.crc.ricoh.com/~gormish/jpeg2000conformance/ 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',
3) Manually using Makefile.nix: corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
- Manually edit the config.nix file been checked out of course).
- Manually create an opj_config.h file from opj_config.h.in.user
and edit this opj_config.h
- Then : (if 'WITH_JPWL' is defined in config.nix)
make -f Makefile.nix all
make -f Makefile.nix install
make -f Makefile.nix clean
make -f Makefile.nix uninstall
- If 'WITH_JPWL' is not defined in config.nix
and you want to clean/compile/install/uninstall JPWL:
call the respective target in the respective directory.
MACOSX MACOSX
------ ------
@ -98,7 +107,7 @@ If it does not work, try adding the following flag to the cmake command :
WINDOWS WINDOWS
------- -------
If you're using cygwin or MinGW, the same procedures as for Unix can be used. 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). 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.

13
LICENSE
View File

@ -1,10 +1,11 @@
/* /*
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2007, Professor Benoit Macq * Copyright (c) 2002-2012, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2003-2012, Antonin Descampe
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2003-2009, Francois-Olivier Devaux
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2001-2003, David Janssens
* 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
@ -27,4 +28,4 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */

View File

@ -1,4 +1,4 @@
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpwl=yes --enable-mj2=yes DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpip-server=yes --enable-jpwl=yes --enable-mj2=yes
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
@ -7,6 +7,10 @@ SUBDIRS = libopenjpeg applications doc
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libopenjpeg1.pc pkgconfig_DATA = libopenjpeg1.pc
if WANT_JPWL
pkgconfig_DATA += libopenjpeg-jpwl.pc
endif
MAINTAINERCLEANFILES = \ MAINTAINERCLEANFILES = \
Makefile.in \ Makefile.in \
@ -22,20 +26,25 @@ ltmain.sh \
missing missing
EXTRA_DIST = \ EXTRA_DIST = \
CMake/CheckHaveGetopt.cmake \ CMake/CTestCustom.cmake.in \
CMake/FindFCGI.cmake \
CMake/FindLCMS2.cmake \
CMake/FindLCMS.cmake \
CMake/OpenJPEGConfig.cmake.in \ CMake/OpenJPEGConfig.cmake.in \
testing/CTestCustom.cmake.in \
testing/CTestConfig.cmake \
CMakeLists.txt \ CMakeLists.txt \
LICENSE \ CTestConfig.cmake \
AUTHORS \
CHANGES \ CHANGES \
README \
INSTALL \ INSTALL \
LICENSE \
NEWS \
README \
THANKS \
bootstrap.sh \ bootstrap.sh \
libopenjpeg1.pc.cmake \ libopenjpeg1.pc.cmake \
libopenjpeg1.pc.in \ libopenjpeg1.pc.in \
opj_configh.cmake.in \ libopenjpeg-jpwl.pc.in \
opj_config.h.in.user \ opj_config.h.cmake.in \
m4/opj_check_lib.m4 \ m4/opj_check_lib.m4 \
m4/opj_doxygen.m4 \ m4/opj_doxygen.m4 \
m4/pkg.m4 m4/pkg.m4
@ -49,9 +58,16 @@ doc:
@cd doc && make doc @cd doc && make doc
install-data-hook: 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 $(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
endif
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt @echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.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 @cat $(top_builddir)/report.txt
@rm $(top_builddir)/report.txt @rm $(top_builddir)/report.txt

View File

@ -1,183 +0,0 @@
#top Makefile.nix
include config.nix
TARGET = openjpeg
COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC
INCLUDE = -I. -Ilibopenjpeg
LIBRARIES = -lstdc++
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c \
./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c \
./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c \
./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c \
./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c \
./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c \
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h \
./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h \
./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h \
./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h \
./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h \
./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h \
./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_malloc.h \
./libopenjpeg/opj_includes.h
INSTALL_LIBDIR = $(prefix)/lib
headerdir = openjpeg-$(MAJOR).$(MINOR)
INSTALL_INCLUDE = $(prefix)/include/$(headerdir)
# Converts cr/lf to just lf
DOS2UNIX = dos2unix
MODULES = $(SRCS:.c=.o)
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
LIBNAME = lib$(TARGET)
ifeq ($(ENABLE_SHARED),yes)
SHAREDLIB = $(LIBNAME).so.$(MAJOR).$(MINOR).$(BUILD)
else
STATICLIB = $(LIBNAME).a
endif
default: all
all: OpenJPEG
make -C codec -f Makefile.nix all
make -C mj2 -f Makefile.nix all
ifeq ($(WITH_JPWL),yes)
make -C jpwl -f Makefile.nix all
endif
ifeq ($(WITH_JP3D),yes)
make -C jp3d -f Makefile.nix all
endif
dos2unix:
@$(DOS2UNIX) $(SRCS) $(INCLS)
OpenJPEG: $(STATICLIB) $(SHAREDLIB)
install -d bin
ifeq ($(ENABLE_SHARED),yes)
install -m 755 $(SHAREDLIB) bin
(cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR))
(cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so)
else
install -m 644 $(STATICLIB) bin
endif
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
ifeq ($(ENABLE_SHARED),yes)
$(SHAREDLIB): $(MODULES)
$(CC) -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
else
$(STATICLIB): $(MODULES)
rm -f $(STATICLIB)
$(AR) r $@ $(MODULES)
endif
install: OpenJPEG
install -d $(DESTDIR)$(INSTALL_LIBDIR)
ifeq ($(ENABLE_SHARED),yes)
install -m 755 -o root -g root $(SHAREDLIB) $(DESTDIR)$(INSTALL_LIBDIR)
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR) )
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
ln -sf $(SHAREDLIB) $(LIBNAME).so )
else
install -m 644 -o root -g root $(STATICLIB) $(DESTDIR)$(INSTALL_LIBDIR)
(cd $(DESTDIR)$(INSTALL_LIBDIR) && ranlib $(STATICLIB) )
endif
install -d $(DESTDIR)$(INSTALL_INCLUDE)
install -m 644 -o root -g root libopenjpeg/openjpeg.h \
$(DESTDIR)$(INSTALL_INCLUDE)
(cd $(DESTDIR)$(prefix)/include && \
ln -sf $(headerdir)/openjpeg.h openjpeg.h)
make -C codec -f Makefile.nix install
make -C mj2 -f Makefile.nix install
ifeq ($(WITH_JPWL),yes)
make -C jpwl -f Makefile.nix install
endif
ifeq ($(WITH_JP3D),yes)
make -C jp3d -f Makefile.nix install
endif
$(LDCONFIG)
make -C doc -f Makefile.nix install
ifeq ($(WITH_JPWL),yes)
jpwl-all:
make -C jpwl -f Makefile.nix all
jpwl-install: jpwl-all
make -C jpwl -f Makefile.nix install
$(LDCONFIG)
jpwl-clean:
make -C jpwl -f Makefile.nix clean
jpwl-uninstall:
make -C jpwl -f Makefile.nix uninstall
endif
ifeq ($(WITH_JP3D),yes)
jp3d-all:
make -C jp3d -f Makefile.nix all
jp3d-install: jp3d-all
make -C jp3d -f Makefile.nix install
$(LDCONFIG)
jp3d-clean:
make -C jp3d -f Makefile.nix clean
jp3d-uninstall:
make -C jp3d -f Makefile.nix uninstall
endif
doc-all:
make -C doc -f Makefile.nix all
doc-install: doc-all
make -C doc -f Makefile.nix install
clean:
rm -rf bin
rm -f core u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB)
make -C codec -f Makefile.nix clean
make -C mj2 -f Makefile.nix clean
make -C doc -f Makefile.nix clean
ifeq ($(WITH_JPWL),yes)
make -C jpwl -f Makefile.nix clean
endif
ifeq ($(WITH_JP3D),yes)
make -C jp3d -f Makefile.nix clean
endif
doc-clean:
make -C doc -f Makefile.nix clean
uninstall:
ifeq ($(ENABLE_SHARED),yes)
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
rm -f $(LIBNAME).so $(LIBNAME).so.$(MAJOR).$(MINOR) $(SHAREDLIB) )
else
rm -f $(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)
endif
$(LDCONFIG)
rm -f $(DESTDIR)$(prefix)/include/openjpeg.h
rm -rf $(DESTDIR)$(INSTALL_INCLUDE)
make -C codec -f Makefile.nix uninstall
make -C mj2 -f Makefile.nix uninstall
make -C doc -f Makefile.nix uninstall
ifeq ($(WITH_JPWL),yes)
make -C jpwl -f Makefile.nix uninstall
endif
ifeq ($(WITH_JP3D),yes)
make -C jp3d -f Makefile.nix uninstall
endif
distclean: clean
rm -rf bin

34
NEWS Normal file
View File

@ -0,0 +1,34 @@
OpenJPEG NEWS - user visible changes
====================================
Changes from OpenJPEG 1.4.0 to OpenJPEG 1.5.0
----------------------------------------------
New Features:
* openjpip:
- complete client-server architecture for remote browsing of jpeg 2000 images.
- located in 'applications/jpip'.
- see corresponding README for more details.
API modifications:
* 'bool' type has been replaced by 'opj_bool' type. 'stdbool.h' is no more required.
Misc:
* added this NEWS file.
* improved cmake and autotools build methods.
* removed manual makefiles, VS project files and XCode project files.
* added a 'thirdparty' directory to contain all dependencies.
- These libraries will be build only if there are not found on the system.
- Note that libopenjpeg itself does not have any dependency.
* changed the directory hierarchy of the whole project. See README files for details.
* tests : a complete test suite has been setup.
- both JPEG 2000 conformance tests and non-regressions tests are configured.
- results are submitted to the OpenJPEG dashboard (http://my.cdash.org/index.php?project=OPENJPEG)
- images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
- configuration files and utilities are located in 'tests' folder.
* OPJViewer re-activated (need wxWidgets)
* Huge amount of bug fixes. See CHANGES for details.

10
README
View File

@ -13,11 +13,13 @@ Details on folders hierarchy:
* JavaOpenJPEG: java jni to use openjpeg in a java program * 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. * 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) * OPJViewer: gui for displaying j2k files (based on wxWidget)
* thirdparty: thirdparty libraries used by some applications. These libraries will be build only if there are not found on the system. Note that libopenjpeg itself does not have any dependency. * 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 * doc: doxygen documentation setup file and man pages
* testing: all files required to test the library and executables (obsolete) * 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 * CMake: cmake related files
* m4: autotools related files * m4: autotools related files
see LICENSE for license and copyright information see LICENSE for license and copyright information.
see INSTALL for installation procedures. see INSTALL for installation procedures.
see NEWS for user visible changes in successive releases.
see CHANGES for per-revision changes.

33
THANKS Normal file
View File

@ -0,0 +1,33 @@
OpenJPEG THANKS file
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
or submitting actual code. Here is a list of these people. Help me keep
it complete and exempt of errors.
Mathieu Malaterre
Winfried Szukalski
Vincent Torri
Bob Friesenhahn
Callum Lerwick
Dzonatas Sol
Mickaël Savinaud
Julien Malik
Jerôme Fimes
Herve Drolon
Yannick Verschueren
Sebastien Lugan
Kaori Hagihara
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

View File

@ -1,9 +1,22 @@
# Build the each application if it needed # Build the each application if it needed
IF(BUILD_CODEC) IF(BUILD_CODEC)
ADD_SUBDIRECTORY(codec) ADD_SUBDIRECTORY(codec)
ENDIF(BUILD_CODEC) ENDIF(BUILD_CODEC)
IF(BUILD_MJ2) IF(BUILD_MJ2)
ADD_SUBDIRECTORY(mj2) ADD_SUBDIRECTORY(mj2)
ENDIF(BUILD_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)

View File

@ -1,40 +1,47 @@
#JavaOpenJPEG/CMakeLists.txt #JavaOpenJPEG/CMakeLists.txt
# First thing define the common source: # First thing define the common source:
SET(common_SRCS SET(openjpegjni_SRCS
../codec/convert.c JavaOpenJPEGDecoder.c
../codec/index.c JavaOpenJPEG.c
) )
# If not getopt was found then add it to the lib: # JNI binding:
IF(DONT_HAVE_GETOPT) find_package(JNI REQUIRED)
SET(common_SRCS include_directories(${JNI_INCLUDE_DIRS})
${common_SRCS}
../common/getopt.c
)
ENDIF(DONT_HAVE_GETOPT)
# required header file:
# Headers file are located here: include_directories(
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg ${OPENJPEG_SOURCE_DIR}/libopenjpeg
${LCMS_INCLUDE_DIR} ${OPENJPEG_SOURCE_DIR}/applications/common
${PNG_INCLUDE_DIR} ${OPENJPEG_SOURCE_DIR}/applications/codec
${ZLIB_INCLUDE_DIR}
${TIFF_INCLUDE_DIR}
) )
# Loop over all executables: add_library(openjpegjni MODULE
FOREACH(exe j2k_to_image image_to_j2k) ${openjpegjni_SRCS}
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS}) )
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES}
${PNG_LIBRARIES} ${ZLIB_LIBRARY} ${LCMS_LIB})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} -lm)
ENDIF(UNIX)
# Install exe
INSTALL_TARGETS(/bin/ ${exe})
ENDFOREACH(exe)
# build jar:
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
# build dep list:
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
# make sure target javac dir exists:
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
# Build java
ADD_CUSTOM_COMMAND(
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
COMMAND ${Java_JAR_EXECUTABLE} cvf ${LIBRARY_OUTPUT_PATH}/openjpeg.jar org
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes
DEPENDS ${java_srcs}
COMMENT "javac *.java; jar cvf -> openjpeg.jar"
)
# name the target
ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
COMMENT "building openjpeg.jar"
)

View File

@ -37,7 +37,7 @@
#include <math.h> #include <math.h>
#include "openjpeg.h" #include "openjpeg.h"
#include "getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"
#include "index.h" #include "index.h"
#include "dirent.h" #include "dirent.h"
@ -204,6 +204,8 @@ 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 : devide packets of every tile into tile-parts (-TP R) [R, L, C]\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");
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n"); fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
@ -216,6 +218,9 @@ void encode_help_display() {
fprintf(stdout,"\n"); fprintf(stdout,"\n");
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n"); fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
fprintf(stdout,"\n"); fprintf(stdout,"\n");
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
fprintf(stdout,"\n");
/* UniPG>> */ /* UniPG>> */
#ifdef USE_JPWL #ifdef USE_JPWL
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n"); fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
@ -375,7 +380,7 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
} }
void cinema_parameters(opj_cparameters_t *parameters){ void cinema_parameters(opj_cparameters_t *parameters){
parameters->tile_size_on = false; parameters->tile_size_on = OPJ_FALSE;
parameters->cp_tdx=1; parameters->cp_tdx=1;
parameters->cp_tdy=1; parameters->cp_tdy=1;
@ -492,21 +497,22 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, int parse_cmdline_encoder(int argc, char **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;
option_t long_option[]={ opj_option_t long_option[]={
{"cinema2K",REQ_ARG, NULL ,'w'}, {"cinema2K",REQ_ARG, NULL ,'w'},
{"cinema4K",NO_ARG, NULL ,'y'}, {"cinema4K",NO_ARG, NULL ,'y'},
{"ImgDir",REQ_ARG, NULL ,'z'}, {"ImgDir",REQ_ARG, NULL ,'z'},
{"TP",REQ_ARG, NULL ,'v'}, {"TP",REQ_ARG, NULL ,'u'},
{"SOP",NO_ARG, NULL ,'S'}, {"SOP",NO_ARG, NULL ,'S'},
{"EPH",NO_ARG, NULL ,'E'}, {"EPH",NO_ARG, NULL ,'E'},
{"OutFor",REQ_ARG, NULL ,'O'}, {"OutFor",REQ_ARG, NULL ,'O'},
{"POC",REQ_ARG, NULL ,'P'}, {"POC",REQ_ARG, NULL ,'P'},
{"ROI",REQ_ARG, NULL ,'R'}, {"ROI",REQ_ARG, NULL ,'R'},
{"jpip",NO_ARG, NULL, 'J'}
}; };
/* 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:" 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 */
@ -523,7 +529,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
reset_options_reading(); reset_options_reading();
while (1) { while (1) {
int c = getopt_long(argc, argv, optlist,long_option,totlen); int c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
@ -532,7 +538,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'o': /* output file */ case 'o': /* output file */
{ {
char *outfile = optarg; char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile); parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case J2K_CFMT: case J2K_CFMT:
@ -550,14 +556,14 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'O': /* output format */ case 'O': /* output format */
{ {
char outformat[50]; char outformat[50];
char *of = optarg; char *of = opj_optarg;
sprintf(outformat,".%s",of); sprintf(outformat,".%s",of);
img_fol->set_out_format = 1; img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat); parameters->cod_format = get_file_format(outformat);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case J2K_CFMT: case J2K_CFMT:
case JP2_CFMT: case JP2_CFMT:
img_fol->out_format = optarg; img_fol->out_format = opj_optarg;
break; break;
default: default:
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n"); fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
@ -572,7 +578,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'r': /* rates rates/distorsion */ case 'r': /* rates rates/distorsion */
{ {
char *s = optarg; char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) { while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++; parameters->tcp_numlayers++;
while (*s && *s != ',') { while (*s && *s != ',') {
@ -590,7 +596,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'q': /* add fixed_quality */ case 'q': /* add fixed_quality */
{ {
char *s = optarg; char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) { while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++; parameters->tcp_numlayers++;
while (*s && *s != ',') { while (*s && *s != ',') {
@ -612,7 +618,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
int *row = NULL, *col = NULL; int *row = NULL, *col = NULL;
int numlayers = 0, numresolution = 0, matrix_width = 0; int numlayers = 0, numresolution = 0, matrix_width = 0;
char *s = optarg; char *s = opj_optarg;
sscanf(s, "%d", &numlayers); sscanf(s, "%d", &numlayers);
s++; s++;
if (numlayers > 9) if (numlayers > 9)
@ -656,8 +662,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 't': /* tiles */ case 't': /* tiles */
{ {
sscanf(optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy); sscanf(opj_optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
parameters->tile_size_on = true; parameters->tile_size_on = OPJ_TRUE;
} }
break; break;
@ -665,7 +671,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'n': /* resolution */ case 'n': /* resolution */
{ {
sscanf(optarg, "%d", &parameters->numresolution); sscanf(opj_optarg, "%d", &parameters->numresolution);
} }
break; break;
@ -675,7 +681,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
char sep; char sep;
int res_spec = 0; int res_spec = 0;
char *s = optarg; char *s = opj_optarg;
do { do {
sep = 0; sep = 0;
sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec], sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
@ -694,7 +700,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'b': /* code-block dimension */ case 'b': /* code-block dimension */
{ {
int cblockw_init = 0, cblockh_init = 0; int cblockw_init = 0, cblockh_init = 0;
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init); sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024 if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) { || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
fprintf(stderr, fprintf(stderr,
@ -711,7 +717,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'x': /* creation of index file */ case 'x': /* creation of index file */
{ {
char *index = optarg; char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN); strncpy(indexfilename, index, OPJ_PATH_LEN);
} }
break; break;
@ -722,7 +728,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
{ {
char progression[4]; char progression[4];
strncpy(progression, optarg, 4); strncpy(progression, opj_optarg, 4);
parameters->prog_order = give_progression(progression); parameters->prog_order = give_progression(progression);
if (parameters->prog_order == -1) { if (parameters->prog_order == -1) {
fprintf(stderr, "Unrecognized progression order " fprintf(stderr, "Unrecognized progression order "
@ -736,7 +742,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 's': /* subsampling factor */ case 's': /* subsampling factor */
{ {
if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx, if (sscanf(opj_optarg, "%d,%d", &parameters->subsampling_dx,
&parameters->subsampling_dy) != 2) { &parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n"); fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
return 1; return 1;
@ -748,7 +754,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'd': /* coordonnate of the reference grid */ case 'd': /* coordonnate of the reference grid */
{ {
if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0, if (sscanf(opj_optarg, "%d,%d", &parameters->image_offset_x0,
&parameters->image_offset_y0) != 2) { &parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument " fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
"error !! [-d x0,y0]\n"); "error !! [-d x0,y0]\n");
@ -770,7 +776,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
int numpocs = 0; /* number of progression order change (POC) default 0 */ int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */ opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
char *s = optarg; char *s = opj_optarg;
POC = parameters->POC; POC = parameters->POC;
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile, while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
@ -812,7 +818,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'M': /* Mode switch pas tous au point !! */ case 'M': /* Mode switch pas tous au point !! */
{ {
int value = 0; int value = 0;
if (sscanf(optarg, "%d", &value) == 1) { if (sscanf(opj_optarg, "%d", &value) == 1) {
for (i = 0; i <= 5; i++) { for (i = 0; i <= 5; i++) {
int cache = value & (1 << i); int cache = value & (1 << i);
if (cache) if (cache)
@ -826,7 +832,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'R': /* ROI */ case 'R': /* ROI */
{ {
if (sscanf(optarg, "c=%d,U=%d", &parameters->roi_compno, if (sscanf(opj_optarg, "c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) { &parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n"); fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
return 1; return 1;
@ -838,7 +844,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'T': /* Tile offset */ case 'T': /* Tile offset */
{ {
if (sscanf(optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) { if (sscanf(opj_optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]"); fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1; return 1;
} }
@ -849,9 +855,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'C': /* add a comment */ case 'C': /* add a comment */
{ {
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1); parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
if(parameters->cp_comment) { if(parameters->cp_comment) {
strcpy(parameters->cp_comment, optarg); strcpy(parameters->cp_comment, opj_optarg);
} }
} }
break; break;
@ -867,9 +873,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
/* ------------------------------------------------------ */ /* ------------------------------------------------------ */
case 'v': /* Tile part generation*/ case 'u': /* Tile part generation*/
{ {
parameters->tp_flag = optarg[0]; parameters->tp_flag = opj_optarg[0];
parameters->tp_on = 1; parameters->tp_on = 1;
} }
break; break;
@ -878,8 +884,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'z': /* Image Directory path */ case 'z': /* Image Directory path */
{ {
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1); img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,optarg); strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1; img_fol->set_imgdir=1;
} }
break; break;
@ -889,7 +895,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'w': /* Digital Cinema 2K profile compliance*/ case 'w': /* Digital Cinema 2K profile compliance*/
{ {
int fps=0; int fps=0;
sscanf(optarg,"%d",&fps); sscanf(opj_optarg,"%d",&fps);
if(fps == 24){ if(fps == 24){
parameters->cp_cinema = CINEMA2K_24; parameters->cp_cinema = CINEMA2K_24;
}else if(fps == 48 ){ }else if(fps == 48 ){
@ -933,7 +939,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
/* search for different protection methods */ /* search for different protection methods */
/* break the option in comma points and parse the result */ /* break the option in comma points and parse the result */
token = strtok(optarg, ","); token = strtok(opj_optarg, ",");
while(token != NULL) { while(token != NULL) {
/* search header error protection method */ /* search header error protection method */
@ -1238,7 +1244,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
break; break;
#endif /* USE_JPWL */ #endif /* USE_JPWL */
/* <<UniPG */ /* <<UniPG */
/* ------------------------------------------------------ */
case 'J': /* jpip on */
{
parameters->jpip_on = OPJ_TRUE;
}
break;
/* ------------------------------------------------------ */ /* ------------------------------------------------------ */
default: default:
@ -1616,7 +1628,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
jbyte *jbBody; jbyte *jbBody;
jshort *jsBody; jshort *jsBody;
jint *jiBody; jint *jiBody;
boolean 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");
@ -1764,7 +1776,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
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 */ char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
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;
opj_event_mgr_t event_mgr; /* event manager */ opj_event_mgr_t event_mgr; /* event manager */
@ -1898,7 +1910,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */ if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
cinfo = opj_create_compress(CODEC_J2K); cinfo = opj_create_compress(CODEC_J2K);
} else { /* JP2 format output */ } else { /* JP2 format output */
cinfo = opj_create_compress(CODEC_JP2); cinfo = opj_create_compress(CODEC_JP2);
} }
/* catch events using our callbacks and give a local context */ /* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, &msgErrorCallback_vars); opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, &msgErrorCallback_vars);

View File

@ -37,7 +37,7 @@
#include <math.h> #include <math.h>
#include "openjpeg.h" #include "openjpeg.h"
#include "getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"
#include "dirent.h" #include "dirent.h"
#include "org_openJpeg_OpenJPEGJavaDecoder.h" #include "org_openJpeg_OpenJPEGJavaDecoder.h"
@ -206,7 +206,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 **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
/* parse the command line */ /* parse the command line */
int totlen; int totlen;
option_t long_option[]={ opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'}, {"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'}, {"OutFor",REQ_ARG, NULL ,'O'},
}; };
@ -229,13 +229,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
reset_options_reading(); reset_options_reading();
while (1) { while (1) {
int c = getopt_long(argc, argv,optlist,long_option,totlen); int c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
case 'i': /* input file */ case 'i': /* input file */
{ {
char *infile = optarg; char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile); parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) { switch(parameters->decod_format) {
case J2K_CFMT: case J2K_CFMT:
@ -256,7 +256,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'o': /* output file */ case 'o': /* output file */
{ {
char *outfile = optarg; char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile); parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case PGX_DFMT: case PGX_DFMT:
@ -279,7 +279,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'O': /* output format */ case 'O': /* output format */
{ {
char outformat[50]; char outformat[50];
char *of = optarg; char *of = opj_optarg;
sprintf(outformat,".%s",of); sprintf(outformat,".%s",of);
img_fol->set_out_format = 1; img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat); parameters->cod_format = get_file_format(outformat);
@ -315,7 +315,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'r': /* reduce option */ case 'r': /* reduce option */
{ {
sscanf(optarg, "%d", &parameters->cp_reduce); sscanf(opj_optarg, "%d", &parameters->cp_reduce);
} }
break; break;
@ -324,7 +324,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'l': /* layering option */ case 'l': /* layering option */
{ {
sscanf(optarg, "%d", &parameters->cp_layer); sscanf(opj_optarg, "%d", &parameters->cp_layer);
} }
break; break;
@ -338,8 +338,8 @@ 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*)malloc(strlen(optarg) + 1); img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,optarg); strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1; img_fol->set_imgdir=1;
} }
break; break;
@ -351,7 +351,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
{ {
char *token = NULL; char *token = NULL;
token = strtok(optarg, ","); token = strtok(opj_optarg, ",");
while(token != NULL) { while(token != NULL) {
/* search expected number of components */ /* search expected number of components */
@ -418,7 +418,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
default: default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg); fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
break; break;
} }
} }

View File

@ -1,14 +0,0 @@
# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k
CFLAGS = -O3 -lstdc++ # -g -p -pg
all: j2k_to_image image_to_j2k
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
gcc $(CFLAGS) ../common/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
gcc $(CFLAGS) ../common/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
clean:
rm -f j2k_to_image image_to_j2k

View File

@ -1,278 +0,0 @@
/*
* @(#)jawt.h 1.10 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _JAVASOFT_JAWT_H_
#define _JAVASOFT_JAWT_H_
#include "jni.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* AWT native interface (new in JDK 1.3)
*
* The AWT native interface allows a native C or C++ application a means
* by which to access native structures in AWT. This is to facilitate moving
* legacy C and C++ applications to Java and to target the needs of the
* community who, at present, wish to do their own native rendering to canvases
* for performance reasons. Standard extensions such as Java3D also require a
* means to access the underlying native data structures of AWT.
*
* There may be future extensions to this API depending on demand.
*
* A VM does not have to implement this API in order to pass the JCK.
* It is recommended, however, that this API is implemented on VMs that support
* standard extensions, such as Java3D.
*
* Since this is a native API, any program which uses it cannot be considered
* 100% pure java.
*/
/*
* AWT Native Drawing Surface (JAWT_DrawingSurface).
*
* For each platform, there is a native drawing surface structure. This
* platform-specific structure can be found in jawt_md.h. It is recommended
* that additional platforms follow the same model. It is also recommended
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
*
*******************
* EXAMPLE OF USAGE:
*******************
*
* In Win32, a programmer wishes to access the HWND of a canvas to perform
* native rendering into it. The programmer has declared the paint() method
* for their canvas subclass to be native:
*
*
* MyCanvas.java:
*
* import java.awt.*;
*
* public class MyCanvas extends Canvas {
*
* static {
* System.loadLibrary("mylib");
* }
*
* public native void paint(Graphics g);
* }
*
*
* myfile.c:
*
* #include "jawt_md.h"
* #include <assert.h>
*
* JNIEXPORT void JNICALL
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
* {
* JAWT awt;
* JAWT_DrawingSurface* ds;
* JAWT_DrawingSurfaceInfo* dsi;
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
* jboolean result;
* jint lock;
*
* // Get the AWT
* awt.version = JAWT_VERSION_1_3;
* result = JAWT_GetAWT(env, &awt);
* assert(result != JNI_FALSE);
*
* // Get the drawing surface
* ds = awt.GetDrawingSurface(env, canvas);
* assert(ds != NULL);
*
* // Lock the drawing surface
* lock = ds->Lock(ds);
* assert((lock & JAWT_LOCK_ERROR) == 0);
*
* // Get the drawing surface info
* dsi = ds->GetDrawingSurfaceInfo(ds);
*
* // Get the platform-specific drawing info
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
*
* //////////////////////////////
* // !!! DO PAINTING HERE !!! //
* //////////////////////////////
*
* // Free the drawing surface info
* ds->FreeDrawingSurfaceInfo(dsi);
*
* // Unlock the drawing surface
* ds->Unlock(ds);
*
* // Free the drawing surface
* awt.FreeDrawingSurface(ds);
* }
*
*/
/*
* JAWT_Rectangle
* Structure for a native rectangle.
*/
typedef struct jawt_Rectangle {
jint x;
jint y;
jint width;
jint height;
} JAWT_Rectangle;
struct jawt_DrawingSurface;
/*
* JAWT_DrawingSurfaceInfo
* Structure for containing the underlying drawing information of a component.
*/
typedef struct jawt_DrawingSurfaceInfo {
/*
* Pointer to the platform-specific information. This can be safely
* cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
* JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details.
*/
void* platformInfo;
/* Cached pointer to the underlying drawing surface */
struct jawt_DrawingSurface* ds;
/* Bounding rectangle of the drawing surface */
JAWT_Rectangle bounds;
/* Number of rectangles in the clip */
jint clipSize;
/* Clip rectangle array */
JAWT_Rectangle* clip;
} JAWT_DrawingSurfaceInfo;
#define JAWT_LOCK_ERROR 0x00000001
#define JAWT_LOCK_CLIP_CHANGED 0x00000002
#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004
#define JAWT_LOCK_SURFACE_CHANGED 0x00000008
/*
* JAWT_DrawingSurface
* Structure for containing the underlying drawing information of a component.
* All operations on a JAWT_DrawingSurface MUST be performed from the same
* thread as the call to GetDrawingSurface.
*/
typedef struct jawt_DrawingSurface {
/*
* Cached reference to the Java environment of the calling thread.
* If Lock(), Unlock(), GetDrawingSurfaceInfo() or
* FreeDrawingSurfaceInfo() are called from a different thread,
* this data member should be set before calling those functions.
*/
JNIEnv* env;
/* Cached reference to the target object */
jobject target;
/*
* Lock the surface of the target component for native rendering.
* When finished drawing, the surface must be unlocked with
* Unlock(). This function returns a bitmask with one or more of the
* following values:
*
* JAWT_LOCK_ERROR - When an error has occurred and the surface could not
* be locked.
*
* JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
*
* JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
*
* JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
*/
jint (JNICALL *Lock)
(struct jawt_DrawingSurface* ds);
/*
* Get the drawing surface info.
* The value returned may be cached, but the values may change if
* additional calls to Lock() or Unlock() are made.
* Lock() must be called before this can return a valid value.
* Returns NULL if an error has occurred.
* When finished with the returned value, FreeDrawingSurfaceInfo must be
* called.
*/
JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
(struct jawt_DrawingSurface* ds);
/*
* Free the drawing surface info.
*/
void (JNICALL *FreeDrawingSurfaceInfo)
(JAWT_DrawingSurfaceInfo* dsi);
/*
* Unlock the drawing surface of the target component for native rendering.
*/
void (JNICALL *Unlock)
(struct jawt_DrawingSurface* ds);
} JAWT_DrawingSurface;
/*
* JAWT
* Structure for containing native AWT functions.
*/
typedef struct jawt {
/*
* Version of this structure. This must always be set before
* calling JAWT_GetAWT()
*/
jint version;
/*
* Return a drawing surface from a target jobject. This value
* may be cached.
* Returns NULL if an error has occurred.
* Target must be a java.awt.Component (should be a Canvas
* or Window for native rendering).
* FreeDrawingSurface() must be called when finished with the
* returned JAWT_DrawingSurface.
*/
JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
(JNIEnv* env, jobject target);
/*
* Free the drawing surface allocated in GetDrawingSurface.
*/
void (JNICALL *FreeDrawingSurface)
(JAWT_DrawingSurface* ds);
/*
* Since 1.4
* Locks the entire AWT for synchronization purposes
*/
void (JNICALL *Lock)(JNIEnv* env);
/*
* Since 1.4
* Unlocks the entire AWT for synchronization purposes
*/
void (JNICALL *Unlock)(JNIEnv* env);
/*
* Since 1.4
* Returns a reference to a java.awt.Component from a native
* platform handle. On Windows, this corresponds to an HWND;
* on Solaris and Linux, this is a Drawable. For other platforms,
* see the appropriate machine-dependent header file for a description.
* The reference returned by this function is a local
* reference that is only valid in this environment.
* This function returns a NULL reference if no component could be
* found with matching platform information.
*/
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
} JAWT;
/*
* Get the AWT native structure. This function returns JNI_FALSE if
* an error occurs.
*/
_JNI_IMPORT_OR_EXPORT_
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
#define JAWT_VERSION_1_3 0x00010003
#define JAWT_VERSION_1_4 0x00010004
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* !_JAVASOFT_JAWT_H_ */

View File

@ -1,237 +0,0 @@
/*
* @(#)jdwpTransport.h 1.7 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*
* Java Debug Wire Protocol Transport Service Provider Interface.
*/
#ifndef JDWPTRANSPORT_H
#define JDWPTRANSPORT_H
#include "jni.h"
enum {
JDWPTRANSPORT_VERSION_1_0 = 0x00010000
};
#ifdef __cplusplus
extern "C" {
#endif
struct jdwpTransportNativeInterface_;
struct _jdwpTransportEnv;
#ifdef __cplusplus
typedef _jdwpTransportEnv jdwpTransportEnv;
#else
typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
#endif /* __cplusplus */
/*
* Errors. Universal errors with JVMTI/JVMDI equivalents keep the
* values the same.
*/
typedef enum {
JDWPTRANSPORT_ERROR_NONE = 0,
JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
JDWPTRANSPORT_ERROR_INTERNAL = 113,
JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
JDWPTRANSPORT_ERROR_IO_ERROR = 202,
JDWPTRANSPORT_ERROR_TIMEOUT = 203,
JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
} jdwpTransportError;
/*
* Structure to define capabilities
*/
typedef struct {
unsigned int can_timeout_attach :1;
unsigned int can_timeout_accept :1;
unsigned int can_timeout_handshake :1;
unsigned int reserved3 :1;
unsigned int reserved4 :1;
unsigned int reserved5 :1;
unsigned int reserved6 :1;
unsigned int reserved7 :1;
unsigned int reserved8 :1;
unsigned int reserved9 :1;
unsigned int reserved10 :1;
unsigned int reserved11 :1;
unsigned int reserved12 :1;
unsigned int reserved13 :1;
unsigned int reserved14 :1;
unsigned int reserved15 :1;
} JDWPTransportCapabilities;
/*
* Structures to define packet layout.
*
* See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
*/
enum {
JDWPTRANSPORT_FLAGS_NONE = 0x0,
JDWPTRANSPORT_FLAGS_REPLY = 0x80
};
typedef struct {
jint len;
jint id;
jbyte flags;
jbyte cmdSet;
jbyte cmd;
jbyte *data;
} jdwpCmdPacket;
typedef struct {
jint len;
jint id;
jbyte flags;
jshort errorCode;
jbyte *data;
} jdwpReplyPacket;
typedef struct {
union {
jdwpCmdPacket cmd;
jdwpReplyPacket reply;
} type;
} jdwpPacket;
/*
* JDWP functions called by the transport.
*/
typedef struct jdwpTransportCallback {
void *(*alloc)(jint numBytes); /* Call this for all allocations */
void (*free)(void *buffer); /* Call this for all deallocations */
} jdwpTransportCallback;
typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
jdwpTransportCallback *callback,
jint version,
jdwpTransportEnv** env);
/* Function Interface */
struct jdwpTransportNativeInterface_ {
/* 1 : RESERVED */
void *reserved1;
/* 2 : Get Capabilities */
jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
JDWPTransportCapabilities *capabilities_ptr);
/* 3 : Attach */
jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
const char* address,
jlong attach_timeout,
jlong handshake_timeout);
/* 4: StartListening */
jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
const char* address,
char** actual_address);
/* 5: StopListening */
jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
/* 6: Accept */
jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
jlong accept_timeout,
jlong handshake_timeout);
/* 7: IsOpen */
jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
/* 8: Close */
jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
/* 9: ReadPacket */
jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
jdwpPacket *pkt);
/* 10: Write Packet */
jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
const jdwpPacket* pkt);
/* 11: GetLastError */
jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
char** error);
};
/*
* Use inlined functions so that C++ code can use syntax such as
* env->Attach("mymachine:5000", 10*1000, 0);
*
* rather than using C's :-
*
* (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
*/
struct _jdwpTransportEnv {
const struct jdwpTransportNativeInterface_ *functions;
#ifdef __cplusplus
jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
return functions->GetCapabilities(this, capabilities_ptr);
}
jdwpTransportError Attach(const char* address, jlong attach_timeout,
jlong handshake_timeout) {
return functions->Attach(this, address, attach_timeout, handshake_timeout);
}
jdwpTransportError StartListening(const char* address,
char** actual_address) {
return functions->StartListening(this, address, actual_address);
}
jdwpTransportError StopListening(void) {
return functions->StopListening(this);
}
jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
return functions->Accept(this, accept_timeout, handshake_timeout);
}
jboolean IsOpen(void) {
return functions->IsOpen(this);
}
jdwpTransportError Close(void) {
return functions->Close(this);
}
jdwpTransportError ReadPacket(jdwpPacket *pkt) {
return functions->ReadPacket(this, pkt);
}
jdwpTransportError WritePacket(const jdwpPacket* pkt) {
return functions->WritePacket(this, pkt);
}
jdwpTransportError GetLastError(char** error) {
return functions->GetLastError(this, error);
}
#endif /* __cplusplus */
};
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* JDWPTRANSPORT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,642 +0,0 @@
/*
* @(#)jvmpi.h 1.28 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _JAVASOFT_JVMPI_H_
#define _JAVASOFT_JVMPI_H_
#include "jni.h"
#define JVMPI_VERSION_1 ((jint)0x10000001) /* implied 0 for minor version */
#define JVMPI_VERSION_1_1 ((jint)0x10000002)
#define JVMPI_VERSION_1_2 ((jint)0x10000003)
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*jvmpi_void_function_of_void)(void *);
#ifdef __cplusplus
}
#endif
/****************************************************************
* Profiler interface data structures.
****************************************************************/
/* identifier types. */
struct _jobjectID;
typedef struct _jobjectID * jobjectID; /* type of object ids */
/* raw monitors */
struct _JVMPI_RawMonitor;
typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;
/* call frame */
typedef struct {
jint lineno; /* line number in the source file */
jmethodID method_id; /* method executed in this frame */
} JVMPI_CallFrame;
/* call trace */
typedef struct {
JNIEnv *env_id; /* Env where trace was recorded */
jint num_frames; /* number of frames in this trace */
JVMPI_CallFrame *frames; /* frames */
} JVMPI_CallTrace;
/* method */
typedef struct {
char *method_name; /* name of method */
char *method_signature; /* signature of method */
jint start_lineno; /* -1 if native, abstract .. */
jint end_lineno; /* -1 if native, abstract .. */
jmethodID method_id; /* id assigned to this method */
} JVMPI_Method;
/* Field */
typedef struct {
char *field_name; /* name of field */
char *field_signature; /* signature of field */
} JVMPI_Field;
/* line number info for a compiled method */
typedef struct {
jint offset; /* offset from beginning of method */
jint lineno; /* lineno from beginning of src file */
} JVMPI_Lineno;
/* event */
typedef struct {
jint event_type; /* event_type */
JNIEnv *env_id; /* env where this event occured */
union {
struct {
const char *class_name; /* class name */
char *source_name; /* name of source file */
jint num_interfaces; /* number of interfaces implemented */
jint num_methods; /* number of methods in the class */
JVMPI_Method *methods; /* methods */
jint num_static_fields; /* number of static fields */
JVMPI_Field *statics; /* static fields */
jint num_instance_fields; /* number of instance fields */
JVMPI_Field *instances; /* instance fields */
jobjectID class_id; /* id of the class object */
} class_load;
struct {
jobjectID class_id; /* id of the class object */
} class_unload;
struct {
unsigned char *class_data; /* content of class file */
jint class_data_len; /* class file length */
unsigned char *new_class_data; /* instrumented class file */
jint new_class_data_len; /* new class file length */
void * (*malloc_f)(unsigned int); /* memory allocation function */
} class_load_hook;
struct {
jint arena_id;
jobjectID class_id; /* id of object class */
jint is_array; /* JVMPI_NORMAL_OBJECT, ... */
jint size; /* size in number of bytes */
jobjectID obj_id; /* id assigned to this object */
} obj_alloc;
struct {
jobjectID obj_id; /* id of the object */
} obj_free;
struct {
jint arena_id; /* cur arena id */
jobjectID obj_id; /* cur object id */
jint new_arena_id; /* new arena id */
jobjectID new_obj_id; /* new object id */
} obj_move;
struct {
jint arena_id; /* id of arena */
const char *arena_name; /* name of arena */
} new_arena;
struct {
jint arena_id; /* id of arena */
} delete_arena;
struct {
char *thread_name; /* name of thread */
char *group_name; /* name of group */
char *parent_name; /* name of parent */
jobjectID thread_id; /* id of the thread object */
JNIEnv *thread_env_id;
} thread_start;
struct {
int dump_level; /* level of the heap dump info */
char *begin; /* where all the root records begin,
please see the heap dump buffer
format described below */
char *end; /* where the object records end. */
jint num_traces; /* number of thread traces,
0 if dump level = JVMPI_DUMP_LEVEL_0 */
JVMPI_CallTrace *traces; /* thread traces collected during
heap dump */
} heap_dump;
struct {
jobjectID obj_id; /* object id */
jobject ref_id; /* id assigned to the globalref */
} jni_globalref_alloc;
struct {
jobject ref_id; /* id of the global ref */
} jni_globalref_free;
struct {
jmethodID method_id; /* method */
} method;
struct {
jmethodID method_id; /* id of method */
jobjectID obj_id; /* id of target object */
} method_entry2;
struct {
jmethodID method_id; /* id of compiled method */
void *code_addr; /* code start addr. in memory */
jint code_size; /* code size */
jint lineno_table_size; /* size of lineno table */
JVMPI_Lineno *lineno_table; /* lineno info */
} compiled_method_load;
struct {
jmethodID method_id; /* id of unloaded compiled method */
} compiled_method_unload;
struct {
jmethodID method_id; /* id of the method the instruction belongs to */
jint offset; /* instruction offset in the method's bytecode */
union {
struct {
jboolean is_true; /* whether true or false branch is taken */
} if_info;
struct {
jint key; /* top stack value used as an index */
jint low; /* min value of the index */
jint hi; /* max value of the index */
} tableswitch_info;
struct {
jint chosen_pair_index; /* actually chosen pair index (0-based)
* if chosen_pair_index == pairs_total then
* the 'default' branch is taken
*/
jint pairs_total; /* total number of lookupswitch pairs */
} lookupswitch_info;
} u;
} instruction;
struct {
char *begin; /* beginning of dump buffer,
see below for format */
char *end; /* end of dump buffer */
jint num_traces; /* number of traces */
JVMPI_CallTrace *traces; /* traces of all threads */
jint *threads_status; /* status of all threads */
} monitor_dump;
struct {
const char *name; /* name of raw monitor */
JVMPI_RawMonitor id; /* id */
} raw_monitor;
struct {
jobjectID object; /* Java object */
} monitor;
struct {
jobjectID object; /* Java object */
jlong timeout; /* timeout period */
} monitor_wait;
struct {
jlong used_objects;
jlong used_object_space;
jlong total_object_space;
} gc_info;
struct {
jint data_len;
char *data;
} object_dump;
} u;
} JVMPI_Event;
/* interface functions */
typedef struct {
jint version; /* JVMPI version */
/* ------interface implemented by the profiler------ */
/**
* Function called by the JVM to notify an event.
*/
void (*NotifyEvent)(JVMPI_Event *event);
/* ------interface implemented by the JVM------ */
/**
* Function called by the profiler to enable/disable/send notification
* for a particular event type.
*
* event_type - event_type
* arg - event specific arg
*
* return JVMPI_NOT_AVAILABLE, JVMPI_SUCCESS or JVMPI_FAIL
*/
jint (*EnableEvent)(jint event_type, void *arg);
jint (*DisableEvent)(jint event_type, void *arg);
jint (*RequestEvent)(jint event_type, void *arg);
/**
* Function called by the profiler to get a stack
* trace from the JVM.
*
* trace - trace data structure to be filled
* depth - maximum depth of the trace.
*/
void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
/**
* Function called by profiler when it wants to exit/stop.
*/
void (*ProfilerExit)(jint);
/**
* Utility functions provided by the JVM.
*/
JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
/**
* Function called by the profiler to get the current thread's CPU time.
*
* return time in nanoseconds;
*/
jlong (*GetCurrentThreadCpuTime)(void);
void (*SuspendThread)(JNIEnv *env);
void (*ResumeThread)(JNIEnv *env);
jint (*GetThreadStatus)(JNIEnv *env);
jboolean (*ThreadHasRun)(JNIEnv *env);
/* This function can be called safely only after JVMPI_EVENT_VM_INIT_DONE
notification by the JVM. */
jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
/* thread local storage access functions to avoid locking in time
critical functions */
void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
void * (*GetThreadLocalStorage)(JNIEnv *env_id);
/* control GC */
void (*DisableGC)(void);
void (*EnableGC)(void);
void (*RunGC)(void);
jobjectID (*GetThreadObject)(JNIEnv *env);
jobjectID (*GetMethodClass)(jmethodID mid);
/* JNI <-> jobject conversions */
jobject (*jobjectID2jobject)(jobjectID jid);
jobjectID (*jobject2jobjectID)(jobject jobj);
void (*SuspendThreadList)
(jint reqCount, JNIEnv **reqList, jint *results);
void (*ResumeThreadList)
(jint reqCount, JNIEnv **reqList, jint *results);
} JVMPI_Interface;
/* type of argument passed to RequestEvent for heap dumps */
typedef struct {
jint heap_dump_level;
} JVMPI_HeapDumpArg;
/**********************************************************************
* Constants and formats used in JVM Profiler Interface.
**********************************************************************/
/*
* Event type constants.
*/
#define JVMPI_EVENT_METHOD_ENTRY ((jint)1)
#define JVMPI_EVENT_METHOD_ENTRY2 ((jint)2)
#define JVMPI_EVENT_METHOD_EXIT ((jint)3)
#define JVMPI_EVENT_OBJECT_ALLOC ((jint)4)
#define JVMPI_EVENT_OBJECT_FREE ((jint)5)
#define JVMPI_EVENT_OBJECT_MOVE ((jint)6)
#define JVMPI_EVENT_COMPILED_METHOD_LOAD ((jint)7)
#define JVMPI_EVENT_COMPILED_METHOD_UNLOAD ((jint)8)
#define JVMPI_EVENT_INSTRUCTION_START ((jint)9)
#define JVMPI_EVENT_THREAD_START ((jint)33)
#define JVMPI_EVENT_THREAD_END ((jint)34)
#define JVMPI_EVENT_CLASS_LOAD_HOOK ((jint)35)
#define JVMPI_EVENT_HEAP_DUMP ((jint)37)
#define JVMPI_EVENT_JNI_GLOBALREF_ALLOC ((jint)38)
#define JVMPI_EVENT_JNI_GLOBALREF_FREE ((jint)39)
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC ((jint)40)
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE ((jint)41)
#define JVMPI_EVENT_CLASS_LOAD ((jint)42)
#define JVMPI_EVENT_CLASS_UNLOAD ((jint)43)
#define JVMPI_EVENT_DATA_DUMP_REQUEST ((jint)44)
#define JVMPI_EVENT_DATA_RESET_REQUEST ((jint)45)
#define JVMPI_EVENT_JVM_INIT_DONE ((jint)46)
#define JVMPI_EVENT_JVM_SHUT_DOWN ((jint)47)
#define JVMPI_EVENT_ARENA_NEW ((jint)48)
#define JVMPI_EVENT_ARENA_DELETE ((jint)49)
#define JVMPI_EVENT_OBJECT_DUMP ((jint)50)
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER ((jint)51)
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED ((jint)52)
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT ((jint)53)
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTER ((jint)54)
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED ((jint)55)
#define JVMPI_EVENT_MONITOR_CONTENDED_EXIT ((jint)56)
#define JVMPI_EVENT_MONITOR_WAIT ((jint)57)
#define JVMPI_EVENT_MONITOR_WAITED ((jint)58)
#define JVMPI_EVENT_MONITOR_DUMP ((jint)59)
#define JVMPI_EVENT_GC_START ((jint)60)
#define JVMPI_EVENT_GC_FINISH ((jint)61)
#define JVMPI_MAX_EVENT_TYPE_VAL ((jint)61)
/* old definitions, to be removed */
#define JVMPI_EVENT_LOAD_COMPILED_METHOD ((jint)7)
#define JVMPI_EVENT_UNLOAD_COMPILED_METHOD ((jint)8)
#define JVMPI_EVENT_NEW_ARENA ((jint)48)
#define JVMPI_EVENT_DELETE_ARENA ((jint)49)
#define JVMPI_EVENT_DUMP_DATA_REQUEST ((jint)44)
#define JVMPI_EVENT_RESET_DATA_REQUEST ((jint)45)
#define JVMPI_EVENT_OBJ_ALLOC ((jint)4)
#define JVMPI_EVENT_OBJ_FREE ((jint)5)
#define JVMPI_EVENT_OBJ_MOVE ((jint)6)
#define JVMPI_REQUESTED_EVENT ((jint)0x10000000)
/*
* enabling/disabling event notification.
*/
/* results */
#define JVMPI_SUCCESS ((jint)0)
#define JVMPI_NOT_AVAILABLE ((jint)1)
#define JVMPI_FAIL ((jint)-1)
/*
* Thread status
*/
enum {
JVMPI_THREAD_RUNNABLE = 1,
JVMPI_THREAD_MONITOR_WAIT,
JVMPI_THREAD_CONDVAR_WAIT
};
#define JVMPI_THREAD_SUSPENDED 0x8000
#define JVMPI_THREAD_INTERRUPTED 0x4000
/*
* Thread priority
*/
#define JVMPI_MINIMUM_PRIORITY 1
#define JVMPI_MAXIMUM_PRIORITY 10
#define JVMPI_NORMAL_PRIORITY 5
/*
* Object type constants.
*/
#define JVMPI_NORMAL_OBJECT ((jint)0)
#define JVMPI_CLASS ((jint)2)
#define JVMPI_BOOLEAN ((jint)4)
#define JVMPI_CHAR ((jint)5)
#define JVMPI_FLOAT ((jint)6)
#define JVMPI_DOUBLE ((jint)7)
#define JVMPI_BYTE ((jint)8)
#define JVMPI_SHORT ((jint)9)
#define JVMPI_INT ((jint)10)
#define JVMPI_LONG ((jint)11)
/*
* Monitor dump constants.
*/
#define JVMPI_MONITOR_JAVA 0x01
#define JVMPI_MONITOR_RAW 0x02
/*
* Heap dump constants.
*/
#define JVMPI_GC_ROOT_UNKNOWN 0xff
#define JVMPI_GC_ROOT_JNI_GLOBAL 0x01
#define JVMPI_GC_ROOT_JNI_LOCAL 0x02
#define JVMPI_GC_ROOT_JAVA_FRAME 0x03
#define JVMPI_GC_ROOT_NATIVE_STACK 0x04
#define JVMPI_GC_ROOT_STICKY_CLASS 0x05
#define JVMPI_GC_ROOT_THREAD_BLOCK 0x06
#define JVMPI_GC_ROOT_MONITOR_USED 0x07
#define JVMPI_GC_ROOT_THREAD_OBJ 0x08
#define JVMPI_GC_CLASS_DUMP 0x20
#define JVMPI_GC_INSTANCE_DUMP 0x21
#define JVMPI_GC_OBJ_ARRAY_DUMP 0x22
#define JVMPI_GC_PRIM_ARRAY_DUMP 0x23
/*
* Dump levels
*/
#define JVMPI_DUMP_LEVEL_0 ((jint)0)
#define JVMPI_DUMP_LEVEL_1 ((jint)1)
#define JVMPI_DUMP_LEVEL_2 ((jint)2)
/* Types used in dumps -
*
* u1: 1 byte
* u2: 2 bytes
* u4: 4 bytes
* u8: 8 bytes
*
* ty: u1 where:
* JVMPI_CLASS: object
* JVMPI_BOOLEAN: boolean
* JVMPI_CHAR: char
* JVMPI_FLOAT: float
* JVMPI_DOUBLE: double
* JVMPI_BYTE: byte
* JVMPI_SHORT: short
* JVMPI_INT: int
* JVMPI_LONG: long
*
* vl: values, exact type depends on the type of the value:
* JVMPI_BOOLEAN & JVMPI_BYTE: u1
* JVMPI_SHORT & JVMPI_CHAR: u2
* JVMPI_INT & JVMPI_FLOAT: u4
* JVMPI_LONG & JVMPI_DOUBLE: u8
* JVMPI_CLASS: jobjectID
*/
/* Format of the monitor dump buffer:
*
* u1 monitor type
*
* JVMPI_MONITOR_JAVA Java monitor
*
* jobjectID object
* JNIEnv * owner thread
* u4 entry count
* u4 # of threads waiting to enter
* [JNIEnv *]* threads waiting to enter
* u4 # of threads waiting to be notified
* [JNIEnv *]* threads waiting to be notified
*
* JVMPI_MONITOR_RAW raw monitor
*
* char * name
* JVMPI_RawMonitor raw monitor
* JNIEnv * owner thread
* u4 entry count
* u4 # of threads waiting to enter
* [JNIEnv *]* threads waiting to enter
* u4 # of threads waiting to be notified
* [JNIEnv *]* threads waiting to be notified
*/
/* Format of the heap dump buffer depends on the dump level
* specified in the JVMPI_HeapDumpArg passed to RequestEvent as arg.
* The default is JVMPI_DUMP_LEVEL_2.
*
* JVMPI_DUMP_LEVEL_0:
*
* u1 object type (JVMPI_CLASS ...)
* jobjectID object
*
* JVMPI_DUMP_LEVEL_1 and JVMPI_DUMP_LEVEL_2 use the following format:
* In the case of JVMPI_DUMP_LEVEL_1 the values of primitive fields in object
* instance dumps , the values of primitive statics in class dumps and the
* values of primitive arrays are excluded. JVMPI_DUMP_LEVEL_2 includes the
* primitive values.
*
* u1 record type
*
* JVMPI_GC_ROOT_UNKNOWN unknown root
*
* jobjectID object
*
* JVMPI_GC_ROOT_JNI_GLOBAL JNI global ref root
*
* jobjectID object
* jobject JNI global reference
*
* JVMPI_GC_ROOT_JNI_LOCAL JNI local ref
*
* jobjectID object
* JNIEnv * thread
* u4 frame # in stack trace (-1 for empty)
*
* JVMPI_GC_ROOT_JAVA_FRAME Java stack frame
*
* jobjectID object
* JNIEnv * thread
* u4 frame # in stack trace (-1 for empty)
*
* JVMPI_GC_ROOT_NATIVE_STACK Native stack
*
* jobjectID object
* JNIEnv * thread
*
* JVMPI_GC_ROOT_STICKY_CLASS System class
*
* jobjectID class object
*
* JVMPI_GC_ROOT_THREAD_BLOCK Reference from thread block
*
* jobjectID thread object
* JNIEnv * thread
*
* JVMPI_GC_ROOT_MONITOR_USED Busy monitor
*
* jobjectID object
*
* JVMPI_GC_CLASS_DUMP dump of a class object
*
* jobjectID class
* jobjectID super
* jobjectID class loader
* jobjectID signers
* jobjectID protection domain
* jobjectID class name
* void * reserved
*
* u4 instance size (in bytes)
*
* [jobjectID]* interfaces
*
* u2 size of constant pool
* [u2, constant pool index,
* ty, type,
* vl]* value
*
* [vl]* static field values
*
* JVMPI_GC_INSTANCE_DUMP dump of a normal object
*
* jobjectID object
* jobjectID class
* u4 number of bytes that follow
* [vl]* instance field values (class, followed
* by super, super's super ...)
*
* JVMPI_GC_OBJ_ARRAY_DUMP dump of an object array
*
* jobjectID array object
* u4 number of elements
* jobjectID element class
* [jobjectID]* elements
*
* JVMPI_GC_PRIM_ARRAY_DUMP dump of a primitive array
*
* jobjectID array object
* u4 number of elements
* ty element type
* [vl]* elements
*
*/
/* Format of the dump received in JVMPI_EVENT_OBJECT_DUMP:
* All the records have JVMPI_DUMP_LEVEL_2 information.
*
* u1 record type
*
* followed by a:
*
* JVMPI_GC_CLASS_DUMP,
* JVMPI_GC_INSTANCE_DUMP,
* JVMPI_GC_OBJ_ARRAY_DUMP, or
* JVMPI_GC_PRIM_ARRAY_DUMP record.
*/
#endif /* !_JAVASOFT_JVMPI_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +0,0 @@
/*
* @(#)jawt_md.h 1.7 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _JAVASOFT_JAWT_MD_H_
#define _JAVASOFT_JAWT_MD_H_
#include <windows.h>
#include "jawt.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Win32-specific declarations for AWT native interface.
* See notes in jawt.h for an example of use.
*/
typedef struct jawt_Win32DrawingSurfaceInfo {
/* Native window, DDB, or DIB handle */
union {
HWND hwnd;
HBITMAP hbitmap;
void* pbits;
};
/*
* This HDC should always be used instead of the HDC returned from
* BeginPaint() or any calls to GetDC().
*/
HDC hdc;
HPALETTE hpalette;
} JAWT_Win32DrawingSurfaceInfo;
#ifdef __cplusplus
}
#endif
#endif /* !_JAVASOFT_JAWT_MD_H_ */

View File

@ -1,19 +0,0 @@
/*
* @(#)jni_md.h 1.14 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */

View File

@ -6,7 +6,7 @@ if WANT_MJ2
SUBDIRS += mj2 SUBDIRS += mj2
endif endif
if WANT_JPIP if WANT_JPIP_CODE
SUBDIRS += jpip SUBDIRS += jpip
endif endif
@ -15,5 +15,5 @@ CMakeLists.txt \
common/color.c \ common/color.c \
common/color.h \ common/color.h \
common/format_defs.h \ common/format_defs.h \
common/getopt.c \ common/opj_getopt.c \
common/getopt.h common/opj_getopt.h

View File

@ -0,0 +1,25 @@
PROJECT(viewer CXX)
FIND_PACKAGE(wxWidgets REQUIRED)
INCLUDE(${wxWidgets_USE_FILE})
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/..
)
# original flags:
# -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")
SET(OPJV_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/wxjp2parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
)
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)

View File

@ -1,41 +0,0 @@
# Makefile for OPJViewer
# General configuration variables:
CC = $(shell wx-config-2.8 --cxx)
AR = ar
CFLAGS = -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS $(shell wx-config-2.8 --cxxflags) # -g -p -pg -DUSE_JPWL
OPJV_SRCS = source/imagjpeg2000.cpp source/wxj2kparser.cpp source/OPJViewer.cpp source/wxjp2parser.cpp source/OPJDialogs.cpp source/OPJThreads.cpp source/OPJAbout.cpp ../codec/index.c
MODULES = $(OPJV_SRCS:.cpp=.o)
all: opjviewer lib
.cpp.o:
$(CC) $(CFLAGS) -c $< -o $@
lib:
cd ../jpwl; make
opjviewer: $(OPJV_SRCS) lib
$(CC) $(CFLAGS) -I .. -I ../codec -I ../libopenjpeg $(OPJV_SRCS) -o OPJViewer -L ../jpwl -lopenjpeg_JPWL -lm -lstdc++ -ltiff $(shell wx-config-2.8 --libs)
clean:
rm -f OPJViewer *.o *.a
cd ../libopenjpeg; rm -f *.o
#.cpp.o :
# $(CXX) -g -c `wx-config-2.8 --cxxflags` -I ../.. -D wxUSE_LIBOPENJPEG -D wxHACK_BOOLEAN -o $@ $<
#all: $(PROGRAM)
#$(PROGRAM): $(OBJECTS)
# $(CXX) -o $(PROGRAM) $(OBJECTS) -lopenjpeg -L ../.. `wx-config-2.8 --libs`
#clean:
# rm -f *.o $(PROGRAM)

View File

@ -1,290 +0,0 @@
# Microsoft Developer Studio Project File - Name="OPJViewer" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=OPJVIEWER - WIN32 RELEASE
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "OPJViewer.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "OPJViewer.mak" CFG="OPJVIEWER - WIN32 RELEASE"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "OPJViewer - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "OPJViewer - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "OPJViewer - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /D "OPJ_HTMLABOUT" /D "OPJ_MANYFORMATS" /D "OPJ_INICONFIG" /FR /FD /Zm200 /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x409 /i "$(WXWIN28)\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib mxflib.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"$(WXWIN28)\lib\vc_lib" /libpath:"..\jpwl\Release" /libpath:"$(MXFLIB)\build\msvc\Release" /IGNORE:4089
# SUBTRACT LINK32 /pdb:none /nodefaultlib
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Update build number
PostBuild_Cmds=buildupdate.bat
# End Special Build Tool
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "OPJViewer___Win32_Debug"
# PROP BASE Intermediate_Dir "OPJViewer___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "$(WXWIN28)\INCLUDE" /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "_DEBUG" /D "__WXDEBUG__" /D WXDEBUG=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /D "OPJ_INICONFIG" /D "OPJ_MANYFORMATS" /D "USE_JPSEC" /FR /FD /GZ /Zm200 /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /i "$(WXWIN28)\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlibd.lib wxregexd.lib wxpngd.lib wxjpegd.lib wxtiffd.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_html.lib wxmsw28d_adv.lib LibOpenJPEG_JPWLd.lib mxflib.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"$(WXWIN28)\lib\vc_lib" /libpath:"..\jpwl\Debug" /libpath:"$(MXFLIB)\build\msvc\Debug"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "OPJViewer - Win32 Release"
# Name "OPJViewer - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\source\imagjpeg2000.cpp
# End Source File
# Begin Source File
SOURCE=.\source\imagmxf.cpp
# End Source File
# Begin Source File
SOURCE=..\codec\index.c
# End Source File
# Begin Source File
SOURCE=.\source\OPJAbout.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJDialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJThreads.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.cpp
# End Source File
# Begin Source File
SOURCE=.\source\wxj2kparser.cpp
# End Source File
# Begin Source File
SOURCE=.\source\wxjp2parser.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\source\about_htm.h
# End Source File
# Begin Source File
SOURCE=.\source\build.h
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\source\imagjpeg2000.h
# End Source File
# Begin Source File
SOURCE=.\source\imagmxf.h
# End Source File
# Begin Source File
SOURCE=..\codec\index.h
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\source\wx\msw\blank.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\bullseye.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\cdrom.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\computer.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\cross.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\drive.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\file1.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\floppy.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\folder1.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\folder2.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\hand.cur
# End Source File
# Begin Source File
SOURCE=.\source\icon1.xpm
# End Source File
# Begin Source File
SOURCE=.\source\icon2.xpm
# End Source File
# Begin Source File
SOURCE=.\source\icon3.xpm
# End Source File
# Begin Source File
SOURCE=.\source\icon4.xpm
# End Source File
# Begin Source File
SOURCE=.\source\icon5.xpm
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\magnif1.cur
# End Source File
# Begin Source File
SOURCE=.\source\opj_logo.xpm
# End Source File
# Begin Source File
SOURCE=.\source\OPJChild.ico
# End Source File
# Begin Source File
SOURCE=.\source\OPJChild16.xpm
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.ico
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.rc
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer16.xpm
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pbrush.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pencil.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pntleft.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pntright.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\removble.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\rightarr.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\roller.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\std.ico
# End Source File
# End Group
# End Target
# End Project

View File

@ -1,56 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "LibOpenJPEG_JPWL"=..\jpwl\LibOpenJPEG_JPWL.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "OPJViewer"=.\OPJViewer.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name LibOpenJPEG_JPWL
End Project Dependency
}}}
###############################################################################
Project: "mxflib"="..\..\..\..\mxflib-1.0.0\build\msvc\mxflib.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -1,15 +0,0 @@
::== buildupdate.bat
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=2,* delims=^(^) " %%a in ('find /v "" ^< .\source\build.h') do (
rem echo %%a
set /A M = %%a + 1
echo Build %%a done^!
echo wxT^("!M!"^) > buildtemp283746825t347
)
if exist buildtemp283746825t347 move /Y buildtemp283746825t347 .\source\build.h
if exist buildtemp283746825t347 del /F /Q buildtemp283746825t347
::==

View File

@ -360,6 +360,22 @@ wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent)
return panel; return panel;
} }
void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
{
if (event.IsChecked()) {
wxLogMessage(wxT("JPWL enabled"));
m_expcompsCtrl->Enable(true);
m_maxtilesCtrl->Enable(true);
} else {
wxLogMessage(wxT("JPWL disabled"));
m_expcompsCtrl->Enable(false);
m_maxtilesCtrl->Enable(false);
}
}
#endif // USE_JPWL
void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event) void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
{ {
size_t pp; size_t pp;
@ -384,22 +400,6 @@ void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
} }
void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
{
if (event.IsChecked()) {
wxLogMessage(wxT("JPWL enabled"));
m_expcompsCtrl->Enable(true);
m_maxtilesCtrl->Enable(true);
} else {
wxLogMessage(wxT("JPWL disabled"));
m_expcompsCtrl->Enable(false);
m_maxtilesCtrl->Enable(false);
}
}
#endif // USE_JPWL

View File

@ -1373,6 +1373,8 @@ void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
wxT("JPEG 2000 codestream (*.j2k)|*.j2k") wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
wxT("|JPEG 2000 file format (*.jp2)|*.jp2"); wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
#endif #endif
#else
wxT("Houston we have a problem");
#endif #endif
wxFileDialog dialog(this, _T("Save image file"), wxFileDialog dialog(this, _T("Save image file"),

View File

@ -214,8 +214,8 @@ class OPJViewerApp: public wxApp
#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;
int m_framewidth, m_frameheight;
#endif // USE_JPWL #endif // USE_JPWL
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;
@ -782,9 +782,10 @@ public:
#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_framenumCtrl, *m_maxtilesCtrl; wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
wxCheckBox *m_enablejpwlCheck; wxCheckBox *m_enablejpwlCheck;
#endif // USE_JPWL #endif // USE_JPWL
wxSpinCtrl *m_framenumCtrl;
protected: protected:

View File

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char *icon1_xpm[] = { static const char *icon1_xpm[] = {
/* columns rows colors chars-per-pixel */ /* columns rows colors chars-per-pixel */
"32 32 41 1", "32 32 41 1",
"> c #97C4E7", "> c #97C4E7",

View File

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char *icon2_xpm[] = { static const char *icon2_xpm[] = {
/* columns rows colors chars-per-pixel */ /* columns rows colors chars-per-pixel */
"32 32 15 1", "32 32 15 1",
". c Black", ". c Black",

View File

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char *icon3_xpm[] = { static const char *icon3_xpm[] = {
/* columns rows colors chars-per-pixel */ /* columns rows colors chars-per-pixel */
"32 32 41 1", "32 32 41 1",
"6 c #EDF2FB", "6 c #EDF2FB",

View File

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char *icon4_xpm[] = { static const char *icon4_xpm[] = {
/* columns rows colors chars-per-pixel */ /* columns rows colors chars-per-pixel */
"32 32 5 1", "32 32 5 1",
". c Black", ". c Black",

View File

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char *icon5_xpm[] = { static const char *icon5_xpm[] = {
/* columns rows colors chars-per-pixel */ /* columns rows colors chars-per-pixel */
"32 32 41 1", "32 32 41 1",
"0 c #AAC1E8", "0 c #AAC1E8",

View File

@ -93,7 +93,7 @@ unsigned short int marker_val[] = {
}; };
// Marker names // Marker names
char *marker_name[] = { static const char *marker_name[] = {
"SOC", "SOT", "SOD", "EOC", "SOC", "SOT", "SOD", "EOC",
"SIZ", "SIZ",
"COD", "COC", "RGN", "QCD", "QCC", "POD", "COD", "COC", "RGN", "QCD", "QCC", "POD",
@ -109,7 +109,7 @@ char *marker_name[] = {
}; };
// Marker descriptions // Marker descriptions
char *marker_descr[] = { static const char *marker_descr[] = {
"Start of codestream", "Start of tile-part", "Start of data", "End of codestream", "Start of codestream", "Start of tile-part", "Start of data", "End of codestream",
"Image and tile size", "Image and tile size",
"Coding style default", "Coding style component", "Region-of-interest", "Quantization default", "Coding style default", "Coding style component", "Region-of-interest", "Quantization default",

View File

@ -5,15 +5,8 @@ SET(common_SRCS
convert.c convert.c
index.c index.c
${OPENJPEG_SOURCE_DIR}/applications/common/color.c ${OPENJPEG_SOURCE_DIR}/applications/common/color.c
) ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
SET(common_SRCS
${common_SRCS}
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
) )
ENDIF(DONT_HAVE_GETOPT)
# Headers file are located here: # Headers file are located here:
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
@ -37,7 +30,14 @@ ENDIF(WIN32)
FOREACH(exe j2k_to_image image_to_j2k j2k_dump) FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS}) ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME} TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} ) ${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: # On unix you need to link to the math library:
IF(UNIX) IF(UNIX)
@ -70,7 +70,14 @@ IF(BUILD_JPWL)
) )
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) ${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) IF(UNIX)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m) TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
@ -87,7 +94,14 @@ IF(BUILD_JPWL)
) )
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME}) ${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) IF(UNIX)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m) TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
@ -96,4 +110,4 @@ IF(BUILD_JPWL)
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
) )
ENDIF(BUILD_JPWL) ENDIF(BUILD_JPWL)

View File

@ -22,7 +22,7 @@ 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_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
j2k_to_image_SOURCES = \ j2k_to_image_SOURCES = \
../common/color.c \ ../common/color.c \
../common/getopt.c \ ../common/opj_getopt.c \
convert.c \ convert.c \
index.c \ index.c \
j2k_to_image.c \ j2k_to_image.c \
@ -41,7 +41,7 @@ image_to_j2k_CPPFLAGS = \
image_to_j2k_CFLAGS = image_to_j2k_CFLAGS =
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
image_to_j2k_SOURCES = \ image_to_j2k_SOURCES = \
../common/getopt.c \ ../common/opj_getopt.c \
convert.c \ convert.c \
index.c \ index.c \
image_to_j2k.c \ image_to_j2k.c \
@ -60,10 +60,10 @@ j2k_dump_CPPFLAGS = \
j2k_dump_CFLAGS = j2k_dump_CFLAGS =
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
j2k_dump_SOURCES = \ j2k_dump_SOURCES = \
../common/getopt.c \ ../common/opj_getopt.c \
index.c \ index.c \
j2k_dump.c \ j2k_dump.c \
../common/getopt.h \ ../common/opj_getopt.h \
index.h index.h
JPWL_j2k_to_image_CPPFLAGS = \ JPWL_j2k_to_image_CPPFLAGS = \
@ -81,7 +81,7 @@ 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@ JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@
JPWL_j2k_to_image_SOURCES = \ JPWL_j2k_to_image_SOURCES = \
../common/color.c \ ../common/color.c \
../common/getopt.c \ ../common/opj_getopt.c \
index.c \ index.c \
convert.c \ convert.c \
j2k_to_image.c j2k_to_image.c
@ -99,7 +99,7 @@ JPWL_image_to_j2k_CFLAGS =
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@ JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
JPWL_image_to_j2k_SOURCES = \ JPWL_image_to_j2k_SOURCES = \
..//common/getopt.c \ ../common/opj_getopt.c \
index.c \ index.c \
convert.c \ convert.c \
image_to_j2k.c image_to_j2k.c

View File

@ -1,68 +0,0 @@
#codec Makefile
include ../config.nix
CFLAGS = -Wall
INSTALL_BIN = $(prefix)/bin
INCLUDE = -I.. -I. -I../libopenjpeg -I../common
USERLIBS = -lm
ifeq ($(WITH_TIFF),yes)
INCLUDE += $(TIFF_INCLUDE)
USERLIBS += $(TIFF_LIB)
endif
ifeq ($(WITH_PNG),yes)
INCLUDE += $(PNG_INCLUDE)
USERLIBS += $(PNG_LIB)
endif
ifeq ($(WITH_LCMS2),yes)
INCLUDE += $(LCMS2_INCLUDE)
USERLIBS += $(LCMS2_LIB)
endif
ifeq ($(WITH_LCMS1),yes)
INCLUDE += $(LCMS1_INCLUDE)
USERLIBS += $(LCMS1_LIB)
endif
CFLAGS += $(INCLUDE) -lstdc++ # -g -p -pg
all: j2k_to_image image_to_j2k j2k_dump
install -d ../bin
install j2k_to_image image_to_j2k j2k_dump ../bin
ifeq ($(ENABLE_SHARED),yes)
ELIB = ../libopenjpeg.so.$(MAJOR).$(MINOR).$(BUILD)
else
ELIB = ../libopenjpeg.a
endif
j2k_to_image: j2k_to_image.c $(ELIB)
$(CC) $(CFLAGS) ../common/getopt.c index.c convert.c \
../common/color.c j2k_to_image.c \
-o j2k_to_image $(ELIB) $(USERLIBS)
image_to_j2k: image_to_j2k.c $(ELIB)
$(CC) $(CFLAGS) ../common/getopt.c index.c convert.c image_to_j2k.c \
-o image_to_j2k $(ELIB) $(USERLIBS)
j2k_dump: j2k_dump.c $(ELIB)
$(CC) $(CFLAGS) ../common/getopt.c index.c j2k_dump.c \
-o j2k_dump $(ELIB) $(USERLIBS)
clean:
rm -f j2k_to_image image_to_j2k j2k_dump
install: all
install -d $(DESTDIR)$(INSTALL_BIN)
install -m 755 -o root -g root j2k_to_image $(DESTDIR)$(INSTALL_BIN)
install -m 755 -o root -g root image_to_j2k $(DESTDIR)$(INSTALL_BIN)
install -m 755 -o root -g root j2k_dump $(DESTDIR)$(INSTALL_BIN)
uninstall:
rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_to_image
rm -f $(DESTDIR)$(INSTALL_BIN)/image_to_j2k
rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_dump

View File

@ -67,9 +67,9 @@ static int int_floorlog2(int a) {
<<-- <<-- <<-- <<-- */ <<-- <<-- <<-- <<-- */
// TGA header definition. #ifdef INFORMATION_ONLY
#pragma pack(push,1) // Pack structure byte aligned /* TGA header definition. */
typedef struct tga_header struct tga_header
{ {
unsigned char id_length; /* Image id field length */ unsigned char id_length; /* Image id field length */
unsigned char colour_map_type; /* Colour map type */ unsigned char colour_map_type; /* Colour map type */
@ -89,35 +89,66 @@ typedef struct tga_header
unsigned short image_height; /* Image height */ unsigned short image_height; /* Image height */
unsigned char pixel_depth; /* Pixel depth */ unsigned char pixel_depth; /* Pixel depth */
unsigned char image_desc; /* Image descriptor */ unsigned char image_desc; /* Image descriptor */
} tga_header; };
#pragma pack(pop) // Return to normal structure packing alignment. #endif /* INFORMATION_ONLY */
static unsigned short get_ushort(unsigned short val) {
#ifdef ORDER_BIGENDIAN
return( ((val & 0xff) << 8) + (val >> 8) );
#else
return( val );
#endif
}
#define TGA_HEADER_SIZE 18
int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
unsigned int *width, unsigned int *height, int *flip_image) unsigned int *width, unsigned int *height, int *flip_image)
{ {
int palette_size; int palette_size;
tga_header tga ; unsigned char *tga ;
unsigned char id_len, cmap_type, image_type;
unsigned char pixel_depth, image_desc;
unsigned short cmap_index, cmap_len, cmap_entry_size;
unsigned short x_origin, y_origin, image_w, image_h;
if (!bits_per_pixel || !width || !height || !flip_image) if (!bits_per_pixel || !width || !height || !flip_image)
return 0; return 0;
tga = (unsigned char*)malloc(18);
// Read TGA header
if ( fread((unsigned char*)&tga, sizeof(tga_header), 1, fp) != 1 ) if ( fread(tga, TGA_HEADER_SIZE, 1, fp) != 1 )
{ {
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
return 0 ; return 0 ;
} }
id_len = (unsigned char)tga[0];
cmap_type = (unsigned char)tga[1];
image_type = (unsigned char)tga[2];
cmap_index = get_ushort(*(unsigned short*)(&tga[3]));
cmap_len = get_ushort(*(unsigned short*)(&tga[5]));
cmap_entry_size = (unsigned char)tga[7];
*bits_per_pixel = tga.pixel_depth;
*width = tga.image_width;
*height = tga.image_height ;
// Ignore tga identifier, if present ... x_origin = get_ushort(*(unsigned short*)(&tga[8]));
if (tga.id_length) y_origin = get_ushort(*(unsigned short*)(&tga[10]));
image_w = get_ushort(*(unsigned short*)(&tga[12]));
image_h = get_ushort(*(unsigned short*)(&tga[14]));
pixel_depth = (unsigned char)tga[16];
image_desc = (unsigned char)tga[17];
free(tga);
*bits_per_pixel = (unsigned int)pixel_depth;
*width = (unsigned int)image_w;
*height = (unsigned int)image_h;
/* Ignore tga identifier, if present ... */
if (id_len)
{ {
unsigned char *id = (unsigned char *) malloc(tga.id_length); unsigned char *id = (unsigned char *) malloc(id_len);
if ( !fread(id, tga.id_length, 1, fp) ) if ( !fread(id, id_len, 1, fp) )
{ {
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
free(id); free(id);
@ -126,19 +157,19 @@ int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
free(id); free(id);
} }
// Test for compressed formats ... not yet supported ... /* Test for compressed formats ... not yet supported ...
// Note :- 9 - RLE encoded palettized. // Note :- 9 - RLE encoded palettized.
// 10 - RLE encoded RGB. // 10 - RLE encoded RGB. */
if (tga.image_type > 8) if (image_type > 8)
{ {
fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n"); fprintf(stderr, "Sorry, compressed tga files are not currently supported.\n");
return 0 ; return 0 ;
} }
*flip_image = !(tga.image_desc & 32); *flip_image = !(image_desc & 32);
// Palettized formats are not yet supported, skip over the palette, if present ... /* Palettized formats are not yet supported, skip over the palette, if present ... */
palette_size = tga.colour_map_length * (tga.colour_map_entry_size/8); palette_size = cmap_len * (cmap_entry_size/8);
if (palette_size>0) if (palette_size>0)
{ {
@ -151,31 +182,56 @@ int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height, int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
opj_bool flip_image) opj_bool flip_image)
{ {
tga_header tga; unsigned short image_w, image_h, us0;
unsigned char uc0, image_type;
unsigned char pixel_depth, image_desc;
if (!bits_per_pixel || !width || !height) if (!bits_per_pixel || !width || !height)
return 0; return 0;
memset(&tga, 0, sizeof(tga_header)); pixel_depth = 0;
if ( bits_per_pixel < 256 ) if ( bits_per_pixel < 256 )
tga.pixel_depth = (unsigned char)bits_per_pixel; pixel_depth = (unsigned char)bits_per_pixel;
else{ else{
fprintf(stderr,"ERROR: Wrong bits per pixel inside tga_header"); fprintf(stderr,"ERROR: Wrong bits per pixel inside tga_header");
return 0; return 0;
} }
tga.image_width = (unsigned short)width; uc0 = 0;
tga.image_height = (unsigned short)height;
tga.image_type = 2; // Uncompressed. if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; /* id_length */
tga.image_desc = 8; // 8 bits per component. if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; /* colour_map_type */
image_type = 2; /* Uncompressed. */
if(fwrite(&image_type, 1, 1, fp) != 1) goto fails;
us0 = 0;
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; /* colour_map_index */
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; /* colour_map_length */
if(fwrite(&uc0, 1, 1, fp) != 1) goto fails; /* colour_map_entry_size */
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; /* x_origin */
if(fwrite(&us0, 2, 1, fp) != 1) goto fails; /* y_origin */
image_w = (unsigned short)width;
image_h = (unsigned short) height;
if(fwrite(&image_w, 2, 1, fp) != 1) goto fails;
if(fwrite(&image_h, 2, 1, fp) != 1) goto fails;
if(fwrite(&pixel_depth, 1, 1, fp) != 1) goto fails;
image_desc = 8; /* 8 bits per component. */
if (flip_image) if (flip_image)
tga.image_desc |= 32; image_desc |= 32;
if(fwrite(&image_desc, 1, 1, fp) != 1) goto fails;
// Write TGA header
fwrite((unsigned char*)&tga, sizeof(tga_header), 1, fp);
return 1; return 1;
fails:
fputs("\nwrite_tgaheader: write ERROR\n", stderr);
return 0;
} }
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
@ -201,15 +257,15 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image)) if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image))
return NULL; return NULL;
// We currently only support 24 & 32 bit tga's ... /* We currently only support 24 & 32 bit tga's ... */
if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32))) if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32)))
return NULL; return NULL;
/* initialize image components */ /* initialize image components */
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
mono = (pixel_bit_depth == 8) || (pixel_bit_depth == 16); // Mono with & without alpha. mono = (pixel_bit_depth == 8) || (pixel_bit_depth == 16); /* Mono with & without alpha. */
save_alpha = (pixel_bit_depth == 16) || (pixel_bit_depth == 32); // Mono with alpha, or RGB with alpha save_alpha = (pixel_bit_depth == 16) || (pixel_bit_depth == 32); /* Mono with alpha, or RGB with alpha */
if (mono) { if (mono) {
color_space = CLRSPC_GRAY; color_space = CLRSPC_GRAY;
@ -333,12 +389,13 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
int imagetotga(opj_image_t * image, const char *outfile) { int imagetotga(opj_image_t * image, const char *outfile) {
int width, height, bpp, x, y; int width, height, bpp, x, y;
opj_bool write_alpha; opj_bool write_alpha;
int i; int i, adjustR, adjustG, adjustB;
unsigned int alpha_channel; unsigned int alpha_channel;
float r,g,b,a; float r,g,b,a;
unsigned char value; unsigned char value;
float scale; float scale;
FILE *fdest; FILE *fdest;
size_t res;
fdest = fopen(outfile, "wb"); fdest = fopen(outfile, "wb");
if (!fdest) { if (!fdest) {
@ -358,10 +415,10 @@ int imagetotga(opj_image_t * image, const char *outfile) {
width = image->comps[0].w; width = image->comps[0].w;
height = image->comps[0].h; height = image->comps[0].h;
// Mono with alpha, or RGB with alpha. /* Mono with alpha, or RGB with alpha. */
write_alpha = (image->numcomps==2) || (image->numcomps==4); write_alpha = (image->numcomps==2) || (image->numcomps==4);
// Write TGA header /* Write TGA header */
bpp = write_alpha ? 32 : 24; bpp = write_alpha ? 32 : 24;
if (!tga_writeheader(fdest, bpp, width , height, OPJ_TRUE)) if (!tga_writeheader(fdest, bpp, width , height, OPJ_TRUE))
return 1; return 1;
@ -370,35 +427,55 @@ int imagetotga(opj_image_t * image, const char *outfile) {
scale = 255.0f / (float)((1<<image->comps[0].prec)-1); scale = 255.0f / (float)((1<<image->comps[0].prec)-1);
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
adjustB = (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
for (y=0; y < height; y++) { for (y=0; y < height; y++) {
unsigned int index=y*width; unsigned int index=y*width;
for (x=0; x < width; x++, index++) { for (x=0; x < width; x++, index++) {
r = (float)(image->comps[0].data[index]); r = (float)(image->comps[0].data[index] + adjustR);
if (image->numcomps>2) { if (image->numcomps>2) {
g = (float)(image->comps[1].data[index]); g = (float)(image->comps[1].data[index] + adjustG);
b = (float)(image->comps[2].data[index]); b = (float)(image->comps[2].data[index] + adjustB);
} }
else {// Greyscale ... else {/* Greyscale ... */
g = r; g = r;
b = r; b = r;
} }
// TGA format writes BGR ... /* TGA format writes BGR ... */
value = (unsigned char)(b*scale); value = (unsigned char)(b*scale);
fwrite(&value,1,1,fdest); res = fwrite(&value,1,1,fdest);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
value = (unsigned char)(g*scale); value = (unsigned char)(g*scale);
fwrite(&value,1,1,fdest); res = fwrite(&value,1,1,fdest);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
value = (unsigned char)(r*scale); value = (unsigned char)(r*scale);
fwrite(&value,1,1,fdest); res = fwrite(&value,1,1,fdest);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
if (write_alpha) { if (write_alpha) {
a = (float)(image->comps[alpha_channel].data[index]); a = (float)(image->comps[alpha_channel].data[index]);
value = (unsigned char)(a*scale); value = (unsigned char)(a*scale);
fwrite(&value,1,1,fdest); res = fwrite(&value,1,1,fdest);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
} }
} }
} }
@ -631,7 +708,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
free(RGB); free(RGB);
}/* if (Info_h.biBitCount == 24) */ }/* if (Info_h.biBitCount == 24) */
else else
if (Info_h.biBitCount == 8 && Info_h.biCompression == 0)//RGB if (Info_h.biBitCount == 8 && Info_h.biCompression == 0)/*RGB */
{ {
if(Info_h.biClrUsed == 0) Info_h.biClrUsed = 256; if(Info_h.biClrUsed == 0) Info_h.biClrUsed = 256;
else else
@ -742,7 +819,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
free(table_B); free(table_B);
}/* RGB8 */ }/* RGB8 */
else else
if (Info_h.biBitCount == 8 && Info_h.biCompression == 1)//RLE8 if (Info_h.biBitCount == 8 && Info_h.biCompression == 1)/*RLE8*/
{ {
unsigned char *pix, *beyond; unsigned char *pix, *beyond;
int *gray, *red, *green, *blue; int *gray, *red, *green, *blue;
@ -878,7 +955,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
} }
else else
{ {
//int *red, *green, *blue; /*int *red, *green, *blue;*/
red = image->comps[0].data; red = image->comps[0].data;
green = image->comps[1].data; green = image->comps[1].data;
@ -1288,6 +1365,7 @@ int imagetopgx(opj_image_t * image, const char *outfile) {
char bname[256]; /* buffer for name */ char bname[256]; /* buffer for name */
char *name = bname; /* pointer */ char *name = bname; /* pointer */
int nbytes = 0; int nbytes = 0;
size_t res;
const size_t olen = strlen(outfile); const size_t olen = strlen(outfile);
const size_t dotpos = olen - 4; const size_t dotpos = olen - 4;
const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */ const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */
@ -1300,7 +1378,7 @@ int imagetopgx(opj_image_t * image, const char *outfile) {
name = (char*)malloc(total+1); name = (char*)malloc(total+1);
} }
strncpy(name, outfile, dotpos); strncpy(name, outfile, dotpos);
//if (image->numcomps > 1) { /*if (image->numcomps > 1) {*/
sprintf(name+dotpos, "_%d.pgx", compno); sprintf(name+dotpos, "_%d.pgx", compno);
/*} else { /*} else {
strcpy(name+dotpos, ".pgx"); strcpy(name+dotpos, ".pgx");
@ -1330,7 +1408,11 @@ int imagetopgx(opj_image_t * image, const char *outfile) {
int v = image->comps[compno].data[i]; int v = image->comps[compno].data[i];
for (j = nbytes - 1; j >= 0; j--) { for (j = nbytes - 1; j >= 0; j--) {
char byte = (char) (v >> (j * 8)); char byte = (char) (v >> (j * 8));
fwrite(&byte, 1, 1, fdest); res = fwrite(&byte, 1, 1, fdest);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", name);
return 1;
}
} }
} }
fclose(fdest); fclose(fdest);
@ -1742,7 +1824,7 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
} }
} }
else else
if((format == 7 && header_info.bw)) //MONO if((format == 7 && header_info.bw)) /*MONO*/
{ {
unsigned char uc; unsigned char uc;
@ -1769,7 +1851,7 @@ int imagetopnm(opj_image_t * image, const char *outfile)
FILE *fdest = NULL; FILE *fdest = NULL;
const char *tmp = outfile; const char *tmp = outfile;
char *destname; char *destname;
alpha = NULL;
if((prec = image->comps[0].prec) > 16) if((prec = image->comps[0].prec) > 16)
{ {
fprintf(stderr,"%s:%d:imagetopnm\n\tprecision %d is larger than 16" fprintf(stderr,"%s:%d:imagetopnm\n\tprecision %d is larger than 16"
@ -1831,7 +1913,7 @@ int imagetopnm(opj_image_t * image, const char *outfile)
{ {
fprintf(fdest, "P6\n# OpenJPEG-%s\n%d %d\n%d\n", fprintf(fdest, "P6\n# OpenJPEG-%s\n%d %d\n%d\n",
opj_version(), wr, hr, max); opj_version(), wr, hr, max);
alpha = NULL; adjustA = 0; adjustA = 0;
} }
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
@ -1958,13 +2040,13 @@ int imagetopnm(opj_image_t * image, const char *outfile)
<<-- <<-- <<-- <<-- */ <<-- <<-- <<-- <<-- */
typedef struct tiff_infoheader{ typedef struct tiff_infoheader{
DWORD tiWidth; // Width of Image in pixel DWORD tiWidth; /* Width of Image in pixel*/
DWORD tiHeight; // Height of Image in pixel DWORD tiHeight; /* Height of Image in pixel */
DWORD tiPhoto; // Photometric DWORD tiPhoto; /* Photometric */
WORD tiBps; // Bits per sample WORD tiBps; /* Bits per sample */
WORD tiSf; // Sample Format WORD tiSf; /* Sample Format */
WORD tiSpp; // Sample per pixel 1-bilevel,gray scale , 2- RGB WORD tiSpp; /* Sample per pixel 1-bilevel,gray scale , 2- RGB */
WORD tiPC; // Planar config (1-Interleaved, 2-Planarcomp) WORD tiPC; /* Planar config (1-Interleaved, 2-Planarcomp) */
}tiff_infoheader_t; }tiff_infoheader_t;
int imagetotif(opj_image_t * image, const char *outfile) int imagetotif(opj_image_t * image, const char *outfile)
@ -2070,7 +2152,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
} }
else else
break; break;
}//for(i = 0;) }/*for(i = 0;)*/
if(last_i < ssize) if(last_i < ssize)
{ {
@ -2103,10 +2185,10 @@ int imagetotif(opj_image_t * image, const char *outfile)
} }
else else
break; break;
}//for(i) }/*for(i)*/
}//if(last_i < ssize) }/*if(last_i < ssize)*/
} //if(bps == 8) } /*if(bps == 8)*/
else else
if(bps == 16) if(bps == 16)
{ {
@ -2138,8 +2220,8 @@ int imagetotif(opj_image_t * image, const char *outfile)
b = (b<<ushift) + (b>>dshift); b = (b<<ushift) + (b>>dshift);
if(has_alpha) a = (a<<ushift) + (a>>dshift); if(has_alpha) a = (a<<ushift) + (a>>dshift);
} }
dat8[i+0] = r;//LSB dat8[i+0] = r;/*LSB*/
dat8[i+1] = (r >> 8);//MSB dat8[i+1] = (r >> 8);/*MSB*/
dat8[i+2] = g; dat8[i+2] = g;
dat8[i+3] = (g >> 8); dat8[i+3] = (g >> 8);
dat8[i+4] = b; dat8[i+4] = b;
@ -2154,7 +2236,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
} }
else else
break; break;
}//for(i = 0;) }/*for(i = 0;)*/
if(last_i < ssize) if(last_i < ssize)
{ {
@ -2183,8 +2265,8 @@ int imagetotif(opj_image_t * image, const char *outfile)
b = (b<<ushift) + (b>>dshift); b = (b<<ushift) + (b>>dshift);
if(has_alpha) a = (a<<ushift) + (a>>dshift); if(has_alpha) a = (a<<ushift) + (a>>dshift);
} }
dat8[i+0] = r;//LSB dat8[i+0] = r;/*LSB*/
if(i+1 < ssize) dat8[i+1] = (r >> 8);else break;//MSB if(i+1 < ssize) dat8[i+1] = (r >> 8);else break;/*MSB*/
if(i+2 < ssize) dat8[i+2] = g; else break; if(i+2 < ssize) dat8[i+2] = g; else break;
if(i+3 < ssize) dat8[i+3] = (g >> 8);else break; if(i+3 < ssize) dat8[i+3] = (g >> 8);else break;
if(i+4 < ssize) dat8[i+4] = b; else break; if(i+4 < ssize) dat8[i+4] = b; else break;
@ -2199,18 +2281,18 @@ int imagetotif(opj_image_t * image, const char *outfile)
} }
else else
break; break;
}//for(i) }/*for(i)*/
}//if(last_i < ssize) }/*if(last_i < ssize)*/
}//if(bps == 16) }/*if(bps == 16)*/
(void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size); (void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
}//for(strip = 0; ) }/*for(strip = 0; )*/
_TIFFfree((void*)buf); _TIFFfree((void*)buf);
TIFFClose(tif); TIFFClose(tif);
return 0; return 0;
}//RGB(A) }/*RGB(A)*/
if(image->numcomps == 1 /* GRAY */ if(image->numcomps == 1 /* GRAY */
|| ( image->numcomps == 2 /* GRAY_ALPHA */ || ( image->numcomps == 2 /* GRAY_ALPHA */
@ -2271,8 +2353,8 @@ int imagetotif(opj_image_t * image, const char *outfile)
} }
else else
break; break;
}//for(i ) }/*for(i )*/
}//if(bps == 8 }/*if(bps == 8*/
else else
if(bps == 16) if(bps == 16)
{ {
@ -2297,21 +2379,21 @@ int imagetotif(opj_image_t * image, const char *outfile)
r = (r<<ushift) + (r>>dshift); r = (r<<ushift) + (r>>dshift);
if(has_alpha) a = (a<<ushift) + (a>>dshift); if(has_alpha) a = (a<<ushift) + (a>>dshift);
} }
dat8[i+0] = r;//LSB dat8[i+0] = r;/*LSB*/
dat8[i+1] = r >> 8;//MSB dat8[i+1] = r >> 8;/*MSB*/
if(has_alpha) if(has_alpha)
{ {
dat8[i+2] = a; dat8[i+2] = a;
dat8[i+3] = a >> 8; dat8[i+3] = a >> 8;
} }
index++; index++;
}//if(index < imgsize) }/*if(index < imgsize)*/
else else
break; break;
}//for(i ) }/*for(i )*/
} }
(void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size); (void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
}//for(strip }/*for(strip*/
_TIFFfree(buf); _TIFFfree(buf);
TIFFClose(tif); TIFFClose(tif);
@ -2481,9 +2563,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
{ {
if(index < imgsize) if(index < imgsize)
{ {
image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0]; // R image->comps[0].data[index] = ( dat8[i+1] << 8 ) | dat8[i+0]; /* R */
image->comps[1].data[index] = ( dat8[i+3] << 8 ) | dat8[i+2]; // G image->comps[1].data[index] = ( dat8[i+3] << 8 ) | dat8[i+2]; /* G */
image->comps[2].data[index] = ( dat8[i+5] << 8 ) | dat8[i+4]; // B image->comps[2].data[index] = ( dat8[i+5] << 8 ) | dat8[i+4]; /* B */
if(has_alpha) if(has_alpha)
image->comps[3].data[index] = ( dat8[i+7] << 8 ) | dat8[i+6]; image->comps[3].data[index] = ( dat8[i+7] << 8 ) | dat8[i+6];
@ -2505,8 +2587,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
} }
else else
break; break;
}//for(i = 0) }/*for(i = 0)*/
}//if(Info.tiBps == 16) }/*if(Info.tiBps == 16)*/
else else
if(Info.tiBps == 8) if(Info.tiBps == 8)
{ {
@ -2516,9 +2598,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
{ {
if(index < imgsize) if(index < imgsize)
{ {
image->comps[0].data[index] = dat8[i+0];// R image->comps[0].data[index] = dat8[i+0];/* R */
image->comps[1].data[index] = dat8[i+1];// G image->comps[1].data[index] = dat8[i+1];/* G */
image->comps[2].data[index] = dat8[i+2];// B image->comps[2].data[index] = dat8[i+2];/* B */
if(has_alpha) if(has_alpha)
image->comps[3].data[index] = dat8[i+3]; image->comps[3].data[index] = dat8[i+3];
@ -2533,11 +2615,11 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
image->comps[3].data[index] = image->comps[3].data[index] << 4 ; image->comps[3].data[index] = image->comps[3].data[index] << 4 ;
} }
index++; index++;
}//if(index }/*if(index*/
else else
break; break;
}//for(i ) }/*for(i )*/
}//if( Info.tiBps == 8) }/*if( Info.tiBps == 8)*/
else else
if(Info.tiBps == 12)/* CINEMA file */ if(Info.tiBps == 12)/* CINEMA file */
{ {
@ -2560,15 +2642,15 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
} }
else else
break; break;
}//for(i ) }/*for(i )*/
} }
}//for(strip = 0; ) }/*for(strip = 0; )*/
_TIFFfree(buf); _TIFFfree(buf);
TIFFClose(tif); TIFFClose(tif);
return image; return image;
}//RGB(A) }/*RGB(A)*/
if(Info.tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */ if(Info.tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
{ {
@ -2631,7 +2713,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
} }
else else
break; break;
}//for(i ) }/*for(i )*/
} }
else else
if(Info.tiBps == 8) if(Info.tiBps == 8)
@ -2649,14 +2731,14 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
} }
else else
break; break;
}//for(i ) }/*for(i )*/
} }
}//for(strip = 0; }/*for(strip = 0;*/
_TIFFfree(buf); _TIFFfree(buf);
TIFFClose(tif); TIFFClose(tif);
}//GRAY(A) }/*GRAY(A)*/
return image; return image;
@ -2775,6 +2857,7 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw
int imagetoraw(opj_image_t * image, const char *outfile) int imagetoraw(opj_image_t * image, const char *outfile)
{ {
FILE *rawFile = NULL; FILE *rawFile = NULL;
size_t res;
int compno; int compno;
int w, h; int w, h;
int line, row; int line, row;
@ -2812,7 +2895,11 @@ int imagetoraw(opj_image_t * image, const char *outfile)
for (line = 0; line < h; line++) { for (line = 0; line < h; line++) {
for(row = 0; row < w; row++) { for(row = 0; row < w; row++) {
curr = (signed char) (*ptr & mask); curr = (signed char) (*ptr & mask);
fwrite(&curr, sizeof(signed char), 1, rawFile); res = fwrite(&curr, sizeof(signed char), 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
ptr++; ptr++;
} }
} }
@ -2825,7 +2912,11 @@ int imagetoraw(opj_image_t * image, const char *outfile)
for (line = 0; line < h; line++) { for (line = 0; line < h; line++) {
for(row = 0; row < w; row++) { for(row = 0; row < w; row++) {
curr = (unsigned char) (*ptr & mask); curr = (unsigned char) (*ptr & mask);
fwrite(&curr, sizeof(unsigned char), 1, rawFile); res = fwrite(&curr, sizeof(unsigned char), 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
ptr++; ptr++;
} }
} }
@ -2843,9 +2934,17 @@ int imagetoraw(opj_image_t * image, const char *outfile)
unsigned char temp; unsigned char temp;
curr = (signed short int) (*ptr & mask); curr = (signed short int) (*ptr & mask);
temp = (unsigned char) (curr >> 8); temp = (unsigned char) (curr >> 8);
fwrite(&temp, 1, 1, rawFile); res = fwrite(&temp, 1, 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
temp = (unsigned char) curr; temp = (unsigned char) curr;
fwrite(&temp, 1, 1, rawFile); res = fwrite(&temp, 1, 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
ptr++; ptr++;
} }
} }
@ -2860,9 +2959,17 @@ int imagetoraw(opj_image_t * image, const char *outfile)
unsigned char temp; unsigned char temp;
curr = (unsigned short int) (*ptr & mask); curr = (unsigned short int) (*ptr & mask);
temp = (unsigned char) (curr >> 8); temp = (unsigned char) (curr >> 8);
fwrite(&temp, 1, 1, rawFile); res = fwrite(&temp, 1, 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
temp = (unsigned char) curr; temp = (unsigned char) curr;
fwrite(&temp, 1, 1, rawFile); res = fwrite(&temp, 1, 1, rawFile);
if( res < 1 ) {
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
return 1;
}
ptr++; ptr++;
} }
} }

View File

@ -51,7 +51,7 @@
#include "opj_config.h" #include "opj_config.h"
#include "openjpeg.h" #include "openjpeg.h"
#include "getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"
#include "index.h" #include "index.h"
@ -193,6 +193,8 @@ void encode_help_display(void) {
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 : devide packets of every tile into tile-parts (-TP R) [R, L, C]\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");
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n"); fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
@ -209,6 +211,9 @@ void encode_help_display(void) {
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n"); fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n"); fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stdout,"\n"); fprintf(stdout,"\n");
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
fprintf(stdout,"\n");
/* UniPG>> */ /* UniPG>> */
#ifdef USE_JPWL #ifdef USE_JPWL
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n"); fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
@ -422,7 +427,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparamet
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename)); strncpy(parameters->infile, infilename, sizeof(infilename));
//Set output file /*Set output file*/
strcpy(temp_ofname,get_file_name(image_filename)); strcpy(temp_ofname,get_file_name(image_filename));
while((temp_p = strtok(NULL,".")) != NULL){ while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1); strcat(temp_ofname,temp1);
@ -574,20 +579,21 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) { img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
int i, j, totlen, c; int i, j, totlen, c;
option_t long_option[]={ opj_option_t long_option[]={
{"cinema2K",REQ_ARG, NULL ,'w'}, {"cinema2K",REQ_ARG, NULL ,'w'},
{"cinema4K",NO_ARG, NULL ,'y'}, {"cinema4K",NO_ARG, NULL ,'y'},
{"ImgDir",REQ_ARG, NULL ,'z'}, {"ImgDir",REQ_ARG, NULL ,'z'},
{"TP",REQ_ARG, NULL ,'v'}, {"TP",REQ_ARG, NULL ,'u'},
{"SOP",NO_ARG, NULL ,'S'}, {"SOP",NO_ARG, NULL ,'S'},
{"EPH",NO_ARG, NULL ,'E'}, {"EPH",NO_ARG, NULL ,'E'},
{"OutFor",REQ_ARG, NULL ,'O'}, {"OutFor",REQ_ARG, NULL ,'O'},
{"POC",REQ_ARG, NULL ,'P'}, {"POC",REQ_ARG, NULL ,'P'},
{"ROI",REQ_ARG, NULL ,'R'}, {"ROI",REQ_ARG, NULL ,'R'},
{"jpip",NO_ARG, NULL, 'J'}
}; };
/* parse the command line */ /* parse the command line */
const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:" const char optlist[] = "i:o:r: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 */
@ -598,13 +604,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
raw_cp->rawWidth = 0; raw_cp->rawWidth = 0;
do{ do{
c = getopt_long(argc, argv, optlist,long_option,totlen); c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
case 'i': /* input file */ case 'i': /* input file */
{ {
char *infile = optarg; char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile); parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) { switch(parameters->decod_format) {
case PGX_DFMT: case PGX_DFMT:
@ -630,7 +636,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'o': /* output file */ case 'o': /* output file */
{ {
char *outfile = optarg; char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile); parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case J2K_CFMT: case J2K_CFMT:
@ -648,14 +654,14 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'O': /* output format */ case 'O': /* output format */
{ {
char outformat[50]; char outformat[50];
char *of = optarg; char *of = opj_optarg;
sprintf(outformat,".%s",of); sprintf(outformat,".%s",of);
img_fol->set_out_format = 1; img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat); parameters->cod_format = get_file_format(outformat);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case J2K_CFMT: case J2K_CFMT:
case JP2_CFMT: case JP2_CFMT:
img_fol->out_format = optarg; img_fol->out_format = opj_optarg;
break; break;
default: default:
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n"); fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
@ -670,7 +676,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'r': /* rates rates/distorsion */ case 'r': /* rates rates/distorsion */
{ {
char *s = optarg; char *s = opj_optarg;
parameters->tcp_numlayers = 0; parameters->tcp_numlayers = 0;
while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) { while (sscanf(s, "%f", &parameters->tcp_rates[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++; parameters->tcp_numlayers++;
@ -691,7 +697,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'F': /* Raw image format parameters */ case 'F': /* Raw image format parameters */
{ {
char signo; char signo;
char *s = optarg; char *s = opj_optarg;
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) { if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
if (signo == 's') { if (signo == 's') {
raw_cp->rawSigned = OPJ_TRUE; raw_cp->rawSigned = OPJ_TRUE;
@ -724,7 +730,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'q': /* add fixed_quality */ case 'q': /* add fixed_quality */
{ {
char *s = optarg; char *s = opj_optarg;
while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) { while (sscanf(s, "%f", &parameters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
parameters->tcp_numlayers++; parameters->tcp_numlayers++;
while (*s && *s != ',') { while (*s && *s != ',') {
@ -746,7 +752,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
int *row = NULL, *col = NULL; int *row = NULL, *col = NULL;
int numlayers = 0, numresolution = 0, matrix_width = 0; int numlayers = 0, numresolution = 0, matrix_width = 0;
char *s = optarg; char *s = opj_optarg;
sscanf(s, "%d", &numlayers); sscanf(s, "%d", &numlayers);
s++; s++;
if (numlayers > 9) if (numlayers > 9)
@ -790,7 +796,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 't': /* tiles */ case 't': /* tiles */
{ {
sscanf(optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy); sscanf(opj_optarg, "%d,%d", &parameters->cp_tdx, &parameters->cp_tdy);
parameters->tile_size_on = OPJ_TRUE; parameters->tile_size_on = OPJ_TRUE;
} }
break; break;
@ -799,7 +805,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'n': /* resolution */ case 'n': /* resolution */
{ {
sscanf(optarg, "%d", &parameters->numresolution); sscanf(opj_optarg, "%d", &parameters->numresolution);
} }
break; break;
@ -809,7 +815,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
char sep; char sep;
int res_spec = 0; int res_spec = 0;
char *s = optarg; char *s = opj_optarg;
do { do {
sep = 0; sep = 0;
sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec], sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
@ -828,7 +834,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'b': /* code-block dimension */ case 'b': /* code-block dimension */
{ {
int cblockw_init = 0, cblockh_init = 0; int cblockw_init = 0, cblockh_init = 0;
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init); sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024 if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) { || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
fprintf(stderr, fprintf(stderr,
@ -845,7 +851,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'x': /* creation of index file */ case 'x': /* creation of index file */
{ {
char *index = optarg; char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN); strncpy(indexfilename, index, OPJ_PATH_LEN);
} }
break; break;
@ -856,7 +862,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
{ {
char progression[4]; char progression[4];
strncpy(progression, optarg, 4); strncpy(progression, opj_optarg, 4);
parameters->prog_order = give_progression(progression); parameters->prog_order = give_progression(progression);
if (parameters->prog_order == -1) { if (parameters->prog_order == -1) {
fprintf(stderr, "Unrecognized progression order " fprintf(stderr, "Unrecognized progression order "
@ -870,7 +876,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 's': /* subsampling factor */ case 's': /* subsampling factor */
{ {
if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx, if (sscanf(opj_optarg, "%d,%d", &parameters->subsampling_dx,
&parameters->subsampling_dy) != 2) { &parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n"); fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
return 1; return 1;
@ -882,7 +888,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'd': /* coordonnate of the reference grid */ case 'd': /* coordonnate of the reference grid */
{ {
if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0, if (sscanf(opj_optarg, "%d,%d", &parameters->image_offset_x0,
&parameters->image_offset_y0) != 2) { &parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument " fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
"error !! [-d x0,y0]\n"); "error !! [-d x0,y0]\n");
@ -904,7 +910,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
int numpocs = 0; /* number of progression order change (POC) default 0 */ int numpocs = 0; /* number of progression order change (POC) default 0 */
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */ opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
char *s = optarg; char *s = opj_optarg;
POC = parameters->POC; POC = parameters->POC;
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile, while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
@ -946,7 +952,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'M': /* Mode switch pas tous au point !! */ case 'M': /* Mode switch pas tous au point !! */
{ {
int value = 0; int value = 0;
if (sscanf(optarg, "%d", &value) == 1) { if (sscanf(opj_optarg, "%d", &value) == 1) {
for (i = 0; i <= 5; i++) { for (i = 0; i <= 5; i++) {
int cache = value & (1 << i); int cache = value & (1 << i);
if (cache) if (cache)
@ -960,7 +966,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'R': /* ROI */ case 'R': /* ROI */
{ {
if (sscanf(optarg, "c=%d,U=%d", &parameters->roi_compno, if (sscanf(opj_optarg, "c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) { &parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n"); fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
return 1; return 1;
@ -972,7 +978,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'T': /* Tile offset */ case 'T': /* Tile offset */
{ {
if (sscanf(optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) { if (sscanf(opj_optarg, "%d,%d", &parameters->cp_tx0, &parameters->cp_ty0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]"); fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1; return 1;
} }
@ -983,9 +989,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'C': /* add a comment */ case 'C': /* add a comment */
{ {
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1); parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
if(parameters->cp_comment) { if(parameters->cp_comment) {
strcpy(parameters->cp_comment, optarg); strcpy(parameters->cp_comment, opj_optarg);
} }
} }
break; break;
@ -1001,9 +1007,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
/* ------------------------------------------------------ */ /* ------------------------------------------------------ */
case 'v': /* Tile part generation*/ case 'u': /* Tile part generation*/
{ {
parameters->tp_flag = optarg[0]; parameters->tp_flag = opj_optarg[0];
parameters->tp_on = 1; parameters->tp_on = 1;
} }
break; break;
@ -1012,8 +1018,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'z': /* Image Directory path */ case 'z': /* Image Directory path */
{ {
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1); img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,optarg); strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1; img_fol->set_imgdir=1;
} }
break; break;
@ -1023,7 +1029,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
case 'w': /* Digital Cinema 2K profile compliance*/ case 'w': /* Digital Cinema 2K profile compliance*/
{ {
int fps=0; int fps=0;
sscanf(optarg,"%d",&fps); sscanf(opj_optarg,"%d",&fps);
if(fps == 24){ if(fps == 24){
parameters->cp_cinema = CINEMA2K_24; parameters->cp_cinema = CINEMA2K_24;
}else if(fps == 48 ){ }else if(fps == 48 ){
@ -1067,7 +1073,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
/* search for different protection methods */ /* search for different protection methods */
/* break the option in comma points and parse the result */ /* break the option in comma points and parse the result */
token = strtok(optarg, ","); token = strtok(opj_optarg, ",");
while(token != NULL) { while(token != NULL) {
/* search header error protection method */ /* search header error protection method */
@ -1369,9 +1375,16 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
break; break;
#endif /* USE_JPWL */ #endif /* USE_JPWL */
/* <<UniPG */ /* <<UniPG */
/* ------------------------------------------------------ */
case 'J': /* jpip on */
{
parameters->jpip_on = OPJ_TRUE;
}
break;
/* ------------------------------------------------------ */ /* ------------------------------------------------------ */
default: default:
fprintf(stderr, "ERROR -> Command line not valid\n"); fprintf(stderr, "ERROR -> Command line not valid\n");
return 1; return 1;
@ -1537,7 +1550,7 @@ int main(int argc, char **argv) {
num_images=get_num_images(img_fol.imgdirpath); num_images=get_num_images(img_fol.imgdirpath);
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t)); dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){ if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names 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*)); dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){ if(!dirptr->filename_buf){
return 0; return 0;
@ -1668,6 +1681,7 @@ int main(int argc, char **argv) {
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */ if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
int codestream_length; int codestream_length;
size_t res;
opj_cio_t *cio = NULL; opj_cio_t *cio = NULL;
FILE *f = NULL; FILE *f = NULL;
@ -1685,8 +1699,8 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */ /* encode the image */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info); bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else else
bSuccess = opj_encode(cinfo, cio, image, NULL); bSuccess = opj_encode(cinfo, cio, image, NULL);
if (!bSuccess) { if (!bSuccess) {
@ -1702,7 +1716,11 @@ int main(int argc, char **argv) {
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile); fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
return 1; return 1;
} }
fwrite(cio->buffer, 1, codestream_length, f); res = fwrite(cio->buffer, 1, codestream_length, f);
if( res < (size_t)codestream_length ) { /* FIXME */
fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
return 1;
}
fclose(f); fclose(f);
fprintf(stderr,"Generated outfile %s\n",parameters.outfile); fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
@ -1723,11 +1741,13 @@ int main(int argc, char **argv) {
opj_destroy_cstr_info(&cstr_info); opj_destroy_cstr_info(&cstr_info);
} else { /* JP2 format output */ } else { /* JP2 format output */
int codestream_length; int codestream_length;
size_t res;
opj_cio_t *cio = NULL; opj_cio_t *cio = NULL;
FILE *f = NULL; FILE *f = NULL;
opj_cinfo_t *cinfo = NULL;
/* get a JP2 compressor handle */ /* get a JP2 compressor handle */
opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2); cinfo = opj_create_compress(CODEC_JP2);
/* catch events using our callbacks and give a local context */ /* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr); opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
@ -1740,8 +1760,8 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */ /* encode the image */
if (*indexfilename) // If need to extract codestream information if (*indexfilename || parameters.jpip_on) /* If need to extract codestream information*/
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info); bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else else
bSuccess = opj_encode(cinfo, cio, image, NULL); bSuccess = opj_encode(cinfo, cio, image, NULL);
if (!bSuccess) { if (!bSuccess) {
@ -1757,7 +1777,11 @@ int main(int argc, char **argv) {
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile); fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
return 1; return 1;
} }
fwrite(cio->buffer, 1, codestream_length, f); res = fwrite(cio->buffer, 1, codestream_length, f);
if( res < (size_t)codestream_length ) { /* FIXME */
fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
return 1;
}
fclose(f); fclose(f);
fprintf(stderr,"Generated outfile %s\n",parameters.outfile); fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */ /* close and free the byte stream */

View File

@ -260,7 +260,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
int x1 = x0 + cstr_info->tile_x; int x1 = x0 + cstr_info->tile_x;
int y1 = y0 + cstr_info->tile_y; int y1 = y0 + cstr_info->tile_y;
// Count the maximum number of precincts /* Count the maximum number of precincts */
int max_numprec = 0; int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) { for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]; int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
@ -311,7 +311,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
} /* PCRL */ } /* PCRL */
else { /* CPRL */ else { /* CPRL */
// Count the maximum number of precincts /* Count the maximum number of precincts */
int max_numprec = 0; int max_numprec = 0;
for (resno = 0; resno < max_numdecompos + 1; resno++) { for (resno = 0; resno < max_numdecompos + 1; resno++) {
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]; int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];

View File

@ -47,7 +47,7 @@
#include "openjpeg.h" #include "openjpeg.h"
#include "j2k.h" #include "j2k.h"
#include "jp2.h" #include "jp2.h"
#include "getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"
#include "index.h" #include "index.h"
@ -180,7 +180,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename)); strncpy(parameters->infile, infilename, sizeof(infilename));
//Set output file /*Set output file*/
strcpy(temp_ofname,strtok(image_filename,".")); strcpy(temp_ofname,strtok(image_filename,"."));
while((temp_p = strtok(NULL,".")) != NULL){ while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1); strcat(temp_ofname,temp1);
@ -197,7 +197,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) { int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */ /* parse the command line */
int totlen, c; int totlen, c;
option_t long_option[]={ opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'}, {"ImgDir",REQ_ARG, NULL ,'y'},
}; };
const char optlist[] = "i:o:h"; const char optlist[] = "i:o:h";
@ -207,13 +207,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
totlen=sizeof(long_option); totlen=sizeof(long_option);
img_fol->set_out_format = 0; img_fol->set_out_format = 0;
do { do {
c = getopt_long(argc, argv,optlist,long_option,totlen); c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
case 'i': /* input file */ case 'i': /* input file */
{ {
char *infile = optarg; char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile); parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) { switch(parameters->decod_format) {
case J2K_CFMT: case J2K_CFMT:
@ -234,7 +234,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'o': /* output file */ case 'o': /* output file */
{ {
char *outfile = optarg; char *outfile = opj_optarg;
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1); strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
} }
break; break;
@ -249,8 +249,8 @@ 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*)malloc(strlen(optarg) + 1); img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,optarg); strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1; img_fol->set_imgdir=1;
} }
break; break;
@ -258,7 +258,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
default: default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg); fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
break; break;
} }
}while(c != -1); }while(c != -1);
@ -356,7 +356,7 @@ int main(int argc, char *argv[])
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t)); dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){ if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names 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*)); dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){ if(!dirptr->filename_buf){
@ -377,7 +377,7 @@ int main(int argc, char *argv[])
num_images=1; num_images=1;
} }
// /* */
if (parameters.outfile[0] != 0) if (parameters.outfile[0] != 0)
{ {
fout = fopen(parameters.outfile,"w"); fout = fopen(parameters.outfile,"w");
@ -418,6 +418,7 @@ int main(int argc, char *argv[])
{ {
free(src); free(src);
fclose(fsrc); fclose(fsrc);
fclose(fout);
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n"); fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
return 1; return 1;
} }
@ -444,7 +445,7 @@ int main(int argc, char *argv[])
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -452,6 +453,8 @@ int main(int argc, char *argv[])
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);
fclose(fout);
free(src);
return 1; return 1;
} }
/* dump image */ /* dump image */
@ -491,7 +494,7 @@ int main(int argc, char *argv[])
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -499,6 +502,8 @@ int main(int argc, char *argv[])
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);
fclose(fout);
free(src);
return 1; return 1;
} }
/* dump image */ /* dump image */
@ -542,7 +547,7 @@ int main(int argc, char *argv[])
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -550,6 +555,8 @@ int main(int argc, char *argv[])
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);
fclose(fout);
free(src);
return 1; return 1;
} }
@ -604,7 +611,7 @@ static void j2k_dump_image(FILE *fd, opj_image_t * img) {
fprintf(fd, " comp %d {\n", compno); fprintf(fd, " comp %d {\n", compno);
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy); fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
fprintf(fd, " prec=%d\n", comp->prec); fprintf(fd, " prec=%d\n", comp->prec);
//fprintf(fd, " bpp=%d\n", comp->bpp); /*fprintf(fd, " bpp=%d\n", comp->bpp);*/
fprintf(fd, " sgnd=%d\n", comp->sgnd); fprintf(fd, " sgnd=%d\n", comp->sgnd);
fprintf(fd, " }\n"); fprintf(fd, " }\n");
} }

View File

@ -51,7 +51,7 @@
#include "opj_config.h" #include "opj_config.h"
#include "openjpeg.h" #include "openjpeg.h"
#include "getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"
#include "index.h" #include "index.h"
@ -221,7 +221,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename)); strncpy(parameters->infile, infilename, sizeof(infilename));
//Set output file /*Set output file*/
strcpy(temp_ofname,strtok(image_filename,".")); strcpy(temp_ofname,strtok(image_filename,"."));
while((temp_p = strtok(NULL,".")) != NULL){ while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1); strcat(temp_ofname,temp1);
@ -238,7 +238,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) { int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */ /* parse the command line */
int totlen, c; int totlen, c;
option_t long_option[]={ opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'}, {"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'}, {"OutFor",REQ_ARG, NULL ,'O'},
}; };
@ -254,13 +254,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
totlen=sizeof(long_option); totlen=sizeof(long_option);
img_fol->set_out_format = 0; img_fol->set_out_format = 0;
do { do {
c = getopt_long(argc, argv,optlist,long_option,totlen); c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
case 'i': /* input file */ case 'i': /* input file */
{ {
char *infile = optarg; char *infile = opj_optarg;
parameters->decod_format = get_file_format(infile); parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) { switch(parameters->decod_format) {
case J2K_CFMT: case J2K_CFMT:
@ -281,7 +281,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'o': /* output file */ case 'o': /* output file */
{ {
char *outfile = optarg; char *outfile = opj_optarg;
parameters->cod_format = get_file_format(outfile); parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) { switch(parameters->cod_format) {
case PGX_DFMT: case PGX_DFMT:
@ -305,7 +305,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'O': /* output format */ case 'O': /* output format */
{ {
char outformat[50]; char outformat[50];
char *of = optarg; char *of = opj_optarg;
sprintf(outformat,".%s",of); sprintf(outformat,".%s",of);
img_fol->set_out_format = 1; img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat); parameters->cod_format = get_file_format(outformat);
@ -344,7 +344,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'r': /* reduce option */ case 'r': /* reduce option */
{ {
sscanf(optarg, "%d", &parameters->cp_reduce); sscanf(opj_optarg, "%d", &parameters->cp_reduce);
} }
break; break;
@ -353,7 +353,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case 'l': /* layering option */ case 'l': /* layering option */
{ {
sscanf(optarg, "%d", &parameters->cp_layer); sscanf(opj_optarg, "%d", &parameters->cp_layer);
} }
break; break;
@ -367,15 +367,15 @@ 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*)malloc(strlen(optarg) + 1); img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,optarg); strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1; img_fol->set_imgdir=1;
} }
break; break;
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
case 'x': /* Creation of index file */ case 'x': /* Creation of index file */
{ {
char *index = optarg; char *index = opj_optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN); strncpy(indexfilename, index, OPJ_PATH_LEN);
} }
break; break;
@ -387,7 +387,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
{ {
char *token = NULL; char *token = NULL;
token = strtok(optarg, ","); token = strtok(opj_optarg, ",");
while(token != NULL) { while(token != NULL) {
/* search expected number of components */ /* search expected number of components */
@ -454,7 +454,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
default: default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg); fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
break; break;
} }
}while(c != -1); }while(c != -1);
@ -551,7 +551,7 @@ int main(int argc, char **argv) {
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t)); dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){ if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names 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*)); dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){ if(!dirptr->filename_buf){
@ -625,7 +625,7 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -633,6 +633,7 @@ int main(int argc, char **argv) {
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);
free(src);
return 1; return 1;
} }
@ -667,7 +668,7 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -675,6 +676,7 @@ int main(int argc, char **argv) {
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);
free(src);
return 1; return 1;
} }
@ -709,7 +711,7 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
if (*indexfilename) // If need to extract codestream information if (*indexfilename) /* If need to extract codestream information*/
image = opj_decode_with_info(dinfo, cio, &cstr_info); image = opj_decode_with_info(dinfo, cio, &cstr_info);
else else
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
@ -717,6 +719,7 @@ int main(int argc, char **argv) {
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);
free(src);
return 1; return 1;
} }
@ -844,7 +847,7 @@ int main(int argc, char **argv) {
} }
return 0; return 0;
} }
//end main /*end main*/

View File

@ -124,7 +124,7 @@
# error "not implemented" # error "not implemented"
# elif defined(__sgi) /* Silicon Graphics */ # elif defined(__sgi) /* Silicon Graphics */
# define HAVE_DIRENT_H # define HAVE_DIRENT_H
# elif defined(sun) || defined(_sun) /* Sun Solaris */ # elif defined(sun) || defined(__sun) /* Sun Solaris */
# define HAVE_DIRENT_H # define HAVE_DIRENT_H
# elif defined(__FreeBSD__) /* FreeBSD */ # elif defined(__FreeBSD__) /* FreeBSD */
# define HAVE_DIRENT_H # define HAVE_DIRENT_H

View File

@ -45,4 +45,4 @@
#define TGA_DFMT 16 #define TGA_DFMT 16
#define PNG_DFMT 17 #define PNG_DFMT 17
#endif /* _OPJ_FORMAT_DEFS_H_ */ #endif /* _OPJ_FORMAT_DEFS_H_ */

View File

@ -1,29 +0,0 @@
/* last review : october 29th, 2002 */
#ifndef _GETOPT_H_
#define _GETOPT_H_
typedef struct option
{
const char *name;
int has_arg;
int *flag;
int val;
}option_t;
#define NO_ARG 0
#define REQ_ARG 1
#define OPT_ARG 2
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
extern char *optarg;
extern int getopt(int nargc, char *const *nargv, const char *ostr);
extern int getopt_long(int argc, char * const argv[], const char *optstring,
const struct option *longopts, int totlen);
extern void reset_options_reading(void);
#endif /* _GETOPT_H_ */

View File

@ -34,117 +34,110 @@
/* last review : october 29th, 2002 */ /* last review : october 29th, 2002 */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "opj_getopt.h"
int opterr = 1, /* if error message should be printed */ int opj_opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */ opj_optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */ opj_optopt, /* character checked for validity */
optreset; /* reset getopt */ opj_optreset; /* reset getopt */
const char *optarg; /* argument associated with option */ char *opj_optarg; /* argument associated with option */
typedef struct option
{
const char *name;
int has_arg;
int *flag;
int val;
}option_t;
#define BADCH (int)'?' #define BADCH (int)'?'
#define BADARG (int)':' #define BADARG (int)':'
#define EMSG "" static char EMSG[]={""};
/* As this class remembers its values from one Java call to the other, reset the values before each use */ /* As this class remembers its values from one Java call to the other, reset the values before each use */
void reset_options_reading(void) { void reset_options_reading(void) {
opterr = 1; opj_opterr = 1;
optind = 1; opj_optind = 1;
} }
/* /*
* getopt -- * getopt --
* Parse argc/argv argument vector. * Parse argc/argv argument vector.
*/ */
int getopt(int nargc, char *const *nargv, const char *ostr) { int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
# define __progname nargv[0] # define __progname nargv[0]
static const char *place = EMSG; /* option letter processing */ static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */ char *oli = NULL; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */ if (opj_optreset || !*place) { /* update scanning pointer */
optreset = 0; opj_optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') { if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
place = EMSG; place = EMSG;
return (-1); return (-1);
} }
if (place[1] && *++place == '-') { /* found "--" */ if (place[1] && *++place == '-') { /* found "--" */
++optind; ++opj_optind;
place = EMSG; place = EMSG;
return (-1); return (-1);
} }
} /* option letter okay? */ } /* option letter okay? */
if ((optopt = (int) *place++) == (int) ':' || if ((opj_optopt = (int) *place++) == (int) ':' ||
!(oli = strchr(ostr, optopt))) { !(oli = strchr(ostr, opj_optopt))) {
/* /*
* if the user didn't specify '-' as an option, * if the user didn't specify '-' as an option,
* assume it means -1. * assume it means -1.
*/ */
if (optopt == (int) '-') if (opj_optopt == (int) '-')
return (-1); return (-1);
if (!*place) if (!*place)
++optind; ++opj_optind;
if (opterr && *ostr != ':') { if (opj_opterr && *ostr != ':') {
fprintf(stderr, fprintf(stderr,
"%s: illegal option -- %c\n", __progname, optopt); "%s: illegal option -- %c\n", __progname, opj_optopt);
return (BADCH); return (BADCH);
} }
} }
if (*++oli != ':') { /* don't need argument */ if (*++oli != ':') { /* don't need argument */
optarg = NULL; opj_optarg = NULL;
if (!*place) if (!*place)
++optind; ++opj_optind;
} else { /* need an argument */ } else { /* need an argument */
if (*place) /* no white space */ if (*place) /* no white space */
optarg = place; opj_optarg = place;
else if (nargc <= ++optind) { /* no arg */ else if (nargc <= ++opj_optind) { /* no arg */
place = EMSG; place = EMSG;
if (*ostr == ':') if (*ostr == ':')
return (BADARG); return (BADARG);
if (opterr) { if (opj_opterr) {
fprintf(stderr, fprintf(stderr,
"%s: option requires an argument -- %c\n", "%s: option requires an argument -- %c\n",
__progname, optopt); __progname, opj_optopt);
return (BADCH); return (BADCH);
} }
} else /* white space */ } else /* white space */
optarg = nargv[optind]; opj_optarg = nargv[opj_optind];
place = EMSG; place = EMSG;
++optind; ++opj_optind;
} }
return (optopt); /* dump back option letter */ return (opj_optopt); /* dump back option letter */
} }
int getopt_long(int argc, char * const argv[], const char *optstring, int opj_getopt_long(int argc, char * const argv[], const char *optstring,
const struct option *longopts, int totlen) { const opj_option_t *longopts, int totlen) {
static int lastidx,lastofs; static int lastidx,lastofs;
char *tmp; char *tmp;
int i,len; int i,len;
char param = 1; char param = 1;
again: again:
if (optind >= argc || !argv[optind] || *argv[optind]!='-') if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
return -1; return -1;
if (argv[optind][0]=='-' && argv[optind][1]==0) { if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
if(optind >= (argc - 1)){ /* no more input parameters */ if(opj_optind >= (argc - 1)){ /* no more input parameters */
param = 0; param = 0;
} }
else{ /* more input parameters */ else{ /* more input parameters */
if(argv[optind + 1][0] == '-'){ if(argv[opj_optind + 1][0] == '-'){
param = 0; /* Missing parameter after '-' */ param = 0; /* Missing parameter after '-' */
} }
else{ else{
@ -154,108 +147,108 @@ again:
} }
if (param == 0) { if (param == 0) {
++optind; ++opj_optind;
return (BADCH); return (BADCH);
} }
if (argv[optind][0]=='-') { /* long option */ if (argv[opj_optind][0]=='-') { /* long option */
char* arg=argv[optind]+1; char* arg=argv[opj_optind]+1;
const struct option* o; const opj_option_t* o;
o=longopts; o=longopts;
len=sizeof(longopts[0]); len=sizeof(longopts[0]);
if (param > 1){ if (param > 1){
arg = argv[optind+1]; arg = argv[opj_optind+1];
optind++; opj_optind++;
} }
else else
arg = argv[optind]+1; arg = argv[opj_optind]+1;
if(strlen(arg)>1){ if(strlen(arg)>1){
for (i=0;i<totlen;i=i+len,o++) { for (i=0;i<totlen;i=i+len,o++) {
if (!strcmp(o->name,arg)) { /* match */ if (!strcmp(o->name,arg)) { /* match */
if (o->has_arg == 0) { if (o->has_arg == 0) {
if ((argv[optind+1])&&(!(argv[optind+1][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[optind+1]); fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
++optind; ++opj_optind;
} }
}else{ }else{
optarg=argv[optind+1]; opj_optarg=argv[opj_optind+1];
if(optarg){ if(opj_optarg){
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */ if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) { if (opj_opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg); fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH); return (BADCH);
} }
} }
} }
if (!optarg && o->has_arg==1) { /* no argument there */ if (!opj_optarg && o->has_arg==1) { /* no argument there */
if (opterr) { if (opj_opterr) {
fprintf(stderr,"%s: option requires an argument \n",arg); fprintf(stderr,"%s: option requires an argument \n",arg);
return (BADCH); return (BADCH);
} }
} }
++optind; ++opj_optind;
} }
++optind; ++opj_optind;
if (o->flag) if (o->flag)
*(o->flag)=o->val; *(o->flag)=o->val;
else else
return o->val; return o->val;
return 0; return 0;
} }
}//(end for)String not found in the list }/*(end for)String not found in the list*/
fprintf(stderr,"Invalid option %s\n",arg); fprintf(stderr,"Invalid option %s\n",arg);
++optind; ++opj_optind;
return (BADCH); return (BADCH);
}else{ /*Single character input parameter*/ }else{ /*Single character input parameter*/
if (*optstring==':') return ':'; if (*optstring==':') return ':';
if (lastidx!=optind) { if (lastidx!=opj_optind) {
lastidx=optind; lastofs=0; lastidx=opj_optind; lastofs=0;
} }
optopt=argv[optind][lastofs+1]; opj_optopt=argv[opj_optind][lastofs+1];
if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/ if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */ if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
++optind; ++opj_optind;
goto again; goto again;
} }
if (tmp[1]==':') { /* argument expected */ if (tmp[1]==':') { /* argument expected */
if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */ if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
if (!*(optarg=argv[optind]+lastofs+2)) optarg=0; if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
goto found; goto found;
} }
optarg=argv[optind+1]; opj_optarg=argv[opj_optind+1];
if(optarg){ if(opj_optarg){
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */ if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) { if (opj_opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg); fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH); return (BADCH);
} }
} }
} }
if (!optarg) { /* missing argument */ if (!opj_optarg) { /* missing argument */
if (opterr) { if (opj_opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg); fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH); return (BADCH);
} }
} }
++optind; ++opj_optind;
}else {/*Argument not expected*/ }else {/*Argument not expected*/
++lastofs; ++lastofs;
return optopt; return opj_optopt;
} }
found: found:
++optind; ++opj_optind;
return optopt; return opj_optopt;
} else { /* not found */ } else { /* not found */
fprintf(stderr,"Invalid option %s\n",arg); fprintf(stderr,"Invalid option %s\n",arg);
++optind; ++opj_optind;
return (BADCH); return (BADCH);
}//end of not found }/*end of not found*/
}// end of single character }/* end of single character*/
}//end '-' }/*end '-'*/
fprintf(stderr,"Invalid option\n"); fprintf(stderr,"Invalid option\n");
++optind; ++opj_optind;
return (BADCH);; return (BADCH);;
}//end function }/*end function*/

View File

@ -0,0 +1,29 @@
/* last review : october 29th, 2002 */
#ifndef _GETOPT_H_
#define _GETOPT_H_
typedef struct opj_option
{
const char *name;
int has_arg;
int *flag;
int val;
}opj_option_t;
#define NO_ARG 0
#define REQ_ARG 1
#define OPT_ARG 2
extern int opj_opterr;
extern int opj_optind;
extern int opj_optopt;
extern int opj_optreset;
extern char *opj_optarg;
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
const opj_option_t *longopts, int totlen);
extern void reset_options_reading(void);
#endif /* _GETOPT_H_ */

View File

@ -5,6 +5,90 @@ What's New for OpenJPIP
! : changed ! : changed
+ : added + : added
January 26, 2011
! [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 July 6, 2011
* [antonin] JPIP : fixed autotools to work with recent name changes * [antonin] JPIP : fixed autotools to work with recent name changes

View File

@ -0,0 +1,13 @@
# required dep for server:
IF(BUILD_JPIP_SERVER)
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(FCGI REQUIRED)
FIND_PACKAGE(PTHREAD REQUIRED)
ENDIF(BUILD_JPIP_SERVER)
# JPIP library:
ADD_SUBDIRECTORY(libopenjpip)
# JPIP binaries:
ADD_SUBDIRECTORY(util)

View File

@ -1,3 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = libopenjpip opj_server opj_client tools SUBDIRS = libopenjpip util

View File

@ -1,19 +0,0 @@
default: t_libopenjpip t_opj_server t_opj_dec_server t_tools
t_libopenjpip:
make -C libopenjpip -f Makefile.nix
t_opj_server:
make -C opj_server -f Makefile.nix
t_opj_dec_server:
make -C opj_client/opj_dec_server -f Makefile.nix
t_tools:
make -C tools -f Makefile.nix
clean:
make clean -C libopenjpip -f Makefile.nix
make clean -C opj_server -f Makefile.nix
make clean -C opj_client/opj_dec_server -f Makefile.nix
make clean -C tools -f Makefile.nix

View File

@ -1,5 +1,5 @@
======================================================================== ========================================================================
OpenJPIP software 1.0 ReadMe OpenJPIP software 2.1 ReadMe
OpenJPEG: OpenJPEG:
http://www.openjpeg.org http://www.openjpeg.org
@ -26,13 +26,14 @@ OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools,
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html) ( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
The current implementation uses some results from the 2KAN project (http://www.2kan.org). The current implementation uses some results from the 2KAN project (http://www.2kan.org).
First Version 1.0 covers: Version 2.1 covers:
- JPT-stream (Tile based) media types - JPT-stream (Tile) and JPP-stream (Precinct) media types
- Session, channels, cache model managements - Session, channels, cache model managements
- JPIP over HTTP - JPIP over HTTP, HTTP requests and TCP return
- Indexing JPEG 2000 files - Indexing JPEG 2000 files
- Embedding XML formatted metadata - Embedding XML formatted metadata
- Region Of Interest (ROI) requests - Region Of Interest (ROI) requests
- Access to JP2 files with their URL
---------- ----------
2. License 2. License
@ -46,10 +47,9 @@ Neither the author, nor the university accept any responsibility for any kind of
3. System requirements 3. System requirements
---------- ----------
- OpenJPEG library (currently assumes it is installed on the system => will not use the one built higher in the directory structure)
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com) - FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
- libcURL library
- Java application launcher at client - Java application launcher at client
- Kakadu software ( http://www.kakadusoftware.com). Currently required to encode jpeg 2000 images with tile-parts. This will be implemented soon in openjpeg, making this requirement obsolete.
<Optional> <Optional>
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j) - Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
@ -62,8 +62,6 @@ We tested this software with a virtual server running on the same Linux machine
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables. A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course) Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
CMake files ar planned to be included ASAP.
The documentation can be build this way (requires doxygen utility): The documentation can be build this way (requires doxygen utility):
cd doc cd doc
doxygen Doxyfile doxygen Doxyfile
@ -90,6 +88,11 @@ Server:
2. Launch opj_server from the server terminal: 2. Launch opj_server from the server terminal:
% spawn-fcgi -f ./opj_server -p 3000 -n % spawn-fcgi -f ./opj_server -p 3000 -n
For shutting down JPIP server:
%GET http://hostname/myFCGI?quitJPIP
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
Client: Client:
1. Launch image decoding server, and keep it alive as long as image viewers are open 1. Launch image decoding server, and keep it alive as long as image viewers are open
@ -101,10 +104,13 @@ Client:
% ../opj_dec_server % ../opj_dec_server
2. Open image viewers (as many as needed) 2. Open image viewers (as many as needed)
% java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2 % java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [stateless/session] [jptstream/jppstream] [tcp/udp]
( The arguments ( The arguments
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting) - http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
- JP2_filename.jp2 is the name of a JP2 file available on the server.) - path/filename.jp2 is the server local path or URL of a JP2 file
- request type stateless for no caching, session (default) for caching
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
Image viewer GUI instructions: Image viewer GUI instructions:
Scale up request: Enlarge the window Scale up request: Enlarge the window
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
@ -114,7 +120,7 @@ Client:
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction) Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
3. Quit the image decoding server through the telnet, be sure all image viewers are closed 3. Quit the image decoding server through the telnet, be sure all image viewers are closed
% telnet localhost 5000 % telnet localhost 50000
quit quit
---------- ----------
@ -122,12 +128,11 @@ Client:
---------- ----------
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale. An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
1. J2K encoding using Kakadu with an option which introduces the tile-part flag at each resolution level options
% ./kdu_compress -i copenhague1.tif -o copenhague1.j2k Corder=RPCL ORGtparts=R Stiles={256,256} -jpip : embed index table box into the output JP2 file (obligation for JPIP)
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
2. JP2 encoding with embedding indexing data
% ./index_create copenhague1.j2k copenhague1.jp2 2
<Option> <Option>
3. Embed metadata into JP2 file 3. Embed metadata into JP2 file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -0,0 +1,73 @@
INCLUDE_REGULAR_EXPRESSION("^.*$")
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
${FCGI_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${PTHREAD_INCLUDE_DIRS}
)
# Defines the source code for the library
SET(OPENJPIP_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/boxheader_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/codestream_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/imgreg_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/marker_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/msgqueue_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/box_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/faixbox_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/index_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/metadata_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/placeholder_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/byte_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/ihdrbox_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/manfbox_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/mhixbox_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/target_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/cachemodel_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/j2kheader_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_encoder.c
${CMAKE_CURRENT_SOURCE_DIR}/openjpip.c
${CMAKE_CURRENT_SOURCE_DIR}/query_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/channel_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
)
SET(SERVER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/auxtrans_manager.c
)
SET(LOCAL_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/dec_clientmsg_handler.c
)
# Build the library
ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME})
IF(WIN32)
# add Winsock on windows+mingw
TARGET_LINK_LIBRARIES(openjpip_local ws2_32)
ENDIF(WIN32)
# Install library
INSTALL(TARGETS openjpip_local
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
IF(BUILD_JPIP_SERVER)
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${PTHREAD_LIBRARIES})
SET_TARGET_PROPERTIES(openjpip_server
PROPERTIES COMPILE_FLAGS "-DSERVER")
INSTALL(TARGETS openjpip_server
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
ENDIF(BUILD_JPIP_SERVER)

View File

@ -3,9 +3,22 @@ MAINTAINERCLEANFILES = Makefile.in
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR) includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
includes_HEADERS = includes_HEADERS =
lib_LTLIBRARIES = libopenjpip_server.la libopenjpip_local.la lib_LTLIBRARIES =
if WANT_JPIP
lib_LTLIBRARIES += libopenjpip_local.la
endif
if WANT_JPIP_SERVER
lib_LTLIBRARIES += libopenjpip_server.la
endif
JPIP_SRC = \ JPIP_SRC = \
openjpip.c \
query_parser.c \
channel_manager.c \
session_manager.c \
jpip_parser.c \
boxheader_manager.c \ boxheader_manager.c \
codestream_manager.c \ codestream_manager.c \
imgreg_manager.c \ imgreg_manager.c \
@ -21,6 +34,11 @@ ihdrbox_manager.c \
manfbox_manager.c \ manfbox_manager.c \
mhixbox_manager.c \ mhixbox_manager.c \
target_manager.c \ target_manager.c \
cachemodel_manager.c \
j2kheader_manager.c \
jp2k_encoder.c \
sock_manager.c \
openjpip.h \
bool.h \ bool.h \
boxheader_manager.h \ boxheader_manager.h \
box_manager.h \ box_manager.h \
@ -36,35 +54,73 @@ metadata_manager.h \
mhixbox_manager.h \ mhixbox_manager.h \
msgqueue_manager.h \ msgqueue_manager.h \
placeholder_manager.h \ placeholder_manager.h \
target_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 = \ libopenjpip_server_la_CPPFLAGS = \
-I. \ -I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \ -I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \ -I$(top_builddir)/applications/jpip/libopenjpip \
@FCGI_CFLAGS@ \ @FCGI_CFLAGS@ \
@LIBCURL_CFLAGS@ \
-DSERVER -DSERVER
libopenjpip_server_la_CFLAGS = libopenjpip_server_la_CFLAGS = @THREAD_CFLAGS@
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ -lm libopenjpip_server_la_LIBADD = @FCGI_LIBS@ @LIBCURL_LIBS@ @THREAD_LIBS@ -lm
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@ libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
libopenjpip_server_la_SOURCES = $(JPIP_SRC) libopenjpip_server_la_SOURCES = $(JPIP_SRC) $(SERVER_SRC)
libopenjpip_local_la_CPPFLAGS = \ libopenjpip_local_la_CPPFLAGS = \
-I. \ -I. \
-I$(top_srcdir)/libopenjpeg \
-I$(top_builddir)/libopenjpeg \
-I$(top_srcdir)/applications/jpip/libopenjpip \ -I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip -I$(top_builddir)/applications/jpip/libopenjpip \
libopenjpip_local_la_CFLAGS = @LIBCURL_CFLAGS@
libopenjpip_local_la_LIBADD = -lm 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_LDFLAGS = -no-undefined -version-info @lt_version@
libopenjpip_local_la_SOURCES = $(JPIP_SRC) libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
install-data-hook: install-data-hook:
if WANT_JPIP_SERVER
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt @echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
if BUILD_SHARED
@( $(call solist_s) ) >> $(top_builddir)/report.txt @( $(call solist_s) ) >> $(top_builddir)/report.txt
endif
if BUILD_STATIC
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt @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 @echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
if BUILD_SHARED
@( $(call solist_c) ) >> $(top_builddir)/report.txt @( $(call solist_c) ) >> $(top_builddir)/report.txt
endif
if BUILD_STATIC
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt @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)' ;) 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) get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)

View File

@ -1,10 +0,0 @@
default: local server
local:
make -f comMakefile.mk
server:
rm *.o && make jpipserver=yes -f comMakefile.mk
clean:
rm -f *.a *.o *~

View 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;
}

View File

@ -0,0 +1,72 @@
/*
* $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.
*/
#ifndef AUXTRANS_MANAGER_H_
# define AUXTRANS_MANAGER_H_
#include "sock_manager.h"
/** auxiliary transport setting parameters*/
typedef struct auxtrans_param{
int tcpauxport; /**< tcp port*/
int udpauxport; /**< udp port*/
SOCKET tcplistensock; /**< listenning socket for aux tcp (-1 if not open)*/
SOCKET udplistensock; /**< listenning socket for aux udp (-1 if not open)*/
} auxtrans_param_t;
/**
* Initialize auxiliary transport server of JPIP server
*
* @param[in] tcp_auxport opening tcp auxiliary port ( 0 not to open, valid No. 4915265535)
* @param[in] udp_auxport opening udp auxiliary port ( 0 not to open, valid No. 4915265535)
* @return intialized transport parameters
*/
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport);
/**
* Close auxiliary transport server of JPIP server
*
* @param[in] auxtrans closing transport server
*/
void close_aux_transport( auxtrans_param_t auxtrans);
/**
* Send response data on aux transport
*
* @param[in] istcp true if tcp, false if udp
* @param[in] auxtrans available transport parameters
* @param[in] cid channel ID
* @param[in] data sending data
* @param[in] length length of data
* @param[in] maxlenPerFrame maximum data length to send per frame
*/
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int length, int maxlenPerFrame);
#endif /* !AUXTRANS_MANAGER_H_ */

View File

@ -28,11 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include "box_manager.h" #include "box_manager.h"
@ -43,7 +41,7 @@
#define FCGI_stdout stdout #define FCGI_stdout stdout
#define FCGI_stderr stderr #define FCGI_stderr stderr
#define logstream stderr #define logstream stderr
#endif //SERVER #endif /*SERVER*/
boxlist_param_t * gene_boxlist() boxlist_param_t * gene_boxlist()
{ {
@ -74,7 +72,7 @@ boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
if( !boxlist) if( !boxlist)
boxlist = gene_boxlist(); boxlist = gene_boxlist();
insert_box_into_list( box, boxlist); insert_box_into_list( box, boxlist);
}while( pos < offset+length); }while( pos < (int)(offset+length));
return boxlist; return boxlist;
} }
@ -86,7 +84,7 @@ box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
char *boxtype; char *boxtype;
box_param_t *box; box_param_t *box;
// read LBox and TBox /* read LBox and TBox*/
if(!(data = fetch_bytes( fd, offset, 8))){ if(!(data = fetch_bytes( fd, offset, 8))){
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset); fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
return NULL; return NULL;
@ -96,10 +94,10 @@ box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
boxlen = (Byte8_t)big4(data); boxlen = (Byte8_t)big4(data);
boxtype = (char *)(data+4); boxtype = (char *)(data+4);
// box type constraint /* box type constraint*/
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) || if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
(!isalnum(boxtype[2])&&!isblank(boxtype[2])) || (!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
(!isalpha(boxtype[3])&&!isblank(boxtype[3]))){ (!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
free( data); free( data);
return NULL; return NULL;
} }
@ -107,7 +105,7 @@ box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
if( boxlen == 1){ if( boxlen == 1){
Byte_t *data2; Byte_t *data2;
headlen = 16; headlen = 16;
// read XLBox /* read XLBox*/
if((data2 = fetch_bytes( fd, offset+8, 8))){ if((data2 = fetch_bytes( fd, offset+8, 8))){
boxlen = big8(data2); boxlen = big8(data2);
free(data2); free(data2);
@ -135,21 +133,21 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
char *boxtype; char *boxtype;
box_param_t *box; box_param_t *box;
// read LBox and TBox /* read LBox and TBox*/
headlen = 8; headlen = 8;
boxlen = (Byte8_t)big4( stream); boxlen = (Byte8_t)big4( stream);
boxtype = (char *)( stream+4); boxtype = (char *)( stream+4);
// box type constraint /* box type constraint*/
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) || if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
(!isalnum(boxtype[2])&&!isblank(boxtype[2])) || (!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
(!isalpha(boxtype[3])&&!isblank(boxtype[3]))){ (!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
return NULL; return NULL;
} }
if( boxlen == 1){ if( boxlen == 1){
headlen = 16; headlen = 16;
boxlen = big8( stream+8); // read XLBox boxlen = big8( stream+8); /* read XLBox*/
} }
box = (box_param_t *)malloc( sizeof( box_param_t)); box = (box_param_t *)malloc( sizeof( box_param_t));
box->fd = -1; box->fd = -1;
@ -172,19 +170,15 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[
box_param_t *foundbox; box_param_t *foundbox;
if( length==0){ // set the max length if( length==0){ /* set the max length*/
struct stat sb; if( (length = get_filesize( fd) - offset) <= 0)
if( fstat( fd, &sb) == -1){
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
return NULL; return NULL;
}
length = (Byte8_t)sb.st_size - offset;
} }
pos = offset; pos = offset;
while( pos < offset+length-7){ // LBox+TBox-1=7 while( pos < offset+length-7){ /* LBox+TBox-1=7*/
// read LBox and TBox /* read LBox and TBox*/
if((data = fetch_bytes( fd, pos, 8))){ if((data = fetch_bytes( fd, pos, 8))){
headlen = 8; headlen = 8;
boxlen = (Byte8_t)big4(data); boxlen = (Byte8_t)big4(data);
@ -193,7 +187,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[
if( boxlen == 1){ if( boxlen == 1){
Byte_t *data2; Byte_t *data2;
headlen = 16; headlen = 16;
// read XLBox /* read XLBox*/
if((data2 = fetch_bytes( fd, pos+8, 8))){ if((data2 = fetch_bytes( fd, pos+8, 8))){
boxlen = big8(data2); boxlen = big8(data2);
free(data2); free(data2);
@ -236,22 +230,22 @@ box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t le
box_param_t *foundbox; box_param_t *foundbox;
if( length<=0){ // set the max length if( length<=0){ /* set the max length*/
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n"); fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
return NULL; return NULL;
} }
pos = offset; pos = offset;
while( pos < offset+length-7){ // LBox+TBox-1=7 while( pos < offset+length-7){ /* LBox+TBox-1=7*/
// read LBox and TBox /* read LBox and TBox*/
data = stream + pos; data = stream + pos;
headlen = 8; headlen = 8;
boxlen = (Byte8_t)big4(data); boxlen = (Byte8_t)big4(data);
boxtype = (char *)(data+4); boxtype = (char *)(data+4);
if( boxlen == 1){ if( boxlen == 1){
// read XLBox /* read XLBox*/
headlen = 16; headlen = 16;
boxlen = big8( data+8); boxlen = big8( data+8);
} }

View File

@ -31,24 +31,23 @@
#ifndef BOX_MANAGER_H_ #ifndef BOX_MANAGER_H_
# define BOX_MANAGER_H_ # define BOX_MANAGER_H_
#include <stdio.h>
#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*/
Byte8_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;

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -58,6 +59,7 @@ boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
boxlen = fetch_8bytebigendian( fd, offset+8); boxlen = fetch_8bytebigendian( fd, offset+8);
headlen = 16; headlen = 16;
} }
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t)); boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
boxheader->headlen = headlen; boxheader->headlen = headlen;
boxheader->length = boxlen; boxheader->length = boxlen;

View File

@ -34,12 +34,12 @@
#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;

View File

@ -28,9 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#ifdef _WIN32
#include <io.h>
#else
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h>
#include "byte_manager.h" #include "byte_manager.h"
#ifdef SERVER #ifdef SERVER
@ -40,7 +46,7 @@
#define FCGI_stdout stdout #define FCGI_stdout stdout
#define FCGI_stderr stderr #define FCGI_stderr stderr
#define logstream stderr #define logstream stderr
#endif //SERVER #endif /*SERVER*/
Byte_t * fetch_bytes( int fd, long offset, int size) Byte_t * fetch_bytes( int fd, long offset, int size)
@ -144,3 +150,23 @@ Byte8_t big8( Byte_t *buf)
return (((Byte8_t) big4 (buf)) << 32) return (((Byte8_t) big4 (buf)) << 32)
+ ((Byte8_t) big4 (buf + 4)); + ((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;
}

View File

@ -31,18 +31,16 @@
#ifndef BYTE_MANAGER_H_ #ifndef BYTE_MANAGER_H_
# define BYTE_MANAGER_H_ # define BYTE_MANAGER_H_
#include <stdio.h> /** 1Byte parameter type*/
//! 1Byte parameter type
typedef unsigned char Byte_t; typedef unsigned char Byte_t;
//! 2Byte parameter type /** 2Byte parameter type*/
typedef unsigned short int Byte2_t; typedef unsigned short int Byte2_t;
//! 4Byte parameter type /** 4Byte parameter type*/
typedef unsigned int Byte4_t; typedef unsigned int Byte4_t;
//! 8Byte parameter type /** 8Byte parameter type*/
typedef unsigned long long int Byte8_t; typedef unsigned long long int Byte8_t;
@ -118,5 +116,20 @@ Byte4_t big4( Byte_t *buf);
*/ */
Byte8_t big8( Byte_t *buf); Byte8_t big8( Byte_t *buf);
/**
* modify 4Byte code in a codestream
*
* @param[in] code code value
* @param[out] stream modifying codestream
*/
void modify_4Bytecode( Byte4_t code, Byte_t *stream);
/**
* Get file size
*
* @param[in] fd file discriptor
* @return file size
*/
Byte8_t get_filesize( int fd);
#endif /* !BYTE_MANAGER_H_ */ #endif /* !BYTE_MANAGER_H_ */

View File

@ -33,9 +33,6 @@
#include <string.h> #include <string.h>
#include "cache_manager.h" #include "cache_manager.h"
//! maximum length of channel identifier
#define MAX_LENOFCID 30
cachelist_param_t * gene_cachelist() cachelist_param_t * gene_cachelist()
{ {
cachelist_param_t *cachelist; cachelist_param_t *cachelist;
@ -61,16 +58,16 @@ void delete_cachelist(cachelist_param_t **cachelist)
free( *cachelist); free( *cachelist);
} }
cache_param_t * gene_cache( char *targetname, int csn, char *cid) cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
{ {
cache_param_t *cache; cache_param_t *cache;
cache = (cache_param_t *)malloc( sizeof(cache_param_t)); cache = (cache_param_t *)malloc( sizeof(cache_param_t));
strcpy( cache->filename, targetname); cache->filename = strdup( targetname);
cache->tid = strdup( tid);
cache->csn = csn; cache->csn = csn;
cache->cid = (char **)malloc( sizeof(char *)); cache->cid = (char **)malloc( sizeof(char *));
*cache->cid = (char *)malloc( MAX_LENOFCID); *cache->cid = strdup( cid);
strcpy( *cache->cid, cid);
cache->numOfcid = 1; cache->numOfcid = 1;
#if 1 #if 1
cache->metadatalist = NULL; cache->metadatalist = NULL;
@ -86,6 +83,9 @@ cache_param_t * gene_cache( char *targetname, int csn, char *cid)
void delete_cache( cache_param_t **cache) void delete_cache( cache_param_t **cache)
{ {
int i; int i;
free( (*cache)->filename);
free( (*cache)->tid);
delete_metadatalist( &(*cache)->metadatalist); delete_metadatalist( &(*cache)->metadatalist);
@ -110,6 +110,9 @@ cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist)
{ {
cache_param_t *foundcache; cache_param_t *foundcache;
if( !targetname)
return NULL;
foundcache = cachelist->first; foundcache = cachelist->first;
while( foundcache != NULL){ while( foundcache != NULL){
@ -142,6 +145,9 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
cache_param_t *foundcache; cache_param_t *foundcache;
int i; int i;
if( !cid)
return NULL;
foundcache = cachelist->first; foundcache = cachelist->first;
while( foundcache != NULL){ while( foundcache != NULL){
@ -153,28 +159,50 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
return NULL; 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) void add_cachecid( char *cid, cache_param_t *cache)
{ {
char **tmp; if( !cid)
int i; return;
tmp = cache->cid;
cache->cid = (char **)malloc( (cache->numOfcid+1)*sizeof(char *)); 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");
for( i=0; i<cache->numOfcid; i++){ return;
cache->cid[i] = (char *)malloc( MAX_LENOFCID);
strcpy( cache->cid[i], tmp[i]);
free( tmp[i]);
} }
free( tmp);
cache->cid[ cache->numOfcid] = strdup( cid);
cache->cid[ cache->numOfcid] = (char *)malloc( MAX_LENOFCID);
strcpy( cache->cid[ cache->numOfcid], cid);
cache->numOfcid ++; 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_cidInCache( char *cid, cache_param_t *cache);
void remove_cachecid( char *cid, cachelist_param_t *cachelist) void remove_cachecid( char *cid, cachelist_param_t *cachelist)
@ -208,8 +236,7 @@ void remove_cidInCache( char *cid, cache_param_t *cache)
for( i=0, j=0; i<cache->numOfcid; i++){ for( i=0, j=0; i<cache->numOfcid; i++){
if( i != idx){ if( i != idx){
cache->cid[j] = (char *)malloc( MAX_LENOFCID); cache->cid[j] = strdup( tmp[i]);
strcpy( cache->cid[j], tmp[i]);
j++; j++;
} }
free( tmp[i]); free( tmp[i]);
@ -225,6 +252,7 @@ void print_cache( cache_param_t *cache)
fprintf( stdout,"cache\n"); fprintf( stdout,"cache\n");
fprintf( stdout,"\t filename: %s\n", cache->filename); 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 csn: %d\n", cache->csn);
fprintf( stdout,"\t cid:"); fprintf( stdout,"\t cid:");

View File

@ -34,24 +34,22 @@
#include "metadata_manager.h" #include "metadata_manager.h"
#include "ihdrbox_manager.h" #include "ihdrbox_manager.h"
//! maximum length of target name /** cache parameters*/
#define MAX_LENOFTARGET 128
//! cache parameters
typedef struct cache_param{ typedef struct cache_param{
char filename[MAX_LENOFTARGET]; //!< file name char *filename; /**< file name*/
int csn; //!< codestream number char *tid; /**< taregt identifier*/
char **cid; //!< dynamic array of channel identifiers int csn; /**< codestream number*/
int numOfcid; //!< number of cids char **cid; /**< dynamic array of channel identifiers*/
metadatalist_param_t *metadatalist; //!< metadata-bin list int numOfcid; /**< number of cids*/
ihdrbox_param_t *ihdrbox; //!< ihdrbox metadatalist_param_t *metadatalist; /**< metadata-bin list*/
struct cache_param *next; //!< pointer to the next cache ihdrbox_param_t *ihdrbox; /**< ihdrbox*/
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;
@ -74,10 +72,11 @@ void delete_cachelist(cachelist_param_t **cachelist);
* *
* @param[in] targetname target file name * @param[in] targetname target file name
* @param[in] csn codestream number * @param[in] csn codestream number
* @param[in] tid target identifier
* @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( char *targetname, int csn, char *cid); cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
/** /**
* delete a cache * delete a cache
@ -116,7 +115,7 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
/** /**
* search codestream number (csn) by cid * search a cache by cid
* *
* @param[in] cid channel identifer * @param[in] cid channel identifer
* @param[in] cachelist cache list pointer * @param[in] cachelist cache list pointer
@ -124,6 +123,16 @@ cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
*/ */
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist); cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
/**
* search a cache by tid
*
* @param[in] tid target identifer
* @param[in] cachelist cache list pointer
* @return found cache pointer
*/
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist);
/** /**
* add cid into a cache * add cid into a cache
* *
@ -132,6 +141,16 @@ cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
*/ */
void add_cachecid( char *cid, cache_param_t *cache); void add_cachecid( char *cid, cache_param_t *cache);
/**
* update tid of a cache
*
* @param[in] tid target identifier
* @param[in] cache cache pointer
*/
void update_cachetid( char *tid, cache_param_t *cache);
/** /**
* remove cid in cache * remove cid in cache
* *

View File

@ -0,0 +1,233 @@
/*
* $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()
{
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
int i, j, k, n;
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.%d %d\n", i, cachemodel.th_model[i]);
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
fprintf( logstream, "\t compo.%d: ", 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
int i, j, k, n;
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;
}
}

View File

@ -0,0 +1,115 @@
/*
* $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.
*/
#ifndef CACHEMODEL_MANAGER_H_
# define CACHEMODEL_MANAGER_H_
#include "bool.h"
#include "target_manager.h"
/** Cache model parameters*/
typedef struct cachemodel_param{
target_param_t *target; /**< reference pointer to the target*/
bool jppstream; /**< return type, true: JPP-stream, false: JPT-stream*/
bool mhead_model; /**< main header model, if sent, 1, else 0*/
bool *tp_model; /**< dynamic array pointer of tile part model, if sent, 1, else 0*/
bool *th_model; /**< dynamic array pointer of tile header model*/
bool **pp_model; /**< dynamic array pointer of precint packet model*/
struct cachemodel_param *next; /**< pointer to the next cache model*/
} cachemodel_param_t;
/** Cache model list parameters*/
typedef struct cachemodellist_param{
cachemodel_param_t *first; /**< first cache model pointer of the list*/
cachemodel_param_t *last; /**< last cache model pointer of the list*/
} cachemodellist_param_t;
/**
* generate a cache model list
*
* @return pointer to the generated cache model list
*/
cachemodellist_param_t * gene_cachemodellist();
/**
* generate a cache model under a list
*
* @param[in] cachemodellist cachemodel list to insert the generated cache model, NULL for stateless
* @param[in] target pointer the reference target
* @param[in] reqJPP if JPP-stream is desired true, JPT-stream false
* @return pointer to the generated cache model
*/
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP);
/**
* print cache model
*
* @param[in] cachemodel cache model
*/
void print_cachemodel( cachemodel_param_t cachemodel);
/**
* search a cache model of a target
*
* @param[in] target refering target
* @param[in] cachemodellist cache model list
* @return found cache model pointer
*/
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist);
/**
* check if all data has been sent
*
* @param[in] cachemodel cache model
* @return true if sent all, false otherwise
*/
bool is_allsent( cachemodel_param_t cachemodel);
/**
* delete a cache model
*
* @param[in] cachemodel address of the cachemodel pointer
*/
void delete_cachemodel( cachemodel_param_t **cachemodel);
/**
* delete cachemodel list
*
* @param[in,out] cachemodellist address of the cachemodel list pointer
*/
void delete_cachemodellist( cachemodellist_param_t **cachemodellist);
#endif /* !CACHEMODEL_MANAGER_H_ */

View File

@ -54,23 +54,28 @@ channellist_param_t * gene_channellist()
return channellist; 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 * gene_channel( query_param_t query_param, target_param_t *target, channellist_param_t *channellist)
{ {
channel_param_t *channel; channel_param_t *channel;
char transport[4][10] = { "non", "http", "http-tcp", "http-udp"};
// set the target
if( !target){ if( !cachemodel){
fprintf( FCGI_stdout, "Status: 404\r\n"); fprintf( FCGI_stdout, "Status: 404\r\n");
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n"); fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
return NULL; return NULL;
} }
channel = (channel_param_t *)malloc( sizeof(channel_param_t)); channel = (channel_param_t *)malloc( sizeof(channel_param_t));
channel->target = target; channel->cachemodel = cachemodel;
// set channel ID and get present time // set channel ID and get present time
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());; 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; channel->next=NULL;
@ -83,8 +88,12 @@ channel_param_t * gene_channel( query_param_t query_param, target_param_t *targe
channellist->last = channel; channellist->last = channel;
fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid); fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid);
// only http implemented for now fprintf( FCGI_stdout, ",transport=%s", transport[channel->aux]);
fprintf( FCGI_stdout, ",transport=http\r\n");
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; return channel;
} }
@ -141,7 +150,7 @@ void print_allchannel( channellist_param_t *channellist)
ptr = channellist->first; ptr = channellist->first;
while( ptr != NULL){ while( ptr != NULL){
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->target->filename); fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->cachemodel->target->targetname);
ptr=ptr->next; ptr=ptr->next;
} }
} }

View File

@ -33,23 +33,27 @@
#include <time.h> #include <time.h>
#include "query_parser.h" #include "query_parser.h"
#include "target_manager.h" #include "cachemodel_manager.h"
#include "auxtrans_manager.h"
//! Channel parameters /** maximum length of channel identifier*/
#define MAX_LENOFCID 30
/** Channel parameters*/
typedef struct channel_param{ typedef struct channel_param{
target_param_t *target; //!< reference pointer to the target cachemodel_param_t *cachemodel; /**< reference pointer to the cache model*/
char cid[MAX_LENOFCID]; //!< channel identifier char cid[MAX_LENOFCID]; /**< channel identifier*/
// - a record of the client's capabilities and preferences cnew_transport_t aux; /**< auxiliary transport*/
// - 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;
@ -65,11 +69,12 @@ channellist_param_t * gene_channellist();
* generate a channel under the channel list * generate a channel under the channel list
* *
* @param[in] query_param query parameters * @param[in] query_param query parameters
* @param[in] target reference target * @param[in] auxtrans auxiliary transport
* @param[in] cachemodel reference cachemodel
* @param[in] channellist channel list pointer * @param[in] channellist channel list pointer
* @return pointer to the generated channel * @return pointer to the generated channel
*/ */
channel_param_t * gene_channel( query_param_t query_param, target_param_t *target, channellist_param_t *channellist); channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist);
/** /**
* set channel variable parameters * set channel variable parameters

View File

@ -31,14 +31,13 @@
#ifndef CODESTREAM_MANAGER_H_ #ifndef CODESTREAM_MANAGER_H_
# define CODESTREAM_MANAGER_H_ # define CODESTREAM_MANAGER_H_
#include <stdio.h>
#include "byte_manager.h" #include "byte_manager.h"
//! codestream parameters /** codestream parameters*/
typedef struct codestream_param{ typedef struct codestream_param{
int fd; //!< file descriptor int fd; /**< file descriptor*/
Byte8_t offset; //!< byte position of DBox (Box Contents) in the file Byte8_t offset; /**< byte position of DBox (Box Contents) in the file*/
Byte8_t length; //!< content length Byte8_t length; /**< content length*/
} codestream_param_t; } codestream_param_t;

View File

@ -2,16 +2,28 @@ ifdef jpipserver
CFLAGS = -O3 -Wall -m32 -DSERVER CFLAGS = -O3 -Wall -m32 -DSERVER
LIBNAME = libopenjpip_server.a LIBNAME = libopenjpip_server.a
else else
CFLAGS = -O3 -Wall J2KINCDIR = ../../../libopenjpeg
CFLAGS = -O3 -Wall -I$(J2KINCDIR)
LIBNAME = libopenjpip_local.a LIBNAME = libopenjpip_local.a
endif endif
all: $(LIBNAME) all: $(LIBNAME)
$(LIBNAME): target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \ ifdef jpipserver
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \ mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
session_manager.o jpip_parser.o sock_manager.o auxtrans_manager.o
ar r $@ $^ ar r $@ $^
else
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
session_manager.o jpip_parser.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o \
dec_clientmsg_handler.o sock_manager.o
ar r $@ $^
endif
clean: clean:
rm -f $(LIBNAME) *.o *~ rm -f $(LIBNAME) *.o *~

View File

@ -0,0 +1,243 @@
/*
* $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 <string.h>
#include "dec_clientmsg_handler.h"
#include "ihdrbox_manager.h"
#include "jpipstream_manager.h"
#include "jp2k_encoder.h"
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
{
Byte_t *newjpipstream;
int newstreamlen = 0;
cache_param_t *cache;
char *target, *tid, *cid;
metadatalist_param_t *metadatalist;
newjpipstream = receive_JPIPstream( connected_socket, &target, &tid, &cid, &newstreamlen);
fprintf( stderr, "newjpipstream length: %d\n", newstreamlen);
parse_JPIPstream( newjpipstream, newstreamlen, *streamlen, msgqueue);
*jpipstream = update_JPIPstream( newjpipstream, newstreamlen, *jpipstream, streamlen);
free( newjpipstream);
metadatalist = gene_metadatalist();
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
/* cid registration*/
if( target != NULL){
if((cache = search_cache( target, cachelist))){
if( tid != NULL)
update_cachetid( tid, cache);
if( cid != NULL)
add_cachecid( cid, cache);
}
else{
cache = gene_cache( target, msgqueue->last->csn, tid, cid);
insert_cache_into_list( cache, cachelist);
}
}
else
cache = search_cacheBycsn( msgqueue->last->csn, cachelist);
if( cache->metadatalist)
delete_metadatalist( &cache->metadatalist);
cache->metadatalist = metadatalist;
if( target) free( target);
if( tid) free( tid);
if( cid) free( cid);
response_signal( connected_socket, true);
}
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
{
Byte_t *pnmstream;
ihdrbox_param_t *ihdrbox;
char *CIDorTID, tmp[10];
cache_param_t *cache;
int fw, fh;
CIDorTID = receive_string( connected_socket);
if(!(cache = search_cacheBycid( CIDorTID, cachelist)))
if(!(cache = search_cacheBytid( CIDorTID, cachelist))){
free( CIDorTID);
return;
}
free( CIDorTID);
receive_line( connected_socket, tmp);
fw = atoi( tmp);
receive_line( connected_socket, tmp);
fh = atoi( tmp);
ihdrbox = NULL;
pnmstream = jpipstream_to_pnm( jpipstream, msgqueue, cache->csn, fw, fh, &ihdrbox);
send_PNMstream( connected_socket, pnmstream, ihdrbox->width, ihdrbox->height, ihdrbox->nc, ihdrbox->bpc > 8 ? 255 : (1 << ihdrbox->bpc) - 1);
free( ihdrbox);
free( pnmstream);
}
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist)
{
char *cid;
cache_param_t *cache;
boxcontents_param_t *boxcontents;
Byte_t *xmlstream;
cid = receive_string( connected_socket);
if(!(cache = search_cacheBycid( cid, cachelist))){
free( cid);
return;
}
free( cid);
boxcontents = cache->metadatalist->last->boxcontents;
xmlstream = (Byte_t *)malloc( boxcontents->length);
memcpy( xmlstream, jpipstream+boxcontents->offset, boxcontents->length);
send_XMLstream( connected_socket, xmlstream, boxcontents->length);
free( xmlstream);
}
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
{
char *target, *tid = NULL;
cache_param_t *cache;
int tidlen = 0;
target = receive_string( connected_socket);
cache = search_cache( target, cachelist);
free( target);
if( cache){
tid = cache->tid;
tidlen = strlen(tid);
}
send_TIDstream( connected_socket, tid, tidlen);
}
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
{
char *target, *cid = NULL;
cache_param_t *cache;
int cidlen = 0;
target = receive_string( connected_socket);
cache = search_cache( target, cachelist);
free( target);
if( cache){
if( cache->numOfcid > 0){
cid = cache->cid[ cache->numOfcid-1];
cidlen = strlen(cid);
}
}
send_CIDstream( connected_socket, cid, cidlen);
}
void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
{
char *cid;
cid = receive_string( connected_socket);
remove_cachecid( cid, cachelist);
response_signal( connected_socket, true);
free( cid);
}
void handle_SIZreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
{
char *tid, *cid;
cache_param_t *cache;
Byte4_t width, height;
tid = receive_string( connected_socket);
cid = receive_string( connected_socket);
cache = NULL;
if( tid[0] != '0')
cache = search_cacheBytid( tid, cachelist);
if( !cache && cid[0] != '0')
cache = search_cacheBycid( cid, cachelist);
free( tid);
free( cid);
width = height = 0;
if( cache){
if( !cache->ihdrbox)
cache->ihdrbox = get_SIZ_from_jpipstream( jpipstream, msgqueue, cache->csn);
width = cache->ihdrbox->width;
height = cache->ihdrbox->height;
}
send_SIZstream( connected_socket, width, height);
}
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream)
{
char *cid;
cache_param_t *cache;
Byte_t *jp2stream;
Byte8_t jp2len;
cid = receive_string( connected_socket);
if(!(cache = search_cacheBycid( cid, cachelist))){
free( cid);
return;
}
free( cid);
jp2stream = recons_jp2( msgqueue, jpipstream, cache->csn, &jp2len);
if( jp2stream){
save_codestream( jp2stream, jp2len, "jp2");
free( jp2stream);
}
}

View File

@ -0,0 +1,113 @@
/*
* $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
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DEC_CLIENTMSG_HANDLER_H_
# define DEC_CLIENTMSG_HANDLER_H_
#include "imgsock_manager.h"
#include "cache_manager.h"
#include "byte_manager.h"
#include "msgqueue_manager.h"
/**
* handle JPT- JPP- stream message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in,out] jpipstream address of JPT- JPP- stream pointer
* @param[in,out] streamlen address of stream length
* @param[in,out] msgqueue message queue pointer
*/
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue);
/**
* handle PNM request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream jpipstream pointer
* @param[in] msgqueue message queue pointer
* @param[in] cachelist cache list pointer
*/
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
/**
* handle XML request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream address of caching jpipstream pointer
* @param[in] cachelist cache list pointer
*/
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
/**
* handle TargetID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle ChannelID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle distroy ChannelID message
*
* @param[in] connected_socket socket descriptor
* @param[in,out] cachelist cache list pointer
*/
void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle SIZ request message
*
* @param[in] connected_socket socket descriptor
* @param[in,out] cachelist cache list pointer
*/
void handle_SIZreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
/**
* handle saving JP2 file request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in] msgqueue message queue pointer
* @param[in] jpipstream address of caching jpipstream pointer
*/
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream);
#endif /* !DEC_CLIENTMSG_HANDLER_H_ */

View File

@ -39,7 +39,7 @@
#define FCGI_stdout stdout #define FCGI_stdout stdout
#define FCGI_stderr stderr #define FCGI_stderr stderr
#define logstream stderr #define logstream stderr
#endif //SERVER #endif /*SERVER*/
faixbox_param_t * gene_faixbox( box_param_t *box) faixbox_param_t * gene_faixbox( box_param_t *box)
{ {
@ -51,7 +51,7 @@ faixbox_param_t * gene_faixbox( box_param_t *box)
faix->version = fetch_DBox1byte( box, (pos+=1)-1); faix->version = fetch_DBox1byte( box, (pos+=1)-1);
if( faix->version < 0 || 3< faix->version){ if( 3< faix->version){
fprintf( FCGI_stderr, "Error: version %d in faix box is reserved for ISO use.\n", faix->version); fprintf( FCGI_stderr, "Error: version %d in faix box is reserved for ISO use.\n", faix->version);
free(faix); free(faix);
return NULL; return NULL;
@ -59,7 +59,7 @@ faixbox_param_t * gene_faixbox( box_param_t *box)
if( faix->version%2){ if( faix->version%2){
subfaixbox8_param_t *subfaixbox; subfaixbox8_param_t *subfaixbox;
int i; size_t i;
faix->subfaixbox.byte8_params = (subfaixbox8_param_t *)malloc( sizeof(subfaixbox8_param_t)); faix->subfaixbox.byte8_params = (subfaixbox8_param_t *)malloc( sizeof(subfaixbox8_param_t));
@ -83,7 +83,7 @@ faixbox_param_t * gene_faixbox( box_param_t *box)
} }
else{ else{
subfaixbox4_param_t *subfaixbox; subfaixbox4_param_t *subfaixbox;
int i; size_t i;
faix->subfaixbox.byte4_params = (subfaixbox4_param_t *)malloc( sizeof(subfaixbox4_param_t)); faix->subfaixbox.byte4_params = (subfaixbox4_param_t *)malloc( sizeof(subfaixbox4_param_t));
@ -182,10 +182,11 @@ Byte8_t get_elemLen( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id)
Byte4_t get_elemAux( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id) Byte4_t get_elemAux( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id)
{ {
Byte8_t nmax;
if( faix->version <2) if( faix->version <2)
return -1; return -1;
Byte8_t nmax = get_nmax( faix); nmax = get_nmax( faix);
if( faix->version%2) if( faix->version%2)
return faix->subfaixbox.byte8_params->aux[ row_id*nmax+elem_id]; return faix->subfaixbox.byte8_params->aux[ row_id*nmax+elem_id];
else else

View File

@ -34,47 +34,47 @@
#include "byte_manager.h" #include "byte_manager.h"
#include "box_manager.h" #include "box_manager.h"
//! 4byte parameters of a faix element /** 4byte parameters of a faix element*/
typedef struct faixelem4_param{ typedef struct faixelem4_param{
Byte4_t off; //!< offset Byte4_t off; /**< offset*/
Byte4_t len; //!< length Byte4_t len; /**< length*/
} faixelem4_param_t; } faixelem4_param_t;
//! 8byte parameters of a faix element /** 8byte parameters of a faix element*/
typedef struct faixelem8_param{ typedef struct faixelem8_param{
Byte8_t off; //!< offset Byte8_t off; /**< offset*/
Byte8_t len; //!< length Byte8_t len; /**< length*/
} faixelem8_param_t; } faixelem8_param_t;
//! 4byte parameters of fragment array index box /** 4byte parameters of fragment array index box*/
typedef struct subfaixbox4_param{ typedef struct subfaixbox4_param{
Byte4_t nmax; //!< maximum number of valid elements in any row of the array Byte4_t nmax; /**< maximum number of valid elements in any row of the array*/
Byte4_t m; //!< number of raws of the array Byte4_t m; /**< number of raws of the array*/
faixelem4_param_t *elem; //!< dynamic array pointer of faix elements faixelem4_param_t *elem; /**< dynamic array pointer of faix elements*/
Byte4_t *aux; //!< dynamic array pointer of auxiliary Byte4_t *aux; /**< dynamic array pointer of auxiliary*/
//!info in each element for version 2 or 3 /**info in each element for version 2 or 3*/
} subfaixbox4_param_t; } subfaixbox4_param_t;
//! 8byte parameters of fragment array index box /** 8byte parameters of fragment array index box*/
typedef struct subfaixbox8_param{ typedef struct subfaixbox8_param{
Byte8_t nmax; //!< maximum number of valid elements in any row of the array Byte8_t nmax; /**< maximum number of valid elements in any row of the array*/
Byte8_t m; //!< number of raws of the array Byte8_t m; /**< number of raws of the array*/
faixelem8_param_t *elem; //!< dynamic array pointer of faix elements faixelem8_param_t *elem; /**< dynamic array pointer of faix elements*/
Byte4_t *aux; //!< dynamic array pointer of auxiliary Byte4_t *aux; /**< dynamic array pointer of auxiliary*/
//!info in each element for version 2 or 3 /**info in each element for version 2 or 3*/
} subfaixbox8_param_t; } subfaixbox8_param_t;
//! variable sized parameters in fragment array index box /** variable sized parameters in fragment array index box*/
typedef union subfaixbox_param{ typedef union subfaixbox_param{
subfaixbox4_param_t *byte4_params; //!< parameters with 4byte codes for version 0 or 2 subfaixbox4_param_t *byte4_params; /**< parameters with 4byte codes for version 0 or 2*/
subfaixbox8_param_t *byte8_params; //!< parameters with 8byte codes for version 1 or 3 subfaixbox8_param_t *byte8_params; /**< parameters with 8byte codes for version 1 or 3*/
} subfaixbox_param_t; } subfaixbox_param_t;
//! fragment array index box parameters /** fragment array index box parameters*/
//! I.3.2.4.2 Fragment Array Index box /** I.3.2.4.2 Fragment Array Index box*/
typedef struct faixbox_param{ typedef struct faixbox_param{
Byte_t version; //!< Refer to the Table I.3 - Version values Byte_t version; /**< Refer to the Table I.3 - Version values*/
subfaixbox_param_t subfaixbox; //!< rest information in faixbox subfaixbox_param_t subfaixbox; /**< rest information in faixbox*/
} faixbox_param_t; } faixbox_param_t;

View File

@ -32,7 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "ihdrbox_manager.h" #include "ihdrbox_manager.h"
ihdrbox_param_t * get_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jptstream) ihdrbox_param_t * gene_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jpipstream)
{ {
ihdrbox_param_t *ihdrbox; ihdrbox_param_t *ihdrbox;
metadata_param_t *meta; metadata_param_t *meta;
@ -53,7 +53,7 @@ ihdrbox_param_t * get_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jptst
return NULL; return NULL;
} }
ihdr = gene_boxbyTypeinStream( jptstream, get_DBoxoff( jp2h), get_DBoxlen( jp2h), "ihdr"); ihdr = gene_boxbyTypeinStream( jpipstream, get_DBoxoff( jp2h), get_DBoxlen( jp2h), "ihdr");
if( !ihdr){ if( !ihdr){
fprintf( stderr, "ihdr box not found\n"); fprintf( stderr, "ihdr box not found\n");
@ -62,10 +62,10 @@ ihdrbox_param_t * get_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jptst
ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t)); ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t));
ihdrbox->height = big4( jptstream+get_DBoxoff(ihdr)); ihdrbox->height = big4( jpipstream+get_DBoxoff(ihdr));
ihdrbox->width = big4( jptstream+get_DBoxoff(ihdr)+4); ihdrbox->width = big4( jpipstream+get_DBoxoff(ihdr)+4);
ihdrbox->nc = big2( jptstream+get_DBoxoff(ihdr)+8); ihdrbox->nc = big2( jpipstream+get_DBoxoff(ihdr)+8);
ihdrbox->bpc = *(jptstream+get_DBoxoff(ihdr)+10)+1; ihdrbox->bpc = *(jpipstream+get_DBoxoff(ihdr)+10)+1;
free( ihdr); free( ihdr);

View File

@ -35,14 +35,22 @@
#include "box_manager.h" #include "box_manager.h"
#include "metadata_manager.h" #include "metadata_manager.h"
/** I.5.3.1 Image Header box*/
typedef struct ihdrbox_param{ typedef struct ihdrbox_param{
Byte4_t height; Byte4_t height;
Byte4_t width; Byte4_t width;
Byte2_t nc; Byte2_t nc; /**< number of components*/
Byte_t bpc; Byte_t bpc; /**< bits per component*/
} ihdrbox_param_t; } ihdrbox_param_t;
ihdrbox_param_t * get_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jptstream); /**
* generate ihdr box
*
* @param[in] metadatalist metadata list pointer
* @param[in] jpipstream JPT/JPP stream
* @return pointer to generated ihdr box
*/
ihdrbox_param_t * gene_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jpipstream);
#endif /* !IHDRBOX_MANAGER_H_ */ #endif /* !IHDRBOX_MANAGER_H_ */

View File

@ -47,7 +47,7 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
const int rw, const int rh, const int rw, const int rh,
const int XOsiz, const int YOsiz, const int XOsiz, const int YOsiz,
const int Xsiz, const int Ysiz, const int Xsiz, const int Ysiz,
const int numOfdecomp) const int numOfreslev)
{ {
imgreg_param_t imgreg; imgreg_param_t imgreg;
int px,py; int px,py;
@ -61,7 +61,7 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
xmax = Xsiz; xmax = Xsiz;
ymax = Ysiz; ymax = Ysiz;
find_level( numOfdecomp, &imgreg.level, &imgreg.fx, &imgreg.fy, &imgreg.xosiz, &imgreg.yosiz, &xmax, &ymax); find_level( numOfreslev, &imgreg.level, &imgreg.fx, &imgreg.fy, &imgreg.xosiz, &imgreg.yosiz, &xmax, &ymax);
if( rx == -1 || ry == -1){ if( rx == -1 || ry == -1){
imgreg.ox = 0; imgreg.ox = 0;
@ -79,6 +79,12 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
else{ else{
px = ceil((double)((rx+rw)*imgreg.fx)/(double)fx); px = ceil((double)((rx+rw)*imgreg.fx)/(double)fx);
py = ceil((double)((ry+rh)*imgreg.fy)/(double)fy); py = ceil((double)((ry+rh)*imgreg.fy)/(double)fy);
if( imgreg.fx < px)
px = imgreg.fx;
if( imgreg.fy < py)
py = imgreg.fy;
imgreg.sx = px - imgreg.ox; imgreg.sx = px - imgreg.ox;
imgreg.sy = py - imgreg.oy; imgreg.sy = py - imgreg.oy;
} }
@ -120,6 +126,20 @@ void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, i
} }
} }
int comp_decomplev( int fw, int fh, int Xsiz, int Ysiz)
{
int level;
int xmin, xmax, ymin, ymax;
level = 0;
xmin = ymin = 0;
xmax = Xsiz;
ymax = Ysiz;
find_level( 1000, &level, &fw, &fh, &xmin, &ymin, &xmax, &ymax);
return level;
}
void print_imgreg( imgreg_param_t imgreg) void print_imgreg( imgreg_param_t imgreg)
{ {

View File

@ -50,7 +50,7 @@ typedef struct imgreg_param{
* @param[in] rw,rh size of region * @param[in] rw,rh size of region
* @param[in] XOsiz,YOsiz offset from the origin of the reference grid to the left side of the image area * @param[in] XOsiz,YOsiz offset from the origin of the reference grid to the left side of the image area
* @param[in] Xsiz,Ysiz size of the reference grid * @param[in] Xsiz,Ysiz size of the reference grid
* @param[in] numOfdecomp number of decomposition levels * @param[in] numOfreslev number of resolution levels
* @return structure of image region parameters * @return structure of image region parameters
*/ */
imgreg_param_t map_viewin2imgreg( const int fx, const int fy, imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
@ -58,7 +58,7 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
const int rw, const int rh, const int rw, const int rh,
const int XOsiz, const int YOsiz, const int XOsiz, const int YOsiz,
const int Xsiz, const int Ysiz, const int Xsiz, const int Ysiz,
const int numOfdecomp); const int numOfreslev);
/** /**
@ -78,6 +78,18 @@ imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
*/ */
void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, int *xmax, int *ymax); void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, int *xmax, int *ymax);
/**
* compute decomposition level (only to get the level
* use find_level for all parameters
*
* @param[in] fx horizontal frame size
* @param[in] fy vertical frame size
* @param[in] Xsiz image width
* @param[in] Ysiz image height
* @return decomposition level
*/
int comp_decomplev( int fw, int fh, int Xsiz, int Ysiz);
/** /**
* print image region parameters * print image region parameters
* *

View File

@ -28,73 +28,21 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef _WIN32
#include <windows.h>
#define strcasecmp _stricmp
#else
#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include "imgsock_manager.h" #include "imgsock_manager.h"
#if _WIN32
#define BUF_LEN 256 #define strncasecmp _strnicmp
#endif
SOCKET open_listeningsocket()
{
SOCKET listening_socket;
struct sockaddr_in sin;
int sock_optval = 1;
int port = 5000;
listening_socket = socket(AF_INET, SOCK_STREAM, 0);
if ( listening_socket == -1 ){
perror("socket");
exit(1);
}
if ( setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR,
&sock_optval, sizeof(sock_optval)) == -1 ){
perror("setsockopt");
exit(1);
}
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
sin.sin_addr.s_addr = htonl(INADDR_ANY);
if ( bind(listening_socket, (struct sockaddr *)&sin, sizeof(sin)) < 0 ){
perror("bind");
closesocket(listening_socket);
exit(1);
}
if( listen(listening_socket, SOMAXCONN) == -1){
perror("listen");
closesocket(listening_socket);
exit(1);
}
printf("port %d is listened\n", port);
return listening_socket;
}
msgtype_t identify_clientmsg( SOCKET connected_socket) msgtype_t identify_clientmsg( SOCKET connected_socket)
{ {
int receive_size; int receive_size;
char buf[BUF_LEN]; char buf[BUF_LEN];
char *magicid[] = { "JPIP-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"}; static const char *magicid[] = { "JPIP-stream", "PNM request", "XML request",
"TID request", "CID request", "CID destroy", "SIZ request", "JP2 save",
"QUIT"};
int i; int i;
receive_size = receive_line( connected_socket, buf); receive_size = receive_line( connected_socket, buf);
@ -106,7 +54,7 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
for( i=0; i<NUM_OF_MSGTYPES; i++){ for( i=0; i<NUM_OF_MSGTYPES; i++){
if( strncasecmp( magicid[i], buf, strlen(magicid[i])) == 0){ if( strncasecmp( magicid[i], buf, strlen(magicid[i])) == 0){
printf("Client message: %s\n", magicid[i]); fprintf( stderr, "%s\n", magicid[i]);
return i; return i;
} }
} }
@ -115,14 +63,13 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
return MSGERROR; return MSGERROR;
} }
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen) Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid, char **cid, int *streamlen)
{ {
Byte_t *jpipstream=NULL, *ptr; char buf[BUF_LEN], versionstring[] = "version 1.2";
char buf[BUF_LEN], versionstring[] = "version 1.1"; int linelen, datalen;
int linelen, redlen, remlen; Byte_t *jpipstream;
target[0] = 0; *target = *cid = *tid = NULL;
cid[0] = 0;
if((linelen = receive_line( connected_socket, buf)) == 0) if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL; return NULL;
@ -135,40 +82,37 @@ Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, i
return NULL; return NULL;
if( strstr( buf, "jp2")){ if( strstr( buf, "jp2")){
// register cid option /* register cid option*/
strcpy( target, buf); *target = strdup( buf);
if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL;
if( strcmp( buf, "0") != 0)
*tid = strdup( buf);
if((linelen = receive_line( connected_socket, buf)) == 0) if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL; return NULL;
strcpy( cid, buf); if( strcmp( buf, "0") != 0)
*cid = strdup( buf);
if((linelen = receive_line( connected_socket, buf)) == 0) if((linelen = receive_line( connected_socket, buf)) == 0)
return NULL; return NULL;
} }
*streamlen = atoi( buf); datalen = atoi( buf);
fprintf( stderr, "Receiveing Data length: %d\n", *streamlen); fprintf( stderr, "Receive Data: %d Bytes\n", datalen);
jpipstream = receive_stream( connected_socket, datalen);
/* check EOR*/
if( jpipstream[datalen-3] == 0x00 && ( jpipstream[datalen-2] == 0x01 || jpipstream[datalen-2] == 0x02))
*streamlen = datalen -3;
else
*streamlen = datalen;
jpipstream = (unsigned char *)malloc( (*streamlen));
ptr = jpipstream;
remlen = (*streamlen);
while( remlen > 0){
redlen = recv( connected_socket, ptr, remlen, 0);
if( redlen == -1){
fprintf( stderr, "receive JPT- JPP- stream error\n");
break;
}
remlen -= redlen;
ptr = ptr + redlen;
}
fprintf( stderr, " done\n");
return jpipstream; return jpipstream;
} }
void send_stream( SOCKET connected_socket, void *stream, int length);
void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length) void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
{ {
Byte_t header[5]; Byte_t header[5];
@ -183,17 +127,29 @@ void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
send_stream( connected_socket, xmlstream, length); send_stream( connected_socket, xmlstream, length);
} }
void send_IDstream( SOCKET connected_socket, char *id, int idlen, const char *label);
void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen) void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen)
{
send_IDstream( connected_socket, cid, cidlen, "CID");
}
void send_TIDstream( SOCKET connected_socket, char *tid, int tidlen)
{
send_IDstream( connected_socket, tid, tidlen, "TID");
}
void send_IDstream( SOCKET connected_socket, char *id, int idlen, const char *label)
{ {
Byte_t header[4]; Byte_t header[4];
header[0] = 'C'; header[0] = label[0];
header[1] = 'I'; header[1] = label[1];
header[2] = 'D'; header[2] = label[2];
header[3] = cidlen & 0xff; header[3] = idlen & 0xff;
send_stream( connected_socket, header, 4); send_stream( connected_socket, header, 4);
send_stream( connected_socket, cid, cidlen); send_stream( connected_socket, id, idlen);
} }
void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval) void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
@ -215,45 +171,21 @@ void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int wi
send_stream( connected_socket, pnmstream, pnmlen); send_stream( connected_socket, pnmstream, pnmlen);
} }
void send_stream( SOCKET connected_socket, void *stream, int length) void send_SIZstream( SOCKET connected_socket, unsigned int width, unsigned int height)
{ {
void *ptr = stream; Byte_t responce[9];
int remlen = length;
responce[0] = 'S';
responce[1] = 'I';
responce[2] = 'Z';
responce[3] = (width >> 16) & 0xff;
responce[4] = (width >> 8) & 0xff;
responce[5] = width & 0xff;
responce[6] = (height >> 16) & 0xff;
responce[7] = (height >> 8) & 0xff;
responce[8] = height & 0xff;
while( remlen > 0){ send_stream( connected_socket, responce, 9);
int sentlen = send( connected_socket, ptr, remlen, 0);
if( sentlen == -1){
fprintf( stderr, "sending stream error\n");
break;
}
remlen = remlen - sentlen;
ptr = ptr + sentlen;
}
}
int receive_line(SOCKET connected_socket, char *p)
{
int len = 0;
while (1){
int ret;
ret = recv( connected_socket, p, 1, 0);
if ( ret == -1 ){
perror("receive");
exit(1);
} else if ( ret == 0 ){
break;
}
if ( *p == '\n' )
break;
p++;
len++;
}
*p = '\0';
if( len == 0)
fprintf( stderr, "Header receive error\n");
return len;
} }
void response_signal( SOCKET connected_socket, bool succeed) void response_signal( SOCKET connected_socket, bool succeed)
@ -265,6 +197,5 @@ void response_signal( SOCKET connected_socket, bool succeed)
else else
code = 0; code = 0;
if( send( connected_socket, &code, 1, 0) != 1) send_stream( connected_socket, &code, 1);
fprintf( stderr, "Response signalling error\n");
} }

View File

@ -33,23 +33,10 @@
#include "bool.h" #include "bool.h"
#include "byte_manager.h" #include "byte_manager.h"
#include "sock_manager.h"
#ifdef _WIN32 #define NUM_OF_MSGTYPES 9
#include <winsock2.h> typedef enum eMSGTYPE{ JPIPSTREAM, PNMREQ, XMLREQ, TIDREQ, CIDREQ, CIDDST, SIZREQ, JP2SAVE, QUIT, MSGERROR} msgtype_t;
#else
typedef int SOCKET;
#define closesocket close
#endif //_WIN32
/**
* open listening socket
*
* @return new socket
*/
SOCKET open_listeningsocket();
#define NUM_OF_MSGTYPES 7
typedef enum eMSGTYPE{ JPIPSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
/** /**
* indeitify client message type * indeitify client message type
@ -63,20 +50,21 @@ msgtype_t identify_clientmsg( SOCKET connected_socket);
* receive a JPT- JPP- stream from client * receive a JPT- JPP- stream from client
* *
* @param [in] connected_socket file descriptor of the connected socket * @param [in] connected_socket file descriptor of the connected socket
* @param [out] target received target file name (if not received, null string) * @param [out] target address of received target file name string pointer ( malloced, if not received, NULL)
* @param [out] cid received channel identifier (if not received, null string) * @param [out] tid address of received target identifier string pointer ( malloced, if not received, null string)
* @param [out] cid address of received channel identifier string pointer ( malloced, if not received, null string)
* @param [out] streamlen length of the received codestream * @param [out] streamlen length of the received codestream
* @return JPT- JPP- codestream * @return JPT- JPP- codestream
*/ */
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen); Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid, char **cid, int *streamlen);
/** /**
* send PGM/PPM image stream to the client * send PGM/PPM image stream to the client
* *
* @param [in] connected_socket file descriptor of the connected socket * @param [in] connected_socket file descriptor of the connected socket
* @param [in] pnmstream PGM/PPM image codestream * @param [in] pnmstream PGM/PPM image codestream
* @param [in] width width of the image * @param [in] width width of the PGM/PPM image (different from the original image)
* @param [in] height height of the image * @param [in] height height of the PGM/PPM image
* @param [in] numofcomp number of components of the image * @param [in] numofcomp number of components of the image
* @param [in] maxval maximum value of the image (only 255 supported) * @param [in] maxval maximum value of the image (only 255 supported)
*/ */
@ -91,6 +79,15 @@ void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int wi
*/ */
void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length); void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
/**
* send TID data stream to the client
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [in] tid tid string
* @param [in] tidlen legnth of the tid string
*/
void send_TIDstream( SOCKET connected_socket, char *tid, int tidlen);
/** /**
* send CID data stream to the client * send CID data stream to the client
* *
@ -100,6 +97,15 @@ void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
*/ */
void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen); void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen);
/**
* send SIZ data stream to the client
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [in] width original width of the image
* @param [in] height original height of the image
*/
void send_SIZstream( SOCKET connected_socket, unsigned int width, unsigned int height);
/** /**
* send response signal to the client * send response signal to the client
* *
@ -108,15 +114,6 @@ void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen);
*/ */
void response_signal( SOCKET connected_socket, bool succeed); void response_signal( SOCKET connected_socket, bool succeed);
/**
* receive a string line (ending with '\n') from client
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [out] buf string to be stored
* @return red size
*/
int receive_line(SOCKET connected_socket, char *buf);
#endif /* !IMGSOCK_MANAGER_H_ */ #endif /* !IMGSOCK_MANAGER_H_ */
/*! \file /*! \file
@ -125,13 +122,13 @@ int receive_line(SOCKET connected_socket, char *buf);
*\section sec1 JPIP-stream *\section sec1 JPIP-stream
* Cache JPT- JPP- stream in server * Cache JPT- JPP- stream in server
* *
* client -> server: JPIP-stream\\n version 1.1\\n (optional for cid registration: targetnamestring\\n cidstring\\n) bytelengthvalue\\n data \n * client -> server: JPIP-stream\\n version 1.1\\n (optional for cid registration: targetnamestring\\n tidstring\\n cidstring\\n) bytelengthvalue\\n data \n
* server -> client: 1 or 0 (of 1Byte response signal) * server -> client: 1 or 0 (of 1Byte response signal)
* *
*\section sec2 PNM request *\section sec2 PNM request
* Get decoded PGM/PPM image * Get decoded PGM/PPM image
* *
* client -> server: PNM request\\n cidstring\\n fw\\n fh\\n \n * client -> server: PNM request\\n [cid/tid]string\\n fw\\n fh\\n \n
* server -> client: P6 or P5 (2Byte) width (2Byte Big endian) height (2Byte Big endian) maxval (1Byte) data * server -> client: P6 or P5 (2Byte) width (2Byte Big endian) height (2Byte Big endian) maxval (1Byte) data
* *
*\section sec3 XML request *\section sec3 XML request
@ -140,25 +137,37 @@ int receive_line(SOCKET connected_socket, char *buf);
* client -> server: XML request\\n \n * client -> server: XML request\\n \n
* server -> client: XML (3Byte) length (2Byte Big endian) data * server -> client: XML (3Byte) length (2Byte Big endian) data
* *
*\section sec4 CID request *\section sec4 TID request
* Get target ID of target image
*
* client -> server: TID request\\n targetname\\n \n
* server -> client: TID (3Byte) length (1Byte) tiddata
*
*\section sec5 CID request
* Get Channel ID of identical target image * Get Channel ID of identical target image
* *
* client -> server: CID request\\n targetname\\n \n * client -> server: CID request\\n targetname\\n \n
* server -> client: CID (3Byte) length (1Byte) ciddata * server -> client: CID (3Byte) length (1Byte) ciddata
* *
*\section sec5 CID destroy *\section sec6 CID destroy
* Close Channel ID * Close Channel ID
* *
* client -> server: CID destroy\\n ciddata \n * client -> server: CID destroy\\n ciddata \n
* server -> client: 1 or 0 (of 1Byte response signal) * server -> client: 1 or 0 (of 1Byte response signal)
* *
*\section sec6 JP2 save *\section sec7 SIZ request
* Get original size of image
*
* client -> server: SIZ request\\n tidstring\\n cidstring\\n \n
* server -> client: SIZ (3Byte) width (3Byte Big endian) height (3Byte Big endian)
*
*\section sec8 JP2 save
* Save in JP2 file format * Save in JP2 file format
* *
* client -> server: JP2 save\\n ciddata \n * client -> server: JP2 save\\n ciddata \n
* server -> client: 1 or 0 (of 1Byte response signal) * server -> client: 1 or 0 (of 1Byte response signal)
* *
*\section sec7 QUIT *\section sec9 QUIT
* Quit the opj_dec_server program * Quit the opj_dec_server program
* *
* client -> server: quit or QUIT * client -> server: quit or QUIT

View File

@ -28,13 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include "bool.h"
#include "index_manager.h" #include "index_manager.h"
#include "box_manager.h" #include "box_manager.h"
#include "manfbox_manager.h" #include "manfbox_manager.h"
@ -51,7 +50,7 @@
#define FCGI_stdout stdout #define FCGI_stdout stdout
#define FCGI_stderr stderr #define FCGI_stderr stderr
#define logstream stderr #define logstream stderr
#endif //SERVER #endif /*SERVER*/
/** /**
* chekc JP2 box indexing * chekc JP2 box indexing
@ -77,14 +76,12 @@ index_param_t * parse_jp2file( int fd)
box_param_t *cidx; box_param_t *cidx;
metadatalist_param_t *metadatalist; metadatalist_param_t *metadatalist;
boxlist_param_t *toplev_boxlist; boxlist_param_t *toplev_boxlist;
struct stat sb; Byte8_t filesize;
if( fstat( fd, &sb) == -1){
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
return NULL;
}
if( !(toplev_boxlist = get_boxstructure( fd, 0, sb.st_size))){ if( !(filesize = get_filesize( fd)))
return NULL;
if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))){
fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n"); fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
return NULL; return NULL;
} }
@ -129,54 +126,96 @@ void print_index( index_param_t index)
fprintf( logstream, "\tCodestream Offset: %#llx\n", index.offset); fprintf( logstream, "\tCodestream Offset: %#llx\n", index.offset);
fprintf( logstream, "\t Length: %#llx\n", index.length); fprintf( logstream, "\t Length: %#llx\n", index.length);
fprintf( logstream, "\tMain header Length: %#llx\n", index.mhead_length); fprintf( logstream, "\tMain header Length: %#llx\n", index.mhead_length);
fprintf( logstream, "\t Rsiz: %#x\n", index.Rsiz);
fprintf( logstream, "\t Xsiz, Ysiz: (%d,%d) = (%#x, %#x)\n", index.Xsiz, index.Ysiz, index.Xsiz, index.Ysiz);
fprintf( logstream, "\t XOsiz, YOsiz: (%d,%d) = (%#x, %#x)\n", index.XOsiz, index.YOsiz, index.XOsiz, index.YOsiz);
fprintf( logstream, "\t XTsiz, YTsiz: (%d,%d) = (%#x, %#x)\n", index.XTsiz, index.YTsiz, index.XTsiz, index.YTsiz);
fprintf( logstream, "\t XTOsiz, YTOsiz: (%d,%d) = (%#x, %#x)\n", index.XTOsiz, index.YTOsiz, index.XTOsiz, index.YTOsiz);
fprintf( logstream, "\t XTnum, YTnum: (%d,%d)\n", index.XTnum, index.YTnum);
fprintf( logstream, "\t Num of Components: %d\n", index.Csiz);
for( i=0; i<index.Csiz; i++) print_SIZ( index.SIZ);
fprintf( logstream, "\t[%d] (Ssiz, XRsiz, YRsiz): (%d, %d, %d) = (%#x, %#x, %#x)\n", i, index.Ssiz[i], index.XRsiz[i], index.YRsiz[i], index.Ssiz[i], index.XRsiz[i], index.YRsiz[i]); print_COD( index.COD);
fprintf( logstream, "Tile part information: \n");
print_faixbox( index.tilepart); print_faixbox( index.tilepart);
fprintf( logstream, "Tile header information: \n");
for( i=0; i<(int)(index.SIZ.XTnum*index.SIZ.YTnum);i++)
print_mhixbox( index.tileheader[i]);
fprintf( logstream, "Precinct packet information: \n");
for( i=0; i<index.SIZ.Csiz; i++){
fprintf( logstream, "Component %d\n", i);
print_faixbox( index.precpacket[i]);
}
print_allmetadata( index.metadatalist); print_allmetadata( index.metadatalist);
} }
void print_cachemodel( index_param_t index) void print_SIZ( SIZmarker_param_t SIZ)
{ {
Byte8_t TPnum; // num of tile parts in each tile int i;
int i, j, k, n;
TPnum = get_nmax( index.tilepart); fprintf( logstream, "\tImage and Tile SIZ parameters\n");
fprintf( logstream, "\t Rsiz: %#x\n", SIZ.Rsiz);
fprintf( logstream, "\t Xsiz, Ysiz: (%d,%d) = (%#x, %#x)\n", SIZ.Xsiz, SIZ.Ysiz, SIZ.Xsiz, SIZ.Ysiz);
fprintf( logstream, "\t XOsiz, YOsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XOsiz, SIZ.YOsiz, SIZ.XOsiz, SIZ.YOsiz);
fprintf( logstream, "\t XTsiz, YTsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XTsiz, SIZ.YTsiz, SIZ.XTsiz, SIZ.YTsiz);
fprintf( logstream, "\t XTOsiz, YTOsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XTOsiz, SIZ.YTOsiz, SIZ.XTOsiz, SIZ.YTOsiz);
fprintf( logstream, "\t XTnum, YTnum: (%d,%d)\n", SIZ.XTnum, SIZ.YTnum);
fprintf( logstream, "\t Num of Components: %d\n", SIZ.Csiz);
fprintf( logstream, "\t main header model: %d\n", index.mhead_model); for( i=0; i<SIZ.Csiz; i++)
fprintf( logstream, "\t[%d] (Ssiz, XRsiz, YRsiz): (%d, %d, %d) = (%#x, %#x, %#x)\n", i, SIZ.Ssiz[i], SIZ.XRsiz[i], SIZ.YRsiz[i], SIZ.Ssiz[i], SIZ.XRsiz[i], SIZ.YRsiz[i]);
}
fprintf( logstream, "\t tile part model:\n"); void print_COD( CODmarker_param_t COD)
for( i=0, n=0; i<index.YTnum; i++){ {
for( j=0; j<index.XTnum; j++){ int i;
for( k=0; k<TPnum; k++)
fprintf( logstream, "%d", index.tp_model[n++]); fprintf( logstream, "\tCoding style default COD parameters\n");
fprintf( logstream, " "); fprintf( logstream, "\t Progression order: %d [ LRCP=0, RLCP=1, RPCL=2, PCRL=3, CPRL=4]\n", COD.prog_order);
} fprintf( logstream, "\t Num of layers: %d\n", COD.numOflayers);
fprintf( logstream, "\n"); fprintf( logstream, "\t Decomposition lvl: %d\n", COD.numOfdecomp);
for( i=0; i<=((COD.Scod & 0x01) ? COD.numOfdecomp:0); i++){
fprintf( logstream, "\t [%d] XPsiz, YPsiz: (%d,%d) = (%#x, %#x)\n",i, COD.XPsiz[i], COD.YPsiz[i], COD.XPsiz[i], COD.YPsiz[i]);
} }
} }
void delete_index( index_param_t **index) void delete_index( index_param_t **index)
{ {
int i;
delete_metadatalist( &((*index)->metadatalist)); delete_metadatalist( &((*index)->metadatalist));
delete_COD( (*index)->COD);
delete_faixbox( &((*index)->tilepart)); delete_faixbox( &((*index)->tilepart));
free( (*index)->tp_model);
for( i=0; i< (int)((*index)->SIZ.XTnum*(*index)->SIZ.YTnum);i++)
delete_mhixbox( &((*index)->tileheader[i]));
free( (*index)->tileheader);
for( i=0; i<(*index)->SIZ.Csiz; i++)
delete_faixbox( &((*index)->precpacket[i]));
free( (*index)->precpacket);
free(*index); free(*index);
} }
void delete_COD( CODmarker_param_t COD)
{
if( COD.XPsiz) free( COD.XPsiz);
if( COD.YPsiz) free( COD.YPsiz);
}
bool check_JP2boxidx( boxlist_param_t *toplev_boxlist) bool check_JP2boxidx( boxlist_param_t *toplev_boxlist)
{ {
box_param_t *iptr, *fidx, *prxy; box_param_t *iptr, *fidx, *prxy;
box_param_t *cidx, *jp2c; box_param_t *cidx, *jp2c;
Byte8_t off;
Byte8_t len;
int pos;
Byte8_t ooff;
boxheader_param_t *obh;
Byte_t ni;
Byte8_t ioff;
boxheader_param_t *ibh;
iptr = search_box( "iptr", toplev_boxlist); iptr = search_box( "iptr", toplev_boxlist);
fidx = search_box( "fidx", toplev_boxlist); fidx = search_box( "fidx", toplev_boxlist);
@ -184,40 +223,39 @@ bool check_JP2boxidx( boxlist_param_t *toplev_boxlist)
jp2c = search_box( "jp2c", toplev_boxlist); jp2c = search_box( "jp2c", toplev_boxlist);
prxy = gene_childboxbyType( fidx, 0, "prxy"); prxy = gene_childboxbyType( fidx, 0, "prxy");
Byte8_t off = fetch_DBox8bytebigendian( iptr, 0); off = fetch_DBox8bytebigendian( iptr, 0);
if( off != fidx->offset) if( off != fidx->offset)
fprintf( FCGI_stderr, "Reference File Index box offset in Index Finder box not correct\n"); fprintf( FCGI_stderr, "Reference File Index box offset in Index Finder box not correct\n");
Byte8_t len = fetch_DBox8bytebigendian( iptr, 8); len = fetch_DBox8bytebigendian( iptr, 8);
if( len != fidx->length) if( len != fidx->length)
fprintf( FCGI_stderr, "Reference File Index box length in Index Finder box not correct\n"); fprintf( FCGI_stderr, "Reference File Index box length in Index Finder box not correct\n");
pos = 0;
int pos = 0; ooff = fetch_DBox8bytebigendian( prxy, pos);
Byte8_t ooff = fetch_DBox8bytebigendian( prxy, pos);
if( ooff != jp2c->offset) if( ooff != jp2c->offset)
fprintf( FCGI_stderr, "Reference jp2c offset in prxy box not correct\n"); fprintf( FCGI_stderr, "Reference jp2c offset in prxy box not correct\n");
pos += 8; pos += 8;
boxheader_param_t *obh = gene_childboxheader( prxy, pos); obh = gene_childboxheader( prxy, pos);
if( obh->length != jp2c->length || strncmp( obh->type, "jp2c",4)!=0) if( obh->length != jp2c->length || strncmp( obh->type, "jp2c",4)!=0)
fprintf( FCGI_stderr, "Reference jp2c header in prxy box not correct\n"); fprintf( FCGI_stderr, "Reference jp2c header in prxy box not correct\n");
pos += obh->headlen; pos += obh->headlen;
free(obh); free(obh);
Byte_t ni = fetch_DBox1byte( prxy, pos); ni = fetch_DBox1byte( prxy, pos);
if( ni != 1){ if( ni != 1){
fprintf( FCGI_stderr, "Multiple indexes not supported\n"); fprintf( FCGI_stderr, "Multiple indexes not supported\n");
return false; return false;
} }
pos += 1; pos += 1;
Byte8_t ioff = fetch_DBox8bytebigendian( prxy, pos); ioff = fetch_DBox8bytebigendian( prxy, pos);
if( ioff != cidx->offset) if( ioff != cidx->offset)
fprintf( FCGI_stderr, "Reference cidx offset in prxy box not correct\n"); fprintf( FCGI_stderr, "Reference cidx offset in prxy box not correct\n");
pos += 8; pos += 8;
boxheader_param_t *ibh = gene_childboxheader( prxy, pos); ibh = gene_childboxheader( prxy, pos);
if( ibh->length != cidx->length || strncmp( ibh->type, "cidx",4)!=0) if( ibh->length != cidx->length || strncmp( ibh->type, "cidx",4)!=0)
fprintf( FCGI_stderr, "Reference cidx header in prxy box not correct\n"); fprintf( FCGI_stderr, "Reference cidx header in prxy box not correct\n");
pos += ibh->headlen; pos += ibh->headlen;
@ -269,6 +307,16 @@ bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx);
*/ */
bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx); bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx);
/**
* set code index parameters from ppix box
* I.3.2.4.6 Precinct Packet Index Table box
*
* @param[in] cidx_box pointer to the reference cidx_box
* @param[out] jp2idx pointer to index parameters
* @return if succeeded (true) or failed (false)
*/
bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx);
bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx) bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx)
{ {
box_param_t *manf_box; box_param_t *manf_box;
@ -296,13 +344,19 @@ bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx)
} }
set_tpixdata( cidx_box, jp2idx); set_tpixdata( cidx_box, jp2idx);
#ifdef NO_NEED_YET
if( !search_boxheader( "thix", manf)){ if( !search_boxheader( "thix", manf)){
fprintf( FCGI_stderr, "Error: thix box not present in manfbox\n"); fprintf( FCGI_stderr, "Error: thix box not present in manfbox\n");
free(jp2idx);
return false; return false;
} }
set_thixdata( cidx_box, jp2idx); set_thixdata( cidx_box, jp2idx);
#endif
if( !search_boxheader( "ppix", manf)){
fprintf( FCGI_stderr, "Error: ppix box not present in manfbox\n");
free(jp2idx);
return false;
}
set_ppixdata( cidx_box, jp2idx);
delete_manfbox( &manf); delete_manfbox( &manf);
free( manf_box); free( manf_box);
@ -312,23 +366,23 @@ bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx)
bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx) bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx)
{ {
box_param_t *box; //!< cptr box box_param_t *box; /**< cptr box*/
Byte2_t dr, cont; Byte2_t dr, cont;
if( !(box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "cptr"))) if( !(box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "cptr")))
return false; return false;
// DR: Data Reference. /* DR: Data Reference. */
// If 0, the codestream or its Fragment Table box exists in the current file /* If 0, the codestream or its Fragment Table box exists in the current file*/
if(( dr = fetch_DBox2bytebigendian( box, 0))){ if(( dr = fetch_DBox2bytebigendian( box, 0))){
fprintf( FCGI_stderr, "Error: Codestream not present in current file\n"); fprintf( FCGI_stderr, "Error: Codestream not present in current file\n");
free( box); free( box);
return false; return false;
} }
// CONT: Container Type /* CONT: Container Type*/
// If 0, the entire codestream appears as a contiguous range of /* If 0, the entire codestream appears as a contiguous range of*/
// bytes within its file or resource. /* bytes within its file or resource.*/
if(( cont = fetch_DBox2bytebigendian( box, 2))){ if(( cont = fetch_DBox2bytebigendian( box, 2))){
fprintf( FCGI_stderr, "Error: Can't cope with fragmented codestreams yet\n"); fprintf( FCGI_stderr, "Error: Can't cope with fragmented codestreams yet\n");
free( box); free( box);
@ -345,34 +399,49 @@ bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx)
/** /**
* set code index parameters from SIZ marker in codestream * set SIZ marker information
* A.5 Fixed information marker segment * A.5 Fixed information marker segment
* A.5.1 Image and tile size (SIZ) * A.5.1 Image and tile size (SIZ)
* *
* @param[in] sizmkidx pointer to SIZ marker index in mhix box * @param[in] sizmkidx pointer to SIZ marker index in mhix box
* @param[in] codestream codestream parameters * @param[in] codestream codestream parameters
* @param[out] jp2idx pointer to index parameters * @param[out] SIZ SIZ marker parameters pointer
* @return if succeeded (true) or failed (false) * @return if succeeded (true) or failed (false)
*/ */
bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, index_param_t *jp2idx); bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ);
/**
* set code index parameters from COD marker in codestream
* A.6 Functional marker segments
* A.6.1 Coding style default (COD)
*
* @param[in] codmkidx pointer to COD marker index in mhix box
* @param[in] codestream codestream parameters
* @param[out] COD COD marker parameters pointer
* @return if succeeded (true) or failed (false)
*/
bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD);
bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx) bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx)
{ {
box_param_t *mhix_box; box_param_t *mhix_box;
mhixbox_param_t *mhix; mhixbox_param_t *mhix;
markeridx_param_t *sizmkidx; markeridx_param_t *sizmkidx;
markeridx_param_t *codmkidx;
if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix"))) if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix")))
return false; return false;
jp2idx->mhead_model = 0;
jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0); jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0);
mhix = gene_mhixbox( mhix_box); mhix = gene_mhixbox( mhix_box);
free( mhix_box); free( mhix_box);
sizmkidx = search_markeridx( 0xff51, mhix); sizmkidx = search_markeridx( 0xff51, mhix);
set_SIZmkrdata( sizmkidx, codestream, jp2idx); set_SIZmkrdata( sizmkidx, codestream, &(jp2idx->SIZ));
codmkidx = search_markeridx( 0xff52, mhix);
set_CODmkrdata( codmkidx, codestream, &(jp2idx->COD));
delete_mhixbox( &mhix); delete_mhixbox( &mhix);
@ -381,25 +450,21 @@ bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, ind
bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx) bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx)
{ {
box_param_t *tpix_box; //!< tpix box box_param_t *tpix_box; /**< tpix box*/
box_param_t *faix_box; //!< faix box box_param_t *faix_box; /**< faix box*/
faixbox_param_t *faix; //!< faix
size_t numOfelem;
if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix"))) if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix"))){
fprintf( FCGI_stderr, "Error: tpix box not present in cidx box\n");
return false; return false;
}
if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix"))) if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix"))){
fprintf( FCGI_stderr, "Error: faix box not present in tpix box\n");
return false; return false;
}
faix = gene_faixbox( faix_box); jp2idx->tilepart = gene_faixbox( faix_box);
jp2idx->tilepart = faix;
numOfelem = get_nmax( faix)*get_m( faix);
jp2idx->tp_model = (bool *)malloc( numOfelem*sizeof(bool));
memset( jp2idx->tp_model, 0, numOfelem*sizeof(bool));
//delete_faixbox( &faix); // currently the jp2idx element
free( tpix_box); free( tpix_box);
free( faix_box); free( faix_box);
@ -413,11 +478,15 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx)
boxheader_param_t *ptr; boxheader_param_t *ptr;
mhixbox_param_t *mhix; mhixbox_param_t *mhix;
Byte8_t pos, mhixseqoff; Byte8_t pos, mhixseqoff;
Byte2_t tile_no;
if( !(thix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "thix"))) if( !(thix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "thix"))){
fprintf( FCGI_stderr, "Error: thix box not present in cidx box\n");
return false; return false;
}
if( !(manf_box = gene_boxbyType( thix_box->fd, get_DBoxoff( thix_box), get_DBoxlen( thix_box), "manf"))){ if( !(manf_box = gene_boxbyType( thix_box->fd, get_DBoxoff( thix_box), get_DBoxlen( thix_box), "manf"))){
fprintf( FCGI_stderr, "Error: manf box not present in thix box\n");
free( thix_box); free( thix_box);
return false; return false;
} }
@ -426,16 +495,24 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx)
ptr = manf->first; ptr = manf->first;
mhixseqoff = manf_box->offset+manf_box->length; mhixseqoff = manf_box->offset+manf_box->length;
pos = 0; pos = 0;
tile_no = 0;
jp2idx->tileheader = (mhixbox_param_t **)malloc( jp2idx->SIZ.XTnum*jp2idx->SIZ.YTnum*sizeof(mhixbox_param_t *));
while( ptr){ while( ptr){
mhix_box = gene_boxbyType( thix_box->fd, mhixseqoff+pos, get_DBoxlen( thix_box)-manf_box->length-pos, "mhix"); if( !(mhix_box = gene_boxbyType( thix_box->fd, mhixseqoff+pos, get_DBoxlen( thix_box)-manf_box->length-pos, "mhix"))){
fprintf( FCGI_stderr, "Error: mhix box not present in thix box\n");
delete_manfbox( &manf);
free( manf_box);
free( thix_box);
return false;
}
mhix = gene_mhixbox( mhix_box); mhix = gene_mhixbox( mhix_box);
pos += mhix_box->length; pos += mhix_box->length;
ptr = ptr->next; ptr = ptr->next;
free( mhix_box); free( mhix_box);
delete_mhixbox( &mhix); jp2idx->tileheader[tile_no++] = mhix;
} }
delete_manfbox( &manf); delete_manfbox( &manf);
@ -445,64 +522,165 @@ bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx)
return true; return true;
} }
bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx)
{
box_param_t *ppix_box, *faix_box, *manf_box;
manfbox_param_t *manf; /**< manf*/
boxheader_param_t *bh; /**< box headers*/
faixbox_param_t *faix; /**< faix*/
Byte8_t inbox_offset;
int comp_idx;
bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, index_param_t *jp2idx) if( !(ppix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "ppix"))){
fprintf( FCGI_stderr, "Error: ppix box not present in cidx box\n");
return false;
}
inbox_offset = get_DBoxoff( ppix_box);
if( !(manf_box = gene_boxbyType( ppix_box->fd, inbox_offset, get_DBoxlen( ppix_box), "manf"))){
fprintf( FCGI_stderr, "Error: manf box not present in ppix box\n");
free( ppix_box);
return false;
}
free( ppix_box);
manf = gene_manfbox( manf_box);
bh = search_boxheader( "faix", manf);
inbox_offset = manf_box->offset + manf_box->length;
free( manf_box);
jp2idx->precpacket = (faixbox_param_t **)malloc( jp2idx->SIZ.Csiz*sizeof(faixbox_param_t *));
for( comp_idx=0; bh!=NULL; bh=bh->next, comp_idx++){
if( jp2idx->SIZ.Csiz <= comp_idx ){
fprintf( FCGI_stderr, "Error: num of faix boxes is not identical to num of components in ppix box\n");
return false;
}
if( !(faix_box = gene_boxbyOffset( cidx_box->fd, inbox_offset))){
fprintf( FCGI_stderr, "Error: faix box not present in ppix box\n");
return false;
}
faix = gene_faixbox( faix_box);
jp2idx->precpacket[comp_idx] = faix;
inbox_offset = faix_box->offset + faix_box->length;
free( faix_box);
}
delete_manfbox( &manf);
return true;
}
bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ)
{ {
marker_param_t sizmkr; marker_param_t sizmkr;
int i; int i;
sizmkr = set_marker( codestream, sizmkidx->code, sizmkidx->offset, sizmkidx->length); sizmkr = set_marker( codestream, sizmkidx->code, sizmkidx->offset, sizmkidx->length);
if( sizmkidx->length != fetch_marker2bytebigendian( sizmkr, 0)){ SIZ->Lsiz = fetch_marker2bytebigendian( sizmkr, 0);
if( sizmkidx->length != SIZ->Lsiz){
fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", sizmkidx->code); fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", sizmkidx->code);
return false; return false;
} }
jp2idx->Rsiz = fetch_marker2bytebigendian( sizmkr, 2); SIZ->Rsiz = fetch_marker2bytebigendian( sizmkr, 2);
jp2idx->Xsiz = fetch_marker4bytebigendian( sizmkr, 4); SIZ->Xsiz = fetch_marker4bytebigendian( sizmkr, 4);
jp2idx->Ysiz = fetch_marker4bytebigendian( sizmkr, 8); SIZ->Ysiz = fetch_marker4bytebigendian( sizmkr, 8);
jp2idx->XOsiz = fetch_marker4bytebigendian( sizmkr, 12); SIZ->XOsiz = fetch_marker4bytebigendian( sizmkr, 12);
jp2idx->YOsiz = fetch_marker4bytebigendian( sizmkr, 16); SIZ->YOsiz = fetch_marker4bytebigendian( sizmkr, 16);
jp2idx->XTsiz = fetch_marker4bytebigendian( sizmkr, 20); SIZ->XTsiz = fetch_marker4bytebigendian( sizmkr, 20);
jp2idx->YTsiz = fetch_marker4bytebigendian( sizmkr, 24); SIZ->YTsiz = fetch_marker4bytebigendian( sizmkr, 24);
jp2idx->XTOsiz = fetch_marker4bytebigendian( sizmkr, 28); SIZ->XTOsiz = fetch_marker4bytebigendian( sizmkr, 28);
jp2idx->YTOsiz = fetch_marker4bytebigendian( sizmkr, 32); SIZ->YTOsiz = fetch_marker4bytebigendian( sizmkr, 32);
jp2idx->Csiz = fetch_marker2bytebigendian( sizmkr, 36); SIZ->Csiz = fetch_marker2bytebigendian( sizmkr, 36);
jp2idx->XTnum = ( jp2idx->Xsiz-jp2idx->XTOsiz+jp2idx->XTsiz-1)/jp2idx->XTsiz; SIZ->XTnum = ( SIZ->Xsiz-SIZ->XTOsiz+SIZ->XTsiz-1)/SIZ->XTsiz;
jp2idx->YTnum = ( jp2idx->Ysiz-jp2idx->YTOsiz+jp2idx->YTsiz-1)/jp2idx->YTsiz; SIZ->YTnum = ( SIZ->Ysiz-SIZ->YTOsiz+SIZ->YTsiz-1)/SIZ->YTsiz;
for( i=0; i<(int)jp2idx->Csiz; i++){ for( i=0; i<(int)SIZ->Csiz; i++){
jp2idx->Ssiz[i] = fetch_marker1byte( sizmkr, 38+i*3); SIZ->Ssiz[i] = fetch_marker1byte( sizmkr, 38+i*3);
jp2idx->XRsiz[i] = fetch_marker1byte( sizmkr, 39+i*3); SIZ->XRsiz[i] = fetch_marker1byte( sizmkr, 39+i*3);
jp2idx->YRsiz[i] = fetch_marker1byte( sizmkr, 40+i*3); SIZ->YRsiz[i] = fetch_marker1byte( sizmkr, 40+i*3);
}
return true;
}
bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD)
{
marker_param_t codmkr;
int i;
codmkr = set_marker( codestream, codmkidx->code, codmkidx->offset, codmkidx->length);
COD->Lcod = fetch_marker2bytebigendian( codmkr, 0);
if( codmkidx->length != COD->Lcod){
fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", codmkidx->code);
return false;
}
COD->Scod = fetch_marker1byte( codmkr, 2);
COD->prog_order = fetch_marker1byte( codmkr, 3);
COD->numOflayers = fetch_marker2bytebigendian( codmkr, 4);
COD->numOfdecomp = fetch_marker1byte( codmkr, 7);
if(COD->Scod & 0x01){
COD->XPsiz = (Byte4_t *)malloc( (COD->numOfdecomp+1)*sizeof(Byte4_t));
COD->YPsiz = (Byte4_t *)malloc( (COD->numOfdecomp+1)*sizeof(Byte4_t));
for( i=0; i<=COD->numOfdecomp; i++){
/*precinct size*/
COD->XPsiz[i] = pow( 2, fetch_marker1byte( codmkr, 12+i) & 0x0F);
COD->YPsiz[i] = pow( 2,(fetch_marker1byte( codmkr, 12+i) & 0xF0) >> 4);
}
}
else{
COD->XPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
COD->YPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
COD->XPsiz[0] = COD->YPsiz[0] = pow(2,15);
} }
return true; return true;
} }
/* very very generic name see NOMINMAX */
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
Byte4_t max( Byte4_t n1, Byte4_t n2); Byte4_t max( Byte4_t n1, Byte4_t n2);
Byte4_t min( Byte4_t n1, Byte4_t n2); Byte4_t min( Byte4_t n1, Byte4_t n2);
range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_id, int level); range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_XYid, int level);
range_param_t get_tile_Xrange( index_param_t index, Byte4_t tile_xid, int level) range_param_t get_tile_Xrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
{ {
return get_tile_range( index.XOsiz, index.Xsiz, index.XTOsiz, index.XTsiz, tile_xid, level); return get_tile_range( SIZ.XOsiz, SIZ.Xsiz, SIZ.XTOsiz, SIZ.XTsiz, tile_id%SIZ.XTnum, level);
} }
range_param_t get_tile_Yrange( index_param_t index, Byte4_t tile_yid, int level) range_param_t get_tile_Yrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
{ {
return get_tile_range( index.YOsiz, index.Ysiz, index.YTOsiz, index.YTsiz, tile_yid, level); return get_tile_range( SIZ.YOsiz, SIZ.Ysiz, SIZ.YTOsiz, SIZ.YTsiz, tile_id/SIZ.XTnum, level);
} }
range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_id, int level) range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_XYid, int level)
{ {
range_param_t range; range_param_t range;
int n; int n;
range.minvalue = max( Osiz, TOsiz+tile_id*Tsiz); range.minvalue = max( Osiz, TOsiz+tile_XYid*Tsiz);
range.maxvalue = min( siz, TOsiz+(tile_id+1)*Tsiz); range.maxvalue = min( siz, TOsiz+(tile_XYid+1)*Tsiz);
for( n=0; n<level; n++){ for( n=0; n<level; n++){
range.minvalue = ceil(range.minvalue/2.0); range.minvalue = ceil(range.minvalue/2.0);
@ -511,6 +689,23 @@ range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t
return range; return range;
} }
Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
{
range_param_t tile_Xrange;
tile_Xrange = get_tile_Xrange( SIZ, tile_id, level);
return tile_Xrange.maxvalue - tile_Xrange.minvalue;
}
Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
{
range_param_t tile_Yrange;
tile_Yrange = get_tile_Yrange( SIZ, tile_id, level);
return tile_Yrange.maxvalue - tile_Yrange.minvalue;
}
/* TODO: what is this code doing ? will all compiler be able to optimize the following ? */
Byte4_t max( Byte4_t n1, Byte4_t n2) Byte4_t max( Byte4_t n1, Byte4_t n2)
{ {
if( n1 < n2) if( n1 < n2)
@ -526,3 +721,11 @@ Byte4_t min( Byte4_t n1, Byte4_t n2)
else else
return n2; return n2;
} }
bool isJPTfeasible( index_param_t index)
{
if( 1 < get_nmax( index.tilepart))
return true;
else
return false;
}

View File

@ -31,50 +31,64 @@
#ifndef INDEX_MANAGER_H_ #ifndef INDEX_MANAGER_H_
# define INDEX_MANAGER_H_ # define INDEX_MANAGER_H_
#include <stdio.h>
#include "bool.h"
#include "byte_manager.h" #include "byte_manager.h"
#include "faixbox_manager.h" #include "faixbox_manager.h"
#include "metadata_manager.h" #include "metadata_manager.h"
#include "mhixbox_manager.h"
#include "bool.h"
//! index parameters /** progression order */
typedef enum porder {
PROG_UNKNOWN = -1, /**< place-holder */
LRCP = 0, /**< layer-resolution-component-precinct order */
RLCP = 1, /**< resolution-layer-component-precinct order */
RPCL = 2, /**< resolution-precinct-component-layer order */
PCRL = 3, /**< precinct-component-resolution-layer order */
CPRL = 4 /**< component-precinct-resolution-layer order */
} porder_t;
/** A.5.1 Image and tile size (SIZ)*/
typedef struct SIZmarker_param{
Byte2_t Lsiz; /**< length of marker segment excluding the marker*/
Byte2_t Rsiz; /**< capabilities that a decoder needs*/
Byte4_t Xsiz; /**< width of the reference grid*/
Byte4_t Ysiz; /**< height of the reference grid*/
Byte4_t XOsiz; /**< horizontal offset from the origin of the reference grid to the left side of the image area*/
Byte4_t YOsiz; /**< vertical offset from the origin of the reference grid to the top side of the image area*/
Byte4_t XTsiz; /**< width of one reference tile with respect to the reference grid*/
Byte4_t YTsiz; /**< height of one reference tile with respect to the reference grid*/
Byte4_t XTOsiz; /**< horizontal offset from the origin of the reference grid to the left side of the first tile*/
Byte4_t YTOsiz; /**< vertical offset from the origin of the reference grid to the top side of the first tile*/
Byte4_t XTnum; /**< number of tiles in horizontal direction*/
Byte4_t YTnum; /**< number of tiles in vertical direction*/
Byte2_t Csiz; /**< number of the components in the image*/
Byte_t Ssiz[3]; /**< precision (depth) in bits and sign of the component samples*/
Byte_t XRsiz[3]; /**< horizontal separation of a sample of component with respect to the reference grid*/
Byte_t YRsiz[3]; /**< vertical separation of a sample of component with respect to the reference grid*/
} SIZmarker_param_t;
/** A.6.1 Coding style default (COD)*/
typedef struct CODmarker_param{
Byte2_t Lcod; /**< length of marker segment excluding the marker*/
Byte_t Scod; /**< Coding style for all components*/
porder_t prog_order; /**< progression order*/
Byte2_t numOflayers; /**< number of layers*/
Byte_t numOfdecomp; /**< number of decompositions levels*/
Byte4_t *XPsiz; /**< dynamic array of precinct width at successive resolution level in order*/
Byte4_t *YPsiz; /**< dynamic array of precinct height at successive resolution level in order*/
} CODmarker_param_t;
/** index parameters*/
typedef struct index_param{ typedef struct index_param{
metadatalist_param_t *metadatalist; //!< metadata-bin list metadatalist_param_t *metadatalist; /**< metadata-bin list*/
Byte8_t offset; //!< codestream offset Byte8_t offset; /**< codestream offset*/
Byte8_t length; //!< codestream length Byte8_t length; /**< codestream length */
Byte8_t mhead_length; //!< main header length Byte8_t mhead_length; /**< main header length */
//! A.5.1 Image and tile size (SIZ) SIZmarker_param_t SIZ; /**< SIZ marker information*/
Byte2_t Rsiz; //!< capabilities that a decoder needs CODmarker_param_t COD; /**< COD marker information*/
Byte4_t Xsiz; //!< width of the reference grid faixbox_param_t *tilepart; /**< tile part information from tpix box*/
Byte4_t Ysiz; //!< height of the reference grid mhixbox_param_t **tileheader; /**< dynamic array of tile header information from thix box*/
Byte4_t XOsiz; //!< horizontal offset from the origin of faixbox_param_t **precpacket; /**< dynamic array of precint packet information from ppix box*/
//!the reference grid to the left side of the image area
Byte4_t YOsiz; //!< vertical offset from the origin of
//!the reference grid to the top side of the image area
Byte4_t XTsiz; //!< width of one reference tile with
//!respect to the reference grid
Byte4_t YTsiz; //!< height of one reference tile with
//!respect to the reference grid
Byte4_t XTOsiz; //!< horizontal offset from the origin of
//!the reference grid to the left side of the first tile
Byte4_t YTOsiz; //!< vertical offset from the origin of
//!the reference grid to the top side of
//!the first tile
Byte4_t XTnum; //!< number of tiles in horizontal direction
Byte4_t YTnum; //!< number of tiles in vertical
//!direction
Byte2_t Csiz; //!< number of the components in the image
Byte_t Ssiz[3]; //!< precision (depth) in bits and sign
//!of the component samples
Byte_t XRsiz[3]; //!< horizontal separation of a sample of
//!component with respect to the reference grid
Byte_t YRsiz[3]; //!< vertical separation of a sample of
//!component with respect to the reference grid
faixbox_param_t *tilepart; //!< tile part information from tpix box
bool mhead_model; //!< main header model, if sent, 1, else 0
bool *tp_model; //!< dynamic array pointer of tile part
//!model, if sent, 1, else 0
} index_param_t; } index_param_t;
@ -95,12 +109,18 @@ index_param_t * parse_jp2file( int fd);
void print_index( index_param_t index); void print_index( index_param_t index);
/** /**
* print cache model * print Image and Tile SIZ parameters
* *
* @param[in] index index parameters * @param[in] SIZ SIZ marker information
*/ */
void print_cachemodel( index_param_t index); void print_SIZ( SIZmarker_param_t SIZ);
/**
* print Coding style default COD parameters
*
* @param[in] COD COD marker information
*/
void print_COD( CODmarker_param_t COD);
/** /**
* delete index * delete index
@ -109,31 +129,59 @@ void print_cachemodel( index_param_t index);
*/ */
void delete_index( index_param_t **index); void delete_index( index_param_t **index);
//! 1-dimensional range parameters /**
* delete dynamic arrays in COD marker
*
* @param[in] COD COD marker information
*/
void delete_COD( CODmarker_param_t COD);
/** 1-dimensional range parameters*/
typedef struct range_param{ typedef struct range_param{
Byte4_t minvalue; //!< minimal value Byte4_t minvalue; /**< minimal value*/
Byte4_t maxvalue; //!< maximal value Byte4_t maxvalue; /**< maximal value*/
} range_param_t; } range_param_t;
/** /**
* get horizontal range of the tile in reference grid * get horizontal range of the tile in reference grid
* *
* @param[in] index index parameters * @param[in] SIZ SIZ marker information
* @param[in] tile_xid tile id in x-direction (0<= <XTnum) * @param[in] tile_id tile id
* @param[in] level decomposition level * @param[in] level decomposition level
* @return structured range parameter * @return structured range parameter
*/ */
range_param_t get_tile_Xrange( index_param_t index, Byte4_t tile_xid, int level); range_param_t get_tile_Xrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
/** /**
* get vertical range of the tile in reference grid * get vertical range of the tile in reference grid
* *
* @param[in] index index parameters * @param[in] SIZ SIZ marker information
* @param[in] tile_yid tile id in y-direction (0<= <YTnum) * @param[in] tile_id tile id
* @param[in] level decomposition level * @param[in] level decomposition level
* @return structured range parameter * @return structured range parameter
*/ */
range_param_t get_tile_Yrange( index_param_t index, Byte4_t tile_yid, int level); range_param_t get_tile_Yrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
/**
* get tile wdith at the decomposition level
*
* @param[in] SIZ SIZ marker information
* @param[in] tile_id tile id
* @param[in] level decomposition level
* @return tile width
*/
Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
/**
* answers if the target is feasible to JPT-stream
*
* @param[in] index index parameters
* @return true if JPT-stream is feasible
*/
bool isJPTfeasible( index_param_t index);
#endif /* !INDEX_MANAGER_H_ */ #endif /* !INDEX_MANAGER_H_ */

View File

@ -0,0 +1,291 @@
/*
* $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
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "j2kheader_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
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream);
bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD)
{
if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){
fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n");
return false;
}
if( SIZ){
*SIZ = get_SIZmkrdata_from_j2kstream( j2kstream);
if( SIZ->Lsiz == 0)
return false;
j2kstream += (SIZ->Lsiz+2);
}
if( COD){
if( !SIZ)
j2kstream += (big2( j2kstream+2) + 2);
*COD = get_CODmkrdata_from_j2kstream( j2kstream);
if( COD->Lcod == 0)
return false;
}
return true;
}
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
{
SIZmarker_param_t SIZ ={0};
int i;
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
fprintf( FCGI_stderr, "Error, SIZ marker not found in the reconstructed j2kstream\n");
return SIZ;
}
SIZ.Lsiz = big2( SIZstream);
SIZ.Rsiz = big2( SIZstream+2);
SIZ.Xsiz = big4( SIZstream+4);
SIZ.Ysiz = big4( SIZstream+8);
SIZ.XOsiz = big4( SIZstream+12);
SIZ.YOsiz = big4( SIZstream+16);
SIZ.XTsiz = big4( SIZstream+20);
SIZ.YTsiz = big4( SIZstream+24);
SIZ.XTOsiz = big4( SIZstream+28);
SIZ.YTOsiz = big4( SIZstream+32);
SIZ.Csiz = big2( SIZstream+36);
SIZ.XTnum = ( SIZ.Xsiz-SIZ.XTOsiz+SIZ.XTsiz-1)/SIZ.XTsiz;
SIZ.YTnum = ( SIZ.Ysiz-SIZ.YTOsiz+SIZ.YTsiz-1)/SIZ.YTsiz;
for( i=0; i<(int)SIZ.Csiz; i++){
SIZ.Ssiz[i] = *(SIZstream+(38+i*3));
SIZ.XRsiz[i] = *(SIZstream+(39+i*3));
SIZ.YRsiz[i] = *(SIZstream+(40+i*3));
}
return SIZ;
}
CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
{
CODmarker_param_t COD;
int i;
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
return COD;
}
COD.Lcod = big2( CODstream);
COD.Scod = *( CODstream+2);
COD.prog_order = *( CODstream+3);
COD.numOflayers = big2( CODstream+4);
COD.numOfdecomp = *( CODstream+7);
if(COD.Scod & 0x01){
COD.XPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
for( i=0; i<=COD.numOfdecomp; i++){
//precinct size
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
}
}
else{
COD.XPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
COD.YPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
COD.XPsiz[0] = COD.YPsiz[0] = pow(2,15);
}
return COD;
}
bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream);
Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *CODstream);
bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen)
{
Byte2_t newLcod;
if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){
fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n");
return false;
}
if(!modify_SIZmkrstream( SIZ, COD.numOfdecomp-numOfdecomp, j2kstream))
return false;
j2kstream += SIZ.Lsiz+2;
if( !(newLcod = modify_CODmkrstream( COD, numOfdecomp, j2kstream)))
return false;
memmove( j2kstream+2+newLcod, j2kstream+2+COD.Lcod, (*j2klen)-(SIZ.Lsiz+COD.Lcod+6));
*j2klen -= ( COD.Lcod - newLcod);
return true;
}
bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream)
{
int i;
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
fprintf( FCGI_stderr, "Error, SIZ marker not found in the reconstructed j2kstream\n");
return false;
}
for( i=0; i<difOfdecomplev; i++){
SIZ.Xsiz = ceil( (double)SIZ.Xsiz/2.0);
SIZ.Ysiz = ceil( (double)SIZ.Ysiz/2.0);
SIZ.XOsiz = ceil( (double)SIZ.XOsiz/2.0);
SIZ.YOsiz = ceil( (double)SIZ.YOsiz/2.0);
SIZ.XTsiz = ceil( (double)SIZ.XTsiz/2.0);
SIZ.YTsiz = ceil( (double)SIZ.YTsiz/2.0);
SIZ.XTOsiz = ceil( (double)SIZ.XTOsiz/2.0);
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
}
SIZstream += 4; // skip Lsiz + Rsiz
modify_4Bytecode( SIZ.Xsiz, SIZstream);
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
modify_4Bytecode( SIZ.XOsiz, SIZstream+8);
modify_4Bytecode( SIZ.YOsiz, SIZstream+12);
modify_4Bytecode( SIZ.XTsiz, SIZstream+16);
modify_4Bytecode( SIZ.YTsiz, SIZstream+20);
modify_4Bytecode( SIZ.XTOsiz, SIZstream+24);
modify_4Bytecode( SIZ.YTOsiz, SIZstream+28);
return true;
}
Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *CODstream)
{
Byte2_t newLcod;
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
return 0;
}
if( COD.Scod & 0x01){
newLcod = 13+numOfdecomp;
*CODstream++ = (Byte_t)((Byte2_t)(newLcod & 0xff00) >> 8);
*CODstream++ = (Byte_t)(newLcod & 0x00ff);
}
else{
newLcod = COD.Lcod;
CODstream += 2;
}
CODstream += 5; // skip Scod & SGcod
// SPcod
*CODstream++ = (Byte_t) numOfdecomp;
return newLcod;
}
bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte2_t *oldLcoc, Byte2_t *newLcoc);
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
{
Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
Byte_t *thstream, *SOTstream, *Psot_stream;
Byte2_t oldLcoc, newLcoc;
SOTstream = thstream = j2kstream+SOToffset;
if( *SOTstream++ != 0xff || *SOTstream++ != 0x90){
fprintf( FCGI_stderr, "Error, thstream is not starting with SOT marker\n");
return false;
}
SOTstream += 4; // skip Lsot & Isot
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
Psot_stream = SOTstream;
thstream += 12; // move to next marker (SOT always 12bytes)
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
return false;
memmove( thstream+newLcoc+2, thstream+oldLcoc+2, (*j2klen)-(thstream-j2kstream+oldLcoc+2));
*j2klen -= ( oldLcoc - newLcoc);
}
thstream += 2;
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
}
if( (*j2klen)-SOToffset != Psot){
Psot = (*j2klen)-SOToffset;
modify_4Bytecode( Psot, Psot_stream);
}
return true;
}
bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte2_t *oldLcoc, Byte2_t *newLcoc)
{
if( *COCstream++ != 0xff || *COCstream++ != 0x53){
fprintf( FCGI_stderr, "Error, COC marker not found in the reconstructed j2kstream\n");
return false;
}
*oldLcoc = big2( COCstream);
*newLcoc = (Csiz < 257 ? 10 : 11) + numOfdecomp;
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
else COCstream += 3;
*COCstream = numOfdecomp;
return true;
}

View File

@ -0,0 +1,73 @@
/*
* $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
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef J2KHEADER_MANAGER_H_
# define J2KHEADER_MANAGER_H_
#include "bool.h"
#include "byte_manager.h"
#include "index_manager.h"
/**
* get main header information from j2k codestream
*
* @param[in] j2kstream j2k codestream
* @param[out] SIZ SIZ marker pointer
* @param[out] COD COD marker pointer
* @return if succeeded (true) or failed (false)
*/
bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD);
/**
* modify main header in j2k codestream to fit with the new number of decompositions
*
* @param[in] j2kstream j2k codestream
* @param[in] numOfdecomp the New number of decompositions
* @param[in] SIZ original SIZ marker information
* @param[in] COD original COD marker information
* @param[out] j2klen pointer to the length of j2k code stream
* @return if succeeded (true) or failed (false)
*/
bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen);
/**
* modify tile header in j2k codestream to fit with the tile part length, and new number of decompositions for multi-componet images
*
* @param[in] j2kstream j2k codestream
* @param[in] SOToffset offset of SOT marker from the beginning of j2kstream
* @param[in] numOfdecomp the New number of decompositions, -1 if the same as original
* @param[in] Csiz number of components
* @param[out] j2klen pointer to the length of j2k code stream
* @return if succeeded (true) or failed (false)
*/
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen);
#endif /* !J2KHEADER_MANAGER_H_ */

View File

@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "jp2k_decoder.h" #include "jp2k_decoder.h"
@ -75,6 +76,9 @@ Byte_t * j2k_to_pnm( Byte_t *j2kstream, Byte8_t j2klen, ihdrbox_param_t **ihdrbo
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
fprintf(stderr, "image is decoded!\n");
if(!image) { if(!image) {
fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n"); fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo); opj_destroy_decompress(dinfo);
@ -94,9 +98,10 @@ Byte_t * j2k_to_pnm( Byte_t *j2kstream, Byte8_t j2klen, ihdrbox_param_t **ihdrbo
if(dinfo) { if(dinfo) {
opj_destroy_decompress(dinfo); opj_destroy_decompress(dinfo);
} }
/* free image data structure */ /* free image data structure */
opj_image_destroy(image); opj_image_destroy(image);
return pnmstream; return pnmstream;
} }
@ -134,13 +139,13 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
if(*ihdrbox){ if(*ihdrbox){
if( (*ihdrbox)->nc != image->numcomps) if( (*ihdrbox)->nc != image->numcomps)
fprintf( stderr, "Exception: num of components not identical, codestream: %d, ihdrbox: %d\n", image->numcomps, (*ihdrbox)->nc); fprintf( stderr, "Exception: num of components not identical, codestream: %d, ihdrbox: %d\n", image->numcomps, (*ihdrbox)->nc);
if( (*ihdrbox)->width != image->comps[0].w) if( (*ihdrbox)->width != image->comps[0].w)
fprintf( stderr, "Exception: width value not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].w, (*ihdrbox)->width); (*ihdrbox)->width = image->comps[0].w;
if( (*ihdrbox)->height != image->comps[0].h) if( (*ihdrbox)->height != image->comps[0].h)
fprintf( stderr, "Exception: heigth value not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].h, (*ihdrbox)->height); (*ihdrbox)->height = image->comps[0].h;
if( (*ihdrbox)->bpc != image->comps[0].prec) if( (*ihdrbox)->bpc != image->comps[0].prec)
fprintf( stderr, "Exception: bits per component not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].prec, (*ihdrbox)->bpc); fprintf( stderr, "Exception: bits per component not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].prec, (*ihdrbox)->bpc);
} }

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