Compare commits
470 Commits
version.2.
...
codingstyl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0febbff19e | ||
|
|
bede1568b1 | ||
|
|
5c5ae1d51a | ||
|
|
6ec68a27f8 | ||
|
|
4b927ecea3 | ||
|
|
0efb2f5293 | ||
|
|
3767af52de | ||
|
|
1b86fb6f48 | ||
|
|
a42d03df79 | ||
|
|
cb33ff43bb | ||
|
|
6a1974d40d | ||
|
|
87c0d7dc1e | ||
|
|
0dd44e7dba | ||
|
|
9cad6bc1f6 | ||
|
|
79b1c4cc85 | ||
|
|
c00ee8bff7 | ||
|
|
a205f70328 | ||
|
|
9c5b30005e | ||
|
|
83e5e2703e | ||
|
|
3a0253f4e2 | ||
|
|
99c4f621bd | ||
|
|
2e4fadf330 | ||
|
|
8f9905936c | ||
|
|
a834ab305f | ||
|
|
51efe91971 | ||
|
|
4ddc2627dd | ||
|
|
5d56fb3115 | ||
|
|
51cbcd5748 | ||
|
|
f51d52f85a | ||
|
|
c414d9c238 | ||
|
|
e5ca873ab1 | ||
|
|
601aa38c30 | ||
|
|
fb4be3894e | ||
|
|
c37d69b25e | ||
|
|
a77717583e | ||
|
|
968085190c | ||
|
|
93a61459cd | ||
|
|
38ffbbe42e | ||
|
|
ce26e523dd | ||
|
|
7dfcbf9d7b | ||
|
|
4ac509182a | ||
|
|
0ae66e891a | ||
|
|
9f78c68953 | ||
|
|
f080ab8ce0 | ||
|
|
e975ca2832 | ||
|
|
b06bed7b7b | ||
|
|
b7a162348d | ||
|
|
540aa58f6c | ||
|
|
d48be27f5a | ||
|
|
eaf55b677c | ||
|
|
0967d64854 | ||
|
|
5799672237 | ||
|
|
a1fc83cc25 | ||
|
|
ad7eb5630e | ||
|
|
4831badeb4 | ||
|
|
80be580d50 | ||
|
|
05b3afd28f | ||
|
|
e1122a8f50 | ||
|
|
f9d47e28b9 | ||
|
|
8034ffde8b | ||
|
|
b3a15954f6 | ||
|
|
83249c318f | ||
|
|
b1a8e1adcb | ||
|
|
ee04854e1a | ||
|
|
b3c581760f | ||
|
|
bd3959dc77 | ||
|
|
fd424cfb66 | ||
|
|
e734f0522a | ||
|
|
9729405a8f | ||
|
|
65f78eaa73 | ||
|
|
08238dbed6 | ||
|
|
c8d03fea9b | ||
|
|
6721f8a53f | ||
|
|
54a5860ee2 | ||
|
|
372fead0d7 | ||
|
|
98324bbd6b | ||
|
|
522d13af2a | ||
|
|
26dcb7c125 | ||
|
|
51a67a9cbf | ||
|
|
dd81b5892d | ||
|
|
0cd240e2e3 | ||
|
|
dac03fd168 | ||
|
|
d02bf257a6 | ||
|
|
0f1b1c63b4 | ||
|
|
11a27e6d20 | ||
|
|
ab8929262a | ||
|
|
813121e688 | ||
|
|
7a7901cd6d | ||
|
|
c5a8732b0e | ||
|
|
101a0034e2 | ||
|
|
2c8ba10cc9 | ||
|
|
30a0180d84 | ||
|
|
99c4376aed | ||
|
|
c3493063b9 | ||
|
|
4042210416 | ||
|
|
dc869c2985 | ||
|
|
caeb91121a | ||
|
|
891e7c298a | ||
|
|
d60937922f | ||
|
|
229d9cdb9c | ||
|
|
f0a980ec16 | ||
|
|
cc9bf1d557 | ||
|
|
a01f7cdee0 | ||
|
|
d753441028 | ||
|
|
53d7f70c15 | ||
|
|
70a16d80d9 | ||
|
|
4560d270e0 | ||
|
|
f33f50126c | ||
|
|
8d2019ae73 | ||
|
|
cf6db1641a | ||
|
|
9df5546838 | ||
|
|
b816ac185b | ||
|
|
d92c2b2117 | ||
|
|
d035952c52 | ||
|
|
1ed6ede703 | ||
|
|
d03c4770cb | ||
|
|
50b561e911 | ||
|
|
2d410fc74b | ||
|
|
d5c460fc5f | ||
|
|
62006e2b26 | ||
|
|
d05b19072d | ||
|
|
32ac092dec | ||
|
|
27102f0b06 | ||
|
|
87d44603a0 | ||
|
|
74f71ec923 | ||
|
|
5c3632b00e | ||
|
|
a4eade843f | ||
|
|
cba89a62a1 | ||
|
|
4123c0ba86 | ||
|
|
1a9cb9aef7 | ||
|
|
0dc4914b4e | ||
|
|
e224dee4b8 | ||
|
|
d2ddf006a6 | ||
|
|
a7ae153a46 | ||
|
|
de0a9ed103 | ||
|
|
553714a87a | ||
|
|
1b2ebfc69a | ||
|
|
3259fe2ff8 | ||
|
|
bbef2a9da3 | ||
|
|
5b6ff103bd | ||
|
|
c86827952f | ||
|
|
9b437b0c6a | ||
|
|
c8ae3c5225 | ||
|
|
07f65540b5 | ||
|
|
8414870ca7 | ||
|
|
2dab5fed59 | ||
|
|
26b2728c49 | ||
|
|
e526d435cc | ||
|
|
f8c8222660 | ||
|
|
d6b51b7041 | ||
|
|
987f96004f | ||
|
|
0b6a592372 | ||
|
|
83c9e0b1f2 | ||
|
|
db23831d57 | ||
|
|
0cfe2ca4a9 | ||
|
|
cf352af089 | ||
|
|
c59f464a3f | ||
|
|
05235963d9 | ||
|
|
99fc1ab306 | ||
|
|
f7dbcf1512 | ||
|
|
838dfb8058 | ||
|
|
4da7e9617f | ||
|
|
b9ca882749 | ||
|
|
f9df8ba19a | ||
|
|
09c35dcb84 | ||
|
|
f82d7f3a63 | ||
|
|
faf63fddad | ||
|
|
281537851b | ||
|
|
55dbf8acff | ||
|
|
c16c91797f | ||
|
|
a4e93c3b0a | ||
|
|
4bb5e24d23 | ||
|
|
6cb56b36f6 | ||
|
|
9c911c0e1e | ||
|
|
3ea4486bed | ||
|
|
6e11b55441 | ||
|
|
c6b2fdf572 | ||
|
|
700f8cb4f8 | ||
|
|
7d32f11a6f | ||
|
|
b4e8a425ae | ||
|
|
c8a3117659 | ||
|
|
49cbc11a19 | ||
|
|
3d295431e6 | ||
|
|
c08bd89739 | ||
|
|
1621df453d | ||
|
|
0b611c5250 | ||
|
|
b8ba5a8357 | ||
|
|
9add0fe298 | ||
|
|
ecb00ea4e4 | ||
|
|
cde7423958 | ||
|
|
6c157b60f2 | ||
|
|
fc131a1339 | ||
|
|
4f157f3cf0 | ||
|
|
41730e8cc6 | ||
|
|
82c238f504 | ||
|
|
52c36b4955 | ||
|
|
b7069ce2b2 | ||
|
|
cc2ae75450 | ||
|
|
b97aadcf3e | ||
|
|
1e2dcaf7b3 | ||
|
|
175eceb020 | ||
|
|
7981908754 | ||
|
|
9258f8f6a7 | ||
|
|
41a96aee5a | ||
|
|
897d2c0b75 | ||
|
|
e3579b6c1d | ||
|
|
8d46ac19ff | ||
|
|
4b02d246a4 | ||
|
|
47b7b2787b | ||
|
|
c31a28fcd1 | ||
|
|
cd10f46572 | ||
|
|
29ce132df4 | ||
|
|
5d953558de | ||
|
|
bac2c9e0a3 | ||
|
|
ee0f313848 | ||
|
|
ccdce606f1 | ||
|
|
d7d9f84707 | ||
|
|
4cde646cd7 | ||
|
|
5f02757eef | ||
|
|
4f5ec07c31 | ||
|
|
0a27667878 | ||
|
|
66d890bf22 | ||
|
|
dd00120e96 | ||
|
|
e71247bb90 | ||
|
|
a024980007 | ||
|
|
dc46d267f0 | ||
|
|
c32809d464 | ||
|
|
5be56d582c | ||
|
|
bd291ae5a8 | ||
|
|
f1ba09f690 | ||
|
|
4eabbc8661 | ||
|
|
e4be47279d | ||
|
|
29c644ec49 | ||
|
|
940100c28a | ||
|
|
c31fb68ccc | ||
|
|
15d07f33d1 | ||
|
|
c5dd6035c9 | ||
|
|
2eb97a851d | ||
|
|
8a95efcd3f | ||
|
|
38770403d4 | ||
|
|
589cc547b9 | ||
|
|
a521472427 | ||
|
|
d4ac2f613d | ||
|
|
fa9142b7e4 | ||
|
|
f98df1c715 | ||
|
|
3109759fd7 | ||
|
|
0a4ac0852a | ||
|
|
dc34a6cc8c | ||
|
|
238f4419ab | ||
|
|
60301842c7 | ||
|
|
acbb297a0a | ||
|
|
4fc1073809 | ||
|
|
7c688c3453 | ||
|
|
372c887aad | ||
|
|
0df90afdf7 | ||
|
|
75a33de3bc | ||
|
|
f026c0541e | ||
|
|
e4735c703d | ||
|
|
ae7953849b | ||
|
|
1947323329 | ||
|
|
c3d9719cd4 | ||
|
|
2263b6bacc | ||
|
|
5b66156be4 | ||
|
|
b0035538af | ||
|
|
45ccf501f0 | ||
|
|
15e4168ee2 | ||
|
|
2452bb7c45 | ||
|
|
85904a3291 | ||
|
|
012f22958a | ||
|
|
f3dad25c77 | ||
|
|
e6cf1744d4 | ||
|
|
db9b3400e5 | ||
|
|
c423cc84e7 | ||
|
|
d87de3a88d | ||
|
|
6007ac5c56 | ||
|
|
335e972554 | ||
|
|
8c4afeff40 | ||
|
|
ffd9db9700 | ||
|
|
b190a91ab5 | ||
|
|
f6843d5511 | ||
|
|
a56819eaab | ||
|
|
d6f2d26430 | ||
|
|
9ac3a1572e | ||
|
|
0905cab40a | ||
|
|
2fc9d4956a | ||
|
|
28c6f54798 | ||
|
|
2c7dab7655 | ||
|
|
96ae1b8dfc | ||
|
|
1bbb607069 | ||
|
|
fd1f7cf297 | ||
|
|
5bb074611a | ||
|
|
46c1dd22fc | ||
|
|
06f6911d7b | ||
|
|
ae4799ad07 | ||
|
|
b88025b38f | ||
|
|
b59085db0c | ||
|
|
8048bbc7a2 | ||
|
|
d1591be3d7 | ||
|
|
6b7ad74e26 | ||
|
|
635a358962 | ||
|
|
8f798864a9 | ||
|
|
ac9fb5a302 | ||
|
|
775ee87776 | ||
|
|
0b1f8eb6f7 | ||
|
|
c887df12a3 | ||
|
|
d1b053afe2 | ||
|
|
5e1474cc92 | ||
|
|
dc43ebf96c | ||
|
|
a7060dae1c | ||
|
|
ba05549b0f | ||
|
|
fb0e397330 | ||
|
|
35ddb3abc7 | ||
|
|
237ddd72f1 | ||
|
|
c999b6c0f0 | ||
|
|
4e0de649bd | ||
|
|
6b0a8e3a0f | ||
|
|
eadfad7a50 | ||
|
|
14361eee24 | ||
|
|
c9e231508b | ||
|
|
6347686385 | ||
|
|
1a8f929111 | ||
|
|
56d3f5af6e | ||
|
|
c665e81a39 | ||
|
|
c6c49865fe | ||
|
|
52d27be5c2 | ||
|
|
6e0118231a | ||
|
|
da3786d2d1 | ||
|
|
8d770ece9a | ||
|
|
0a0cb190da | ||
|
|
79b079bdc0 | ||
|
|
dbb67194b2 | ||
|
|
c255e0140c | ||
|
|
2bd6aa54d6 | ||
|
|
c7535d084e | ||
|
|
c0d7afe15c | ||
|
|
6def7e38b4 | ||
|
|
73881d0e52 | ||
|
|
e3291c4e1f | ||
|
|
0fa5a17c98 | ||
|
|
757f9394bf | ||
|
|
daed8cc919 | ||
|
|
d1a941ea50 | ||
|
|
00a47c1e06 | ||
|
|
1fb24aba4b | ||
|
|
2d24b6000d | ||
|
|
8b5e2a5143 | ||
|
|
3ed5858902 | ||
|
|
7a8cdc4bb0 | ||
|
|
4c0ed02806 | ||
|
|
5d00b719f4 | ||
|
|
42132ed6b5 | ||
|
|
31f5efe453 | ||
|
|
78a7762e3f | ||
|
|
33f52fb611 | ||
|
|
81abe5b3bb | ||
|
|
4a09296771 | ||
|
|
6922124c4c | ||
|
|
59b844347c | ||
|
|
bde5ba6ae8 | ||
|
|
16240e21f9 | ||
|
|
33a0e66eb1 | ||
|
|
f7ff08de5a | ||
|
|
f1bae45c76 | ||
|
|
65c07b42e3 | ||
|
|
3888daac6a | ||
|
|
e966fef3eb | ||
|
|
a504edf724 | ||
|
|
dde788b59e | ||
|
|
58fc86452d | ||
|
|
c0cb119c0e | ||
|
|
9a21e1eef0 | ||
|
|
a0688a9874 | ||
|
|
d0ce2ced53 | ||
|
|
e05d2901ec | ||
|
|
c0710f557c | ||
|
|
f095027329 | ||
|
|
8d320bbdf8 | ||
|
|
776b83ddbc | ||
|
|
04ace2a558 | ||
|
|
46afb746f0 | ||
|
|
570dd13f55 | ||
|
|
63f877769c | ||
|
|
04c6bb4a72 | ||
|
|
131cc98491 | ||
|
|
13bcb63b73 | ||
|
|
0ba5d15b58 | ||
|
|
7e38446075 | ||
|
|
548aff34f4 | ||
|
|
8397eac382 | ||
|
|
a2c2d86d3d | ||
|
|
3bc360fc9d | ||
|
|
ae1da37558 | ||
|
|
f57f59b10d | ||
|
|
b65e3ebdb6 | ||
|
|
50acc339c5 | ||
|
|
f123ce8f8a | ||
|
|
c3629e37a2 | ||
|
|
cf5153c518 | ||
|
|
3b7dced8e6 | ||
|
|
03a410e03d | ||
|
|
0a6eaaa605 | ||
|
|
7f8f284ee5 | ||
|
|
09fb8b6989 | ||
|
|
9e6c62199a | ||
|
|
d47f7a249d | ||
|
|
7280263988 | ||
|
|
3e1fad2da4 | ||
|
|
d72940c56b | ||
|
|
ad4fad0965 | ||
|
|
aff9cb39ed | ||
|
|
0a3f234df7 | ||
|
|
efb70af001 | ||
|
|
e65303b903 | ||
|
|
413de4fbfa | ||
|
|
984351f86f | ||
|
|
f8796711e8 | ||
|
|
0b540067b1 | ||
|
|
3df347eded | ||
|
|
eb7c6d295a | ||
|
|
f126eb0d41 | ||
|
|
7256e43c48 | ||
|
|
a0a3af1dee | ||
|
|
48832d944f | ||
|
|
06bd61b571 | ||
|
|
a1c754c737 | ||
|
|
fef1276901 | ||
|
|
45f33cdbd6 | ||
|
|
1acfa211ae | ||
|
|
2f3fd1194e | ||
|
|
f08af3ed82 | ||
|
|
2720a1a405 | ||
|
|
31fd8d3fe8 | ||
|
|
6868ee373e | ||
|
|
b9a247b559 | ||
|
|
50a205d20f | ||
|
|
b0072bf658 | ||
|
|
2c810567dd | ||
|
|
0a1a29a7fe | ||
|
|
7d21871ed8 | ||
|
|
a38b97fae0 | ||
|
|
45313a8dfa | ||
|
|
b08135e7c1 | ||
|
|
4bac8488df | ||
|
|
de04302c15 | ||
|
|
997758f91c | ||
|
|
763214f7c0 | ||
|
|
77e8dad503 | ||
|
|
1758445a75 | ||
|
|
7a77a8047d | ||
|
|
d8767cbcb7 | ||
|
|
7924d3a456 | ||
|
|
ec84bafcd8 | ||
|
|
08c09b74cf | ||
|
|
7aece5e8e7 | ||
|
|
8d93eae64a | ||
|
|
9a3d660d1b | ||
|
|
7199d9b5d3 | ||
|
|
d19a4ab676 | ||
|
|
f105cb5471 | ||
|
|
4db4198722 | ||
|
|
616a3345c4 | ||
|
|
1f8d84a562 | ||
|
|
a54d757a3e | ||
|
|
b5eb374fb9 | ||
|
|
f1d69068c7 | ||
|
|
ee130e2306 | ||
|
|
9ba6bc6042 | ||
|
|
5e1a0fad08 | ||
|
|
c05118dc49 | ||
|
|
1adf89d5d2 |
63
.travis.yml
Normal file
63
.travis.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
language: c
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- gcc-multilib
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
||||
- os: linux
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- gcc-mingw-w64-base
|
||||
- binutils-mingw-w64-x86-64
|
||||
- gcc-mingw-w64-x86-64
|
||||
- gcc-mingw-w64
|
||||
- os: linux
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- gcc-mingw-w64-base
|
||||
- binutils-mingw-w64-i686
|
||||
- gcc-mingw-w64-i686
|
||||
- gcc-mingw-w64
|
||||
- os: linux
|
||||
compiler: gcc-4.8
|
||||
env: OPJ_CI_ABI_CHECK=1
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.8
|
||||
- libelf-dev
|
||||
- elfutils
|
||||
- texinfo
|
||||
- exuberant-ctags
|
||||
|
||||
install:
|
||||
- ./tools/travis-ci/install.sh
|
||||
|
||||
script:
|
||||
- ./tools/travis-ci/run.sh
|
||||
- ./tools/travis-ci/abi-check.sh
|
||||
6
AUTHORS
6
AUTHORS
@@ -3,10 +3,10 @@ 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.
|
||||
Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
|
||||
Giuseppe Baruffa added the JPWL functionalities.
|
||||
Micka<EFBFBD>l Savinaud implemented the final OpenJPEG v2 version based on a big merge between 1.5 version and alpha version of v2.
|
||||
Mathieu Malaterre participate to the OpenJPEG v2 version and release the OpenJPEG 1.5 and 1.5.1 version.
|
||||
Micka<EFBFBD>l Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
|
||||
Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
|
||||
Yannick Verschueren,
|
||||
Herve Drolon,
|
||||
Francois-Olivier Devaux,
|
||||
|
||||
@@ -11,6 +11,9 @@ cmake_minimum_required(VERSION 2.8.2)
|
||||
|
||||
if(COMMAND CMAKE_POLICY)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENJPEG_NAMESPACE)
|
||||
@@ -47,6 +50,7 @@ set(PACKAGE_VERSION
|
||||
# 1.5 | 5
|
||||
# 1.5.1 | 5
|
||||
# 2.0 | 6
|
||||
# 2.0.1 | 6
|
||||
# 2.1 | 7
|
||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||
@@ -94,6 +98,8 @@ endif()
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Install directories
|
||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} projectname)
|
||||
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||
@@ -118,6 +124,7 @@ if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
|
||||
if(BUILD_DOC)
|
||||
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||
endif()
|
||||
@@ -125,6 +132,7 @@ endif()
|
||||
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||
if(WIN32)
|
||||
@@ -141,6 +149,11 @@ if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
|
||||
option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Big endian test:
|
||||
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||
@@ -177,7 +190,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# For all builds, make sure openjpeg is std99 compliant:
|
||||
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -212,6 +225,18 @@ CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
include(TestLargeFiles)
|
||||
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||
|
||||
# Allocating Aligned Memory Blocks
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||
include(CheckSymbolExists)
|
||||
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
||||
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
|
||||
# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
|
||||
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
# memalign (obsolete)
|
||||
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Library
|
||||
if(BUILD_JPIP_SERVER)
|
||||
@@ -264,8 +289,7 @@ configure_file(
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||
# build documentation in doc subdir:
|
||||
if(BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
@@ -279,8 +303,8 @@ if(BUILD_TESTING)
|
||||
include(CTest)
|
||||
|
||||
# Search openjpeg data needed for the tests
|
||||
# They could be found via svn on the OpenJPEG google code project
|
||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||
# They could be found via git on the OpenJPEG GitHub code project
|
||||
# git clone https://github.com/uclouvain/openjpeg-data.git
|
||||
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||
@@ -307,16 +331,25 @@ install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install CHANGES and LICENSE
|
||||
if(BUILD_DOC)
|
||||
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
endif()
|
||||
|
||||
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
endif()
|
||||
|
||||
include (cmake/OpenJPEGCPack.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# pkgconfig support
|
||||
# enabled by default on Unix, disabled by default on other platforms
|
||||
if(UNIX)
|
||||
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
|
||||
else()
|
||||
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
|
||||
endif()
|
||||
if(BUILD_PKGCONFIG_FILES)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)
|
||||
|
||||
2
INSTALL
2
INSTALL
@@ -44,7 +44,7 @@ Main available cmake flags:
|
||||
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
||||
make
|
||||
make Experimental
|
||||
Note : JPEG2000 test files are available with 'svn checkout http://openjpeg.googlecode.com/svn/data' (about 70 Mo).
|
||||
Note : JPEG2000 test files are available with 'git clone https://github.com/uclouvain/openjpeg-data.git'.
|
||||
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
||||
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
||||
been checked out of course).
|
||||
|
||||
11
LICENSE
11
LICENSE
@@ -1,7 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2012, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2012, Antonin Descampe
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2003-2009, Francois-Olivier Devaux
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
|
||||
40
NEWS
40
NEWS
@@ -2,6 +2,46 @@
|
||||
OpenJPEG NEWS - user visible changes
|
||||
====================================
|
||||
|
||||
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.X.X
|
||||
----------------------------------------------
|
||||
|
||||
New Features:
|
||||
|
||||
* Digital Cinema profiles have been fixed and updated
|
||||
* New option to disable MCT if needed
|
||||
* extended RAW support: it is now possible to input raw images
|
||||
with subsampled color components (422, 420, etc)
|
||||
* New way to deal with profiles
|
||||
|
||||
API/ABI modifications: (see abi_compat_report in dev-utils/scripts)
|
||||
|
||||
* Removed deprecated functions
|
||||
- opj_stream_create_default_file_stream(FILE*,...)
|
||||
- opj_stream_create_file_stream(FILE*,...)
|
||||
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
|
||||
* Added
|
||||
- opj_stream_create_default_file_stream(char*,...)
|
||||
- opj_stream_create_file_stream(char*,...)
|
||||
- opj_stream_destroy(opj_stream_t*)
|
||||
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
|
||||
... opj_stream_free_user_data_fn p_function)
|
||||
- JPEG 2000 profiles and Part-2 extensions defined through '#define'
|
||||
* Changed
|
||||
- 'alpha' field added to 'opj_image_comp' structure
|
||||
- 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
|
||||
- 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
|
||||
- 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
|
||||
(not yet used in use)
|
||||
- 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
|
||||
|
||||
Misc:
|
||||
|
||||
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
||||
and will soon become official reference software at the
|
||||
JPEG committee.
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
|
||||
|
||||
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0
|
||||
----------------------------------------------
|
||||
|
||||
|
||||
47
README
47
README
@@ -1,47 +0,0 @@
|
||||
|
||||
OPENJPEG LIBRARY and APPLICATIONS
|
||||
----------------------------------
|
||||
|
||||
Details on folders hierarchy:
|
||||
|
||||
* src
|
||||
* lib
|
||||
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
|
||||
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||
* openjp3d: JP3D implementation
|
||||
* openmj2: MJ2 implementation
|
||||
* bin: contains all applications that use the openjpeg library
|
||||
* common: common files to all applications
|
||||
* jp2: a basic codec
|
||||
* mj2: motion jpeg 2000 executables
|
||||
* jpip: OpenJPIP applications (server and dec server)
|
||||
* java: a Java client viewer for JPIP
|
||||
* jp3d: JP3D applications
|
||||
* tcltk: a test tool for JP3D
|
||||
* wx
|
||||
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||
* wrapping
|
||||
* java: java jni to use openjpeg in a java program
|
||||
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||
* doc: doxygen documentation setup file and man pages
|
||||
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||
* cmake: cmake related files
|
||||
|
||||
see LICENSE for license and copyright information.
|
||||
see INSTALL for installation procedures.
|
||||
see NEWS for user visible changes in successive releases.
|
||||
see CHANGES for per-revision changes.
|
||||
|
||||
----------------
|
||||
API/ABI
|
||||
|
||||
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
||||
only exposes a limited subset of its functions. It uses a mecanism of
|
||||
exporting/hiding functions. If you are unsure which functions you can use in
|
||||
your applications, you should compile OpenJPEG using something similar to gcc:
|
||||
-fvisibility=hidden compilation flag.
|
||||
See also: http://gcc.gnu.org/wiki/Visibility
|
||||
|
||||
On windows, MSVC directly supports export/hidding function and as such the only
|
||||
API available is the one supported by OpenJPEG.
|
||||
79
README.md
Normal file
79
README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
# OPENJPEG Library and Applications
|
||||
|
||||
## What is OpenJPEG ?
|
||||
|
||||
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
|
||||
|
||||
## Who can use the code ?
|
||||
[![badge-license]][link-license]
|
||||
|
||||
Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
|
||||
|
||||
## How to install and use OpenJPEG ?
|
||||
API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec).
|
||||
|
||||
## Current Status
|
||||
[![badge-build]][link-build]
|
||||
|
||||
[![badge-msvc-build]][link-msvc-build]
|
||||
|
||||
[![badge-coverity]][link-coverity]
|
||||
|
||||
## Who are the developers ?
|
||||
|
||||
The library is developed and maintained by the Image and Signal Processing Group ([ISPGroup](http://sites.uclouvain.be/ispgroup/)), in the Université catholique de Louvain ([UCL](http://www.uclouvain.be/en-index.html), with the support of the [CNES](https://cnes.fr/), the [CS](http://www.c-s.fr/) company and the [intoPIX](http://www.intopix.com) company. The JPWL module has been developed by the Digital Signal Processing Lab ([DSPLab](http://dsplab.diei.unipg.it/)) of the University of Perugia, Italy ([UNIPG](http://www.unipg.it/)).
|
||||
|
||||
## Details on folders hierarchy
|
||||
|
||||
* src
|
||||
* lib
|
||||
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
|
||||
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||
* openjp3d: JP3D implementation
|
||||
* openmj2: MJ2 implementation
|
||||
* bin: contains all applications that use the openjpeg library
|
||||
* common: common files to all applications
|
||||
* jp2: a basic codec
|
||||
* mj2: motion jpeg 2000 executables
|
||||
* jpip: OpenJPIP applications (server and dec server)
|
||||
* java: a Java client viewer for JPIP
|
||||
* jp3d: JP3D applications
|
||||
* tcltk: a test tool for JP3D
|
||||
* wx
|
||||
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||
* wrapping
|
||||
* java: java jni to use openjpeg in a java program
|
||||
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||
* doc: doxygen documentation setup file and man pages
|
||||
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in [openjpeg-data](https://github.com/uclouvain/openjpeg-data) repository.
|
||||
* cmake: cmake related files
|
||||
|
||||
See [LICENSE][link-license] for license and copyright information.
|
||||
|
||||
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL) for installation procedures.
|
||||
|
||||
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS) for user visible changes in successive releases.
|
||||
|
||||
## API/ABI
|
||||
|
||||
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
||||
only exposes a limited subset of its functions. It uses a mechanism of
|
||||
exporting/hiding functions. If you are unsure which functions you can use in
|
||||
your applications, you should compile OpenJPEG using something similar to gcc:
|
||||
`-fvisibility=hidden` compilation flag.
|
||||
See also: http://gcc.gnu.org/wiki/Visibility
|
||||
|
||||
On windows, MSVC directly supports export/hiding function and as such the only
|
||||
API available is the one supported by OpenJPEG.
|
||||
|
||||
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
|
||||
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause "Simplified" License"
|
||||
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause "Simplified" License"
|
||||
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=master "Build Status"
|
||||
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
|
||||
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
|
||||
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
|
||||
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
|
||||
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
|
||||
50
THANKS
50
THANKS
@@ -4,30 +4,32 @@ Many people have contributed to OpenJPEG by reporting problems, suggesting vario
|
||||
or submitting actual code. Here is a list of these people. Help me keep
|
||||
it complete and exempt of errors.
|
||||
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Bob Friesenhahn
|
||||
Callum Lerwick
|
||||
Dzonatas Sol
|
||||
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
|
||||
Giuseppe Baruffa
|
||||
Ben Boeckel
|
||||
Aaron Boxer
|
||||
David Burken
|
||||
Matthieu Darbois
|
||||
Rex Dieter
|
||||
Herve Drolon
|
||||
Antonin Descampe
|
||||
Francois-Olivier Devaux
|
||||
Parvatha Elangovan
|
||||
Jerôme Fimes
|
||||
Bob Friesenhahn
|
||||
Kaori Hagihara
|
||||
Luc Hermitte
|
||||
Luis Ibanez
|
||||
David Janssens
|
||||
Hans Johnson
|
||||
Callum Lerwick
|
||||
Sebastien Lugan
|
||||
Benoit Macq
|
||||
Arnaud Maye
|
||||
Julien Malik
|
||||
Vincent Nicolas
|
||||
Glenn Pearson
|
||||
Giuseppe Baruffa
|
||||
Arnaud Maye
|
||||
Rex Dieter
|
||||
David Burken
|
||||
Parvatha Elangovan
|
||||
Hans Johnson
|
||||
Luc Hermitte
|
||||
Dzonatas Sol
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Yannick Verschueren
|
||||
Peter Wimmer
|
||||
|
||||
23
appveyor.yml
Normal file
23
appveyor.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: 2.1.1.{build}
|
||||
branches:
|
||||
except:
|
||||
- coverity_scan
|
||||
skip_tags: true
|
||||
clone_depth: 50
|
||||
environment:
|
||||
matrix:
|
||||
- OPJ_CI_ARCH: x86
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||
- OPJ_CI_ARCH: x64
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||
- OPJ_CI_ARCH: x86
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS100COMNTOOLS)
|
||||
install:
|
||||
- cmd: c:\cygwin\bin\bash ./tools/travis-ci/install.sh
|
||||
build_script:
|
||||
- cmd: >-
|
||||
"%OPJ_CI_VSCOMNTOOLS%..\..\VC\vcvarsall.bat" %OPJ_CI_ARCH%
|
||||
|
||||
bash ./tools/travis-ci/run.sh
|
||||
test: off
|
||||
deploy: off
|
||||
@@ -30,7 +30,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
# java also warns about deprecated API
|
||||
".*java.*deprecation"
|
||||
".*deprecation.*"
|
||||
# supress warnings caused by 3rd party libs:
|
||||
# suppress warnings caused by 3rd party libs:
|
||||
".*thirdparty.*"
|
||||
"libtiff.*has no symbols"
|
||||
"libpng.*has no symbols"
|
||||
|
||||
12
cmake/FindJPYLYZER.cmake
Normal file
12
cmake/FindJPYLYZER.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# this module looks for JPYLYZER
|
||||
# http://jpylyzer.openpreservation.org
|
||||
#
|
||||
|
||||
find_program(JPYLYZER_EXECUTABLE
|
||||
jpylyzer
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
JPYLYZER_EXECUTABLE
|
||||
)
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Cause a compile-time error if off_t is smaller than 64 bits */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Cause a compile-time error if off_t is smaller than 64 bits */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#
|
||||
|
||||
macro(OPJ_TEST_LARGE_FILES VARIABLE)
|
||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
||||
if(NOT DEFINED ${VARIABLE})
|
||||
|
||||
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
|
||||
# and then separately fseeko. However, in the future we might have 128-bit filesystems
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
__int64 off=0;
|
||||
__int64 off=0;
|
||||
|
||||
_fseeki64(NULL, off, SEEK_SET);
|
||||
_fseeki64(NULL, off, SEEK_SET);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -36,21 +36,21 @@
|
||||
*
|
||||
* \section home Home page
|
||||
*
|
||||
* The Home Page of the OpenJPEG library can be found at:
|
||||
*
|
||||
* http://code.google.com/p/openjpeg/
|
||||
*
|
||||
* More information about the OpenJPEG library is available here:
|
||||
* The Home Page of the OpenJPEG project can be found at:
|
||||
*
|
||||
* http://www.openjpeg.org/
|
||||
*
|
||||
* The source code repository is available here:
|
||||
*
|
||||
* http://github.com/uclouvain/openjpeg
|
||||
*
|
||||
* The OpenJPEG mailing list is located here:
|
||||
*
|
||||
* http://groups.google.com/group/openjpeg
|
||||
*
|
||||
* All the source code is online and can be retrieved using svn from here:
|
||||
* The test files repository is available here:
|
||||
*
|
||||
* http://openjpeg.googlecode.com/svn/
|
||||
* http://github.com/uclouvain/openjpeg-data
|
||||
*
|
||||
* \section license License
|
||||
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH opj_compress 1 "Version 1.4.0" "opj_compress" "converts to jpeg2000 files"
|
||||
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_compress -
|
||||
@@ -203,9 +203,9 @@ Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||
.B opj_compress -i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||
.P
|
||||
.SH AUTHORS
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
.br
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
.br
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
.br
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH opj_decompress 1 "Version 1.4.0" "opj_decompress" "converts jpeg2000 files"
|
||||
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_decompress -
|
||||
@@ -73,9 +73,19 @@ n is the maximum number of quality layers to decode. See LAYERS below)
|
||||
.B \-\^OutFor "ext"
|
||||
(extension for output files)
|
||||
.P
|
||||
.SH JPIP OPTIONS
|
||||
Options usable only if the library has been compiled with
|
||||
.B BUILD_JPIP
|
||||
.TP
|
||||
.B -jpip
|
||||
Embed index table box into the output JP2 file (compulsory for JPIP)
|
||||
.TP
|
||||
.B -TP R
|
||||
Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream)
|
||||
.P
|
||||
.SH JPWL OPTIONS
|
||||
Options usable only if the library has been compiled with
|
||||
.B -DUSE_JPWL
|
||||
.B BUILD_JPWL
|
||||
.TP
|
||||
.B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3)
|
||||
.TP
|
||||
@@ -91,9 +101,9 @@ Set the maximum number of quality layers to decode. If there are less quality la
|
||||
.P
|
||||
'\".SH BUGS
|
||||
.SH AUTHORS
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
.br
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
.br
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
.br
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH opj_dump 1 "Version 1.4.0" "opj_dump" "dumps jpeg2000 files"
|
||||
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_dump -
|
||||
|
||||
@@ -313,9 +313,9 @@ typedef struct opj_cparameters
|
||||
'\".SH OPTIONS
|
||||
'\".SH BUGS
|
||||
.SH AUTHORS
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -64,7 +64,7 @@
|
||||
*
|
||||
*
|
||||
* \section sysarchtect System Architecture
|
||||
* JPIP protocol is implimented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n
|
||||
* JPIP protocol is implemented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n
|
||||
* Figure below represents the overview of our system architecture.\n
|
||||
* The JPIP server parses JPIP query and sends corresponding JPT/JPP-stream.
|
||||
* The JPIP client viewer is an image viewer with GUI to publish JPIP requests and receive JPT/JPP-stream.\n
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -34,5 +40,8 @@
|
||||
|
||||
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||
extern void color_apply_icc_profile(opj_image_t *image);
|
||||
extern void color_cielab_to_rgb(opj_image_t *image);
|
||||
|
||||
extern void color_cmyk_to_rgb(opj_image_t *image);
|
||||
extern void color_esycc_to_rgb(opj_image_t *image);
|
||||
#endif /* _OPJ_COLOR_H_ */
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "opj_config_private.h"
|
||||
|
||||
/* create opj_apps_config.h for CMake */
|
||||
|
||||
#cmakedefine OPJ_HAVE_LIBPNG @HAVE_LIBPNG@
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 3-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
@@ -39,212 +44,213 @@ static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#include "opj_getopt.h"
|
||||
|
||||
int opj_opterr = 1, /* if error message should be printed */
|
||||
opj_optind = 1, /* index into parent argv vector */
|
||||
opj_optopt, /* character checked for validity */
|
||||
opj_optreset; /* reset getopt */
|
||||
char *opj_optarg; /* argument associated with option */
|
||||
opj_optind = 1, /* index into parent argv vector */
|
||||
opj_optopt, /* character checked for validity */
|
||||
opj_optreset; /* reset getopt */
|
||||
char *opj_optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
static char EMSG[]={""};
|
||||
static char EMSG[]= {""};
|
||||
|
||||
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||
void reset_options_reading(void) {
|
||||
opj_opterr = 1;
|
||||
opj_optind = 1;
|
||||
void opj_reset_options_reading(void)
|
||||
{
|
||||
opj_opterr = 1;
|
||||
opj_optind = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
int opj_getopt(int nargc, char *const *nargv, const char *ostr)
|
||||
{
|
||||
# define __progname nargv[0]
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli = NULL; /* option letter list index */
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
const char *oli = NULL; /* option letter list index */
|
||||
|
||||
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||
opj_optreset = 0;
|
||||
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||
opj_optreset = 0;
|
||||
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++opj_optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
||||
!(oli = strchr(ostr, opj_optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (opj_optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
if (opj_opterr && *ostr != ':') {
|
||||
fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++opj_optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
opj_optarg = NULL;
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
opj_optarg = place;
|
||||
else if (nargc <= ++opj_optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
} else /* white space */
|
||||
opj_optarg = nargv[opj_optind];
|
||||
place = EMSG;
|
||||
++opj_optind;
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
||||
!(oli = strchr(ostr, opj_optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (opj_optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
if (opj_opterr && *ostr != ':') {
|
||||
fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
opj_optarg = NULL;
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
opj_optarg = place;
|
||||
else if (nargc <= ++opj_optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
} else /* white space */
|
||||
opj_optarg = nargv[opj_optind];
|
||||
place = EMSG;
|
||||
++opj_optind;
|
||||
}
|
||||
return (opj_optopt); /* dump back option letter */
|
||||
return (opj_optopt); /* dump back option letter */
|
||||
}
|
||||
|
||||
|
||||
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||
const opj_option_t *longopts, int totlen) {
|
||||
static int lastidx,lastofs;
|
||||
char *tmp;
|
||||
int i,len;
|
||||
char param = 1;
|
||||
const opj_option_t *longopts, int totlen)
|
||||
{
|
||||
static int lastidx,lastofs;
|
||||
const char *tmp;
|
||||
int i,len;
|
||||
char param = 1;
|
||||
|
||||
again:
|
||||
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
||||
return -1;
|
||||
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
||||
return -1;
|
||||
|
||||
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
||||
if(opj_optind >= (argc - 1)){ /* no more input parameters */
|
||||
param = 0;
|
||||
}
|
||||
else{ /* more input parameters */
|
||||
if(argv[opj_optind + 1][0] == '-'){
|
||||
param = 0; /* Missing parameter after '-' */
|
||||
}
|
||||
else{
|
||||
param = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
||||
if(opj_optind >= (argc - 1)) { /* no more input parameters */
|
||||
param = 0;
|
||||
} else { /* more input parameters */
|
||||
if(argv[opj_optind + 1][0] == '-') {
|
||||
param = 0; /* Missing parameter after '-' */
|
||||
} else {
|
||||
param = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (param == 0) {
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}
|
||||
if (param == 0) {
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}
|
||||
|
||||
if (argv[opj_optind][0]=='-') { /* long option */
|
||||
char* arg=argv[opj_optind]+1;
|
||||
const opj_option_t* o;
|
||||
o=longopts;
|
||||
len=sizeof(longopts[0]);
|
||||
if (argv[opj_optind][0]=='-') { /* long option */
|
||||
char* arg=argv[opj_optind]+1;
|
||||
const opj_option_t* o;
|
||||
o=longopts;
|
||||
len=sizeof(longopts[0]);
|
||||
|
||||
if (param > 1){
|
||||
arg = argv[opj_optind+1];
|
||||
opj_optind++;
|
||||
}
|
||||
else
|
||||
arg = argv[opj_optind]+1;
|
||||
if (param > 1) {
|
||||
arg = argv[opj_optind+1];
|
||||
opj_optind++;
|
||||
} else
|
||||
arg = argv[opj_optind]+1;
|
||||
|
||||
if(strlen(arg)>1){
|
||||
for (i=0;i<totlen;i=i+len,o++) {
|
||||
if (!strcmp(o->name,arg)) { /* match */
|
||||
if (o->has_arg == 0) {
|
||||
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))){
|
||||
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
||||
++opj_optind;
|
||||
}
|
||||
}else{
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg){
|
||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
}
|
||||
++opj_optind;
|
||||
if (o->flag)
|
||||
*(o->flag)=o->val;
|
||||
else
|
||||
return o->val;
|
||||
return 0;
|
||||
}
|
||||
}/*(end for)String not found in the list*/
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}else{ /*Single character input parameter*/
|
||||
if (*optstring==':') return ':';
|
||||
if (lastidx!=opj_optind) {
|
||||
lastidx=opj_optind; lastofs=0;
|
||||
}
|
||||
opj_optopt=argv[opj_optind][lastofs+1];
|
||||
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
||||
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||
++opj_optind;
|
||||
goto again;
|
||||
}
|
||||
if (tmp[1]==':') { /* argument expected */
|
||||
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
||||
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
||||
goto found;
|
||||
}
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg){
|
||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg) { /* missing argument */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
}else {/*Argument not expected*/
|
||||
++lastofs;
|
||||
return opj_optopt;
|
||||
}
|
||||
if(strlen(arg)>1) {
|
||||
for (i=0; i<totlen; i=i+len,o++) {
|
||||
if (!strcmp(o->name,arg)) { /* match */
|
||||
if (o->has_arg == 0) {
|
||||
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))) {
|
||||
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
||||
++opj_optind;
|
||||
}
|
||||
} else {
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg) {
|
||||
if (opj_optarg[0] == '-') { /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
}
|
||||
++opj_optind;
|
||||
if (o->flag)
|
||||
*(o->flag)=o->val;
|
||||
else
|
||||
return o->val;
|
||||
return 0;
|
||||
}
|
||||
}/*(end for)String not found in the list*/
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
} else { /*Single character input parameter*/
|
||||
if (*optstring==':') return ':';
|
||||
if (lastidx!=opj_optind) {
|
||||
lastidx=opj_optind;
|
||||
lastofs=0;
|
||||
}
|
||||
opj_optopt=argv[opj_optind][lastofs+1];
|
||||
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
||||
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||
++opj_optind;
|
||||
goto again;
|
||||
}
|
||||
if (tmp[1]==':') { /* argument expected */
|
||||
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
||||
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
||||
goto found;
|
||||
}
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg) {
|
||||
if (opj_optarg[0] == '-') { /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg) { /* missing argument */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
} else {/*Argument not expected*/
|
||||
++lastofs;
|
||||
return opj_optopt;
|
||||
}
|
||||
found:
|
||||
++opj_optind;
|
||||
return opj_optopt;
|
||||
} else { /* not found */
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}/*end of not found*/
|
||||
++opj_optind;
|
||||
return opj_optopt;
|
||||
} else { /* not found */
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}/*end of not found*/
|
||||
|
||||
}/* end of single character*/
|
||||
}/*end '-'*/
|
||||
fprintf(stderr,"Invalid option\n");
|
||||
++opj_optind;
|
||||
return (BADCH);;
|
||||
}/* end of single character*/
|
||||
}/*end '-'*/
|
||||
fprintf(stderr,"Invalid option\n");
|
||||
++opj_optind;
|
||||
return (BADCH);;
|
||||
}/*end function*/
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
#ifndef _GETOPT_H_
|
||||
#define _GETOPT_H_
|
||||
|
||||
typedef struct opj_option
|
||||
{
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
}opj_option_t;
|
||||
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
|
||||
@@ -23,7 +22,7 @@ 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);
|
||||
const opj_option_t *longopts, int totlen);
|
||||
extern void opj_reset_options_reading(void);
|
||||
|
||||
#endif /* _GETOPT_H_ */
|
||||
|
||||
72
src/bin/common/opj_string.h
Normal file
72
src/bin/common/opj_string.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef OPJ_STRING_H
|
||||
#define OPJ_STRING_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
/* strnlen is not standard, strlen_s is C11... */
|
||||
/* keep in mind there still is a buffer read overflow possible */
|
||||
static size_t opj_strnlen_s(const char *src, size_t max_len)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (src == NULL) {
|
||||
return 0U;
|
||||
}
|
||||
for (len = 0U; (*src != '\0') && (len < max_len); src++, len++);
|
||||
return len;
|
||||
}
|
||||
|
||||
/* should be equivalent to C11 function except for the handler */
|
||||
/* keep in mind there still is a buffer read overflow possible */
|
||||
static int opj_strcpy_s(char* dst, size_t dst_size, const char* src)
|
||||
{
|
||||
size_t src_len = 0U;
|
||||
if ((dst == NULL) || (dst_size == 0U)) {
|
||||
return EINVAL;
|
||||
}
|
||||
if (src == NULL) {
|
||||
dst[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
src_len = opj_strnlen_s(src, dst_size);
|
||||
if (src_len >= dst_size) {
|
||||
return ERANGE;
|
||||
}
|
||||
memcpy(dst, src, src_len);
|
||||
dst[src_len] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* OPJ_STRING_H */
|
||||
@@ -3,11 +3,24 @@
|
||||
# First thing define the common source:
|
||||
set(common_SRCS
|
||||
convert.c
|
||||
convert.h
|
||||
convertbmp.c
|
||||
index.c
|
||||
index.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
|
||||
)
|
||||
|
||||
if(OPJ_HAVE_LIBTIFF)
|
||||
list(APPEND common_SRCS converttif.c)
|
||||
endif()
|
||||
if(OPJ_HAVE_LIBPNG)
|
||||
list(APPEND common_SRCS convertpng.c)
|
||||
endif()
|
||||
|
||||
# Headers file are located here:
|
||||
include_directories(
|
||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||
@@ -50,8 +63,15 @@ foreach(exe opj_decompress opj_compress opj_dump)
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
if(OPJ_USE_DSYMUTIL)
|
||||
add_custom_command(TARGET ${exe} POST_BUILD
|
||||
COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
|
||||
COMMENT "dsymutil $<TARGET_FILE:${exe}>"
|
||||
DEPENDS ${exe})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(BUILD_DOC)
|
||||
# Install man pages
|
||||
install(
|
||||
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
|
||||
@@ -59,3 +79,4 @@ install(
|
||||
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
|
||||
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||
#
|
||||
endif()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -31,22 +37,51 @@
|
||||
#ifndef __J2K_CONVERT_H
|
||||
#define __J2K_CONVERT_H
|
||||
|
||||
/**@name RAW component encoding parameters */
|
||||
/*@{*/
|
||||
typedef struct raw_comp_cparameters {
|
||||
/** subsampling in X direction */
|
||||
int dx;
|
||||
/** subsampling in Y direction */
|
||||
int dy;
|
||||
/*@}*/
|
||||
} raw_comp_cparameters_t;
|
||||
|
||||
/**@name RAW image encoding parameters */
|
||||
/*@{*/
|
||||
typedef struct raw_cparameters {
|
||||
/** width of the raw image */
|
||||
int rawWidth;
|
||||
/** height of the raw image */
|
||||
int rawHeight;
|
||||
/** components of the raw image */
|
||||
int rawComp;
|
||||
/** bit depth of the raw image */
|
||||
int rawBitDepth;
|
||||
/** signed/unsigned raw image */
|
||||
OPJ_BOOL rawSigned;
|
||||
/*@}*/
|
||||
/** width of the raw image */
|
||||
int rawWidth;
|
||||
/** height of the raw image */
|
||||
int rawHeight;
|
||||
/** number of components of the raw image */
|
||||
int rawComp;
|
||||
/** bit depth of the raw image */
|
||||
int rawBitDepth;
|
||||
/** signed/unsigned raw image */
|
||||
OPJ_BOOL rawSigned;
|
||||
/** raw components parameters */
|
||||
raw_comp_cparameters_t *rawComps;
|
||||
/*@}*/
|
||||
} raw_cparameters_t;
|
||||
|
||||
/* Component precision clipping */
|
||||
void clip_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||
/* Component precision scaling */
|
||||
void scale_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||
|
||||
/* planar / interleaved conversions */
|
||||
typedef void (* convert_32s_CXPX)(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length);
|
||||
extern const convert_32s_CXPX convert_32s_CXPX_LUT[5];
|
||||
typedef void (* convert_32s_PXCX)(OPJ_INT32 const* const* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length, OPJ_INT32 adjust);
|
||||
extern const convert_32s_PXCX convert_32s_PXCX_LUT[5];
|
||||
/* bit depth conversions */
|
||||
typedef void (* convert_XXx32s_C1R)(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length);
|
||||
extern const convert_XXx32s_C1R convert_XXu32s_C1R_LUT[9]; /* up to 8bpp */
|
||||
typedef void (* convert_32sXXx_C1R)(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length);
|
||||
extern const convert_32sXXx_C1R convert_32sXXu_C1R_LUT[9]; /* up to 8bpp */
|
||||
|
||||
|
||||
/* TGA conversion */
|
||||
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
int imagetotga(opj_image_t * image, const char *outfile);
|
||||
@@ -68,7 +103,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
int imagetopgx(opj_image_t *image, const char *outfile);
|
||||
|
||||
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
int imagetopnm(opj_image_t *image, const char *outfile);
|
||||
int imagetopnm(opj_image_t *image, const char *outfile, int force_split);
|
||||
|
||||
/* RAW conversion */
|
||||
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||
|
||||
958
src/bin/jp2/convertbmp.c
Normal file
958
src/bin/jp2/convertbmp.c
Normal file
@@ -0,0 +1,958 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_apps_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
typedef struct {
|
||||
OPJ_UINT16 bfType; /* 'BM' for Bitmap (19776) */
|
||||
OPJ_UINT32 bfSize; /* Size of the file */
|
||||
OPJ_UINT16 bfReserved1; /* Reserved : 0 */
|
||||
OPJ_UINT16 bfReserved2; /* Reserved : 0 */
|
||||
OPJ_UINT32 bfOffBits; /* Offset */
|
||||
} OPJ_BITMAPFILEHEADER;
|
||||
|
||||
typedef struct {
|
||||
OPJ_UINT32 biSize; /* Size of the structure in bytes */
|
||||
OPJ_UINT32 biWidth; /* Width of the image in pixels */
|
||||
OPJ_UINT32 biHeight; /* Heigth of the image in pixels */
|
||||
OPJ_UINT16 biPlanes; /* 1 */
|
||||
OPJ_UINT16 biBitCount; /* Number of color bits by pixels */
|
||||
OPJ_UINT32 biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
|
||||
OPJ_UINT32 biSizeImage; /* Size of the image in bytes */
|
||||
OPJ_UINT32 biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
|
||||
OPJ_UINT32 biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
|
||||
OPJ_UINT32 biClrUsed; /* Number of color used in the image (0: ALL) */
|
||||
OPJ_UINT32 biClrImportant; /* Number of important color (0: ALL) */
|
||||
OPJ_UINT32 biRedMask; /* Red channel bit mask */
|
||||
OPJ_UINT32 biGreenMask; /* Green channel bit mask */
|
||||
OPJ_UINT32 biBlueMask; /* Blue channel bit mask */
|
||||
OPJ_UINT32 biAlphaMask; /* Alpha channel bit mask */
|
||||
OPJ_UINT32 biColorSpaceType; /* Color space type */
|
||||
OPJ_UINT8 biColorSpaceEP[36]; /* Color space end points */
|
||||
OPJ_UINT32 biRedGamma; /* Red channel gamma */
|
||||
OPJ_UINT32 biGreenGamma; /* Green channel gamma */
|
||||
OPJ_UINT32 biBlueGamma; /* Blue channel gamma */
|
||||
OPJ_UINT32 biIntent; /* Intent */
|
||||
OPJ_UINT32 biIccProfileData; /* ICC profile data */
|
||||
OPJ_UINT32 biIccProfileSize; /* ICC profile size */
|
||||
OPJ_UINT32 biReserved; /* Reserved */
|
||||
} OPJ_BITMAPINFOHEADER;
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1R(
|
||||
OPJ_UINT8 const* pSrc, OPJ_INT32 srcStride,
|
||||
OPJ_INT32* pDst, OPJ_INT32 dstStride,
|
||||
OPJ_UINT8 const* pLUT,
|
||||
OPJ_UINT32 width, OPJ_UINT32 height)
|
||||
{
|
||||
OPJ_UINT32 y;
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
OPJ_UINT32 x;
|
||||
|
||||
for(x = 0; x < width; x++) {
|
||||
pDst[x] = (OPJ_INT32)pLUT[pSrc[x]];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pDst += dstStride;
|
||||
}
|
||||
}
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1P3R(
|
||||
OPJ_UINT8 const* pSrc, OPJ_INT32 srcStride,
|
||||
OPJ_INT32* const* pDst, OPJ_INT32 const* pDstStride,
|
||||
OPJ_UINT8 const* const* pLUT,
|
||||
OPJ_UINT32 width, OPJ_UINT32 height)
|
||||
{
|
||||
OPJ_UINT32 y;
|
||||
OPJ_INT32* pR = pDst[0];
|
||||
OPJ_INT32* pG = pDst[1];
|
||||
OPJ_INT32* pB = pDst[2];
|
||||
OPJ_UINT8 const* pLUT_R = pLUT[0];
|
||||
OPJ_UINT8 const* pLUT_G = pLUT[1];
|
||||
OPJ_UINT8 const* pLUT_B = pLUT[2];
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
OPJ_UINT32 x;
|
||||
|
||||
for(x = 0; x < width; x++) {
|
||||
OPJ_UINT8 idx = pSrc[x];
|
||||
pR[x] = (OPJ_INT32)pLUT_R[idx];
|
||||
pG[x] = (OPJ_INT32)pLUT_G[idx];
|
||||
pB[x] = (OPJ_INT32)pLUT_B[idx];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pR += pDstStride[0];
|
||||
pG += pDstStride[1];
|
||||
pB += pDstStride[2];
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp24toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image)
|
||||
{
|
||||
int index;
|
||||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++) {
|
||||
for(x = 0; x < width; x++) {
|
||||
image->comps[0].data[index] = (OPJ_INT32)pSrc[3*x+2]; /* R */
|
||||
image->comps[1].data[index] = (OPJ_INT32)pSrc[3*x+1]; /* G */
|
||||
image->comps[2].data[index] = (OPJ_INT32)pSrc[3*x+0]; /* B */
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp_mask_get_shift_and_prec(OPJ_UINT32 mask, OPJ_UINT32* shift, OPJ_UINT32* prec)
|
||||
{
|
||||
OPJ_UINT32 l_shift, l_prec;
|
||||
|
||||
l_shift = l_prec = 0U;
|
||||
|
||||
if (mask != 0U) {
|
||||
while ((mask & 1U) == 0U) {
|
||||
mask >>= 1;
|
||||
l_shift++;
|
||||
}
|
||||
while (mask & 1U) {
|
||||
mask >>= 1;
|
||||
l_prec++;
|
||||
}
|
||||
}
|
||||
*shift = l_shift;
|
||||
*prec = l_prec;
|
||||
}
|
||||
|
||||
static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT32 redMask, OPJ_UINT32 greenMask, OPJ_UINT32 blueMask, OPJ_UINT32 alphaMask)
|
||||
{
|
||||
int index;
|
||||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
OPJ_UINT32 alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++) {
|
||||
for(x = 0; x < width; x++) {
|
||||
OPJ_UINT32 value = 0U;
|
||||
|
||||
value |= ((OPJ_UINT32)pSrc[4*x+0]) << 0;
|
||||
value |= ((OPJ_UINT32)pSrc[4*x+1]) << 8;
|
||||
value |= ((OPJ_UINT32)pSrc[4*x+2]) << 16;
|
||||
value |= ((OPJ_UINT32)pSrc[4*x+3]) << 24;
|
||||
|
||||
image->comps[0].data[index] = (OPJ_INT32)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (OPJ_INT32)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (OPJ_INT32)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (OPJ_INT32)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmpmask16toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT32 redMask, OPJ_UINT32 greenMask, OPJ_UINT32 blueMask, OPJ_UINT32 alphaMask)
|
||||
{
|
||||
int index;
|
||||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
OPJ_UINT32 alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++) {
|
||||
for(x = 0; x < width; x++) {
|
||||
OPJ_UINT32 value = 0U;
|
||||
|
||||
value |= ((OPJ_UINT32)pSrc[2*x+0]) << 0;
|
||||
value |= ((OPJ_UINT32)pSrc[2*x+1]) << 8;
|
||||
|
||||
image->comps[0].data[index] = (OPJ_INT32)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (OPJ_INT32)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (OPJ_INT32)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (OPJ_INT32)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static opj_image_t* bmp8toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT8 const* const* pLUT)
|
||||
{
|
||||
OPJ_UINT32 width, height;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
if (image->numcomps == 1U) {
|
||||
opj_applyLUT8u_8u32s_C1R(pSrc, -(OPJ_INT32)stride, image->comps[0].data, (OPJ_INT32)width, pLUT[0], width, height);
|
||||
} else {
|
||||
OPJ_INT32* pDst[3];
|
||||
OPJ_INT32 pDstStride[3];
|
||||
|
||||
pDst[0] = image->comps[0].data;
|
||||
pDst[1] = image->comps[1].data;
|
||||
pDst[2] = image->comps[2].data;
|
||||
pDstStride[0] = (OPJ_INT32)width;
|
||||
pDstStride[1] = (OPJ_INT32)width;
|
||||
pDstStride[2] = (OPJ_INT32)width;
|
||||
opj_applyLUT8u_8u32s_C1P3R(pSrc, -(OPJ_INT32)stride, pDst, pDstStride, pLUT, width, height);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static OPJ_BOOL bmp_read_file_header(FILE* IN, OPJ_BITMAPFILEHEADER* header)
|
||||
{
|
||||
header->bfType = (OPJ_UINT16)getc(IN);
|
||||
header->bfType |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||
|
||||
if (header->bfType != 19778) {
|
||||
fprintf(stderr,"Error, not a BMP file!\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
header->bfSize = (OPJ_UINT32)getc(IN);
|
||||
header->bfSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->bfSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->bfSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->bfReserved1 = (OPJ_UINT16)getc(IN);
|
||||
header->bfReserved1 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||
|
||||
header->bfReserved2 = (OPJ_UINT16)getc(IN);
|
||||
header->bfReserved2 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||
|
||||
header->bfOffBits = (OPJ_UINT32)getc(IN);
|
||||
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 24;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
|
||||
{
|
||||
memset(header, 0, sizeof(*header));
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
header->biSize = (OPJ_UINT32)getc(IN);
|
||||
header->biSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
switch (header->biSize) {
|
||||
case 12U: /* BITMAPCOREHEADER */
|
||||
case 40U: /* BITMAPINFOHEADER */
|
||||
case 52U: /* BITMAPV2INFOHEADER */
|
||||
case 56U: /* BITMAPV3INFOHEADER */
|
||||
case 108U: /* BITMAPV4HEADER */
|
||||
case 124U: /* BITMAPV5HEADER */
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biWidth = (OPJ_UINT32)getc(IN);
|
||||
header->biWidth |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biWidth |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biWidth |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biHeight = (OPJ_UINT32)getc(IN);
|
||||
header->biHeight |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biHeight |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biHeight |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biPlanes = (OPJ_UINT16)getc(IN);
|
||||
header->biPlanes |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||
|
||||
header->biBitCount = (OPJ_UINT16)getc(IN);
|
||||
header->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||
|
||||
if(header->biSize >= 40U) {
|
||||
header->biCompression = (OPJ_UINT32)getc(IN);
|
||||
header->biCompression |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biCompression |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biCompression |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biSizeImage = (OPJ_UINT32)getc(IN);
|
||||
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biXpelsPerMeter = (OPJ_UINT32)getc(IN);
|
||||
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biYpelsPerMeter = (OPJ_UINT32)getc(IN);
|
||||
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biClrUsed = (OPJ_UINT32)getc(IN);
|
||||
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biClrImportant = (OPJ_UINT32)getc(IN);
|
||||
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 56U) {
|
||||
header->biRedMask = (OPJ_UINT32)getc(IN);
|
||||
header->biRedMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biRedMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biRedMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biGreenMask = (OPJ_UINT32)getc(IN);
|
||||
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biBlueMask = (OPJ_UINT32)getc(IN);
|
||||
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biAlphaMask = (OPJ_UINT32)getc(IN);
|
||||
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 108U) {
|
||||
header->biColorSpaceType = (OPJ_UINT32)getc(IN);
|
||||
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {
|
||||
fprintf(stderr,"Error, can't read BMP header\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biRedGamma = (OPJ_UINT32)getc(IN);
|
||||
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biGreenGamma = (OPJ_UINT32)getc(IN);
|
||||
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biBlueGamma = (OPJ_UINT32)getc(IN);
|
||||
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 124U) {
|
||||
header->biIntent = (OPJ_UINT32)getc(IN);
|
||||
header->biIntent |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biIntent |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biIntent |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileData = (OPJ_UINT32)getc(IN);
|
||||
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileSize = (OPJ_UINT32)getc(IN);
|
||||
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||
|
||||
header->biReserved = (OPJ_UINT32)getc(IN);
|
||||
header->biReserved |= (OPJ_UINT32)getc(IN) << 8;
|
||||
header->biReserved |= (OPJ_UINT32)getc(IN) << 16;
|
||||
header->biReserved |= (OPJ_UINT32)getc(IN) << 24;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL bmp_read_raw_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||
{
|
||||
OPJ_ARG_NOT_USED(width);
|
||||
|
||||
if ( fread(pData, sizeof(OPJ_UINT8), stride * height, IN) != (stride * height) ) {
|
||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL bmp_read_rle8_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||
{
|
||||
OPJ_UINT32 x, y;
|
||||
OPJ_UINT8 *pix;
|
||||
const OPJ_UINT8 *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
|
||||
x = y = 0U;
|
||||
while (y < height) {
|
||||
int c = getc(IN);
|
||||
|
||||
if (c) {
|
||||
int j;
|
||||
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||
*pix = c1;
|
||||
}
|
||||
} else {
|
||||
c = getc(IN);
|
||||
if (c == 0x00) { /* EOL */
|
||||
x = 0;
|
||||
++y;
|
||||
pix = pData + y * stride + x;
|
||||
} else if (c == 0x01) { /* EOP */
|
||||
break;
|
||||
} else if (c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN);
|
||||
x += (OPJ_UINT32)c;
|
||||
c = getc(IN);
|
||||
y += (OPJ_UINT32)c;
|
||||
pix = pData + y * stride + x;
|
||||
} else { /* 03 .. 255 */
|
||||
int j;
|
||||
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||
*pix = c1;
|
||||
}
|
||||
if ((OPJ_UINT32)c & 1U) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}/* while() */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||
{
|
||||
OPJ_UINT32 x, y;
|
||||
OPJ_UINT8 *pix;
|
||||
const OPJ_UINT8 *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
x = y = 0U;
|
||||
while(y < height) {
|
||||
int c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c) {/* encoded mode */
|
||||
int j;
|
||||
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||
*pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
} else { /* absolute mode */
|
||||
c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c == 0x00) { /* EOL */
|
||||
x = 0;
|
||||
y++;
|
||||
pix = pData + y * stride;
|
||||
} else if(c == 0x01) { /* EOP */
|
||||
break;
|
||||
} else if(c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN);
|
||||
x += (OPJ_UINT32)c;
|
||||
c = getc(IN);
|
||||
y += (OPJ_UINT32)c;
|
||||
pix = pData + y * stride + x;
|
||||
} else { /* 03 .. 255 : absolute mode */
|
||||
int j;
|
||||
OPJ_UINT8 c1 = 0U;
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||
if((j&1) == 0) {
|
||||
c1 = (OPJ_UINT8)getc(IN);
|
||||
}
|
||||
*pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* while(y < height) */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
||||
OPJ_UINT8 lut_R[256], lut_G[256], lut_B[256];
|
||||
OPJ_UINT8 const* pLUT[3];
|
||||
opj_image_t * image = NULL;
|
||||
FILE *IN;
|
||||
OPJ_BITMAPFILEHEADER File_h;
|
||||
OPJ_BITMAPINFOHEADER Info_h;
|
||||
OPJ_UINT32 i, palette_len, numcmpts = 1U;
|
||||
OPJ_BOOL l_result = OPJ_FALSE;
|
||||
OPJ_UINT8* pData = NULL;
|
||||
OPJ_UINT32 stride;
|
||||
|
||||
pLUT[0] = lut_R;
|
||||
pLUT[1] = lut_G;
|
||||
pLUT[2] = lut_B;
|
||||
|
||||
IN = fopen(filename, "rb");
|
||||
if (!IN) {
|
||||
fprintf(stderr, "Failed to open %s for reading !!\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!bmp_read_file_header(IN, &File_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
if (!bmp_read_info_header(IN, &Info_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Load palette */
|
||||
if (Info_h.biBitCount <= 8U) {
|
||||
memset(&lut_R[0], 0, sizeof(lut_R));
|
||||
memset(&lut_G[0], 0, sizeof(lut_G));
|
||||
memset(&lut_B[0], 0, sizeof(lut_B));
|
||||
|
||||
palette_len = Info_h.biClrUsed;
|
||||
if((palette_len == 0U) && (Info_h.biBitCount <= 8U)) {
|
||||
palette_len = (1U << Info_h.biBitCount);
|
||||
}
|
||||
if (palette_len > 256U) {
|
||||
palette_len = 256U;
|
||||
}
|
||||
if (palette_len > 0U) {
|
||||
OPJ_UINT8 has_color = 0U;
|
||||
for (i = 0U; i < palette_len; i++) {
|
||||
lut_B[i] = (OPJ_UINT8)getc(IN);
|
||||
lut_G[i] = (OPJ_UINT8)getc(IN);
|
||||
lut_R[i] = (OPJ_UINT8)getc(IN);
|
||||
(void)getc(IN); /* padding */
|
||||
has_color |= (lut_B[i] ^ lut_G[i]) | (lut_G[i] ^ lut_R[i]);
|
||||
}
|
||||
if(has_color) {
|
||||
numcmpts = 3U;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
numcmpts = 3U;
|
||||
if ((Info_h.biCompression == 3) && (Info_h.biAlphaMask != 0U)) {
|
||||
numcmpts++;
|
||||
}
|
||||
}
|
||||
|
||||
stride = ((Info_h.biWidth * Info_h.biBitCount + 31U) / 32U) * 4U; /* rows are aligned on 32bits */
|
||||
if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /* RLE 4 gets decoded as 8 bits data for now... */
|
||||
stride = ((Info_h.biWidth * 8U + 31U) / 32U) * 4U;
|
||||
}
|
||||
pData = (OPJ_UINT8 *) calloc(1, stride * Info_h.biHeight * sizeof(OPJ_UINT8));
|
||||
if (pData == NULL) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
/* Place the cursor at the beginning of the image information */
|
||||
fseek(IN, 0, SEEK_SET);
|
||||
fseek(IN, (long)File_h.bfOffBits, SEEK_SET);
|
||||
|
||||
switch (Info_h.biCompression) {
|
||||
case 0:
|
||||
case 3:
|
||||
/* read raw data */
|
||||
l_result = bmp_read_raw_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 1:
|
||||
/* read rle8 data */
|
||||
l_result = bmp_read_rle8_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 2:
|
||||
/* read rle4 data */
|
||||
l_result = bmp_read_rle4_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported BMP compression\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
if (!l_result) {
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create the image */
|
||||
memset(&cmptparm[0], 0, sizeof(cmptparm));
|
||||
for(i = 0; i < 4U; i++) {
|
||||
cmptparm[i].prec = 8;
|
||||
cmptparm[i].bpp = 8;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = (OPJ_UINT32)parameters->subsampling_dx;
|
||||
cmptparm[i].dy = (OPJ_UINT32)parameters->subsampling_dy;
|
||||
cmptparm[i].w = Info_h.biWidth;
|
||||
cmptparm[i].h = Info_h.biHeight;
|
||||
}
|
||||
|
||||
image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? OPJ_CLRSPC_GRAY : OPJ_CLRSPC_SRGB);
|
||||
if(!image) {
|
||||
fclose(IN);
|
||||
free(pData);
|
||||
return NULL;
|
||||
}
|
||||
if (numcmpts == 4U) {
|
||||
image->comps[3].alpha = 1;
|
||||
}
|
||||
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (OPJ_UINT32)parameters->image_offset_x0;
|
||||
image->y0 = (OPJ_UINT32)parameters->image_offset_y0;
|
||||
image->x1 = image->x0 + (Info_h.biWidth - 1U) * (OPJ_UINT32)parameters->subsampling_dx + 1U;
|
||||
image->y1 = image->y0 + (Info_h.biHeight - 1U) * (OPJ_UINT32)parameters->subsampling_dy + 1U;
|
||||
|
||||
/* Read the data */
|
||||
if (Info_h.biBitCount == 24 && Info_h.biCompression == 0) { /*RGB */
|
||||
bmp24toimage(pData, stride, image);
|
||||
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
} else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
|
||||
bmp8toimage(pData, stride, image, pLUT); /* RLE 4 gets decoded as 8 bits data for now */
|
||||
} else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask32toimage(pData, stride, image, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, 0x00000000U);
|
||||
} else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
|
||||
bmpmask32toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
} else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask16toimage(pData, stride, image, 0x7C00U, 0x03E0U, 0x001FU, 0x0000U);
|
||||
} else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
|
||||
if ((Info_h.biRedMask == 0U) && (Info_h.biGreenMask == 0U) && (Info_h.biBlueMask == 0U)) {
|
||||
Info_h.biRedMask = 0xF800U;
|
||||
Info_h.biGreenMask = 0x07E0U;
|
||||
Info_h.biBlueMask = 0x001FU;
|
||||
}
|
||||
bmpmask16toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
} else {
|
||||
opj_image_destroy(image);
|
||||
image = NULL;
|
||||
fprintf(stderr, "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
|
||||
}
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return image;
|
||||
}
|
||||
|
||||
int imagetobmp(opj_image_t * image, const char *outfile)
|
||||
{
|
||||
int w, h;
|
||||
int i, pad;
|
||||
FILE *fdest = NULL;
|
||||
int adjustR, adjustG, adjustB;
|
||||
|
||||
if (image->comps[0].prec < 8) {
|
||||
fprintf(stderr, "Unsupported number of components: %d\n", image->comps[0].prec);
|
||||
return 1;
|
||||
}
|
||||
if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
|
||||
&& image->comps[1].dx == image->comps[2].dx
|
||||
&& image->comps[0].dy == image->comps[1].dy
|
||||
&& image->comps[1].dy == image->comps[2].dy
|
||||
&& image->comps[0].prec == image->comps[1].prec
|
||||
&& image->comps[1].prec == image->comps[2].prec) {
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
24 bits color
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c",
|
||||
(OPJ_UINT8) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((w) & 0xff),
|
||||
(OPJ_UINT8) ((w) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((w) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((h) & 0xff),
|
||||
(OPJ_UINT8) ((h) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (3 * h * w + 3 * h * (w % 2)) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
} else
|
||||
adjustR = 0;
|
||||
if (image->comps[1].prec > 8) {
|
||||
adjustG = (int)image->comps[1].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
|
||||
} else
|
||||
adjustG = 0;
|
||||
if (image->comps[2].prec > 8) {
|
||||
adjustB = (int)image->comps[2].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
|
||||
} else
|
||||
adjustB = 0;
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
OPJ_UINT8 rc, gc, bc;
|
||||
int r, g, b;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255;
|
||||
else if(r < 0) r = 0;
|
||||
rc = (OPJ_UINT8)r;
|
||||
|
||||
g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||
g = ((g >> adjustG)+((g >> (adjustG-1))%2));
|
||||
if(g > 255) g = 255;
|
||||
else if(g < 0) g = 0;
|
||||
gc = (OPJ_UINT8)g;
|
||||
|
||||
b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
|
||||
b = ((b >> adjustB)+((b >> (adjustB-1))%2));
|
||||
if(b > 255) b = 255;
|
||||
else if(b < 0) b = 0;
|
||||
bc = (OPJ_UINT8)b;
|
||||
|
||||
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
} else { /* Gray-scale */
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
8 bits non code (Gray scale)
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff,
|
||||
((54 + 1024) >> 16) & 0xff,
|
||||
((54 + 1024) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((w) & 0xff),
|
||||
(OPJ_UINT8) ((w) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((w) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((h) & 0xff),
|
||||
(OPJ_UINT8) ((h) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (h * w + h * (w % 2)) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 8) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 16) & 0xff,
|
||||
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
} else
|
||||
adjustR = 0;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
fprintf(fdest, "%c%c%c%c", i, i, i, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
int r;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255;
|
||||
else if(r < 0) r = 0;
|
||||
|
||||
fprintf(fdest, "%c", (OPJ_UINT8)r);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
477
src/bin/jp2/convertpng.c
Normal file
477
src/bin/jp2/convertpng.c
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_apps_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||
#define MAGIC_SIZE 8
|
||||
/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
|
||||
|
||||
|
||||
static void convert_16u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < length; i++) {
|
||||
OPJ_INT32 val0 = *pSrc++;
|
||||
OPJ_INT32 val1 = *pSrc++;
|
||||
pDst[i] = val0 << 8 | val1;
|
||||
}
|
||||
}
|
||||
|
||||
opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||
{
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
double gamma;
|
||||
int bit_depth, interlace_type,compression_type, filter_type;
|
||||
OPJ_UINT32 i;
|
||||
png_uint_32 width, height = 0U;
|
||||
int color_type;
|
||||
FILE *reader = NULL;
|
||||
OPJ_BYTE** rows = NULL;
|
||||
OPJ_INT32* row32s = NULL;
|
||||
/* j2k: */
|
||||
opj_image_t *image = NULL;
|
||||
opj_image_cmptparm_t cmptparm[4];
|
||||
OPJ_UINT32 nr_comp;
|
||||
OPJ_BYTE sigbuf[8];
|
||||
convert_XXx32s_C1R cvtXXTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
OPJ_INT32* planes[4];
|
||||
|
||||
if((reader = fopen(read_idf, "rb")) == NULL) {
|
||||
fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|
||||
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0) {
|
||||
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
goto fin;
|
||||
if((info = png_create_info_struct(png)) == NULL)
|
||||
goto fin;
|
||||
|
||||
if(setjmp(png_jmpbuf(png)))
|
||||
goto fin;
|
||||
|
||||
png_init_io(png, reader);
|
||||
png_set_sig_bytes(png, MAGIC_SIZE);
|
||||
|
||||
png_read_info(png, info);
|
||||
|
||||
if(png_get_IHDR(png, info, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_type,
|
||||
&compression_type, &filter_type) == 0)
|
||||
goto fin;
|
||||
|
||||
/* png_set_expand():
|
||||
* expand paletted images to RGB, expand grayscale images of
|
||||
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||
* to alpha channels.
|
||||
*/
|
||||
if(color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
|
||||
if(png_get_valid(png, info, PNG_INFO_tRNS)) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
/* We might wan't to expand background */
|
||||
/*
|
||||
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
|
||||
png_color_16p bgnd;
|
||||
png_get_bKGD(png, info, &bgnd);
|
||||
png_set_background(png, bgnd, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
}
|
||||
*/
|
||||
|
||||
if( !png_get_gAMA(png, info, &gamma))
|
||||
gamma = 1.0;
|
||||
|
||||
/* we're not displaying but converting, screen gamma == 1.0 */
|
||||
png_set_gamma(png, 1.0, gamma);
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
color_type = png_get_color_type(png, info);
|
||||
|
||||
switch (color_type) {
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
nr_comp = 1;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
nr_comp = 2;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
nr_comp = 3;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
nr_comp = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: colortype %d is not supported\n", color_type);
|
||||
goto fin;
|
||||
}
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[nr_comp];
|
||||
bit_depth = png_get_bit_depth(png, info);
|
||||
|
||||
switch (bit_depth) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvtXXTo32s = convert_XXu32s_C1R_LUT[bit_depth];
|
||||
break;
|
||||
case 16: /* 16 bpp is specific to PNG */
|
||||
cvtXXTo32s = convert_16u32s_C1R;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: bit depth %d is not supported\n", bit_depth);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
|
||||
rows = (OPJ_BYTE**)calloc(height+1, sizeof(OPJ_BYTE*));
|
||||
for(i = 0; i < height; ++i)
|
||||
rows[i] = (OPJ_BYTE*)malloc(png_get_rowbytes(png,info));
|
||||
|
||||
png_read_image(png, rows);
|
||||
|
||||
/* Create image */
|
||||
memset(cmptparm, 0, sizeof(cmptparm));
|
||||
for(i = 0; i < nr_comp; ++i) {
|
||||
cmptparm[i].prec = (OPJ_UINT32)bit_depth;
|
||||
/* bits_per_pixel: 8 or 16 */
|
||||
cmptparm[i].bpp = (OPJ_UINT32)bit_depth;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = (OPJ_UINT32)params->subsampling_dx;
|
||||
cmptparm[i].dy = (OPJ_UINT32)params->subsampling_dy;
|
||||
cmptparm[i].w = (OPJ_UINT32)width;
|
||||
cmptparm[i].h = (OPJ_UINT32)height;
|
||||
}
|
||||
|
||||
image = opj_image_create(nr_comp, &cmptparm[0], (nr_comp > 2U) ? OPJ_CLRSPC_SRGB : OPJ_CLRSPC_GRAY);
|
||||
if(image == NULL) goto fin;
|
||||
image->x0 = (OPJ_UINT32)params->image_offset_x0;
|
||||
image->y0 = (OPJ_UINT32)params->image_offset_y0;
|
||||
image->x1 = (OPJ_UINT32)(image->x0 + (width - 1) * (OPJ_UINT32)params->subsampling_dx + 1 + image->x0);
|
||||
image->y1 = (OPJ_UINT32)(image->y0 + (height - 1) * (OPJ_UINT32)params->subsampling_dy + 1 + image->y0);
|
||||
|
||||
row32s = (OPJ_INT32 *)malloc((size_t)width * nr_comp * sizeof(OPJ_INT32));
|
||||
if(row32s == NULL) goto fin;
|
||||
|
||||
/* Set alpha channel */
|
||||
image->comps[nr_comp-1U].alpha = 1U - (nr_comp & 1U);
|
||||
|
||||
for(i = 0; i < nr_comp; i++) {
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
|
||||
for(i = 0; i < height; ++i) {
|
||||
cvtXXTo32s(rows[i], row32s, (OPJ_SIZE_T)width * nr_comp);
|
||||
cvtCxToPx(row32s, planes, width);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
fin:
|
||||
if(rows) {
|
||||
for(i = 0; i < height; ++i)
|
||||
free(rows[i]);
|
||||
free(rows);
|
||||
}
|
||||
if (row32s) {
|
||||
free(row32s);
|
||||
}
|
||||
if(png)
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
|
||||
fclose(reader);
|
||||
|
||||
return image;
|
||||
|
||||
}/* pngtoimage() */
|
||||
|
||||
|
||||
static void convert_32s16u_C1R(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < length; i++) {
|
||||
OPJ_UINT32 val = (OPJ_UINT32)pSrc[i];
|
||||
*pDst++ = (OPJ_BYTE)(val >> 8);
|
||||
*pDst++ = (OPJ_BYTE)val;
|
||||
}
|
||||
}
|
||||
int imagetopng(opj_image_t * image, const char *write_idf)
|
||||
{
|
||||
FILE * volatile writer = NULL;
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
png_bytep volatile row_buf = NULL;
|
||||
int nr_comp, color_type;
|
||||
volatile int prec;
|
||||
png_color_8 sig_bit;
|
||||
OPJ_INT32 const* planes[4];
|
||||
int i;
|
||||
OPJ_INT32* volatile buffer32s = NULL;
|
||||
|
||||
volatile int fails = 1;
|
||||
|
||||
memset(&sig_bit, 0, sizeof(sig_bit));
|
||||
prec = (int)image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
nr_comp = (int)image->numcomps;
|
||||
|
||||
if (nr_comp > 4) {
|
||||
nr_comp = 4;
|
||||
}
|
||||
for (i = 1; i < nr_comp; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != nr_comp) {
|
||||
fprintf(stderr,"imagetopng: All components shall have the same subsampling, same bit depth, same sign.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
if(prec > 8 && prec < 16) {
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 16);
|
||||
}
|
||||
prec = 16;
|
||||
} else if(prec < 8 && nr_comp > 1) { /* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 8);
|
||||
}
|
||||
prec = 8;
|
||||
} else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1)==1))) { /* GRAY with non native precision */
|
||||
if ((prec == 5) || (prec == 6)) {
|
||||
prec = 8;
|
||||
} else {
|
||||
prec++;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), (OPJ_UINT32)prec);
|
||||
}
|
||||
}
|
||||
|
||||
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16) {
|
||||
fprintf(stderr,"imagetopng: can not create %s\n\twrong bit_depth %d\n", write_idf, prec);
|
||||
return fails;
|
||||
}
|
||||
|
||||
writer = fopen(write_idf, "wb");
|
||||
|
||||
if(writer == NULL) return fails;
|
||||
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible with the one used at compile time,
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
|
||||
|
||||
if(png == NULL) goto fin;
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED
|
||||
*/
|
||||
info = png_create_info_struct(png);
|
||||
|
||||
if(info == NULL) goto fin;
|
||||
|
||||
/* Set error handling. REQUIRED if you are not supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if(setjmp(png_jmpbuf(png))) goto fin;
|
||||
|
||||
/* I/O initialization functions is REQUIRED
|
||||
*/
|
||||
png_init_io(png, writer);
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||
* REQUIRED
|
||||
*
|
||||
* ERRORS:
|
||||
*
|
||||
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||
*
|
||||
*/
|
||||
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||
|
||||
if(nr_comp >= 3) { /* RGB(A) */
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
|
||||
} else { /* GRAY(A) */
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
sig_bit.gray = (png_byte)prec;
|
||||
}
|
||||
if((nr_comp & 1) == 0) { /* ALPHA */
|
||||
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
sig_bit.alpha = (png_byte)prec;
|
||||
}
|
||||
|
||||
png_set_IHDR(png, info, image->comps[0].w, image->comps[0].h, prec, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
png_set_sBIT(png, info, &sig_bit);
|
||||
/* png_set_gamma(png, 2.2, 1./2.2); */
|
||||
/* png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); */
|
||||
png_write_info(png, info);
|
||||
|
||||
/* setup conversion */
|
||||
{
|
||||
OPJ_SIZE_T rowStride;
|
||||
png_size_t png_row_size;
|
||||
|
||||
png_row_size = png_get_rowbytes(png, info);
|
||||
rowStride = ((OPJ_SIZE_T)image->comps[0].w * (OPJ_SIZE_T)nr_comp * (OPJ_SIZE_T)prec + 7U) / 8U;
|
||||
if (rowStride != (OPJ_SIZE_T)png_row_size) {
|
||||
fprintf(stderr, "Invalid PNG row size\n");
|
||||
goto fin;
|
||||
}
|
||||
row_buf = (png_bytep)malloc(png_row_size);
|
||||
if (row_buf == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for PNG row\n");
|
||||
goto fin;
|
||||
}
|
||||
buffer32s = (OPJ_INT32*)malloc((OPJ_SIZE_T)image->comps[0].w * (OPJ_SIZE_T)nr_comp * sizeof(OPJ_INT32));
|
||||
if (buffer32s == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for interleaved 32s row\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert */
|
||||
{
|
||||
OPJ_SIZE_T width= image->comps[0].w;
|
||||
OPJ_UINT32 y;
|
||||
convert_32s_PXCX cvtPxToCx = convert_32s_PXCX_LUT[nr_comp];
|
||||
convert_32sXXx_C1R cvt32sToPack = NULL;
|
||||
OPJ_INT32 adjust = image->comps[0].sgnd ? 1 << (prec - 1) : 0;
|
||||
png_bytep row_buf_cpy = row_buf;
|
||||
OPJ_INT32* buffer32s_cpy = buffer32s;
|
||||
|
||||
switch (prec) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvt32sToPack = convert_32sXXu_C1R_LUT[prec];
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToPack = convert_32s16u_C1R;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
for(y = 0; y < image->comps[0].h; ++y) {
|
||||
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
|
||||
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (OPJ_SIZE_T)nr_comp);
|
||||
png_write_row(png, row_buf_cpy);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
}
|
||||
|
||||
png_write_end(png, info);
|
||||
|
||||
fails = 0;
|
||||
|
||||
fin:
|
||||
if(png) {
|
||||
png_destroy_write_struct(&png, &info);
|
||||
}
|
||||
if(row_buf) {
|
||||
free(row_buf);
|
||||
}
|
||||
if(buffer32s) {
|
||||
free(buffer32s);
|
||||
}
|
||||
fclose(writer);
|
||||
|
||||
if(fails) (void)remove(write_idf); /* ignore return value */
|
||||
|
||||
return fails;
|
||||
}/* imagetopng() */
|
||||
629
src/bin/jp2/converttif.c
Normal file
629
src/bin/jp2/converttif.c
Normal file
@@ -0,0 +1,629 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_apps_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef OPJ_HAVE_LIBTIFF
|
||||
# error OPJ_HAVE_LIBTIFF_NOT_DEFINED
|
||||
#endif /* OPJ_HAVE_LIBTIFF */
|
||||
|
||||
#include <tiffio.h>
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 2);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)(((src2 & 0x3FU) << 2) | (src3 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = 0U;
|
||||
OPJ_UINT32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 2);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (OPJ_BYTE)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (OPJ_BYTE)(((src2 & 0x3FU) << 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 4);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0xFU) << 4) | (src1 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src1);
|
||||
}
|
||||
|
||||
if (length & 1U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 4);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 6);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)(src1 >> 4);
|
||||
*pDst++ = (OPJ_BYTE)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)(src2 >> 2);
|
||||
*pDst++ = (OPJ_BYTE)(((src2 & 0x3U) << 6) | (src3 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = 0U;
|
||||
OPJ_UINT32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (OPJ_BYTE)(src0 >> 6);
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (OPJ_BYTE)(src1 >> 4);
|
||||
*pDst++ = (OPJ_BYTE)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (OPJ_BYTE)(src2 >> 2);
|
||||
*pDst++ = (OPJ_BYTE)(((src2 & 0x3U) << 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const OPJ_INT32* pSrc, OPJ_UINT16* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
pDst[i] = (OPJ_UINT16)pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
int imagetotif(opj_image_t * image, const char *outfile)
|
||||
{
|
||||
int width, height;
|
||||
int bps,adjust, sgnd;
|
||||
int tiPhoto;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tsize_t strip_size;
|
||||
OPJ_UINT32 i, numcomps;
|
||||
OPJ_SIZE_T rowStride;
|
||||
OPJ_INT32* buffer32s = NULL;
|
||||
OPJ_INT32 const* planes[4];
|
||||
convert_32s_PXCX cvtPxToCx = NULL;
|
||||
convert_32sXXx_C1R cvt32sToTif = NULL;
|
||||
|
||||
bps = (int)image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
|
||||
numcomps = image->numcomps;
|
||||
|
||||
if (image->color_space == OPJ_CLRSPC_CMYK) {
|
||||
if (numcomps < 4U) {
|
||||
fprintf(stderr,"imagetotif: CMYK images shall be composed of at least 4 planes.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
tiPhoto = PHOTOMETRIC_SEPARATED;
|
||||
if (numcomps > 4U) {
|
||||
numcomps = 4U; /* Alpha not supported */
|
||||
}
|
||||
} else if (numcomps > 2U) {
|
||||
tiPhoto = PHOTOMETRIC_RGB;
|
||||
if (numcomps > 4U) {
|
||||
numcomps = 4U;
|
||||
}
|
||||
} else {
|
||||
tiPhoto = PHOTOMETRIC_MINISBLACK;
|
||||
}
|
||||
for (i = 1U; i < numcomps; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != numcomps) {
|
||||
fprintf(stderr,"imagetotif: All components shall have the same subsampling, same bit depth.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps == 0) {
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
tif = TIFFOpen(outfile, "wb");
|
||||
if (!tif) {
|
||||
fprintf(stderr, "imagetotif:failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0U; i < numcomps; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
cvtPxToCx = convert_32s_PXCX_LUT[numcomps];
|
||||
switch (bps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
sgnd = (int)image->comps[0].sgnd;
|
||||
adjust = sgnd ? 1 << (image->comps[0].prec - 1) : 0;
|
||||
width = (int)image->comps[0].w;
|
||||
height = (int)image->comps[0].h;
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, numcomps);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, tiPhoto);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
rowStride = ((OPJ_SIZE_T)width * numcomps * (OPJ_SIZE_T)bps + 7U) / 8U;
|
||||
if (rowStride != (OPJ_SIZE_T)strip_size) {
|
||||
fprintf(stderr, "Invalid TIFF strip size\n");
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->comps[0].h; ++i) {
|
||||
cvtPxToCx(planes, buffer32s, (OPJ_SIZE_T)width, adjust);
|
||||
cvt32sToTif(buffer32s, (OPJ_BYTE *)buf, (OPJ_SIZE_T)width * numcomps);
|
||||
(void)TIFFWriteEncodedStrip(tif, i, (void*)buf, strip_size);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
_TIFFfree((void*)buf);
|
||||
TIFFClose(tif);
|
||||
free(buffer32s);
|
||||
|
||||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 2) | (val1 >> 6));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
pDst[i+3] = (OPJ_INT32)(((val3 & 0x3U) << 8) | val4);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 2) | (val1 >> 6));
|
||||
|
||||
if (length > 1U) {
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
if (length > 2U) {
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 4) | (val1 >> 4));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0xFU) << 8) | val2);
|
||||
}
|
||||
if (length & 1U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 6) | (val1 >> 2));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
pDst[i+3] = (OPJ_INT32)(((val5 & 0x3FU) << 8) | val6);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 6) | (val1 >> 2));
|
||||
|
||||
if (length > 1U) {
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
if (length > 2U) {
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < length; i++) {
|
||||
pDst[i] = pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
|
||||
* CINEMA : 12 bit precision
|
||||
*/
|
||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tstrip_t strip;
|
||||
tsize_t strip_size;
|
||||
int j, currentPlane, numcomps = 0, w, h;
|
||||
OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_UNKNOWN;
|
||||
opj_image_cmptparm_t cmptparm[4]; /* RGBA */
|
||||
opj_image_t *image = NULL;
|
||||
int has_alpha = 0;
|
||||
unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
|
||||
unsigned int tiWidth, tiHeight;
|
||||
OPJ_BOOL is_cinema = OPJ_IS_CINEMA(parameters->rsiz);
|
||||
convert_XXx32s_C1R cvtTifTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
OPJ_INT32* buffer32s = NULL;
|
||||
OPJ_INT32* planes[4];
|
||||
OPJ_SIZE_T rowStride;
|
||||
|
||||
tif = TIFFOpen(filename, "r");
|
||||
|
||||
if(!tif) {
|
||||
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
|
||||
return 0;
|
||||
}
|
||||
tiBps = tiPhoto = tiSf = tiSpp = tiPC = 0;
|
||||
tiWidth = tiHeight = 0;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &tiWidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &tiHeight);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &tiBps);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &tiSf);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
|
||||
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
|
||||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) {
|
||||
fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (tiBps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
{/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
|
||||
uint16* sampleinfo;
|
||||
uint16 extrasamples;
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
|
||||
&extrasamples, &sampleinfo);
|
||||
|
||||
if(extrasamples >= 1) {
|
||||
switch(sampleinfo[0]) {
|
||||
case EXTRASAMPLE_UNSPECIFIED:
|
||||
/* Workaround for some images without correct info about alpha channel
|
||||
*/
|
||||
if(tiSpp > 3)
|
||||
has_alpha = 1;
|
||||
break;
|
||||
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data not pre-multiplied */
|
||||
has_alpha = 1;
|
||||
break;
|
||||
}
|
||||
} else /* extrasamples == 0 */
|
||||
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
|
||||
}
|
||||
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
|
||||
|
||||
if ((tiPhoto == PHOTOMETRIC_RGB) && (is_cinema) && (tiBps != 12U)) {
|
||||
fprintf(stdout,"WARNING:\n"
|
||||
"Input image bitdepth is %d bits\n"
|
||||
"TIF conversion has automatically rescaled to 12-bits\n"
|
||||
"to comply with cinema profiles.\n",
|
||||
tiBps);
|
||||
} else {
|
||||
is_cinema = 0U;
|
||||
}
|
||||
|
||||
if(tiPhoto == PHOTOMETRIC_RGB) { /* RGB(A) */
|
||||
numcomps = 3 + has_alpha;
|
||||
color_space = OPJ_CLRSPC_SRGB;
|
||||
} else if (tiPhoto == PHOTOMETRIC_MINISBLACK) { /* GRAY(A) */
|
||||
numcomps = 1 + has_alpha;
|
||||
color_space = OPJ_CLRSPC_GRAY;
|
||||
}
|
||||
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[numcomps];
|
||||
if (tiPC == PLANARCONFIG_SEPARATE) {
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[1]; /* override */
|
||||
tiSpp = 1U; /* consider only one sample per plane */
|
||||
}
|
||||
|
||||
for(j = 0; j < numcomps; j++) {
|
||||
cmptparm[j].prec = tiBps;
|
||||
cmptparm[j].bpp = tiBps;
|
||||
cmptparm[j].dx = (OPJ_UINT32)subsampling_dx;
|
||||
cmptparm[j].dy = (OPJ_UINT32)subsampling_dy;
|
||||
cmptparm[j].w = (OPJ_UINT32)w;
|
||||
cmptparm[j].h = (OPJ_UINT32)h;
|
||||
}
|
||||
|
||||
image = opj_image_create((OPJ_UINT32)numcomps, &cmptparm[0], color_space);
|
||||
if(!image) {
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (OPJ_UINT32)parameters->image_offset_x0;
|
||||
image->y0 = (OPJ_UINT32)parameters->image_offset_y0;
|
||||
image->x1 = !image->x0 ? (OPJ_UINT32)(w - 1) * (OPJ_UINT32)subsampling_dx + 1 :
|
||||
image->x0 + (OPJ_UINT32)(w - 1) * (OPJ_UINT32)subsampling_dx + 1;
|
||||
image->y1 = !image->y0 ? (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1 :
|
||||
image->y0 + (OPJ_UINT32)(h - 1) * (OPJ_UINT32)subsampling_dy + 1;
|
||||
|
||||
for(j = 0; j < numcomps; j++) {
|
||||
planes[j] = image->comps[j].data;
|
||||
}
|
||||
image->comps[numcomps - 1].alpha = (OPJ_UINT16)(1 - (numcomps & 1));
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
rowStride = ((OPJ_SIZE_T)w * tiSpp * tiBps + 7U) / 8U;
|
||||
buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strip = 0;
|
||||
currentPlane = 0;
|
||||
do {
|
||||
planes[0] = image->comps[currentPlane].data; /* to manage planar data */
|
||||
h= (int)tiHeight;
|
||||
/* Read the Image components */
|
||||
for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++) {
|
||||
const OPJ_UINT8 *dat8;
|
||||
OPJ_SIZE_T ssize;
|
||||
|
||||
ssize = (OPJ_SIZE_T)TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
||||
dat8 = (const OPJ_UINT8*)buf;
|
||||
|
||||
while (ssize >= rowStride) {
|
||||
cvtTifTo32s(dat8, buffer32s, (OPJ_SIZE_T)w * tiSpp);
|
||||
cvtCxToPx(buffer32s, planes, (OPJ_SIZE_T)w);
|
||||
planes[0] += w;
|
||||
planes[1] += w;
|
||||
planes[2] += w;
|
||||
planes[3] += w;
|
||||
dat8 += rowStride;
|
||||
ssize -= rowStride;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
currentPlane++;
|
||||
} while ((tiPC == PLANARCONFIG_SEPARATE) && (currentPlane < numcomps));
|
||||
|
||||
free(buffer32s);
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
|
||||
if (is_cinema) {
|
||||
for (j=0; j < numcomps; ++j) {
|
||||
scale_component(&(image->comps[j]), 12);
|
||||
}
|
||||
|
||||
}
|
||||
return image;
|
||||
|
||||
}/* tiftoimage() */
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -41,352 +46,353 @@ Write a structured index to a file
|
||||
@param index Index filename
|
||||
@return Returns 0 if successful, returns 1 otherwise
|
||||
*/
|
||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
|
||||
{
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
/* <<UniPG */
|
||||
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
OPJ_OFF_T start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
OPJ_OFF_T start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
|
||||
if (cstr_info->prog == OPJ_LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
if (cstr_info->prog == OPJ_LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6" PRId64 " %6" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6" PRId64 " %6" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
|
||||
else if (cstr_info->prog == OPJ_RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
else if (cstr_info->prog == OPJ_RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
|
||||
else if (cstr_info->prog == OPJ_RPCL) { /* RPCL */
|
||||
else if (cstr_info->prog == OPJ_RPCL) { /* RPCL */
|
||||
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
|
||||
else if (cstr_info->prog == OPJ_PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
else if (cstr_info->prog == OPJ_PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9" PRId64 " %9" PRId64 " %7" PRId64,
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9" PRId64 " %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9" PRId64 " %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||
@@ -52,27 +57,28 @@
|
||||
#include "index.h"
|
||||
|
||||
#include "format_defs.h"
|
||||
#include "opj_string.h"
|
||||
|
||||
typedef struct dircnt{
|
||||
/** Buffer for holding images read from Directory*/
|
||||
char *filename_buf;
|
||||
/** Pointer to the buffer*/
|
||||
char **filename;
|
||||
}dircnt_t;
|
||||
typedef struct dircnt {
|
||||
/** Buffer for holding images read from Directory*/
|
||||
char *filename_buf;
|
||||
/** Pointer to the buffer*/
|
||||
char **filename;
|
||||
} dircnt_t;
|
||||
|
||||
|
||||
typedef struct img_folder{
|
||||
/** The directory path of the folder containing input images*/
|
||||
char *imgdirpath;
|
||||
/** Output format*/
|
||||
const char *out_format;
|
||||
/** Enable option*/
|
||||
char set_imgdir;
|
||||
/** Enable Cod Format for output*/
|
||||
char set_out_format;
|
||||
typedef struct img_folder {
|
||||
/** The directory path of the folder containing input images*/
|
||||
char *imgdirpath;
|
||||
/** Output format*/
|
||||
const char *out_format;
|
||||
/** Enable option*/
|
||||
char set_imgdir;
|
||||
/** Enable Cod Format for output*/
|
||||
char set_out_format;
|
||||
|
||||
int flag;
|
||||
}img_fol_t;
|
||||
int flag;
|
||||
} img_fol_t;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Declarations */
|
||||
@@ -85,128 +91,134 @@ static int infile_format(const char *fname);
|
||||
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void decode_help_display(void) {
|
||||
fprintf(stdout,"HELP for opj_dump\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
static void decode_help_display(void)
|
||||
{
|
||||
fprintf(stdout,"\nThis is the opj_dump utility from the OpenJPEG project.\n"
|
||||
"It dumps JPEG 2000 codestream info to stdout or a given file.\n"
|
||||
"It has been compiled against openjp2 library v%s.\n\n",opj_version());
|
||||
|
||||
/* UniPG>> */
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||
#ifdef USE_JPWL
|
||||
"+ JPWL "
|
||||
#endif /* USE_JPWL */
|
||||
"decoder:\n");
|
||||
/* <<UniPG */
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -ImgDir \n");
|
||||
fprintf(stdout," Image file Directory path \n");
|
||||
fprintf(stdout," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||
fprintf(stdout," is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <output file>\n");
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Output file where file info will be dump.\n");
|
||||
fprintf(stdout," By default it will be in the stdout.\n");
|
||||
fprintf(stdout," -v "); /* FIXME WIP_MSD */
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Activate or not the verbose mode (display info and warning message)\n");
|
||||
fprintf(stdout," By default verbose mode is off.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Parameters:\n");
|
||||
fprintf(stdout,"-----------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -ImgDir <directory>\n");
|
||||
fprintf(stdout," Image file Directory path \n");
|
||||
fprintf(stdout," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||
fprintf(stdout," is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <output file>\n");
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Output file where file info will be dump.\n");
|
||||
fprintf(stdout," By default it will be in the stdout.\n");
|
||||
fprintf(stdout," -v "); /* FIXME WIP_MSD */
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Enable informative messages\n");
|
||||
fprintf(stdout," By default verbose mode is off.\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
static int get_num_images(char *imgdirpath)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 0;
|
||||
}
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir) {
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
return num_images;
|
||||
while((content=readdir(dir))!=NULL) {
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
closedir(dir);
|
||||
return num_images;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
static int load_images(dircnt_t *dirptr, char *imgdirpath)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 1;
|
||||
}else {
|
||||
fprintf(stderr,"Folder opened successfully\n");
|
||||
}
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir) {
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 1;
|
||||
} else {
|
||||
fprintf(stderr,"Folder opened successfully\n");
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
while((content=readdir(dir))!=NULL) {
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static int get_file_format(const char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
static int get_file_format(const char *filename)
|
||||
{
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters)
|
||||
{
|
||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
|
||||
strcpy(image_filename,dirptr->filename[imageno]);
|
||||
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||
parameters->decod_format = get_file_format(image_filename);
|
||||
if (parameters->decod_format == -1)
|
||||
return 1;
|
||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||
strcpy(image_filename,dirptr->filename[imageno]);
|
||||
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||
parameters->decod_format = get_file_format(image_filename);
|
||||
if (parameters->decod_format == -1)
|
||||
return 1;
|
||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||
if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infilename) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*Set output file*/
|
||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||
while((temp_p = strtok(NULL,".")) != NULL){
|
||||
strcat(temp_ofname,temp1);
|
||||
sprintf(temp1,".%s",temp_p);
|
||||
}
|
||||
if(img_fol->set_out_format==1){
|
||||
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||
}
|
||||
return 0;
|
||||
/*Set output file*/
|
||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||
while((temp_p = strtok(NULL,".")) != NULL) {
|
||||
strcat(temp_ofname,temp1);
|
||||
sprintf(temp1,".%s",temp_p);
|
||||
}
|
||||
if(img_fol->set_out_format==1) {
|
||||
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfilename) != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -217,161 +229,164 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_d
|
||||
|
||||
static int infile_format(const char *fname)
|
||||
{
|
||||
FILE *reader;
|
||||
const char *s, *magic_s;
|
||||
int ext_format, magic_format;
|
||||
unsigned char buf[12];
|
||||
size_t l_nb_read;
|
||||
FILE *reader;
|
||||
const char *s, *magic_s;
|
||||
int ext_format, magic_format;
|
||||
unsigned char buf[12];
|
||||
size_t l_nb_read;
|
||||
|
||||
reader = fopen(fname, "rb");
|
||||
reader = fopen(fname, "rb");
|
||||
|
||||
if (reader == NULL)
|
||||
return -1;
|
||||
if (reader == NULL)
|
||||
return -1;
|
||||
|
||||
memset(buf, 0, 12);
|
||||
l_nb_read = fread(buf, 1, 12, reader);
|
||||
fclose(reader);
|
||||
if (l_nb_read != 12)
|
||||
return -1;
|
||||
memset(buf, 0, 12);
|
||||
l_nb_read = fread(buf, 1, 12, reader);
|
||||
fclose(reader);
|
||||
if (l_nb_read != 12)
|
||||
return -1;
|
||||
|
||||
|
||||
|
||||
ext_format = get_file_format(fname);
|
||||
ext_format = get_file_format(fname);
|
||||
|
||||
if (ext_format == JPT_CFMT)
|
||||
return JPT_CFMT;
|
||||
if (ext_format == JPT_CFMT)
|
||||
return JPT_CFMT;
|
||||
|
||||
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
|
||||
magic_format = JP2_CFMT;
|
||||
magic_s = ".jp2";
|
||||
}
|
||||
else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
|
||||
magic_format = J2K_CFMT;
|
||||
magic_s = ".j2k or .jpc or .j2c";
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
|
||||
magic_format = JP2_CFMT;
|
||||
magic_s = ".jp2";
|
||||
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
|
||||
magic_format = J2K_CFMT;
|
||||
magic_s = ".j2k or .jpc or .j2c";
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (magic_format == ext_format)
|
||||
return ext_format;
|
||||
if (magic_format == ext_format)
|
||||
return ext_format;
|
||||
|
||||
s = fname + strlen(fname) - 4;
|
||||
s = fname + strlen(fname) - 4;
|
||||
|
||||
fputs("\n===========================================\n", stderr);
|
||||
fprintf(stderr, "The extension of this file is incorrect.\n"
|
||||
"FOUND %s. SHOULD BE %s\n", s, magic_s);
|
||||
fputs("===========================================\n", stderr);
|
||||
fputs("\n===========================================\n", stderr);
|
||||
fprintf(stderr, "The extension of this file is incorrect.\n"
|
||||
"FOUND %s. SHOULD BE %s\n", s, magic_s);
|
||||
fputs("===========================================\n", stderr);
|
||||
|
||||
return magic_format;
|
||||
return magic_format;
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Parse the command line
|
||||
*/
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
};
|
||||
const char optlist[] = "i:o:f:hv";
|
||||
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol)
|
||||
{
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]= {
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'}
|
||||
};
|
||||
const char optlist[] = "i:o:f:hv";
|
||||
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format = 0;
|
||||
do {
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = opj_optarg;
|
||||
parameters->decod_format = infile_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J2K_CFMT:
|
||||
break;
|
||||
case JP2_CFMT:
|
||||
break;
|
||||
case JPT_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||
infile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = opj_optarg;
|
||||
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'f': /* flag */
|
||||
img_fol->flag = atoi(opj_optarg);
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format = 0;
|
||||
do {
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': { /* input file */
|
||||
char *infile = opj_optarg;
|
||||
parameters->decod_format = infile_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J2K_CFMT:
|
||||
break;
|
||||
case JP2_CFMT:
|
||||
break;
|
||||
case JPT_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"[ERROR] Unknown input file format: %s \n"
|
||||
" Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n",
|
||||
infile);
|
||||
return 1;
|
||||
}
|
||||
if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infile) != 0) {
|
||||
fprintf(stderr, "[ERROR] Path is too long\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
case 'o': { /* output file */
|
||||
if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), opj_optarg) != 0) {
|
||||
fprintf(stderr, "[ERROR] Path is too long\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'f': /* flag */
|
||||
img_fol->flag = atoi(opj_optarg);
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
|
||||
case 'v': /* Verbose mode */
|
||||
{
|
||||
parameters->m_verbose = 1;
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
default:
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
case 'y': { /* Image Directory path */
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* check for possible errors */
|
||||
if(img_fol->set_imgdir==1){
|
||||
if(!(parameters->infile[0]==0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
if(img_fol->set_out_format == 0){
|
||||
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||
return 1;
|
||||
}
|
||||
if(!(parameters->outfile[0] == 0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
if(parameters->infile[0] == 0) {
|
||||
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
return 0;
|
||||
case 'v': { /* Verbose mode */
|
||||
parameters->m_verbose = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
default:
|
||||
fprintf(stderr, "[WARNING] An invalid option has been ignored.\n");
|
||||
break;
|
||||
}
|
||||
} while(c != -1);
|
||||
|
||||
/* check for possible errors */
|
||||
if(img_fol->set_imgdir==1) {
|
||||
if(!(parameters->infile[0]==0)) {
|
||||
fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n");
|
||||
return 1;
|
||||
}
|
||||
if(img_fol->set_out_format == 0) {
|
||||
fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used.\n");
|
||||
fprintf(stderr, "Only one format allowed.\n"
|
||||
"Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n");
|
||||
return 1;
|
||||
}
|
||||
if(!(parameters->outfile[0] == 0)) {
|
||||
fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if(parameters->infile[0] == 0) {
|
||||
fprintf(stderr, "[ERROR] Required parameter is missing\n");
|
||||
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||
fprintf(stderr, " Help: %s -h\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -379,23 +394,26 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
|
||||
/**
|
||||
sample error debug callback expecting no client object
|
||||
*/
|
||||
static void error_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[ERROR] %s", msg);
|
||||
static void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning debug callback expecting no client object
|
||||
*/
|
||||
static void warning_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[WARNING] %s", msg);
|
||||
static void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
static void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
static void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -405,178 +423,174 @@ static void info_callback(const char *msg, void *client_data) {
|
||||
/* -------------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fout = NULL;
|
||||
FILE *fout = NULL;
|
||||
|
||||
opj_dparameters_t parameters; /* Decompression parameters */
|
||||
opj_image_t* image = NULL; /* Image structure */
|
||||
opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
|
||||
opj_stream_t *l_stream = NULL; /* Stream */
|
||||
opj_codestream_info_v2_t* cstr_info = NULL;
|
||||
opj_codestream_index_t* cstr_index = NULL;
|
||||
opj_dparameters_t parameters; /* Decompression parameters */
|
||||
opj_image_t* image = NULL; /* Image structure */
|
||||
opj_codec_t* l_codec = NULL; /* Handle to a decompressor */
|
||||
opj_stream_t *l_stream = NULL; /* Stream */
|
||||
opj_codestream_info_v2_t* cstr_info = NULL;
|
||||
opj_codestream_index_t* cstr_index = NULL;
|
||||
|
||||
OPJ_INT32 num_images, imageno;
|
||||
img_fol_t img_fol;
|
||||
dircnt_t *dirptr = NULL;
|
||||
OPJ_INT32 num_images, imageno;
|
||||
img_fol_t img_fol;
|
||||
dircnt_t *dirptr = NULL;
|
||||
|
||||
#ifdef MSD
|
||||
OPJ_BOOL l_go_on = OPJ_TRUE;
|
||||
OPJ_UINT32 l_max_data_size = 1000;
|
||||
OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
|
||||
OPJ_BOOL l_go_on = OPJ_TRUE;
|
||||
OPJ_UINT32 l_max_data_size = 1000;
|
||||
OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
|
||||
#endif
|
||||
|
||||
/* Set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
/* Set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Initialize img_fol */
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
img_fol.flag = OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND;
|
||||
/* Initialize img_fol */
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
img_fol.flag = OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND;
|
||||
|
||||
/* Parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1){
|
||||
int it_image;
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1) {
|
||||
int it_image;
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr) {
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!dirptr->filename_buf) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
for(it_image=0; it_image<num_images; it_image++) {
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
}
|
||||
if (num_images==0) {
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
num_images=1;
|
||||
}
|
||||
|
||||
/* Try to open for writing the output file if necessary */
|
||||
if (parameters.outfile[0] != 0){
|
||||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout){
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
fout = stdout;
|
||||
/* Try to open for writing the output file if necessary */
|
||||
if (parameters.outfile[0] != 0) {
|
||||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
fout = stdout;
|
||||
|
||||
/* Read the header of each image one by one */
|
||||
for(imageno = 0; imageno < num_images ; imageno++){
|
||||
/* Read the header of each image one by one */
|
||||
for(imageno = 0; imageno < num_images ; imageno++) {
|
||||
|
||||
fprintf(stderr,"\n");
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
if(img_fol.set_imgdir==1){
|
||||
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||
fprintf(stderr,"skipping file...\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(img_fol.set_imgdir==1) {
|
||||
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||
fprintf(stderr,"skipping file...\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
/* Read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
|
||||
l_stream = opj_stream_create_default_file_stream_v3(parameters.infile,1);
|
||||
if (!l_stream){
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
|
||||
if (!l_stream) {
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Read the JPEG2000 stream */
|
||||
/* ------------------------ */
|
||||
/* Read the JPEG2000 stream */
|
||||
/* ------------------------ */
|
||||
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT: /* JPEG-2000 codestream */
|
||||
{
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
|
||||
break;
|
||||
}
|
||||
case JP2_CFMT: /* JPEG 2000 compressed image data */
|
||||
{
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
|
||||
break;
|
||||
}
|
||||
case JPT_CFMT: /* JPEG 2000, JPIP */
|
||||
{
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_JPT);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "skipping file..\n");
|
||||
opj_stream_destroy_v3(l_stream);
|
||||
continue;
|
||||
}
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT: { /* JPEG-2000 codestream */
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_J2K);
|
||||
break;
|
||||
}
|
||||
case JP2_CFMT: { /* JPEG 2000 compressed image data */
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_JP2);
|
||||
break;
|
||||
}
|
||||
case JPT_CFMT: { /* JPEG 2000, JPIP */
|
||||
/* Get a decoder handle */
|
||||
l_codec = opj_create_decompress(OPJ_CODEC_JPT);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "skipping file..\n");
|
||||
opj_stream_destroy(l_stream);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_info_handler(l_codec, info_callback,00);
|
||||
opj_set_warning_handler(l_codec, warning_callback,00);
|
||||
opj_set_error_handler(l_codec, error_callback,00);
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_info_handler(l_codec, info_callback,00);
|
||||
opj_set_warning_handler(l_codec, warning_callback,00);
|
||||
opj_set_error_handler(l_codec, error_callback,00);
|
||||
|
||||
/* Setup the decoder decoding parameters using user parameters */
|
||||
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
||||
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
|
||||
opj_stream_destroy_v3(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Setup the decoder decoding parameters using user parameters */
|
||||
if ( !opj_setup_decoder(l_codec, ¶meters) ) {
|
||||
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
|
||||
opj_stream_destroy_v3(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
if(! opj_read_header(l_stream, l_codec, &image)) {
|
||||
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
opj_dump_codec(l_codec, img_fol.flag, fout );
|
||||
opj_dump_codec(l_codec, img_fol.flag, fout );
|
||||
|
||||
cstr_info = opj_get_cstr_info(l_codec);
|
||||
cstr_info = opj_get_cstr_info(l_codec);
|
||||
|
||||
cstr_index = opj_get_cstr_index(l_codec);
|
||||
cstr_index = opj_get_cstr_index(l_codec);
|
||||
|
||||
/* close the byte stream */
|
||||
opj_stream_destroy_v3(l_stream);
|
||||
/* close the byte stream */
|
||||
opj_stream_destroy(l_stream);
|
||||
|
||||
/* free remaining structures */
|
||||
if (l_codec) {
|
||||
opj_destroy_codec(l_codec);
|
||||
}
|
||||
/* free remaining structures */
|
||||
if (l_codec) {
|
||||
opj_destroy_codec(l_codec);
|
||||
}
|
||||
|
||||
/* destroy the image header */
|
||||
opj_image_destroy(image);
|
||||
/* destroy the image header */
|
||||
opj_image_destroy(image);
|
||||
|
||||
/* destroy the codestream index */
|
||||
opj_destroy_cstr_index(&cstr_index);
|
||||
/* destroy the codestream index */
|
||||
opj_destroy_cstr_index(&cstr_index);
|
||||
|
||||
/* destroy the codestream info */
|
||||
opj_destroy_cstr_info(&cstr_info);
|
||||
/* destroy the codestream info */
|
||||
opj_destroy_cstr_info(&cstr_info);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the output file */
|
||||
fclose(fout);
|
||||
/* Close the output file */
|
||||
fclose(fout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -106,14 +106,14 @@
|
||||
*/
|
||||
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__MINGW32__) /* MinGW */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||
# define HAVE_DIRENT_H
|
||||
# define VOID_CLOSEDIR
|
||||
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||
# define HAVE_DIRECT_H
|
||||
# elif defined(__apollo) /* Apollo */
|
||||
@@ -172,7 +172,7 @@
|
||||
|
||||
#elif defined(MSDOS) || defined(WIN32)
|
||||
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
# if defined(WIN32)
|
||||
# define DIRENT_WIN32_INTERFACE
|
||||
# elif defined(MSDOS)
|
||||
@@ -181,7 +181,7 @@
|
||||
# error "missing native dirent interface"
|
||||
# endif
|
||||
|
||||
/*** WIN32 specifics ***/
|
||||
/*** WIN32 specifics ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
# include <windows.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -189,11 +189,11 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*** MS-DOS specifics ***/
|
||||
/*** MS-DOS specifics ***/
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# include <dos.h>
|
||||
|
||||
/* Borland defines file length macros in dir.h */
|
||||
/* Borland defines file length macros in dir.h */
|
||||
# if defined(__BORLANDC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -203,7 +203,7 @@
|
||||
# define _find_t find_t
|
||||
# endif
|
||||
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
# elif defined(__TURBOC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -211,13 +211,13 @@
|
||||
# endif
|
||||
# define DIRENT_USE_FFBLK
|
||||
|
||||
/* MSVC */
|
||||
/* MSVC */
|
||||
# elif defined(_MSC_VER)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# define DIRENT_MAXNAMLEN (12)
|
||||
# endif
|
||||
|
||||
/* Watcom */
|
||||
/* Watcom */
|
||||
# elif defined(__WATCOMC__)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# if defined(__OS2__) || defined(__NT__)
|
||||
@@ -230,7 +230,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||
# endif
|
||||
@@ -239,16 +239,16 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer refering the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer referring the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
char d_name[NAME_MAX + 1];
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
@@ -261,21 +261,21 @@
|
||||
struct _find_t data;
|
||||
# endif
|
||||
# endif
|
||||
} dirent;
|
||||
} dirent;
|
||||
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
char *dirname; /* directory being scanned */
|
||||
dirent current; /* current entry */
|
||||
int dirent_filled; /* is current un-processed? */
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
/*** Operating system specific part ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
HANDLE search_handle;
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# endif
|
||||
} DIR;
|
||||
} DIR;
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -344,46 +344,45 @@ static void _setdirname (struct DIR *dirp);
|
||||
*/
|
||||
static DIR *opendir(const char *dirname)
|
||||
{
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
|
||||
{
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
# ifdef DIRENT_WIN32_INTERFACE
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
# else
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
# endif
|
||||
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +410,7 @@ static DIR *opendir(const char *dirname)
|
||||
* capacity of d_name with different macros and some systems do not define
|
||||
* capacity at all (besides actual declaration of the field). If you really
|
||||
* need to find out storage capacity of d_name then you might want to try
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard although
|
||||
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||
@@ -436,55 +435,55 @@ static DIR *opendir(const char *dirname)
|
||||
static struct dirent *
|
||||
readdir (DIR *dirp)
|
||||
{
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occured */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occurred */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
}
|
||||
|
||||
|
||||
@@ -510,36 +509,36 @@ readdir (DIR *dirp)
|
||||
static int
|
||||
closedir (DIR *dirp)
|
||||
{
|
||||
int retcode = 0;
|
||||
int retcode = 0;
|
||||
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
# endif
|
||||
|
||||
free (dirp);
|
||||
return retcode;
|
||||
free (dirp);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
|
||||
@@ -567,30 +566,30 @@ closedir (DIR *dirp)
|
||||
static void
|
||||
rewinddir (DIR *dirp)
|
||||
{
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -601,36 +600,35 @@ rewinddir (DIR *dirp)
|
||||
static int
|
||||
_initdir (DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0)
|
||||
{
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0) {
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -641,13 +639,13 @@ static const char *
|
||||
_getdirname (const struct dirent *dp)
|
||||
{
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
return dp->data.cFileName;
|
||||
return dp->data.cFileName;
|
||||
|
||||
#elif defined(DIRENT_USE_FFBLK)
|
||||
return dp->data.ff_name;
|
||||
return dp->data.ff_name;
|
||||
|
||||
#else
|
||||
return dp->data.name;
|
||||
return dp->data.name;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -656,14 +654,15 @@ _getdirname (const struct dirent *dp)
|
||||
* Copy name of implementation dependent directory entry to the d_name field.
|
||||
*/
|
||||
static void
|
||||
_setdirname (struct DIR *dirp) {
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
_setdirname (struct DIR *dirp)
|
||||
{
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
}
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,9 +42,9 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#include <string.h>
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
@@ -55,55 +55,56 @@ char *optarg; /* argument associated with option */
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
int getopt(int nargc, char *const *nargv, const char *ostr)
|
||||
{
|
||||
|
||||
# define __progname nargv[0] /* program name */
|
||||
# define __progname nargv[0] /* program name */
|
||||
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
|
||||
if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) {
|
||||
/* if the user didn't specify '-' as an option, assume it means -1. */
|
||||
if (optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stdout,"[ERROR] %s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void) fprintf(stdout, "[ERROR] %s: option requires an argument -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
} else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
} /* option letter okay? */
|
||||
|
||||
if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) {
|
||||
/* if the user didn't specify '-' as an option, assume it means -1. */
|
||||
if (optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stdout,"[ERROR] %s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void) fprintf(stdout, "[ERROR] %s: option requires an argument -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
} else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,326 +48,320 @@
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static double calc_PSNR(opj_volume_t *original, opj_volume_t *decoded)
|
||||
{
|
||||
int max, i, k, compno = 0, size;
|
||||
double sum, total = 0;
|
||||
int global = 1;
|
||||
int max, i, k, compno = 0, size;
|
||||
double sum, total = 0;
|
||||
int global = 1;
|
||||
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
if (global) {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
if (global) {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
|
||||
for (compno = 0; compno < original->numcomps; compno++) {
|
||||
for(sum = 0, i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i] < 0) || (decoded->comps[compno].data[i] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i] - decoded->comps[compno].data[i]) * (original->comps[compno].data[i] - decoded->comps[compno].data[i]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
} else {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0);
|
||||
for (compno = 0; compno < original->numcomps; compno++) {
|
||||
for(sum = 0, i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i] < 0) || (decoded->comps[compno].data[i] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i] - decoded->comps[compno].data[i]) * (original->comps[compno].data[i] - decoded->comps[compno].data[i]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
} else {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0);
|
||||
|
||||
for (k = 0; k < original->z1 - original->z0; k++) {
|
||||
int offset = k * size;
|
||||
for (sum = 0, compno = 0; compno < original->numcomps; compno++) {
|
||||
for(i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i + offset] < 0) || (decoded->comps[compno].data[i + offset] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]) * (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = total + ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
}
|
||||
for (k = 0; k < original->z1 - original->z0; k++) {
|
||||
int offset = k * size;
|
||||
for (sum = 0, compno = 0; compno < original->numcomps; compno++) {
|
||||
for(i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i + offset] < 0) || (decoded->comps[compno].data[i + offset] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]) * (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = total + ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
}
|
||||
|
||||
}
|
||||
if(total == 0) /* perfect reconstruction, PSNR should return infinity */
|
||||
return -1.0;
|
||||
}
|
||||
if(total == 0) /* perfect reconstruction, PSNR should return infinity */
|
||||
return -1.0;
|
||||
|
||||
return total;
|
||||
/*return 20 * log10((max - 1) / sqrt(sum));*/
|
||||
return total;
|
||||
/*return 20 * log10((max - 1) / sqrt(sum));*/
|
||||
}
|
||||
|
||||
static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||
{
|
||||
int max, i, compno = 0, size, sizeM;
|
||||
double sum;
|
||||
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
||||
sigmaxy = 0.0/*, structx = 0.0, structy = 0.0*/;
|
||||
double lcomp,ccomp,scomp;
|
||||
double C1,C2,C3;
|
||||
int max, i, compno = 0, size, sizeM;
|
||||
double sum;
|
||||
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
||||
sigmaxy = 0.0/*, structx = 0.0, structy = 0.0*/;
|
||||
double lcomp,ccomp,scomp;
|
||||
double C1,C2,C3;
|
||||
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
|
||||
/*MSSIM*/
|
||||
/*MSSIM*/
|
||||
|
||||
/* sizeM = size / (original->z1 - original->z0);*/
|
||||
/* sizeM = size / (original->z1 - original->z0);*/
|
||||
|
||||
sizeM = size;
|
||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||
/* First, the luminance of each signal is compared.*/
|
||||
mux += original->comps[compno].data[i];
|
||||
muy += decoded->comps[compno].data[i];
|
||||
}
|
||||
mux /= sizeM;
|
||||
muy /= sizeM;
|
||||
|
||||
/*We use the standard deviation (the square root of variance) as an estimate of the signal contrast.*/
|
||||
sizeM = size;
|
||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||
/* First, the luminance of each signal is compared.*/
|
||||
sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
|
||||
sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
|
||||
sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
|
||||
}
|
||||
sigmax /= sizeM - 1;
|
||||
sigmay /= sizeM - 1;
|
||||
sigmaxy /= sizeM - 1;
|
||||
/* First, the luminance of each signal is compared.*/
|
||||
mux += original->comps[compno].data[i];
|
||||
muy += decoded->comps[compno].data[i];
|
||||
}
|
||||
mux /= sizeM;
|
||||
muy /= sizeM;
|
||||
|
||||
sigmax = sqrt(sigmax);
|
||||
sigmay = sqrt(sigmay);
|
||||
sigmaxy = sqrt(sigmaxy);
|
||||
/*We use the standard deviation (the square root of variance) as an estimate of the signal contrast.*/
|
||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||
/* First, the luminance of each signal is compared.*/
|
||||
sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
|
||||
sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
|
||||
sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
|
||||
}
|
||||
sigmax /= sizeM - 1;
|
||||
sigmay /= sizeM - 1;
|
||||
sigmaxy /= sizeM - 1;
|
||||
|
||||
/*Third, the signal is normalized (divided) by its own standard deviation, */
|
||||
/*so that the two signals being compared have unit standard deviation.*/
|
||||
sigmax = sqrt(sigmax);
|
||||
sigmay = sqrt(sigmay);
|
||||
sigmaxy = sqrt(sigmaxy);
|
||||
|
||||
/*Luminance comparison*/
|
||||
C1 = (0.01 * max) * (0.01 * max);
|
||||
lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
|
||||
/*Constrast comparison*/
|
||||
C2 = (0.03 * max) * (0.03 * max);
|
||||
ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
|
||||
/*Structure comparison*/
|
||||
C3 = C2 / 2;
|
||||
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
||||
/*Similarity measure*/
|
||||
/*Third, the signal is normalized (divided) by its own standard deviation, */
|
||||
/*so that the two signals being compared have unit standard deviation.*/
|
||||
|
||||
sum = lcomp * ccomp * scomp;
|
||||
return sum;
|
||||
/*Luminance comparison*/
|
||||
C1 = (0.01 * max) * (0.01 * max);
|
||||
lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
|
||||
/*Constrast comparison*/
|
||||
C2 = (0.03 * max) * (0.03 * max);
|
||||
ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
|
||||
/*Structure comparison*/
|
||||
C3 = C2 / 2;
|
||||
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
||||
/*Similarity measure*/
|
||||
|
||||
sum = lcomp * ccomp * scomp;
|
||||
return sum;
|
||||
}
|
||||
|
||||
void decode_help_display() {
|
||||
fprintf(stdout,"HELP\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
void decode_help_display()
|
||||
{
|
||||
fprintf(stdout,"HELP\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Required arguments \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -i <compressed file> ( *.jp3d, *.j3d )\n");
|
||||
fprintf(stdout," Currently accepts J3D-files. The file type is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <decompressed file> ( *.pgx, *.bin )\n");
|
||||
fprintf(stdout," Currently accepts PGX-files and BIN-files. Binary data is written to the file (not ascii). \n");
|
||||
fprintf(stdout," If a PGX filename is given, there will be as many output files as slices; \n");
|
||||
fprintf(stdout," an indice starting from 0 will then be appended to the output filename,\n");
|
||||
fprintf(stdout," just before the \"pgx\" extension.\n");
|
||||
fprintf(stdout," -m <characteristics file> ( *.img ) \n");
|
||||
fprintf(stdout," Required only for BIN-files. Ascii data of volume characteristics is written. \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Optional \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -h \n ");
|
||||
fprintf(stdout," Display the help information\n");
|
||||
fprintf(stdout," -r <RFx,RFy,RFz>\n");
|
||||
fprintf(stdout," Set the number of highest resolution levels to be discarded on each dimension. \n");
|
||||
fprintf(stdout," The volume resolution is effectively divided by 2 to the power of the\n");
|
||||
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
|
||||
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
|
||||
fprintf(stdout," -l <number of quality layers to decode>\n");
|
||||
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
|
||||
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
|
||||
fprintf(stdout," are decoded. \n");
|
||||
fprintf(stdout," -O original-file \n");
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Required arguments \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -i <compressed file> ( *.jp3d, *.j3d )\n");
|
||||
fprintf(stdout," Currently accepts J3D-files. The file type is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <decompressed file> ( *.pgx, *.bin )\n");
|
||||
fprintf(stdout," Currently accepts PGX-files and BIN-files. Binary data is written to the file (not ascii). \n");
|
||||
fprintf(stdout," If a PGX filename is given, there will be as many output files as slices; \n");
|
||||
fprintf(stdout," an indice starting from 0 will then be appended to the output filename,\n");
|
||||
fprintf(stdout," just before the \"pgx\" extension.\n");
|
||||
fprintf(stdout," -m <characteristics file> ( *.img ) \n");
|
||||
fprintf(stdout," Required only for BIN-files. Ascii data of volume characteristics is written. \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Optional \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -h \n ");
|
||||
fprintf(stdout," Display the help information\n");
|
||||
fprintf(stdout," -r <RFx,RFy,RFz>\n");
|
||||
fprintf(stdout," Set the number of highest resolution levels to be discarded on each dimension. \n");
|
||||
fprintf(stdout," The volume resolution is effectively divided by 2 to the power of the\n");
|
||||
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
|
||||
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
|
||||
fprintf(stdout," -l <number of quality layers to decode>\n");
|
||||
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
|
||||
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
|
||||
fprintf(stdout," are decoded. \n");
|
||||
fprintf(stdout," -O original-file \n");
|
||||
fprintf(stdout," This option offers the possibility to compute some quality results \n");
|
||||
fprintf(stdout," for the decompressed volume, like the PSNR value achieved or the global SSIM value. \n");
|
||||
fprintf(stdout," Needs the original file in order to compare with the new one.\n");
|
||||
fprintf(stdout," for the decompressed volume, like the PSNR value achieved or the global SSIM value. \n");
|
||||
fprintf(stdout," Needs the original file in order to compare with the new one.\n");
|
||||
fprintf(stdout," NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions) \n");
|
||||
fprintf(stdout," NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option. \n");
|
||||
fprintf(stdout," (i.e. -O original-BIN-file -m original-IMG-file) \n");
|
||||
fprintf(stdout," -BE \n");
|
||||
fprintf(stdout," Define that the recovered volume data will be saved with big endian byte order.\n");
|
||||
fprintf(stdout," By default, little endian byte order is used.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," (i.e. -O original-BIN-file -m original-IMG-file) \n");
|
||||
fprintf(stdout," -BE \n");
|
||||
fprintf(stdout," Define that the recovered volume data will be saved with big endian byte order.\n");
|
||||
fprintf(stdout," By default, little endian byte order is used.\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
int i;
|
||||
static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
|
||||
static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
|
||||
char * ext = strrchr(filename, '.');
|
||||
if(ext) {
|
||||
ext++;
|
||||
for(i = 0; i < sizeof(format) / sizeof(format[0]); i++) {
|
||||
if(strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
int get_file_format(char *filename)
|
||||
{
|
||||
int i;
|
||||
static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
|
||||
static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
|
||||
char * ext = strrchr(filename, '.');
|
||||
if(ext) {
|
||||
ext++;
|
||||
for(i = 0; i < sizeof(format) / sizeof(format[0]); i++) {
|
||||
if(strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
|
||||
/* parse the command line */
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||
{
|
||||
/* parse the command line */
|
||||
|
||||
while (1) {
|
||||
int c = opj_getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = opj_optarg;
|
||||
parameters->decod_format = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J3D_CFMT:
|
||||
case J2K_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unknown format for infile %s [only *.j3d]!! \n", infile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->infile, infile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||
while (1) {
|
||||
int c = opj_getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': { /* input file */
|
||||
char *infile = opj_optarg;
|
||||
parameters->decod_format = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J3D_CFMT:
|
||||
case J2K_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unknown format for infile %s [only *.j3d]!! \n", infile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->infile, infile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm': /* img file */
|
||||
{
|
||||
char *imgfile = opj_optarg;
|
||||
int imgformat = get_file_format(imgfile);
|
||||
switch(imgformat) {
|
||||
case IMG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
|
||||
}
|
||||
break;
|
||||
case 'm': { /* img file */
|
||||
char *imgfile = opj_optarg;
|
||||
int imgformat = get_file_format(imgfile);
|
||||
switch(imgformat) {
|
||||
case IMG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = opj_optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for outfile : %s [accept only *.pgx or *.bin] !!\n\n", outfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||
case 'o': { /* output file */
|
||||
char *outfile = opj_optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for outfile : %s [accept only *.pgx or *.bin] !!\n\n", outfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'O': /* Original image for PSNR computing */
|
||||
{
|
||||
char *original = opj_optarg;
|
||||
parameters->orig_format = get_file_format(original);
|
||||
switch(parameters->orig_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for original file : %s [accept only *.pgx or *.bin] !!\n\n", original);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->original, original, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Original file: %s \n", parameters->original);
|
||||
}
|
||||
break;
|
||||
case 'O': { /* Original image for PSNR computing */
|
||||
char *original = opj_optarg;
|
||||
parameters->orig_format = get_file_format(original);
|
||||
switch(parameters->orig_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for original file : %s [accept only *.pgx or *.bin] !!\n\n", original);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->original, original, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Original file: %s \n", parameters->original);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'r': /* reduce option */
|
||||
{
|
||||
/*sscanf(opj_optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);*/
|
||||
int aux;
|
||||
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||
if (aux == 2)
|
||||
parameters->cp_reduce[2] = 0;
|
||||
else if (aux == 1) {
|
||||
parameters->cp_reduce[1] = parameters->cp_reduce[0];
|
||||
parameters->cp_reduce[2] = 0;
|
||||
}else if (aux == 0){
|
||||
parameters->cp_reduce[0] = 0;
|
||||
parameters->cp_reduce[1] = 0;
|
||||
parameters->cp_reduce[2] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'r': { /* reduce option */
|
||||
/*sscanf(opj_optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);*/
|
||||
int aux;
|
||||
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||
if (aux == 2)
|
||||
parameters->cp_reduce[2] = 0;
|
||||
else if (aux == 1) {
|
||||
parameters->cp_reduce[1] = parameters->cp_reduce[0];
|
||||
parameters->cp_reduce[2] = 0;
|
||||
} else if (aux == 0) {
|
||||
parameters->cp_reduce[0] = 0;
|
||||
parameters->cp_reduce[1] = 0;
|
||||
parameters->cp_reduce[2] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
case 'l': { /* layering option */
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'B': /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
{
|
||||
parameters->bigendian = 1;
|
||||
}
|
||||
break;
|
||||
case 'B': { /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
parameters->bigendian = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'L': /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
{
|
||||
parameters->decod_format = LSE_CFMT;
|
||||
}
|
||||
break;
|
||||
case 'L': { /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
parameters->decod_format = LSE_CFMT;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
{
|
||||
decode_help_display();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'h': { /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for possible errors */
|
||||
/* check for possible errors */
|
||||
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stdout,"[ERROR] At least one required argument is missing\n Check jp3d_to_volume -help for usage information\n");
|
||||
return 1;
|
||||
}
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stdout,"[ERROR] At least one required argument is missing\n Check jp3d_to_volume -help for usage information\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -375,168 +369,180 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_volume_t *volume = NULL;
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_volume_t *volume = NULL;
|
||||
|
||||
opj_volume_t *original = NULL;
|
||||
opj_cparameters_t cparameters; /* original parameters */
|
||||
opj_volume_t *original = NULL;
|
||||
opj_cparameters_t cparameters; /* original parameters */
|
||||
|
||||
FILE *fsrc = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int decodeok;
|
||||
double psnr, ssim;
|
||||
FILE *fsrc = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int decodeok;
|
||||
double psnr, ssim;
|
||||
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
|
||||
/* configure the event callbacks (not required) */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
/* configure the event callbacks (not required) */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* parse input and get user decoding parameters */
|
||||
strcpy(parameters.original,"NULL");
|
||||
strcpy(parameters.imgfile,"NULL");
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters) == 1) {
|
||||
return 0;
|
||||
}
|
||||
strcpy(parameters.original,"NULL");
|
||||
strcpy(parameters.imgfile,"NULL");
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters) == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fprintf(stdout, "[INFO] Loading %s file \n",parameters.decod_format==J3D_CFMT ? ".jp3d" : ".j2k");
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fprintf(stdout, "[INFO] Loading %s file \n",parameters.decod_format==J3D_CFMT ? ".jp3d" : ".j2k");
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
if (parameters.decod_format == J3D_CFMT || parameters.decod_format == J2K_CFMT) {
|
||||
/* get a JP3D or J2K decoder handle */
|
||||
if (parameters.decod_format == J3D_CFMT)
|
||||
dinfo = opj_create_decompress(CODEC_J3D);
|
||||
else if (parameters.decod_format == J2K_CFMT)
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
if (parameters.decod_format == J3D_CFMT || parameters.decod_format == J2K_CFMT) {
|
||||
/* get a JP3D or J2K decoder handle */
|
||||
if (parameters.decod_format == J3D_CFMT)
|
||||
dinfo = opj_create_decompress(CODEC_J3D);
|
||||
else if (parameters.decod_format == J2K_CFMT)
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the volume structure */
|
||||
volume = opj_decode(dinfo, cio);
|
||||
if(!volume) {
|
||||
fprintf(stdout, "[ERROR] jp3d_to_volume: failed to decode volume!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
/* decode the stream and fill the volume structure */
|
||||
volume = opj_decode(dinfo, cio);
|
||||
if(!volume) {
|
||||
fprintf(stdout, "[ERROR] jp3d_to_volume: failed to decode volume!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
}
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
/* create output volume */
|
||||
/* ------------------- */
|
||||
/* create output volume */
|
||||
/* ------------------- */
|
||||
|
||||
switch (parameters.cod_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
decodeok = volumetopgx(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
switch (parameters.cod_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
decodeok = volumetopgx(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
|
||||
case BIN_DFMT: /* BMP */
|
||||
decodeok = volumetobin(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
}
|
||||
switch (parameters.orig_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
if (strcmp("NULL",parameters.original) != 0){
|
||||
fprintf(stdout,"Loading original file %s \n",parameters.original);
|
||||
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
|
||||
original = pgxtovolume(parameters.original,&cparameters);
|
||||
}
|
||||
break;
|
||||
case BIN_DFMT: /* BMP */
|
||||
decodeok = volumetobin(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
}
|
||||
switch (parameters.orig_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
if (strcmp("NULL",parameters.original) != 0) {
|
||||
fprintf(stdout,"Loading original file %s \n",parameters.original);
|
||||
cparameters.subsampling_dx = 1;
|
||||
cparameters.subsampling_dy = 1;
|
||||
cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;
|
||||
cparameters.volume_offset_y0 = 0;
|
||||
cparameters.volume_offset_z0 = 0;
|
||||
original = pgxtovolume(parameters.original,&cparameters);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIN_DFMT: /* BMP */
|
||||
if (strcmp("NULL",parameters.original) != 0 && strcmp("NULL",parameters.imgfile) != 0){
|
||||
fprintf(stdout,"Loading original file %s %s\n",parameters.original,parameters.imgfile);
|
||||
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
|
||||
original = bintovolume(parameters.original,parameters.imgfile,&cparameters);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BIN_DFMT: /* BMP */
|
||||
if (strcmp("NULL",parameters.original) != 0 && strcmp("NULL",parameters.imgfile) != 0) {
|
||||
fprintf(stdout,"Loading original file %s %s\n",parameters.original,parameters.imgfile);
|
||||
cparameters.subsampling_dx = 1;
|
||||
cparameters.subsampling_dy = 1;
|
||||
cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;
|
||||
cparameters.volume_offset_y0 = 0;
|
||||
cparameters.volume_offset_z0 = 0;
|
||||
original = bintovolume(parameters.original,parameters.imgfile,&cparameters);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n ",
|
||||
(volume->comps[0].w >> volume->comps[0].factor[0]),
|
||||
(volume->comps[0].h >> volume->comps[0].factor[1]),
|
||||
(volume->comps[0].l >> volume->comps[0].factor[2]),
|
||||
volume->comps[0].prec);
|
||||
fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n ",
|
||||
(volume->comps[0].w >> volume->comps[0].factor[0]),
|
||||
(volume->comps[0].h >> volume->comps[0].factor[1]),
|
||||
(volume->comps[0].l >> volume->comps[0].factor[2]),
|
||||
volume->comps[0].prec);
|
||||
|
||||
if(original){
|
||||
psnr = calc_PSNR(original,volume);
|
||||
ssim = calc_SSIM(original,volume);
|
||||
if (psnr < 0.0)
|
||||
fprintf(stdout, " PSNR: Inf , SSMI %f -- Perfect reconstruction!\n",ssim);
|
||||
else
|
||||
fprintf(stdout, " PSNR: %f , SSIM %f \n",psnr,ssim);
|
||||
}
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
if(original) {
|
||||
psnr = calc_PSNR(original,volume);
|
||||
ssim = calc_SSIM(original,volume);
|
||||
if (psnr < 0.0)
|
||||
fprintf(stdout, " PSNR: Inf , SSMI %f -- Perfect reconstruction!\n",ssim);
|
||||
else
|
||||
fprintf(stdout, " PSNR: %f , SSIM %f \n",psnr,ssim);
|
||||
}
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
|
||||
/* free volume data structure */
|
||||
opj_volume_destroy(volume);
|
||||
/* free volume data structure */
|
||||
opj_volume_destroy(volume);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,14 +105,14 @@
|
||||
*/
|
||||
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__MINGW32__) /* MinGW */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||
# define HAVE_DIRENT_H
|
||||
# define VOID_CLOSEDIR
|
||||
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||
# define HAVE_DIRECT_H
|
||||
# elif defined(__apollo) /* Apollo */
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
#elif defined(MSDOS) || defined(WIN32)
|
||||
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
# if defined(WIN32)
|
||||
# define DIRENT_WIN32_INTERFACE
|
||||
# elif defined(MSDOS)
|
||||
@@ -180,7 +180,7 @@
|
||||
# error "missing native dirent interface"
|
||||
# endif
|
||||
|
||||
/*** WIN32 specifics ***/
|
||||
/*** WIN32 specifics ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
# include <windows.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -188,11 +188,11 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*** MS-DOS specifics ***/
|
||||
/*** MS-DOS specifics ***/
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# include <dos.h>
|
||||
|
||||
/* Borland defines file length macros in dir.h */
|
||||
/* Borland defines file length macros in dir.h */
|
||||
# if defined(__BORLANDC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -202,7 +202,7 @@
|
||||
# define _find_t find_t
|
||||
# endif
|
||||
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
# elif defined(__TURBOC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -210,13 +210,13 @@
|
||||
# endif
|
||||
# define DIRENT_USE_FFBLK
|
||||
|
||||
/* MSVC */
|
||||
/* MSVC */
|
||||
# elif defined(_MSC_VER)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# define DIRENT_MAXNAMLEN (12)
|
||||
# endif
|
||||
|
||||
/* Watcom */
|
||||
/* Watcom */
|
||||
# elif defined(__WATCOMC__)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# if defined(__OS2__) || defined(__NT__)
|
||||
@@ -229,7 +229,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||
# endif
|
||||
@@ -238,16 +238,16 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer refering the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer referring the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
char d_name[NAME_MAX + 1];
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
@@ -260,21 +260,21 @@
|
||||
struct _find_t data;
|
||||
# endif
|
||||
# endif
|
||||
} dirent;
|
||||
} dirent;
|
||||
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
char *dirname; /* directory being scanned */
|
||||
dirent current; /* current entry */
|
||||
int dirent_filled; /* is current un-processed? */
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
/*** Operating system specific part ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
HANDLE search_handle;
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# endif
|
||||
} DIR;
|
||||
} DIR;
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -343,46 +343,45 @@ static void _setdirname (struct DIR *dirp);
|
||||
*/
|
||||
static DIR *opendir(const char *dirname)
|
||||
{
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
|
||||
{
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
# ifdef DIRENT_WIN32_INTERFACE
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
# else
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
# endif
|
||||
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +409,7 @@ static DIR *opendir(const char *dirname)
|
||||
* capacity of d_name with different macros and some systems do not define
|
||||
* capacity at all (besides actual declaration of the field). If you really
|
||||
* need to find out storage capacity of d_name then you might want to try
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard although
|
||||
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||
@@ -435,55 +434,55 @@ static DIR *opendir(const char *dirname)
|
||||
static struct dirent *
|
||||
readdir (DIR *dirp)
|
||||
{
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occured */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occurred */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
}
|
||||
|
||||
|
||||
@@ -509,36 +508,36 @@ readdir (DIR *dirp)
|
||||
static int
|
||||
closedir (DIR *dirp)
|
||||
{
|
||||
int retcode = 0;
|
||||
int retcode = 0;
|
||||
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
# endif
|
||||
|
||||
free (dirp);
|
||||
return retcode;
|
||||
free (dirp);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
|
||||
@@ -566,30 +565,30 @@ closedir (DIR *dirp)
|
||||
static void
|
||||
rewinddir (DIR *dirp)
|
||||
{
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -600,36 +599,35 @@ rewinddir (DIR *dirp)
|
||||
static int
|
||||
_initdir (DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0)
|
||||
{
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0) {
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -640,13 +638,13 @@ static const char *
|
||||
_getdirname (const struct dirent *dp)
|
||||
{
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
return dp->data.cFileName;
|
||||
return dp->data.cFileName;
|
||||
|
||||
#elif defined(DIRENT_USE_FFBLK)
|
||||
return dp->data.ff_name;
|
||||
return dp->data.ff_name;
|
||||
|
||||
#else
|
||||
return dp->data.name;
|
||||
return dp->data.name;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -655,14 +653,15 @@ _getdirname (const struct dirent *dp)
|
||||
* Copy name of implementation dependent directory entry to the d_name field.
|
||||
*/
|
||||
static void
|
||||
_setdirname (struct DIR *dirp) {
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
_setdirname (struct DIR *dirp)
|
||||
{
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
}
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: opj_dec_server.c 54 2011-05-10 13:22:47Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -54,40 +54,41 @@
|
||||
WSADATA initialisation_win32;
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
dec_server_record_t *server_record;
|
||||
client_t client;
|
||||
int port = 50000;
|
||||
int erreur;
|
||||
(void)erreur;
|
||||
dec_server_record_t *server_record;
|
||||
client_t client;
|
||||
int port = 50000;
|
||||
int erreur;
|
||||
(void)erreur;
|
||||
|
||||
if( argc > 1)
|
||||
port = atoi( argv[1]);
|
||||
if( argc > 1)
|
||||
port = atoi( argv[1]);
|
||||
|
||||
#ifdef _WIN32
|
||||
erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
if( erreur!=0)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
printf( "Initialisation Winsock\n");
|
||||
erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
if( erreur!=0)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
printf( "Initialisation Winsock\n");
|
||||
#endif /*_WIN32*/
|
||||
|
||||
server_record = init_dec_server( port);
|
||||
server_record = init_dec_server( port);
|
||||
|
||||
while(( client = accept_connection( server_record)) != -1 )
|
||||
if(!handle_clientreq( client, server_record))
|
||||
break;
|
||||
while(( client = accept_connection( server_record)) != -1 )
|
||||
if(!handle_clientreq( client, server_record))
|
||||
break;
|
||||
|
||||
terminate_dec_server( &server_record);
|
||||
terminate_dec_server( &server_record);
|
||||
|
||||
#ifdef _WIN32
|
||||
if( WSACleanup() != 0){
|
||||
printf("\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
|
||||
}else{
|
||||
printf("\nWSACleanup OK\n");
|
||||
}
|
||||
if( WSACleanup() != 0) {
|
||||
printf("\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
|
||||
} else {
|
||||
printf("\nWSACleanup OK\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: addXMLinJP2.c 46 2011-02-17 14:50:55Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -74,111 +74,111 @@ char * read_xmlfile( const char filename[], long *fsize);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp;
|
||||
char *xmldata, type[]="xml ";
|
||||
long fsize, boxsize;
|
||||
FILE *fp;
|
||||
char *xmldata, type[]="xml ";
|
||||
long fsize, boxsize;
|
||||
|
||||
if( argc<3){
|
||||
fprintf( stderr, "USAGE: %s modifing.jp2 adding.xml\n", argv[0] );
|
||||
return -1;
|
||||
}
|
||||
if( argc<3) {
|
||||
fprintf( stderr, "USAGE: %s modifing.jp2 adding.xml\n", argv[0] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
fp = open_jp2file( argv[1]);
|
||||
if( !fp)
|
||||
return -1;
|
||||
fp = open_jp2file( argv[1]);
|
||||
if( !fp)
|
||||
return -1;
|
||||
|
||||
xmldata = read_xmlfile( argv[2], &fsize);
|
||||
if( fsize < 0 ) return -1;
|
||||
boxsize = fsize + 8;
|
||||
xmldata = read_xmlfile( argv[2], &fsize);
|
||||
if( fsize < 0 ) return -1;
|
||||
boxsize = fsize + 8;
|
||||
|
||||
fputc( (boxsize>>24)&0xff, fp);
|
||||
fputc( (boxsize>>16)&0xff, fp);
|
||||
fputc( (boxsize>>8)&0xff, fp);
|
||||
fputc( boxsize&0xff, fp);
|
||||
fwrite( type, 4, 1, fp);
|
||||
fwrite( xmldata, (size_t)fsize, 1, fp);
|
||||
fputc( (boxsize>>24)&0xff, fp);
|
||||
fputc( (boxsize>>16)&0xff, fp);
|
||||
fputc( (boxsize>>8)&0xff, fp);
|
||||
fputc( boxsize&0xff, fp);
|
||||
fwrite( type, 4, 1, fp);
|
||||
fwrite( xmldata, (size_t)fsize, 1, fp);
|
||||
|
||||
free( xmldata);
|
||||
fclose(fp);
|
||||
free( xmldata);
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE * open_jp2file( const char filename[])
|
||||
{
|
||||
FILE *fp;
|
||||
char *data;
|
||||
FILE *fp;
|
||||
char *data;
|
||||
|
||||
if( !(fp = fopen( filename, "a+b"))){
|
||||
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
/* Check resource is a JP family file. */
|
||||
if( fseek( fp, 0, SEEK_SET)==-1){
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
if( !(fp = fopen( filename, "a+b"))) {
|
||||
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
/* Check resource is a JP family file. */
|
||||
if( fseek( fp, 0, SEEK_SET)==-1) {
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( 12); /* size of header */
|
||||
if( fread( data, 12, 1, fp) != 1){
|
||||
data = (char *)malloc( 12); /* size of header */
|
||||
if( fread( data, 12, 1, fp) != 1) {
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (read error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( *data || *(data + 1) || *(data + 2) ||
|
||||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)) {
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "No JPEG 2000 Signature box in target %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (read error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( *data || *(data + 1) || *(data + 2) ||
|
||||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "No JPEG 2000 Signature box in target %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
free( data);
|
||||
return fp;
|
||||
return fp;
|
||||
}
|
||||
|
||||
char * read_xmlfile( const char filename[], long *fsize)
|
||||
{
|
||||
FILE *fp;
|
||||
char *data;
|
||||
FILE *fp;
|
||||
char *data;
|
||||
|
||||
/* fprintf( stderr, "open %s\n", filename);*/
|
||||
if(!(fp = fopen( filename, "r"))){
|
||||
fprintf( stderr, "XML file %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
/* fprintf( stderr, "open %s\n", filename);*/
|
||||
if(!(fp = fopen( filename, "r"))) {
|
||||
fprintf( stderr, "XML file %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( fseek( fp, 0, SEEK_END) == -1) {
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( (*fsize = ftell( fp)) == -1) {
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
assert( *fsize >= 0 );
|
||||
|
||||
if( fseek( fp, 0, SEEK_SET) == -1) {
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( (size_t)*fsize);
|
||||
|
||||
if( fread( data, (size_t)*fsize, 1, fp) != 1) {
|
||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||
free( data);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( fseek( fp, 0, SEEK_END) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( (*fsize = ftell( fp)) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
assert( *fsize >= 0 );
|
||||
|
||||
if( fseek( fp, 0, SEEK_SET) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( (size_t)*fsize);
|
||||
|
||||
if( fread( data, (size_t)*fsize, 1, fp) != 1){
|
||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||
free( data);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fclose( fp);
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: test_index.c 46 2011-02-17 14:50:55Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -51,23 +51,23 @@
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
index_t *jp2idx;
|
||||
if( argc < 2 ) return 1;
|
||||
int fd;
|
||||
index_t *jp2idx;
|
||||
if( argc < 2 ) return 1;
|
||||
|
||||
if( (fd = open( argv[1], O_RDONLY)) == -1){
|
||||
fprintf( stderr, "Error: Target %s not found\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
if( (fd = open( argv[1], O_RDONLY)) == -1) {
|
||||
fprintf( stderr, "Error: Target %s not found\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !(jp2idx = get_index_from_JP2file( fd))){
|
||||
fprintf( stderr, "JP2 file broken\n");
|
||||
return -1;
|
||||
}
|
||||
if( !(jp2idx = get_index_from_JP2file( fd))) {
|
||||
fprintf( stderr, "JP2 file broken\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
output_index( jp2idx);
|
||||
destroy_index( &jp2idx);
|
||||
close(fd);
|
||||
output_index( jp2idx);
|
||||
destroy_index( &jp2idx);
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -44,23 +44,23 @@
|
||||
*/
|
||||
static int jpip_to_jp2(char *argv[])
|
||||
{
|
||||
jpip_dec_param_t *dec;
|
||||
jpip_dec_param_t *dec;
|
||||
|
||||
dec = init_jpipdecoder( OPJ_TRUE);
|
||||
dec = init_jpipdecoder( OPJ_TRUE);
|
||||
|
||||
if(!( fread_jpip( argv[1], dec)))
|
||||
return 1;
|
||||
if(!( fread_jpip( argv[1], dec)))
|
||||
return 1;
|
||||
|
||||
decode_jpip( dec);
|
||||
decode_jpip( dec);
|
||||
|
||||
if(!(fwrite_jp2k( argv[2], dec)))
|
||||
return 1;
|
||||
if(!(fwrite_jp2k( argv[2], dec)))
|
||||
return 1;
|
||||
|
||||
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_TRUE, dec); */
|
||||
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_TRUE, dec); */
|
||||
|
||||
destroy_jpipdecoder( &dec);
|
||||
destroy_jpipdecoder( &dec);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \file
|
||||
@@ -76,49 +76,46 @@ static int jpip_to_jp2(char *argv[])
|
||||
*/
|
||||
static int jpip_to_j2k(char *argv[])
|
||||
{
|
||||
jpip_dec_param_t *dec;
|
||||
jpip_dec_param_t *dec;
|
||||
|
||||
dec = init_jpipdecoder( OPJ_FALSE);
|
||||
dec = init_jpipdecoder( OPJ_FALSE);
|
||||
|
||||
if(!( fread_jpip( argv[1], dec)))
|
||||
return 1;
|
||||
if(!( fread_jpip( argv[1], dec)))
|
||||
return 1;
|
||||
|
||||
decode_jpip( dec);
|
||||
decode_jpip( dec);
|
||||
|
||||
if(!(fwrite_jp2k( argv[2], dec)))
|
||||
return 1;
|
||||
if(!(fwrite_jp2k( argv[2], dec)))
|
||||
return 1;
|
||||
|
||||
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_FALSE, dec); */
|
||||
/* output_log( OPJ_TRUE, OPJ_FALSE, OPJ_FALSE, dec); */
|
||||
|
||||
destroy_jpipdecoder( &dec);
|
||||
destroy_jpipdecoder( &dec);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *ext;
|
||||
if( argc < 3){
|
||||
fprintf( stderr, "Too few arguments:\n");
|
||||
fprintf( stderr, " - input jpt or jpp file\n");
|
||||
fprintf( stderr, " - output j2k file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ext = strrchr( argv[2], '.' );
|
||||
if( ext )
|
||||
{
|
||||
/* strcasecmp ? */
|
||||
if( strcmp(ext, ".jp2" ) == 0 )
|
||||
{
|
||||
return jpip_to_jp2(argv);
|
||||
}
|
||||
if( strcmp(ext, ".j2k" ) == 0 )
|
||||
{
|
||||
return jpip_to_j2k(argv);
|
||||
}
|
||||
char *ext;
|
||||
if( argc < 3) {
|
||||
fprintf( stderr, "Too few arguments:\n");
|
||||
fprintf( stderr, " - input jpt or jpp file\n");
|
||||
fprintf( stderr, " - output j2k file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf( stderr, "Invalid file extension for output file: %s\n", argv[2]);
|
||||
return 1;
|
||||
ext = strrchr( argv[2], '.' );
|
||||
if( ext ) {
|
||||
/* strcasecmp ? */
|
||||
if( strcmp(ext, ".jp2" ) == 0 ) {
|
||||
return jpip_to_jp2(argv);
|
||||
}
|
||||
if( strcmp(ext, ".j2k" ) == 0 ) {
|
||||
return jpip_to_j2k(argv);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( stderr, "Invalid file extension for output file: %s\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: opj_server.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
@@ -61,68 +61,68 @@ WSADATA initialisation_win32;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
server_record_t *server_record;
|
||||
server_record_t *server_record;
|
||||
#ifdef SERVER
|
||||
char *query_string;
|
||||
char *query_string;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
if( erreur!=0)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
fprintf( stderr, "Initialisation Winsock\n");
|
||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
if( erreur!=0)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
fprintf( stderr, "Initialisation Winsock\n");
|
||||
#endif /*_WIN32*/
|
||||
|
||||
server_record = init_JPIPserver( 60000, 0);
|
||||
server_record = init_JPIPserver( 60000, 0);
|
||||
|
||||
#ifdef SERVER
|
||||
while(FCGI_Accept() >= 0)
|
||||
while(FCGI_Accept() >= 0)
|
||||
#else
|
||||
|
||||
char query_string[128];
|
||||
while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
|
||||
char query_string[128];
|
||||
while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
|
||||
#endif
|
||||
{
|
||||
QR_t *qr;
|
||||
OPJ_BOOL parse_status;
|
||||
QR_t *qr;
|
||||
OPJ_BOOL parse_status;
|
||||
|
||||
#ifdef SERVER
|
||||
query_string = getenv("QUERY_STRING");
|
||||
query_string = getenv("QUERY_STRING");
|
||||
#endif /*SERVER*/
|
||||
|
||||
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
||||
break;
|
||||
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
||||
break;
|
||||
|
||||
qr = parse_querystring( query_string);
|
||||
qr = parse_querystring( query_string);
|
||||
|
||||
parse_status = process_JPIPrequest( server_record, qr);
|
||||
parse_status = process_JPIPrequest( server_record, qr);
|
||||
|
||||
#ifndef SERVER
|
||||
local_log( OPJ_TRUE, OPJ_TRUE, parse_status, OPJ_FALSE, qr, server_record);
|
||||
local_log( OPJ_TRUE, OPJ_TRUE, parse_status, OPJ_FALSE, qr, server_record);
|
||||
#endif
|
||||
|
||||
if( parse_status)
|
||||
send_responsedata( server_record, qr);
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
}
|
||||
if( parse_status)
|
||||
send_responsedata( server_record, qr);
|
||||
else {
|
||||
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
}
|
||||
|
||||
end_QRprocess( server_record, &qr);
|
||||
end_QRprocess( server_record, &qr);
|
||||
}
|
||||
|
||||
fprintf( FCGI_stderr, "JPIP server terminated by a client request\n");
|
||||
fprintf( FCGI_stderr, "JPIP server terminated by a client request\n");
|
||||
|
||||
terminate_JPIPserver( &server_record);
|
||||
terminate_JPIPserver( &server_record);
|
||||
|
||||
#ifdef _WIN32
|
||||
if( WSACleanup() != 0){
|
||||
fprintf( stderr, "\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
|
||||
}else{
|
||||
fprintf( stderr, "\nWSACleanup OK\n");
|
||||
}
|
||||
if( WSACleanup() != 0) {
|
||||
fprintf( stderr, "\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
|
||||
} else {
|
||||
fprintf( stderr, "\nWSACleanup OK\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $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) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -34,17 +40,17 @@
|
||||
/**@name RAW image encoding parameters */
|
||||
/*@{*/
|
||||
typedef struct raw_cparameters {
|
||||
/** width of the raw image */
|
||||
int rawWidth;
|
||||
/** height of the raw image */
|
||||
int rawHeight;
|
||||
/** components of the raw image */
|
||||
int rawComp;
|
||||
/** bit depth of the raw image */
|
||||
int rawBitDepth;
|
||||
/** signed/unsigned raw image */
|
||||
opj_bool rawSigned;
|
||||
/*@}*/
|
||||
/** width of the raw image */
|
||||
int rawWidth;
|
||||
/** height of the raw image */
|
||||
int rawHeight;
|
||||
/** components of the raw image */
|
||||
int rawComp;
|
||||
/** bit depth of the raw image */
|
||||
int rawBitDepth;
|
||||
/** signed/unsigned raw image */
|
||||
opj_bool rawSigned;
|
||||
/*@}*/
|
||||
} raw_cparameters_t;
|
||||
|
||||
/* TGA conversion */
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -40,352 +45,353 @@ Write a structured index to a file
|
||||
@param index Index filename
|
||||
@return Returns 0 if successful, returns 1 otherwise
|
||||
*/
|
||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index)
|
||||
{
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
/* <<UniPG */
|
||||
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
int start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
int start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
|
||||
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
|
||||
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
|
||||
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
|
||||
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -106,14 +106,14 @@
|
||||
*/
|
||||
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__MINGW32__) /* MinGW */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||
# define HAVE_DIRENT_H
|
||||
# define VOID_CLOSEDIR
|
||||
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||
/* no dirent.h */
|
||||
/* no dirent.h */
|
||||
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||
# define HAVE_DIRECT_H
|
||||
# elif defined(__apollo) /* Apollo */
|
||||
@@ -172,7 +172,7 @@
|
||||
|
||||
#elif defined(MSDOS) || defined(WIN32)
|
||||
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
/* figure out type of underlaying directory interface to be used */
|
||||
# if defined(WIN32)
|
||||
# define DIRENT_WIN32_INTERFACE
|
||||
# elif defined(MSDOS)
|
||||
@@ -181,7 +181,7 @@
|
||||
# error "missing native dirent interface"
|
||||
# endif
|
||||
|
||||
/*** WIN32 specifics ***/
|
||||
/*** WIN32 specifics ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
# include <windows.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -189,11 +189,11 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*** MS-DOS specifics ***/
|
||||
/*** MS-DOS specifics ***/
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# include <dos.h>
|
||||
|
||||
/* Borland defines file length macros in dir.h */
|
||||
/* Borland defines file length macros in dir.h */
|
||||
# if defined(__BORLANDC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -203,7 +203,7 @@
|
||||
# define _find_t find_t
|
||||
# endif
|
||||
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
/* Turbo C defines ffblk structure in dir.h */
|
||||
# elif defined(__TURBOC__)
|
||||
# include <dir.h>
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
@@ -211,13 +211,13 @@
|
||||
# endif
|
||||
# define DIRENT_USE_FFBLK
|
||||
|
||||
/* MSVC */
|
||||
/* MSVC */
|
||||
# elif defined(_MSC_VER)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# define DIRENT_MAXNAMLEN (12)
|
||||
# endif
|
||||
|
||||
/* Watcom */
|
||||
/* Watcom */
|
||||
# elif defined(__WATCOMC__)
|
||||
# if !defined(DIRENT_MAXNAMLEN)
|
||||
# if defined(__OS2__) || defined(__NT__)
|
||||
@@ -230,7 +230,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||
# endif
|
||||
@@ -239,16 +239,16 @@
|
||||
# endif
|
||||
|
||||
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer refering the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
/*
|
||||
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||
* true character array although we have it copied in the implementation
|
||||
* dependent data. We could save some memory if we had declared `d_name'
|
||||
* as a pointer referring the name within implementation dependent data.
|
||||
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||
* something other than four. Besides, directory entries are typically so
|
||||
* small that it takes virtually no time to copy them from place to place.
|
||||
*/
|
||||
typedef struct dirent {
|
||||
char d_name[NAME_MAX + 1];
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
@@ -261,21 +261,21 @@
|
||||
struct _find_t data;
|
||||
# endif
|
||||
# endif
|
||||
} dirent;
|
||||
} dirent;
|
||||
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
/* DIR substitute structure containing directory name. The name is
|
||||
* essential for the operation of ``rewinndir'' function. */
|
||||
typedef struct DIR {
|
||||
char *dirname; /* directory being scanned */
|
||||
dirent current; /* current entry */
|
||||
int dirent_filled; /* is current un-processed? */
|
||||
|
||||
/*** Operating system specific part ***/
|
||||
/*** Operating system specific part ***/
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
HANDLE search_handle;
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
# endif
|
||||
} DIR;
|
||||
} DIR;
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -344,46 +344,45 @@ static void _setdirname (struct DIR *dirp);
|
||||
*/
|
||||
static DIR *opendir(const char *dirname)
|
||||
{
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
|
||||
{
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
/* allocate room for directory name */
|
||||
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||
if (dirp->dirname == NULL) {
|
||||
/* failed to duplicate directory name. errno set by malloc() */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
/* Copy directory name while appending directory separator and "*.*".
|
||||
* Directory separator is not appended if the name already ends with
|
||||
* drive or directory separator. Directory separator is assumed to be
|
||||
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||
strcpy (dirp->dirname, dirname);
|
||||
p = strchr (dirp->dirname, '\0');
|
||||
if (dirp->dirname < p &&
|
||||
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':') {
|
||||
strcpy (p++, "\\");
|
||||
}
|
||||
# ifdef DIRENT_WIN32_INTERFACE
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||
# else
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||
# endif
|
||||
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
/* open stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed */
|
||||
free (dirp->dirname);
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +410,7 @@ static DIR *opendir(const char *dirname)
|
||||
* capacity of d_name with different macros and some systems do not define
|
||||
* capacity at all (besides actual declaration of the field). If you really
|
||||
* need to find out storage capacity of d_name then you might want to try
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
|
||||
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard although
|
||||
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||
@@ -436,55 +435,55 @@ static DIR *opendir(const char *dirname)
|
||||
static struct dirent *
|
||||
readdir (DIR *dirp)
|
||||
{
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
assert(dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
if (dirp->dirent_filled != 0) {
|
||||
/*
|
||||
* Directory entry has already been retrieved and there is no need to
|
||||
* retrieve a new one. Directory entry will be retrieved in advance
|
||||
* when the user calls readdir function for the first time. This is so
|
||||
* because real dirent has separate functions for opening and reading
|
||||
* the stream whereas Win32 and DOS dirents open the stream
|
||||
* automatically when we retrieve the first file. Therefore, we have to
|
||||
* save the first file when opening the stream and later we have to
|
||||
* return the saved entry when the user tries to read the first entry.
|
||||
*/
|
||||
dirp->dirent_filled = 0;
|
||||
} else {
|
||||
/* fill in entry and return that */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occured */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* Last file has been processed or an error occurred */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
_setdirname (dirp);
|
||||
assert (dirp->dirent_filled == 0);
|
||||
}
|
||||
return &dirp->current;
|
||||
}
|
||||
|
||||
|
||||
@@ -510,36 +509,36 @@ readdir (DIR *dirp)
|
||||
static int
|
||||
closedir (DIR *dirp)
|
||||
{
|
||||
int retcode = 0;
|
||||
int retcode = 0;
|
||||
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
/* make sure that dirp points to legal structure */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
/* free directory name and search handles */
|
||||
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
retcode = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||
memset (dirp, 0, sizeof (*dirp));
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
# endif
|
||||
|
||||
free (dirp);
|
||||
return retcode;
|
||||
free (dirp);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
|
||||
@@ -567,30 +566,30 @@ closedir (DIR *dirp)
|
||||
static void
|
||||
rewinddir (DIR *dirp)
|
||||
{
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
/* make sure that dirp is legal */
|
||||
assert (dirp != NULL);
|
||||
if (dirp == NULL) {
|
||||
errno = EBADF;
|
||||
return;
|
||||
}
|
||||
assert (dirp->dirname != NULL);
|
||||
|
||||
/* close previous stream */
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
if (FindClose (dirp->search_handle) == FALSE) {
|
||||
/* Unknown error */
|
||||
errno = EBADF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
/* re-open previous stream */
|
||||
if (_initdir (dirp) == 0) {
|
||||
/* initialization failed but we cannot deal with error. User will notice
|
||||
* error later when she tries to retrieve first directory enty. */
|
||||
/*EMPTY*/;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -601,36 +600,35 @@ rewinddir (DIR *dirp)
|
||||
static int
|
||||
_initdir (DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
assert (dirp != NULL);
|
||||
assert (dirp->dirname != NULL);
|
||||
dirp->dirent_filled = 0;
|
||||
|
||||
# if defined(DIRENT_WIN32_INTERFACE)
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
/* Open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* something went wrong but we don't know what. GetLastError() could
|
||||
* give us more information about the error, but then we should map
|
||||
* the error code into errno. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0)
|
||||
{
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
if (_dos_findfirst (dirp->dirname,
|
||||
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||
&dirp->current.data) != 0) {
|
||||
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||
* more entries could be retrieved. */
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
/* initialize DIR and it's first entry */
|
||||
_setdirname (dirp);
|
||||
dirp->dirent_filled = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -641,13 +639,13 @@ static const char *
|
||||
_getdirname (const struct dirent *dp)
|
||||
{
|
||||
#if defined(DIRENT_WIN32_INTERFACE)
|
||||
return dp->data.cFileName;
|
||||
return dp->data.cFileName;
|
||||
|
||||
#elif defined(DIRENT_USE_FFBLK)
|
||||
return dp->data.ff_name;
|
||||
return dp->data.ff_name;
|
||||
|
||||
#else
|
||||
return dp->data.name;
|
||||
return dp->data.name;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -656,14 +654,15 @@ _getdirname (const struct dirent *dp)
|
||||
* Copy name of implementation dependent directory entry to the d_name field.
|
||||
*/
|
||||
static void
|
||||
_setdirname (struct DIR *dirp) {
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
_setdirname (struct DIR *dirp)
|
||||
{
|
||||
/* make sure that d_name is long enough */
|
||||
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
strncpy (dirp->current.d_name,
|
||||
_getdirname (&dirp->current),
|
||||
NAME_MAX);
|
||||
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||
}
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,23 +23,26 @@ can be bound by the Open JPEG open-source license and disclaimer, expressed else
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -50,263 +53,265 @@ void info_callback(const char *msg, void *client_data) {
|
||||
|
||||
void help_display()
|
||||
{
|
||||
/* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
|
||||
fprintf(stdout," Help for the 'mj2_to_metadata' Program\n");
|
||||
fprintf(stdout," ======================================\n");
|
||||
fprintf(stdout,"The -h option displays this information on screen.\n\n");
|
||||
/* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
|
||||
fprintf(stdout," Help for the 'mj2_to_metadata' Program\n");
|
||||
fprintf(stdout," ======================================\n");
|
||||
fprintf(stdout,"The -h option displays this information on screen.\n\n");
|
||||
|
||||
fprintf(stdout,"mj2_to_metadata generates an XML file from a Motion JPEG 2000 file.\n");
|
||||
fprintf(stdout,"The generated XML shows the structural, but not (yet) curatorial,\n");
|
||||
fprintf(stdout,"metadata from the movie header and from the JPEG 2000 image and tile\n");
|
||||
fprintf(stdout,"headers of a sample frame. Excluded: low-level packed-bits image data.\n\n");
|
||||
fprintf(stdout,"mj2_to_metadata generates an XML file from a Motion JPEG 2000 file.\n");
|
||||
fprintf(stdout,"The generated XML shows the structural, but not (yet) curatorial,\n");
|
||||
fprintf(stdout,"metadata from the movie header and from the JPEG 2000 image and tile\n");
|
||||
fprintf(stdout,"headers of a sample frame. Excluded: low-level packed-bits image data.\n\n");
|
||||
|
||||
fprintf(stdout,"By Default\n");
|
||||
fprintf(stdout,"----------\n");
|
||||
fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexidecimal) as stored in the\n");
|
||||
fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Notes explaining the XML are embedded as terse comments. These include\n");
|
||||
fprintf(stdout," meaning of non-obvious tag abbreviations;\n");
|
||||
fprintf(stdout," range and precision of valid values;\n");
|
||||
fprintf(stdout," interpretations of values, such as enumerations; and\n");
|
||||
fprintf(stdout," current implementation limitations.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"The sample-size and chunk-offset tables, each with 1 row per frame, are not reported.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"The file is self-contained and no verification (e.g., against a DTD) is requested.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Required Parameters (except with -h)\n");
|
||||
fprintf(stdout,"------------------------------------\n");
|
||||
fprintf(stdout,"[Caution: file strings that contain spaces should be wrapped with quotes.]\n");
|
||||
fprintf(stdout,"-i input.mj2 : where 'input' is any source file name or path.\n");
|
||||
fprintf(stdout," MJ2 files created with 'frames_to_mj2' are supported so far.\n");
|
||||
fprintf(stdout," These are silent, single-track, 'MJ2 Simple Profile' videos.\n");
|
||||
fprintf(stdout,"-o output.xml : where 'output' is any destination file name or path.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Optional Parameters\n");
|
||||
fprintf(stdout,"-------------------\n");
|
||||
fprintf(stdout,"-h : Display this help information.\n");
|
||||
fprintf(stdout,"-n : Suppress all mj2_to_metadata notes.\n");
|
||||
fprintf(stdout,"-t : Include sample-size and chunk-offset tables.\n");
|
||||
fprintf(stdout,"-f n : where n > 0. Include jp2 header info for frame n [default=1].\n");
|
||||
fprintf(stdout,"-f 0 : No jp2 header info.\n");
|
||||
fprintf(stdout,"-r : Suppress all 'raw' data for which a 'derived' form exists.\n");
|
||||
fprintf(stdout,"-d : Suppress all 'derived' data.\n");
|
||||
fprintf(stdout," (If both -r and -d given, -r will be ignored.)\n");
|
||||
fprintf(stdout,"-v string : Verify against the DTD file located by the string.\n");
|
||||
fprintf(stdout," Prepend quoted 'string' with either SYSTEM or PUBLIC keyword.\n");
|
||||
fprintf(stdout," Thus, for the distributed DTD placed in the same directory as\n");
|
||||
fprintf(stdout," the output file: -v \"SYSTEM mj2_to_metadata.dtd\"\n");
|
||||
fprintf(stdout," \"PUBLIC\" is used with an access protocol (e.g., http:) + URL.\n");
|
||||
/* More to come */
|
||||
fprintf(stdout,"\n");
|
||||
/* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
|
||||
fprintf(stdout,"By Default\n");
|
||||
fprintf(stdout,"----------\n");
|
||||
fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexadecimal) as stored in the\n");
|
||||
fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Notes explaining the XML are embedded as terse comments. These include\n");
|
||||
fprintf(stdout," meaning of non-obvious tag abbreviations;\n");
|
||||
fprintf(stdout," range and precision of valid values;\n");
|
||||
fprintf(stdout," interpretations of values, such as enumerations; and\n");
|
||||
fprintf(stdout," current implementation limitations.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"The sample-size and chunk-offset tables, each with 1 row per frame, are not reported.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"The file is self-contained and no verification (e.g., against a DTD) is requested.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Required Parameters (except with -h)\n");
|
||||
fprintf(stdout,"------------------------------------\n");
|
||||
fprintf(stdout,"[Caution: file strings that contain spaces should be wrapped with quotes.]\n");
|
||||
fprintf(stdout,"-i input.mj2 : where 'input' is any source file name or path.\n");
|
||||
fprintf(stdout," MJ2 files created with 'frames_to_mj2' are supported so far.\n");
|
||||
fprintf(stdout," These are silent, single-track, 'MJ2 Simple Profile' videos.\n");
|
||||
fprintf(stdout,"-o output.xml : where 'output' is any destination file name or path.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Optional Parameters\n");
|
||||
fprintf(stdout,"-------------------\n");
|
||||
fprintf(stdout,"-h : Display this help information.\n");
|
||||
fprintf(stdout,"-n : Suppress all mj2_to_metadata notes.\n");
|
||||
fprintf(stdout,"-t : Include sample-size and chunk-offset tables.\n");
|
||||
fprintf(stdout,"-f n : where n > 0. Include jp2 header info for frame n [default=1].\n");
|
||||
fprintf(stdout,"-f 0 : No jp2 header info.\n");
|
||||
fprintf(stdout,"-r : Suppress all 'raw' data for which a 'derived' form exists.\n");
|
||||
fprintf(stdout,"-d : Suppress all 'derived' data.\n");
|
||||
fprintf(stdout," (If both -r and -d given, -r will be ignored.)\n");
|
||||
fprintf(stdout,"-v string : Verify against the DTD file located by the string.\n");
|
||||
fprintf(stdout," Prepend quoted 'string' with either SYSTEM or PUBLIC keyword.\n");
|
||||
fprintf(stdout," Thus, for the distributed DTD placed in the same directory as\n");
|
||||
fprintf(stdout," the output file: -v \"SYSTEM mj2_to_metadata.dtd\"\n");
|
||||
fprintf(stdout," \"PUBLIC\" is used with an access protocol (e.g., http:) + URL.\n");
|
||||
/* More to come */
|
||||
fprintf(stdout,"\n");
|
||||
/* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */
|
||||
}
|
||||
|
||||
/* ------------- */
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
|
||||
FILE *file, *xmlout;
|
||||
/* char xmloutname[50]; */
|
||||
opj_mj2_t *movie;
|
||||
FILE *file, *xmlout;
|
||||
/* char xmloutname[50]; */
|
||||
opj_mj2_t *movie;
|
||||
|
||||
char* infile = 0;
|
||||
char* outfile = 0;
|
||||
char* s, S1, S2, S3;
|
||||
int len;
|
||||
unsigned int sampleframe = 1; /* First frame */
|
||||
char* stringDTD = NULL;
|
||||
BOOL notes = TRUE;
|
||||
BOOL sampletables = FALSE;
|
||||
BOOL raw = TRUE;
|
||||
BOOL derived = TRUE;
|
||||
mj2_dparameters_t parameters;
|
||||
char* infile = 0;
|
||||
char* outfile = 0;
|
||||
char* s, S1, S2, S3;
|
||||
int len;
|
||||
unsigned int sampleframe = 1; /* First frame */
|
||||
char* stringDTD = NULL;
|
||||
BOOL notes = TRUE;
|
||||
BOOL sampletables = FALSE;
|
||||
BOOL raw = TRUE;
|
||||
BOOL derived = TRUE;
|
||||
mj2_dparameters_t parameters;
|
||||
|
||||
while (TRUE) {
|
||||
/* ':' after letter means it takes an argument */
|
||||
int c = getopt(argc, argv, "i:o:f:v:hntrd");
|
||||
/* FUTURE: Reserve 'p' for pruning file (which will probably make -t redundant) */
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* IN file */
|
||||
infile = optarg;
|
||||
s = optarg;
|
||||
while (*s) { s++; } /* Run to filename end */
|
||||
s--;
|
||||
S3 = *s;
|
||||
s--;
|
||||
S2 = *s;
|
||||
s--;
|
||||
S1 = *s;
|
||||
while (TRUE) {
|
||||
/* ':' after letter means it takes an argument */
|
||||
int c = getopt(argc, argv, "i:o:f:v:hntrd");
|
||||
/* FUTURE: Reserve 'p' for pruning file (which will probably make -t redundant) */
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* IN file */
|
||||
infile = optarg;
|
||||
s = optarg;
|
||||
while (*s) {
|
||||
s++; /* Run to filename end */
|
||||
}
|
||||
s--;
|
||||
S3 = *s;
|
||||
s--;
|
||||
S2 = *s;
|
||||
s--;
|
||||
S1 = *s;
|
||||
|
||||
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
||||
|| (S1 == 'M' && S2 == 'J' && S3 == '2')) {
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "Input file name must have .mj2 extension, not .%c%c%c.\n", S1, S2, S3);
|
||||
return 1;
|
||||
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
||||
|| (S1 == 'M' && S2 == 'J' && S3 == '2')) {
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "Input file name must have .mj2 extension, not .%c%c%c.\n", S1, S2, S3);
|
||||
return 1;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'o': /* OUT file */
|
||||
outfile = optarg;
|
||||
while (*outfile) { outfile++; } /* Run to filename end */
|
||||
outfile--;
|
||||
S3 = *outfile;
|
||||
outfile--;
|
||||
S2 = *outfile;
|
||||
outfile--;
|
||||
S1 = *outfile;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'o': /* OUT file */
|
||||
outfile = optarg;
|
||||
while (*outfile) {
|
||||
outfile++; /* Run to filename end */
|
||||
}
|
||||
outfile--;
|
||||
S3 = *outfile;
|
||||
outfile--;
|
||||
S2 = *outfile;
|
||||
outfile--;
|
||||
S1 = *outfile;
|
||||
|
||||
outfile = optarg;
|
||||
outfile = optarg;
|
||||
|
||||
if ((S1 == 'x' && S2 == 'm' && S3 == 'l')
|
||||
|| (S1 == 'X' && S2 == 'M' && S3 == 'L'))
|
||||
break;
|
||||
if ((S1 == 'x' && S2 == 'm' && S3 == 'l')
|
||||
|| (S1 == 'X' && S2 == 'M' && S3 == 'L'))
|
||||
break;
|
||||
|
||||
fprintf(stderr,
|
||||
"Output file name must have .xml extension, not .%c%c%c\n", S1, S2, S3);
|
||||
return 1;
|
||||
fprintf(stderr,
|
||||
"Output file name must have .xml extension, not .%c%c%c\n", S1, S2, S3);
|
||||
return 1;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'f': /* Choose sample frame. 0 = none */
|
||||
sscanf(optarg, "%u", &sampleframe);
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'f': /* Choose sample frame. 0 = none */
|
||||
sscanf(optarg, "%u", &sampleframe);
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'v': /* Verification by DTD. */
|
||||
stringDTD = optarg;
|
||||
/* We will not insist upon last 3 chars being "dtd", since non-file
|
||||
access protocol may be used. */
|
||||
if(strchr(stringDTD,'"') != NULL) {
|
||||
fprintf(stderr, "-D's string must not contain any embedded double-quote characters.\n");
|
||||
return 1;
|
||||
}
|
||||
/* ----------------------------------------------------- */
|
||||
case 'v': /* Verification by DTD. */
|
||||
stringDTD = optarg;
|
||||
/* We will not insist upon last 3 chars being "dtd", since non-file
|
||||
access protocol may be used. */
|
||||
if(strchr(stringDTD,'"') != NULL) {
|
||||
fprintf(stderr, "-D's string must not contain any embedded double-quote characters.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp(stringDTD,"PUBLIC ",7) == 0 || strncmp(stringDTD,"SYSTEM ",7) == 0)
|
||||
break;
|
||||
if (strncmp(stringDTD,"PUBLIC ",7) == 0 || strncmp(stringDTD,"SYSTEM ",7) == 0)
|
||||
break;
|
||||
|
||||
fprintf(stderr, "-D's string must start with \"PUBLIC \" or \"SYSTEM \"\n");
|
||||
return 1;
|
||||
fprintf(stderr, "-D's string must start with \"PUBLIC \" or \"SYSTEM \"\n");
|
||||
return 1;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'n': /* Suppress comments */
|
||||
notes = FALSE;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'n': /* Suppress comments */
|
||||
notes = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 't': /* Show sample size and chunk offset tables */
|
||||
sampletables = TRUE;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 't': /* Show sample size and chunk offset tables */
|
||||
sampletables = TRUE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'h': /* Display an help description */
|
||||
help_display();
|
||||
return 0;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'h': /* Display an help description */
|
||||
help_display();
|
||||
return 0;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'r': /* Suppress raw data */
|
||||
raw = FALSE;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'r': /* Suppress raw data */
|
||||
raw = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'd': /* Suppress derived data */
|
||||
derived = FALSE;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'd': /* Suppress derived data */
|
||||
derived = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
default:
|
||||
return 1;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
/* ----------------------------------------------------- */
|
||||
default:
|
||||
return 1;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
|
||||
if(!raw && !derived)
|
||||
raw = TRUE; /* At least one of 'raw' and 'derived' must be true */
|
||||
if(!raw && !derived)
|
||||
raw = TRUE; /* At least one of 'raw' and 'derived' must be true */
|
||||
|
||||
/* Error messages */
|
||||
/* -------------- */
|
||||
if (!infile || !outfile) {
|
||||
fprintf(stderr,"Correct usage: mj2_to_metadata -i mj2-file -o xml-file (plus options)\n");
|
||||
return 1;
|
||||
}
|
||||
/* -------------- */
|
||||
if (!infile || !outfile) {
|
||||
fprintf(stderr,"Correct usage: mj2_to_metadata -i mj2-file -o xml-file (plus options)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* was:
|
||||
if (argc != 3) {
|
||||
printf("Bad syntax: Usage: MJ2_to_metadata inputfile.mj2 outputfile.xml\n");
|
||||
printf("Example: MJ2_to_metadata foreman.mj2 foreman.xml\n");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
len = strlen(infile);
|
||||
if(infile[0] == ' ')
|
||||
{
|
||||
infile++; /* There may be a leading blank if user put space after -i */
|
||||
}
|
||||
/* was:
|
||||
if (argc != 3) {
|
||||
printf("Bad syntax: Usage: MJ2_to_metadata inputfile.mj2 outputfile.xml\n");
|
||||
printf("Example: MJ2_to_metadata foreman.mj2 foreman.xml\n");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
len = strlen(infile);
|
||||
if(infile[0] == ' ') {
|
||||
infile++; /* There may be a leading blank if user put space after -i */
|
||||
}
|
||||
|
||||
file = fopen(infile, "rb"); /* was: argv[1] */
|
||||
file = fopen(infile, "rb"); /* was: argv[1] */
|
||||
|
||||
if (!file) {
|
||||
fprintf(stderr, "Failed to open %s for reading.\n", infile); /* was: argv[1] */
|
||||
return 1;
|
||||
}
|
||||
if (!file) {
|
||||
fprintf(stderr, "Failed to open %s for reading.\n", infile); /* was: argv[1] */
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = strlen(outfile);
|
||||
if(outfile[0] == ' ')
|
||||
{
|
||||
outfile++; /* There may be a leading blank if user put space after -o */
|
||||
}
|
||||
len = strlen(outfile);
|
||||
if(outfile[0] == ' ') {
|
||||
outfile++; /* There may be a leading blank if user put space after -o */
|
||||
}
|
||||
|
||||
// Checking output file
|
||||
xmlout = fopen(outfile, "w"); /* was: argv[2] */
|
||||
if (!xmlout) {
|
||||
fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */
|
||||
return 1;
|
||||
}
|
||||
// Leave it open
|
||||
// Checking output file
|
||||
xmlout = fopen(outfile, "w"); /* was: argv[2] */
|
||||
if (!xmlout) {
|
||||
fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */
|
||||
return 1;
|
||||
}
|
||||
// Leave it open
|
||||
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||
mj2_setup_decoder(dinfo->mj2_handle, ¶meters);
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||
mj2_setup_decoder(dinfo->mj2_handle, ¶meters);
|
||||
|
||||
if (mj2_read_struct(file, movie)) // Creating the movie structure
|
||||
{
|
||||
if (mj2_read_struct(file, movie)) { // Creating the movie structure
|
||||
fclose(xmlout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
xml_write_init(notes, sampletables, raw, derived);
|
||||
xml_write_struct(file, xmlout, movie, sampleframe, stringDTD, &event_mgr);
|
||||
fclose(xmlout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
xml_write_init(notes, sampletables, raw, derived);
|
||||
xml_write_struct(file, xmlout, movie, sampleframe, stringDTD, &event_mgr);
|
||||
fclose(xmlout);
|
||||
fprintf(stderr,"Metadata correctly extracted to XML file \n");;
|
||||
|
||||
fprintf(stderr,"Metadata correctly extracted to XML file \n");;
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,196 +50,194 @@
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
static void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
static void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
static void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
static void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
mj2_dparameters_t mj2_parameters; /* decompression parameters */
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_cio_t *cio = NULL;
|
||||
unsigned int tnum, snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_tk_t *track;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *file, *outfile;
|
||||
char outfilename[50];
|
||||
opj_image_t *img = NULL;
|
||||
unsigned int max_codstrm_size = 0;
|
||||
double total_time = 0;
|
||||
unsigned int numframes = 0;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
mj2_dparameters_t mj2_parameters; /* decompression parameters */
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_cio_t *cio = NULL;
|
||||
unsigned int tnum, snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_tk_t *track;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *file, *outfile;
|
||||
char outfilename[50];
|
||||
opj_image_t *img = NULL;
|
||||
unsigned int max_codstrm_size = 0;
|
||||
double total_time = 0;
|
||||
unsigned int numframes = 0;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s inputfile.mj2 outputfile.yuv\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s inputfile.mj2 outputfile.yuv\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
file = fopen(argv[1], "rb");
|
||||
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Checking output file */
|
||||
outfile = fopen(argv[2], "w");
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
fclose(outfile);
|
||||
/* Checking output file */
|
||||
outfile = fopen(argv[2], "w");
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
fclose(outfile);
|
||||
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = NULL;
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = NULL;
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
movie = (opj_mj2_t*)dinfo->mj2_handle;
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
movie = (opj_mj2_t*)dinfo->mj2_handle;
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
memset(&mj2_parameters, 0, sizeof(mj2_dparameters_t));
|
||||
/* set J2K decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters);
|
||||
memset(&mj2_parameters, 0, sizeof(mj2_dparameters_t));
|
||||
/* set J2K decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
mj2_setup_decoder(movie, &mj2_parameters);
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
mj2_setup_decoder(movie, &mj2_parameters);
|
||||
|
||||
if (mj2_read_struct(file, movie)) /* Creating the movie structure */
|
||||
return 1;
|
||||
if (mj2_read_struct(file, movie)) /* Creating the movie structure */
|
||||
return 1;
|
||||
|
||||
/* Decode first video track */
|
||||
for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
|
||||
if (movie->tk[tnum].track_type == 0)
|
||||
break;
|
||||
}
|
||||
/* Decode first video track */
|
||||
for (tnum=0; tnum < (unsigned int)(movie->num_htk + movie->num_stk + movie->num_vtk); tnum++) {
|
||||
if (movie->tk[tnum].track_type == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (movie->tk[tnum].track_type != 0) {
|
||||
printf("Error. Movie does not contain any video track\n");
|
||||
return 1;
|
||||
}
|
||||
if (movie->tk[tnum].track_type != 0) {
|
||||
printf("Error. Movie does not contain any video track\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
track = &movie->tk[tnum];
|
||||
track = &movie->tk[tnum];
|
||||
|
||||
/* Output info on first video tracl */
|
||||
fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
|
||||
track->num_samples, track->w, track->h);
|
||||
/* Output info on first video tracl */
|
||||
fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
|
||||
track->num_samples, track->w, track->h);
|
||||
|
||||
max_codstrm_size = track->sample[0].sample_size-8;
|
||||
frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char));
|
||||
max_codstrm_size = track->sample[0].sample_size-8;
|
||||
frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char));
|
||||
|
||||
numframes = track->num_samples;
|
||||
numframes = track->num_samples;
|
||||
|
||||
for (snum=0; snum < numframes; snum++)
|
||||
{
|
||||
double init_time = opj_clock();
|
||||
double elapsed_time;
|
||||
for (snum=0; snum < numframes; snum++) {
|
||||
double init_time = opj_clock();
|
||||
double elapsed_time;
|
||||
|
||||
sample = &track->sample[snum];
|
||||
if (sample->sample_size-8 > max_codstrm_size) {
|
||||
max_codstrm_size = sample->sample_size-8;
|
||||
if ((frame_codestream = (unsigned char*)
|
||||
realloc(frame_codestream, max_codstrm_size)) == NULL) {
|
||||
printf("Error reallocation memory\n");
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
fseek(file,sample->offset+8,SEEK_SET);
|
||||
fread(frame_codestream, sample->sample_size-8, 1, file); /* Assuming that jp and ftyp markers size do */
|
||||
sample = &track->sample[snum];
|
||||
if (sample->sample_size-8 > max_codstrm_size) {
|
||||
max_codstrm_size = sample->sample_size-8;
|
||||
if ((frame_codestream = (unsigned char*)
|
||||
realloc(frame_codestream, max_codstrm_size)) == NULL) {
|
||||
printf("Error reallocation memory\n");
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
fseek(file,sample->offset+8,SEEK_SET);
|
||||
fread(frame_codestream, sample->sample_size-8, 1, file); /* Assuming that jp and ftyp markers size do */
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8);
|
||||
|
||||
img = opj_decode(dinfo, cio); /* Decode J2K to image */
|
||||
img = opj_decode(dinfo, cio); /* Decode J2K to image */
|
||||
|
||||
#ifdef WANT_SYCC_TO_RGB
|
||||
if(img->color_space == CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(img);
|
||||
}
|
||||
if(img->color_space == CLRSPC_SYCC) {
|
||||
color_sycc_to_rgb(img);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(img->icc_profile_buf)
|
||||
{
|
||||
if(img->icc_profile_buf) {
|
||||
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
|
||||
color_apply_icc_profile(img);
|
||||
color_apply_icc_profile(img);
|
||||
#endif
|
||||
|
||||
free(img->icc_profile_buf);
|
||||
img->icc_profile_buf = NULL; img->icc_profile_len = 0;
|
||||
}
|
||||
free(img->icc_profile_buf);
|
||||
img->icc_profile_buf = NULL;
|
||||
img->icc_profile_len = 0;
|
||||
}
|
||||
|
||||
if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
|
||||
&& (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
|
||||
|| (img->numcomps == 1)) {
|
||||
if (((img->numcomps == 3) && (img->comps[0].dx == img->comps[1].dx / 2)
|
||||
&& (img->comps[0].dx == img->comps[2].dx / 2 ) && (img->comps[0].dx == 1))
|
||||
|| (img->numcomps == 1)) {
|
||||
|
||||
if (!imagetoyuv(img, argv[2])) /* Convert image to YUV */
|
||||
return 1;
|
||||
}
|
||||
else if ((img->numcomps == 3) &&
|
||||
(img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
|
||||
(img->comps[2].dx == 1))/* If YUV 4:4:4 input --> to bmp */
|
||||
{
|
||||
fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
|
||||
sprintf(outfilename,"output_%d.bmp",snum);
|
||||
if (imagetobmp(img, outfilename)) /* Convert image to BMP */
|
||||
return 1;
|
||||
if (!imagetoyuv(img, argv[2])) /* Convert image to YUV */
|
||||
return 1;
|
||||
} else if ((img->numcomps == 3) &&
|
||||
(img->comps[0].dx == 1) && (img->comps[1].dx == 1)&&
|
||||
(img->comps[2].dx == 1)) { /* If YUV 4:4:4 input --> to bmp */
|
||||
fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
|
||||
sprintf(outfilename,"output_%d.bmp",snum);
|
||||
if (imagetobmp(img, outfilename)) /* Convert image to BMP */
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
|
||||
fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
|
||||
|
||||
sprintf(outfilename,"output_%d.j2k",snum);
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
||||
return 1;
|
||||
}
|
||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
||||
fclose(outfile);
|
||||
}
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
/* free image data structure */
|
||||
opj_image_destroy(img);
|
||||
elapsed_time = opj_clock()-init_time;
|
||||
fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
|
||||
total_time += elapsed_time;
|
||||
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
|
||||
fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
|
||||
|
||||
sprintf(outfilename,"output_%d.j2k",snum);
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
||||
return 1;
|
||||
}
|
||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
||||
fclose(outfile);
|
||||
free(frame_codestream);
|
||||
fclose(file);
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
/* free image data structure */
|
||||
opj_image_destroy(img);
|
||||
elapsed_time = opj_clock()-init_time;
|
||||
fprintf(stderr, "Frame number %d/%d decoded in %.2f mseconds\n", snum + 1, numframes, elapsed_time*1000);
|
||||
total_time += elapsed_time;
|
||||
free(dinfo);
|
||||
|
||||
}
|
||||
fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
|
||||
fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
|
||||
|
||||
free(frame_codestream);
|
||||
fclose(file);
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
free(dinfo);
|
||||
|
||||
fprintf(stdout, "%d frame(s) correctly decompressed\n", snum);
|
||||
fprintf(stdout,"Total decoding time: %.2f seconds (%.1f fps)\n", total_time, (float)numframes/total_time);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -41,110 +46,113 @@
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
int tnum;
|
||||
unsigned int snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_tk_t *track;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *file, *outfile;
|
||||
char outfilename[50];
|
||||
mj2_dparameters_t parameters;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
int tnum;
|
||||
unsigned int snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_tk_t *track;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *file, *outfile;
|
||||
char outfilename[50];
|
||||
mj2_dparameters_t parameters;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s mj2filename output_location\n",argv[0]);
|
||||
printf("Example: %s foreman.mj2 output/foreman\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
memset(¶meters, 0, sizeof(mj2_dparameters_t));
|
||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||
mj2_setup_decoder(movie, ¶meters);
|
||||
|
||||
if (mj2_read_struct(file, movie)) /* Creating the movie structure*/
|
||||
return 1;
|
||||
|
||||
/* Decode first video track */
|
||||
tnum = 0;
|
||||
while (movie->tk[tnum].track_type != 0)
|
||||
tnum ++;
|
||||
|
||||
track = &movie->tk[tnum];
|
||||
|
||||
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
|
||||
|
||||
for (snum=0; snum < track->num_samples; snum++)
|
||||
{
|
||||
sample = &track->sample[snum];
|
||||
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker*/
|
||||
fseek(file,sample->offset+8,SEEK_SET);
|
||||
fread(frame_codestream,sample->sample_size-8,1, file); /* Assuming that jp and ftyp markers size do*/
|
||||
|
||||
sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
||||
return 1;
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s mj2filename output_location\n",argv[0]);
|
||||
printf("Example: %s foreman.mj2 output/foreman\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
||||
fclose(outfile);
|
||||
free(frame_codestream);
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
|
||||
if (!file) {
|
||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
fclose(file);
|
||||
fprintf(stdout, "%d frames correctly extracted\n", snum);
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
return 0;
|
||||
/* get a MJ2 decompressor handle */
|
||||
dinfo = mj2_create_decompress();
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
memset(¶meters, 0, sizeof(mj2_dparameters_t));
|
||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||
mj2_setup_decoder(movie, ¶meters);
|
||||
|
||||
if (mj2_read_struct(file, movie)) /* Creating the movie structure*/
|
||||
return 1;
|
||||
|
||||
/* Decode first video track */
|
||||
tnum = 0;
|
||||
while (movie->tk[tnum].track_type != 0)
|
||||
tnum ++;
|
||||
|
||||
track = &movie->tk[tnum];
|
||||
|
||||
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
|
||||
|
||||
for (snum=0; snum < track->num_samples; snum++) {
|
||||
sample = &track->sample[snum];
|
||||
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker*/
|
||||
fseek(file,sample->offset+8,SEEK_SET);
|
||||
fread(frame_codestream,sample->sample_size-8,1, file); /* Assuming that jp and ftyp markers size do*/
|
||||
|
||||
sprintf(outfilename,"%s_%05d.j2k",argv[2],snum);
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
||||
return 1;
|
||||
}
|
||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
||||
fclose(outfile);
|
||||
free(frame_codestream);
|
||||
}
|
||||
fclose(file);
|
||||
fprintf(stdout, "%d frames correctly extracted\n", snum);
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -36,8 +41,9 @@
|
||||
#include "jp2.h"
|
||||
#include "mj2.h"
|
||||
|
||||
static int int_ceildiv(int a, int b) {
|
||||
return (a + b - 1) / b;
|
||||
static int int_ceildiv(int a, int b)
|
||||
{
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,153 +57,141 @@ Size of memory first allocated for MOOV box
|
||||
|
||||
static int test_image(const char *fname, mj2_cparameters_t *cp)
|
||||
{
|
||||
FILE *reader;
|
||||
opj_image_t *image;
|
||||
unsigned char *src;
|
||||
opj_dinfo_t *dinfo;
|
||||
opj_cio_t *cio;
|
||||
opj_dparameters_t dparameters;
|
||||
int success;
|
||||
long src_len;
|
||||
FILE *reader;
|
||||
opj_image_t *image;
|
||||
unsigned char *src;
|
||||
opj_dinfo_t *dinfo;
|
||||
opj_cio_t *cio;
|
||||
opj_dparameters_t dparameters;
|
||||
int success;
|
||||
long src_len;
|
||||
|
||||
success = 0;
|
||||
success = 0;
|
||||
|
||||
if((reader = fopen(fname, "rb")) == NULL) return success;
|
||||
if((reader = fopen(fname, "rb")) == NULL) return success;
|
||||
|
||||
fseek(reader, 0, SEEK_END);
|
||||
src_len = ftell(reader);
|
||||
fseek(reader, 0, SEEK_SET);
|
||||
src = (unsigned char*) malloc(src_len);
|
||||
fread(src, 1, src_len, reader);
|
||||
fclose(reader);
|
||||
fseek(reader, 0, SEEK_END);
|
||||
src_len = ftell(reader);
|
||||
fseek(reader, 0, SEEK_SET);
|
||||
src = (unsigned char*) malloc(src_len);
|
||||
fread(src, 1, src_len, reader);
|
||||
fclose(reader);
|
||||
|
||||
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0)
|
||||
{
|
||||
free(src); return success;
|
||||
}
|
||||
memset(&dparameters, 0, sizeof(opj_dparameters_t));
|
||||
if(memcmp(src, J2K_CODESTREAM_MAGIC, 4) != 0) {
|
||||
free(src);
|
||||
return success;
|
||||
}
|
||||
memset(&dparameters, 0, sizeof(opj_dparameters_t));
|
||||
|
||||
opj_set_default_decoder_parameters(&dparameters);
|
||||
opj_set_default_decoder_parameters(&dparameters);
|
||||
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
opj_setup_decoder(dinfo, &dparameters);
|
||||
opj_setup_decoder(dinfo, &dparameters);
|
||||
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len);
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len);
|
||||
|
||||
image = opj_decode(dinfo, cio);
|
||||
image = opj_decode(dinfo, cio);
|
||||
|
||||
free(src); cio->buffer = NULL;
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
cio->buffer = NULL;
|
||||
opj_cio_close(cio);
|
||||
|
||||
if(image == NULL) goto fin;
|
||||
if(image == NULL) goto fin;
|
||||
|
||||
cp->numcomps = image->numcomps;
|
||||
cp->w = image->comps[0].w;
|
||||
cp->h = image->comps[0].h;
|
||||
cp->prec = image->comps[0].prec;
|
||||
cp->numcomps = image->numcomps;
|
||||
cp->w = image->comps[0].w;
|
||||
cp->h = image->comps[0].h;
|
||||
cp->prec = image->comps[0].prec;
|
||||
|
||||
if(image->numcomps > 2 )
|
||||
{
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))/* horizontal and vertical*/
|
||||
{
|
||||
/* Y420*/
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
cp->CbCr_subsampling_dx = 2;
|
||||
cp->CbCr_subsampling_dy = 2;
|
||||
}
|
||||
else
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))/* horizontal only*/
|
||||
{
|
||||
/* Y422*/
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
cp->CbCr_subsampling_dx = 2;
|
||||
cp->CbCr_subsampling_dy = 1;
|
||||
}
|
||||
else
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))
|
||||
{
|
||||
/* Y444 or RGB */
|
||||
if(image->numcomps > 2 ) {
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2)) { /* horizontal and vertical*/
|
||||
/* Y420*/
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
cp->CbCr_subsampling_dx = 2;
|
||||
cp->CbCr_subsampling_dy = 2;
|
||||
} else if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1)) { /* horizontal only*/
|
||||
/* Y422*/
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
cp->CbCr_subsampling_dx = 2;
|
||||
cp->CbCr_subsampling_dy = 1;
|
||||
} else if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1)) {
|
||||
/* Y444 or RGB */
|
||||
|
||||
if(image->color_space == CLRSPC_SRGB)
|
||||
{
|
||||
cp->enumcs = ENUMCS_SRGB;
|
||||
if(image->color_space == CLRSPC_SRGB) {
|
||||
cp->enumcs = ENUMCS_SRGB;
|
||||
|
||||
/* cp->CbCr_subsampling_dx = 0; */
|
||||
/* cp->CbCr_subsampling_dy = 0; */
|
||||
}
|
||||
else
|
||||
{
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
/* cp->CbCr_subsampling_dx = 0; */
|
||||
/* cp->CbCr_subsampling_dy = 0; */
|
||||
} else {
|
||||
cp->enumcs = ENUMCS_SYCC;
|
||||
|
||||
cp->CbCr_subsampling_dx = 1;
|
||||
cp->CbCr_subsampling_dy = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cp->enumcs = ENUMCS_GRAY;
|
||||
/* cp->CbCr_subsampling_dx = 0; */
|
||||
/* cp->CbCr_subsampling_dy = 0; */
|
||||
}
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
cp->meth = 2;
|
||||
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||
}
|
||||
else cp->meth = 1;
|
||||
cp->CbCr_subsampling_dx = 1;
|
||||
cp->CbCr_subsampling_dy = 1;
|
||||
}
|
||||
} else {
|
||||
goto fin;
|
||||
}
|
||||
} else {
|
||||
cp->enumcs = ENUMCS_GRAY;
|
||||
/* cp->CbCr_subsampling_dx = 0; */
|
||||
/* cp->CbCr_subsampling_dy = 0; */
|
||||
}
|
||||
if(image->icc_profile_buf) {
|
||||
cp->meth = 2;
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL;
|
||||
} else cp->meth = 1;
|
||||
|
||||
success = 1;
|
||||
success = 1;
|
||||
fin:
|
||||
if(dinfo)
|
||||
opj_destroy_decompress(dinfo);
|
||||
if(dinfo)
|
||||
opj_destroy_decompress(dinfo);
|
||||
|
||||
if(image)
|
||||
opj_image_destroy(image);
|
||||
if(image)
|
||||
opj_image_destroy(image);
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
static void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
static void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
static void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
static void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
static void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
static void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -206,316 +200,311 @@ static void info_callback(const char *msg, void *client_data) {
|
||||
|
||||
static void read_siz_marker(FILE *file, opj_image_t *image)
|
||||
{
|
||||
int len,i;
|
||||
char buf, buf2[2];
|
||||
unsigned char *siz_buffer;
|
||||
opj_cio_t *cio;
|
||||
int len,i;
|
||||
char buf, buf2[2];
|
||||
unsigned char *siz_buffer;
|
||||
opj_cio_t *cio;
|
||||
|
||||
fseek(file, 0, SEEK_SET);
|
||||
do {
|
||||
fread(&buf,1,1, file);
|
||||
if (buf==(char)0xff)
|
||||
fread(&buf,1,1, file);
|
||||
}
|
||||
while (!(buf==(char)0x51));
|
||||
fseek(file, 0, SEEK_SET);
|
||||
do {
|
||||
fread(&buf,1,1, file);
|
||||
if (buf==(char)0xff)
|
||||
fread(&buf,1,1, file);
|
||||
} while (!(buf==(char)0x51));
|
||||
|
||||
fread(buf2,2,1,file); /* Lsiz */
|
||||
len = ((buf2[0])<<8) + buf2[1];
|
||||
fread(buf2,2,1,file); /* Lsiz */
|
||||
len = ((buf2[0])<<8) + buf2[1];
|
||||
|
||||
siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
|
||||
fread(siz_buffer,len, 1, file);
|
||||
cio = opj_cio_open(NULL, siz_buffer, len);
|
||||
siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
|
||||
fread(siz_buffer,len, 1, file);
|
||||
cio = opj_cio_open(NULL, siz_buffer, len);
|
||||
|
||||
cio_read(cio, 2); /* Rsiz (capabilities) */
|
||||
image->x1 = cio_read(cio, 4); /* Xsiz */
|
||||
image->y1 = cio_read(cio, 4); /* Ysiz */
|
||||
image->x0 = cio_read(cio, 4); /* X0siz */
|
||||
image->y0 = cio_read(cio, 4); /* Y0siz */
|
||||
cio_skip(cio, 16); /* XTsiz, YTsiz, XT0siz, YT0siz */
|
||||
cio_read(cio, 2); /* Rsiz (capabilities) */
|
||||
image->x1 = cio_read(cio, 4); /* Xsiz */
|
||||
image->y1 = cio_read(cio, 4); /* Ysiz */
|
||||
image->x0 = cio_read(cio, 4); /* X0siz */
|
||||
image->y0 = cio_read(cio, 4); /* Y0siz */
|
||||
cio_skip(cio, 16); /* XTsiz, YTsiz, XT0siz, YT0siz */
|
||||
|
||||
image->numcomps = cio_read(cio,2); /* Csiz */
|
||||
image->comps =
|
||||
(opj_image_comp_t *) malloc(image->numcomps * sizeof(opj_image_comp_t));
|
||||
image->numcomps = cio_read(cio,2); /* Csiz */
|
||||
image->comps =
|
||||
(opj_image_comp_t *) malloc(image->numcomps * sizeof(opj_image_comp_t));
|
||||
|
||||
for (i = 0; i < image->numcomps; i++) {
|
||||
int tmp;
|
||||
tmp = cio_read(cio,1); /* Ssiz_i */
|
||||
image->comps[i].prec = (tmp & 0x7f) + 1;
|
||||
image->comps[i].sgnd = tmp >> 7;
|
||||
image->comps[i].dx = cio_read(cio,1); /* XRsiz_i */
|
||||
image->comps[i].dy = cio_read(cio,1); /* YRsiz_i */
|
||||
image->comps[i].resno_decoded = 0; /* number of resolution decoded */
|
||||
image->comps[i].factor = 0; /* reducing factor by component */
|
||||
}
|
||||
fseek(file, 0, SEEK_SET);
|
||||
opj_cio_close(cio);
|
||||
free(siz_buffer);
|
||||
for (i = 0; i < image->numcomps; i++) {
|
||||
int tmp;
|
||||
tmp = cio_read(cio,1); /* Ssiz_i */
|
||||
image->comps[i].prec = (tmp & 0x7f) + 1;
|
||||
image->comps[i].sgnd = tmp >> 7;
|
||||
image->comps[i].dx = cio_read(cio,1); /* XRsiz_i */
|
||||
image->comps[i].dy = cio_read(cio,1); /* YRsiz_i */
|
||||
image->comps[i].resno_decoded = 0; /* number of resolution decoded */
|
||||
image->comps[i].factor = 0; /* reducing factor by component */
|
||||
}
|
||||
fseek(file, 0, SEEK_SET);
|
||||
opj_cio_close(cio);
|
||||
free(siz_buffer);
|
||||
}
|
||||
|
||||
static void setparams(opj_mj2_t *movie, opj_image_t *image) {
|
||||
int i, depth_0, depth, sign;
|
||||
static void setparams(opj_mj2_t *movie, opj_image_t *image)
|
||||
{
|
||||
int i, depth_0, depth, sign;
|
||||
|
||||
movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
||||
movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
||||
mj2_init_stdmovie(movie);
|
||||
movie->tk[0].w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
||||
movie->tk[0].h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
||||
mj2_init_stdmovie(movie);
|
||||
|
||||
movie->tk[0].depth = image->comps[0].prec;
|
||||
movie->tk[0].depth = image->comps[0].prec;
|
||||
|
||||
if (image->numcomps==3) {
|
||||
if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1))
|
||||
movie->tk[0].CbCr_subsampling_dx = 1;
|
||||
if (image->numcomps==3) {
|
||||
if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1))
|
||||
movie->tk[0].CbCr_subsampling_dx = 1;
|
||||
else if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2))
|
||||
movie->tk[0].CbCr_subsampling_dx = 2;
|
||||
else
|
||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
||||
|
||||
if ((image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))
|
||||
movie->tk[0].CbCr_subsampling_dy = 1;
|
||||
else if ((image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))
|
||||
movie->tk[0].CbCr_subsampling_dy = 2;
|
||||
else
|
||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
||||
}
|
||||
|
||||
movie->tk[0].sample_rate = 25;
|
||||
|
||||
movie->tk[0].jp2_struct.numcomps = image->numcomps; /* NC */
|
||||
|
||||
/* Init Standard jp2 structure */
|
||||
|
||||
movie->tk[0].jp2_struct.comps =
|
||||
(opj_jp2_comps_t *) malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
|
||||
movie->tk[0].jp2_struct.precedence = 0; /* PRECEDENCE*/
|
||||
movie->tk[0].jp2_struct.approx = 0; /* APPROX*/
|
||||
movie->tk[0].jp2_struct.brand = JP2_JP2; /* BR */
|
||||
movie->tk[0].jp2_struct.minversion = 0; /* MinV */
|
||||
movie->tk[0].jp2_struct.numcl = 1;
|
||||
movie->tk[0].jp2_struct.cl = (unsigned int *) malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
|
||||
movie->tk[0].jp2_struct.cl[0] = JP2_JP2; /* CL0 : JP2 */
|
||||
movie->tk[0].jp2_struct.C = 7; /* C : Always 7*/
|
||||
movie->tk[0].jp2_struct.UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
||||
movie->tk[0].jp2_struct.IPR = 0; /* IPR, no intellectual property*/
|
||||
movie->tk[0].jp2_struct.w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
||||
movie->tk[0].jp2_struct.h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
||||
|
||||
depth_0 = image->comps[0].prec - 1;
|
||||
sign = image->comps[0].sgnd;
|
||||
movie->tk[0].jp2_struct.bpc = depth_0 + (sign << 7);
|
||||
|
||||
for (i = 1; i < image->numcomps; i++) {
|
||||
depth = image->comps[i].prec - 1;
|
||||
sign = image->comps[i].sgnd;
|
||||
if (depth_0 != depth)
|
||||
movie->tk[0].jp2_struct.bpc = 255;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->numcomps; i++)
|
||||
movie->tk[0].jp2_struct.comps[i].bpcc =
|
||||
image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
|
||||
|
||||
if ((image->numcomps == 1 || image->numcomps == 3)
|
||||
&& (movie->tk[0].jp2_struct.bpc != 255))
|
||||
movie->tk[0].jp2_struct.meth = 1;
|
||||
else
|
||||
if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2))
|
||||
movie->tk[0].CbCr_subsampling_dx = 2;
|
||||
else
|
||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
||||
|
||||
if ((image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))
|
||||
movie->tk[0].CbCr_subsampling_dy = 1;
|
||||
else
|
||||
if ((image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))
|
||||
movie->tk[0].CbCr_subsampling_dy = 2;
|
||||
else
|
||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
||||
}
|
||||
|
||||
movie->tk[0].sample_rate = 25;
|
||||
|
||||
movie->tk[0].jp2_struct.numcomps = image->numcomps; /* NC */
|
||||
|
||||
/* Init Standard jp2 structure */
|
||||
|
||||
movie->tk[0].jp2_struct.comps =
|
||||
(opj_jp2_comps_t *) malloc(movie->tk[0].jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
|
||||
movie->tk[0].jp2_struct.precedence = 0; /* PRECEDENCE*/
|
||||
movie->tk[0].jp2_struct.approx = 0; /* APPROX*/
|
||||
movie->tk[0].jp2_struct.brand = JP2_JP2; /* BR */
|
||||
movie->tk[0].jp2_struct.minversion = 0; /* MinV */
|
||||
movie->tk[0].jp2_struct.numcl = 1;
|
||||
movie->tk[0].jp2_struct.cl = (unsigned int *) malloc(movie->tk[0].jp2_struct.numcl * sizeof(int));
|
||||
movie->tk[0].jp2_struct.cl[0] = JP2_JP2; /* CL0 : JP2 */
|
||||
movie->tk[0].jp2_struct.C = 7; /* C : Always 7*/
|
||||
movie->tk[0].jp2_struct.UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
||||
movie->tk[0].jp2_struct.IPR = 0; /* IPR, no intellectual property*/
|
||||
movie->tk[0].jp2_struct.w = int_ceildiv(image->x1 - image->x0, image->comps[0].dx);
|
||||
movie->tk[0].jp2_struct.h = int_ceildiv(image->y1 - image->y0, image->comps[0].dy);
|
||||
|
||||
depth_0 = image->comps[0].prec - 1;
|
||||
sign = image->comps[0].sgnd;
|
||||
movie->tk[0].jp2_struct.bpc = depth_0 + (sign << 7);
|
||||
|
||||
for (i = 1; i < image->numcomps; i++) {
|
||||
depth = image->comps[i].prec - 1;
|
||||
sign = image->comps[i].sgnd;
|
||||
if (depth_0 != depth)
|
||||
movie->tk[0].jp2_struct.bpc = 255;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->numcomps; i++)
|
||||
movie->tk[0].jp2_struct.comps[i].bpcc =
|
||||
image->comps[i].prec - 1 + (image->comps[i].sgnd << 7);
|
||||
|
||||
if ((image->numcomps == 1 || image->numcomps == 3)
|
||||
&& (movie->tk[0].jp2_struct.bpc != 255))
|
||||
movie->tk[0].jp2_struct.meth = 1;
|
||||
else
|
||||
movie->tk[0].jp2_struct.meth = 2;
|
||||
movie->tk[0].jp2_struct.meth = 2;
|
||||
|
||||
if (image->numcomps == 1)
|
||||
movie->tk[0].jp2_struct.enumcs = 17; /* Grayscale */
|
||||
movie->tk[0].jp2_struct.enumcs = 17; /* Grayscale */
|
||||
|
||||
else if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))
|
||||
movie->tk[0].jp2_struct.enumcs = 16; /* RGB */
|
||||
|
||||
else if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))
|
||||
movie->tk[0].jp2_struct.enumcs = 18; /* YUV */
|
||||
|
||||
else
|
||||
if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))
|
||||
movie->tk[0].jp2_struct.enumcs = 16; /* RGB */
|
||||
|
||||
else
|
||||
if ((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))
|
||||
movie->tk[0].jp2_struct.enumcs = 18; /* YUV */
|
||||
|
||||
else
|
||||
movie->tk[0].jp2_struct.enumcs = 0; /* Unkown profile */
|
||||
movie->tk[0].jp2_struct.enumcs = 0; /* Unknown profile */
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
opj_cinfo_t* cinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
unsigned int snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *mj2file, *j2kfile;
|
||||
char *j2kfilename;
|
||||
unsigned char *buf;
|
||||
int offset, mdat_initpos;
|
||||
opj_image_t img;
|
||||
opj_cio_t *cio;
|
||||
mj2_cparameters_t parameters;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
opj_cinfo_t* cinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
unsigned int snum;
|
||||
opj_mj2_t *movie;
|
||||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *mj2file, *j2kfile;
|
||||
char *j2kfilename;
|
||||
unsigned char *buf;
|
||||
int offset, mdat_initpos;
|
||||
opj_image_t img;
|
||||
opj_cio_t *cio;
|
||||
mj2_cparameters_t parameters;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s source_location mj2_filename\n",argv[0]);
|
||||
printf("Example: %s input/input output.mj2\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
mj2file = fopen(argv[2], "wb");
|
||||
|
||||
if (!mj2file) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
memset(&img, 0, sizeof(opj_image_t));
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
cinfo = mj2_create_compress();
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder encoding parameters using user parameters */
|
||||
memset(¶meters, 0, sizeof(mj2_cparameters_t));
|
||||
movie = (opj_mj2_t*) cinfo->mj2_handle;
|
||||
|
||||
j2kfilename = (char*)malloc(strlen(argv[1]) + 12);/* max. '%6d' */
|
||||
sprintf(j2kfilename, "%s_00001.j2k",argv[1]);
|
||||
|
||||
if(test_image(j2kfilename, ¶meters) == 0) goto fin;
|
||||
|
||||
parameters.frame_rate = 25; /* DEFAULT */
|
||||
|
||||
mj2_setup_encoder(movie, ¶meters);
|
||||
|
||||
|
||||
/* Writing JP, FTYP and MDAT boxes
|
||||
Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
|
||||
|
||||
buf = (unsigned char*) malloc (300 * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, 300);
|
||||
mj2_write_jp(cio);
|
||||
mj2_write_ftyp(movie, cio);
|
||||
mdat_initpos = cio_tell(cio);
|
||||
cio_skip(cio, 4);
|
||||
cio_write(cio,MJ2_MDAT, 4);
|
||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||
free(buf);
|
||||
|
||||
/* Insert each j2k codestream in a JP2C box */
|
||||
snum=0;
|
||||
offset = 0;
|
||||
while(1)
|
||||
{
|
||||
mj2_sample_t * new_sample;
|
||||
mj2_chunk_t * new_chunk;
|
||||
sample = &movie->tk[0].sample[snum];
|
||||
sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
|
||||
j2kfile = fopen(j2kfilename, "rb");
|
||||
if (!j2kfile) {
|
||||
if (snum==0) { /* Could not open a single codestream */
|
||||
fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
|
||||
return 1;
|
||||
}
|
||||
else { /* Tried to open a inexistant codestream */
|
||||
fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
|
||||
break;
|
||||
}
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s source_location mj2_filename\n",argv[0]);
|
||||
printf("Example: %s input/input output.mj2\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Calculating offset for samples and chunks */
|
||||
mj2file = fopen(argv[2], "wb");
|
||||
|
||||
if (!mj2file) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
memset(&img, 0, sizeof(opj_image_t));
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
cinfo = mj2_create_compress();
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder encoding parameters using user parameters */
|
||||
memset(¶meters, 0, sizeof(mj2_cparameters_t));
|
||||
movie = (opj_mj2_t*) cinfo->mj2_handle;
|
||||
|
||||
j2kfilename = (char*)malloc(strlen(argv[1]) + 12);/* max. '%6d' */
|
||||
sprintf(j2kfilename, "%s_00001.j2k",argv[1]);
|
||||
|
||||
if(test_image(j2kfilename, ¶meters) == 0) goto fin;
|
||||
|
||||
parameters.frame_rate = 25; /* DEFAULT */
|
||||
|
||||
mj2_setup_encoder(movie, ¶meters);
|
||||
|
||||
|
||||
/* Writing JP, FTYP and MDAT boxes
|
||||
Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
|
||||
|
||||
buf = (unsigned char*) malloc (300 * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, 300);
|
||||
mj2_write_jp(cio);
|
||||
mj2_write_ftyp(movie, cio);
|
||||
mdat_initpos = cio_tell(cio);
|
||||
cio_skip(cio, 4);
|
||||
cio_write(cio,MJ2_MDAT, 4);
|
||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||
free(buf);
|
||||
|
||||
/* Insert each j2k codestream in a JP2C box */
|
||||
snum=0;
|
||||
offset = 0;
|
||||
while(1) {
|
||||
mj2_sample_t * new_sample;
|
||||
mj2_chunk_t * new_chunk;
|
||||
sample = &movie->tk[0].sample[snum];
|
||||
sprintf(j2kfilename,"%s_%05d.j2k",argv[1],snum);
|
||||
j2kfile = fopen(j2kfilename, "rb");
|
||||
if (!j2kfile) {
|
||||
if (snum==0) { /* Could not open a single codestream */
|
||||
fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
|
||||
return 1;
|
||||
} else { /* Tried to open a inexistant codestream */
|
||||
fprintf(stdout,"%d frames are being added to the MJ2 file\n",snum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculating offset for samples and chunks */
|
||||
offset += cio_tell(cio);
|
||||
sample->offset = offset;
|
||||
movie->tk[0].chunk[snum].offset = offset; /* There will be one sample per chunk */
|
||||
|
||||
/* Calculating sample size */
|
||||
fseek(j2kfile,0,SEEK_END);
|
||||
sample->sample_size = ftell(j2kfile) + 8; /* Sample size is codestream + JP2C box header */
|
||||
fseek(j2kfile,0,SEEK_SET);
|
||||
|
||||
/* Reading siz marker of j2k image for the first codestream */
|
||||
if (snum==0)
|
||||
read_siz_marker(j2kfile, &img);
|
||||
|
||||
/* Writing JP2C box header */
|
||||
frame_codestream = (unsigned char*) malloc (sample->sample_size+8);
|
||||
cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);
|
||||
cio_write(cio,sample->sample_size, 4); /* Sample size */
|
||||
cio_write(cio,JP2_JP2C, 4); /* JP2C */
|
||||
|
||||
/* Writing codestream from J2K file to MJ2 file */
|
||||
fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
|
||||
fwrite(frame_codestream,sample->sample_size,1,mj2file);
|
||||
cio_skip(cio, sample->sample_size-8);
|
||||
|
||||
/* Ending loop */
|
||||
fclose(j2kfile);
|
||||
snum++;
|
||||
new_sample = (mj2_sample_t*)
|
||||
realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
|
||||
new_chunk = (mj2_chunk_t*)
|
||||
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
||||
if (new_sample && new_chunk) {
|
||||
movie->tk[0].sample = new_sample;
|
||||
movie->tk[0].chunk = new_chunk;
|
||||
} else {
|
||||
fprintf(stderr, "Failed to allocate enough memory to read %s\n", j2kfilename);
|
||||
return 1;
|
||||
}
|
||||
free(frame_codestream);
|
||||
}
|
||||
|
||||
/* Writing the MDAT box length in header */
|
||||
offset += cio_tell(cio);
|
||||
sample->offset = offset;
|
||||
movie->tk[0].chunk[snum].offset = offset; /* There will be one sample per chunk */
|
||||
buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, 4);
|
||||
cio_write(cio,offset-mdat_initpos,4);
|
||||
fseek(mj2file,(long)mdat_initpos,SEEK_SET);
|
||||
fwrite(buf,4,1,mj2file);
|
||||
fseek(mj2file,0,SEEK_END);
|
||||
free(buf);
|
||||
|
||||
/* Calculating sample size */
|
||||
fseek(j2kfile,0,SEEK_END);
|
||||
sample->sample_size = ftell(j2kfile) + 8; /* Sample size is codestream + JP2C box header */
|
||||
fseek(j2kfile,0,SEEK_SET);
|
||||
/* Setting movie parameters */
|
||||
movie->tk[0].num_samples=snum;
|
||||
movie->tk[0].num_chunks=snum;
|
||||
setparams(movie, &img);
|
||||
|
||||
/* Reading siz marker of j2k image for the first codestream */
|
||||
if (snum==0)
|
||||
read_siz_marker(j2kfile, &img);
|
||||
/* Writing MOOV box */
|
||||
buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
|
||||
mj2_write_moov(movie, cio);
|
||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||
|
||||
/* Writing JP2C box header */
|
||||
frame_codestream = (unsigned char*) malloc (sample->sample_size+8);
|
||||
cio = opj_cio_open(movie->cinfo, frame_codestream, sample->sample_size);
|
||||
cio_write(cio,sample->sample_size, 4); /* Sample size */
|
||||
cio_write(cio,JP2_JP2C, 4); /* JP2C */
|
||||
|
||||
/* Writing codestream from J2K file to MJ2 file */
|
||||
fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
|
||||
fwrite(frame_codestream,sample->sample_size,1,mj2file);
|
||||
cio_skip(cio, sample->sample_size-8);
|
||||
|
||||
/* Ending loop */
|
||||
fclose(j2kfile);
|
||||
snum++;
|
||||
new_sample = (mj2_sample_t*)
|
||||
realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
|
||||
new_chunk = (mj2_chunk_t*)
|
||||
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
||||
if (new_sample && new_chunk) {
|
||||
movie->tk[0].sample = new_sample;
|
||||
movie->tk[0].chunk = new_chunk;
|
||||
} else {
|
||||
fprintf(stderr, "Failed to allocate enough memory to read %s\n", j2kfilename);
|
||||
return 1;
|
||||
}
|
||||
free(frame_codestream);
|
||||
}
|
||||
|
||||
/* Writing the MDAT box length in header */
|
||||
offset += cio_tell(cio);
|
||||
buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, 4);
|
||||
cio_write(cio,offset-mdat_initpos,4);
|
||||
fseek(mj2file,(long)mdat_initpos,SEEK_SET);
|
||||
fwrite(buf,4,1,mj2file);
|
||||
fseek(mj2file,0,SEEK_END);
|
||||
free(buf);
|
||||
|
||||
/* Setting movie parameters */
|
||||
movie->tk[0].num_samples=snum;
|
||||
movie->tk[0].num_chunks=snum;
|
||||
setparams(movie, &img);
|
||||
|
||||
/* Writing MOOV box */
|
||||
buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
|
||||
mj2_write_moov(movie, cio);
|
||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||
|
||||
/* Ending program */
|
||||
free(img.comps);
|
||||
opj_cio_close(cio);
|
||||
/* Ending program */
|
||||
free(img.comps);
|
||||
opj_cio_close(cio);
|
||||
|
||||
fin:
|
||||
fclose(mj2file);
|
||||
mj2_destroy_compress(movie);
|
||||
free(j2kfilename);
|
||||
fclose(mj2file);
|
||||
mj2_destroy_compress(movie);
|
||||
free(j2kfilename);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -884,7 +889,7 @@ void OPJMarkerTree::OnSelChanged(wxTreeEvent& event)
|
||||
|
||||
m_peektextCtrl->WriteText(text);
|
||||
|
||||
delete buffer;
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
/*void LogKeyEvent(const wxChar *name, const wxKeyEvent& event)
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita' degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -175,73 +180,83 @@ class OPJChildFrame;
|
||||
//////////////////////////////////
|
||||
class OPJViewerApp: public wxApp
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJViewerApp() { m_showImages = true; m_showButtons = false; }
|
||||
// class constructor
|
||||
OPJViewerApp()
|
||||
{
|
||||
m_showImages = true;
|
||||
m_showButtons = false;
|
||||
}
|
||||
|
||||
// other methods
|
||||
bool OnInit(void);
|
||||
int OnExit(void);
|
||||
void SetShowImages(bool show) { m_showImages = show; }
|
||||
bool ShowImages() const { return m_showImages; }
|
||||
void ShowCmdLine(const wxCmdLineParser& parser);
|
||||
// other methods
|
||||
bool OnInit(void);
|
||||
int OnExit(void);
|
||||
void SetShowImages(bool show)
|
||||
{
|
||||
m_showImages = show;
|
||||
}
|
||||
bool ShowImages() const
|
||||
{
|
||||
return m_showImages;
|
||||
}
|
||||
void ShowCmdLine(const wxCmdLineParser& parser);
|
||||
|
||||
// all the threads currently alive - as soon as the thread terminates, it's
|
||||
// removed from the array
|
||||
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
|
||||
// all the threads currently alive - as soon as the thread terminates, it's
|
||||
// removed from the array
|
||||
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
|
||||
|
||||
// crit section protects access to all of the arrays below
|
||||
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
|
||||
// crit section protects access to all of the arrays below
|
||||
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
|
||||
|
||||
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
|
||||
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
|
||||
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
|
||||
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
|
||||
|
||||
// the last exiting thread should post to m_semAllDone if this is true
|
||||
// (protected by the same m_critsect)
|
||||
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
|
||||
// the last exiting thread should post to m_semAllDone if this is true
|
||||
// (protected by the same m_critsect)
|
||||
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
|
||||
|
||||
// the list of all filenames written in the command line
|
||||
wxArrayString m_filelist;
|
||||
// the list of all filenames written in the command line
|
||||
wxArrayString m_filelist;
|
||||
|
||||
// displaying engine parameters
|
||||
int m_resizemethod;
|
||||
// displaying engine parameters
|
||||
int m_resizemethod;
|
||||
|
||||
// decoding engine parameters
|
||||
bool m_enabledeco, m_enableparse;
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
// decoding engine parameters
|
||||
bool m_enabledeco, m_enableparse;
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl, m_enablejpwle;
|
||||
int m_expcomps, m_maxtiles;
|
||||
bool m_enablejpwl, m_enablejpwle;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
int m_framewidth, m_frameheight;
|
||||
int m_framewidth, m_frameheight;
|
||||
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
||||
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
|
||||
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
|
||||
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
|
||||
bool m_enablesegmark, m_enablepoc;
|
||||
bool m_enablequality;
|
||||
int m_resolutions, m_progression;
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
||||
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
|
||||
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
|
||||
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
|
||||
bool m_enablesegmark, m_enablepoc;
|
||||
bool m_enablequality;
|
||||
int m_resolutions, m_progression;
|
||||
#ifdef USE_JPWL
|
||||
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
|
||||
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
|
||||
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
|
||||
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
|
||||
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
|
||||
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
|
||||
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
|
||||
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
|
||||
#endif // USE_JPWL
|
||||
|
||||
// some layout settings
|
||||
bool m_showtoolbar, m_showbrowser, m_showpeeker;
|
||||
int m_browserwidth, m_peekerheight;
|
||||
// some layout settings
|
||||
bool m_showtoolbar, m_showbrowser, m_showpeeker;
|
||||
int m_browserwidth, m_peekerheight;
|
||||
|
||||
// application configuration
|
||||
wxConfig *OPJconfig;
|
||||
// application configuration
|
||||
wxConfig *OPJconfig;
|
||||
|
||||
// private methods and variables
|
||||
private:
|
||||
bool m_showImages, m_showButtons;
|
||||
// private methods and variables
|
||||
private:
|
||||
bool m_showImages, m_showButtons;
|
||||
|
||||
};
|
||||
|
||||
@@ -252,37 +267,38 @@ DECLARE_APP(OPJViewerApp)
|
||||
///////////////////////////////////////////
|
||||
class OPJCanvas: public wxScrolledWindow
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||
// class constructor
|
||||
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
void OnEvent(wxMouseEvent& event);
|
||||
void WriteText(const wxString& text) {
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
void OnEvent(wxMouseEvent& event);
|
||||
void WriteText(const wxString& text)
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiEnter();
|
||||
wxMutexGuiEnter();
|
||||
#endif //__WXGTK__
|
||||
wxLogMessage(text);
|
||||
wxLogMessage(text);
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
wxMutexGuiLeave();
|
||||
#endif //__WXGTK__
|
||||
}
|
||||
}
|
||||
|
||||
void OnThreadSignal(wxCommandEvent& event);
|
||||
void OnThreadSignal(wxCommandEvent& event);
|
||||
|
||||
OPJDecoThread *CreateDecoThread(void);
|
||||
OPJEncoThread *CreateEncoThread(void);
|
||||
OPJDecoThread *CreateDecoThread(void);
|
||||
OPJEncoThread *CreateEncoThread(void);
|
||||
|
||||
|
||||
OPJChildFrame *m_childframe;
|
||||
OPJChildFrame *m_childframe;
|
||||
|
||||
wxBitmap m_image, m_image100;
|
||||
wxFileName m_fname, m_savename;
|
||||
long m_zooml;
|
||||
wxBitmap m_image, m_image100;
|
||||
wxFileName m_fname, m_savename;
|
||||
long m_zooml;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
@@ -290,29 +306,38 @@ class OPJCanvas: public wxScrolledWindow
|
||||
///////////////////////////////////////////////////
|
||||
class OPJMarkerData : public wxTreeItemData
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
|
||||
// class constructor
|
||||
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname)
|
||||
{
|
||||
m_start = start;
|
||||
m_length = length;
|
||||
}
|
||||
|
||||
void ShowInfo(wxTreeCtrl *tree);
|
||||
const wxChar *GetDesc1() const { return m_desc.c_str(); }
|
||||
const wxChar *GetDesc2() const { return m_filestring.c_str(); }
|
||||
wxFileOffset m_start, m_length;
|
||||
wxString m_desc;
|
||||
void ShowInfo(wxTreeCtrl *tree);
|
||||
const wxChar *GetDesc1() const
|
||||
{
|
||||
return m_desc.c_str();
|
||||
}
|
||||
const wxChar *GetDesc2() const
|
||||
{
|
||||
return m_filestring.c_str();
|
||||
}
|
||||
wxFileOffset m_start, m_length;
|
||||
wxString m_desc;
|
||||
|
||||
// private methods and variables
|
||||
private:
|
||||
wxString m_filestring;
|
||||
// private methods and variables
|
||||
private:
|
||||
wxString m_filestring;
|
||||
};
|
||||
|
||||
|
||||
class OPJMarkerTree : public wxTreeCtrl
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
TreeCtrlIcon_File,
|
||||
TreeCtrlIcon_FileSelected,
|
||||
TreeCtrlIcon_Folder,
|
||||
@@ -322,15 +347,20 @@ public:
|
||||
|
||||
OPJMarkerTree() { };
|
||||
OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style);
|
||||
virtual ~OPJMarkerTree(){};
|
||||
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
||||
void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style);
|
||||
virtual ~OPJMarkerTree() {};
|
||||
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
||||
void WriteText(const wxString& text)
|
||||
{
|
||||
wxMutexGuiEnter();
|
||||
wxLogMessage(text);
|
||||
wxMutexGuiLeave();
|
||||
}
|
||||
|
||||
wxFileName m_fname;
|
||||
wxTextCtrl *m_peektextCtrl;
|
||||
OPJChildFrame *m_childframe;
|
||||
wxFileName m_fname;
|
||||
wxTextCtrl *m_peektextCtrl;
|
||||
OPJChildFrame *m_childframe;
|
||||
|
||||
/*void OnBeginDrag(wxTreeEvent& event);
|
||||
void OnBeginRDrag(wxTreeEvent& event);
|
||||
@@ -367,9 +397,15 @@ public:
|
||||
/*void DoToggleIcon(const wxTreeItemId& item);*/
|
||||
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
|
||||
|
||||
int ImageSize(void) const { return m_imageSize; }
|
||||
int ImageSize(void) const
|
||||
{
|
||||
return m_imageSize;
|
||||
}
|
||||
|
||||
void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
|
||||
void SetLastItem(wxTreeItemId id)
|
||||
{
|
||||
m_lastItem = id;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
|
||||
@@ -411,12 +447,12 @@ WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChild
|
||||
// Define a new frame
|
||||
class OPJFrame: public wxMDIParentFrame
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
|
||||
~OPJFrame(void);
|
||||
void OnSize(wxSizeEvent& WXUNUSED(event));
|
||||
void OnSize(wxSizeEvent& WXUNUSED(event));
|
||||
void OnAbout(wxCommandEvent& WXUNUSED(event));
|
||||
void OnFileOpen(wxCommandEvent& WXUNUSED(event));
|
||||
void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
|
||||
@@ -424,43 +460,43 @@ class OPJFrame: public wxMDIParentFrame
|
||||
void OnQuit(wxCommandEvent& WXUNUSED(event));
|
||||
void OnClose(wxCommandEvent& WXUNUSED(event));
|
||||
void OnZoom(wxCommandEvent& WXUNUSED(event));
|
||||
void OnFit(wxCommandEvent& event);
|
||||
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
|
||||
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
|
||||
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
|
||||
void OnReload(wxCommandEvent& event);
|
||||
void OnPrevFrame(wxCommandEvent& event);
|
||||
void OnHomeFrame(wxCommandEvent& event);
|
||||
void OnNextFrame(wxCommandEvent& event);
|
||||
void OnLessLayers(wxCommandEvent& event);
|
||||
void OnAllLayers(wxCommandEvent& event);
|
||||
void OnMoreLayers(wxCommandEvent& event);
|
||||
void OnLessRes(wxCommandEvent& event);
|
||||
void OnFullRes(wxCommandEvent& event);
|
||||
void OnMoreRes(wxCommandEvent& event);
|
||||
void OnPrevComp(wxCommandEvent& event);
|
||||
void OnAllComps(wxCommandEvent& event);
|
||||
void OnNextComp(wxCommandEvent& event);
|
||||
void OnSetsEnco(wxCommandEvent& event);
|
||||
void OnSetsDeco(wxCommandEvent& event);
|
||||
void OnSashDrag(wxSashEvent& event);
|
||||
void OpenFiles(wxArrayString paths, wxArrayString filenames);
|
||||
void SaveFile(wxArrayString paths, wxArrayString filenames);
|
||||
void OnNotebook(wxNotebookEvent& event);
|
||||
void Rescale(int scale, OPJChildFrame *child);
|
||||
void OnThreadLogmsg(wxCommandEvent& event);
|
||||
void OnFit(wxCommandEvent& event);
|
||||
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
|
||||
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
|
||||
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
|
||||
void OnReload(wxCommandEvent& event);
|
||||
void OnPrevFrame(wxCommandEvent& event);
|
||||
void OnHomeFrame(wxCommandEvent& event);
|
||||
void OnNextFrame(wxCommandEvent& event);
|
||||
void OnLessLayers(wxCommandEvent& event);
|
||||
void OnAllLayers(wxCommandEvent& event);
|
||||
void OnMoreLayers(wxCommandEvent& event);
|
||||
void OnLessRes(wxCommandEvent& event);
|
||||
void OnFullRes(wxCommandEvent& event);
|
||||
void OnMoreRes(wxCommandEvent& event);
|
||||
void OnPrevComp(wxCommandEvent& event);
|
||||
void OnAllComps(wxCommandEvent& event);
|
||||
void OnNextComp(wxCommandEvent& event);
|
||||
void OnSetsEnco(wxCommandEvent& event);
|
||||
void OnSetsDeco(wxCommandEvent& event);
|
||||
void OnSashDrag(wxSashEvent& event);
|
||||
void OpenFiles(wxArrayString paths, wxArrayString filenames);
|
||||
void SaveFile(wxArrayString paths, wxArrayString filenames);
|
||||
void OnNotebook(wxNotebookEvent& event);
|
||||
void Rescale(int scale, OPJChildFrame *child);
|
||||
void OnThreadLogmsg(wxCommandEvent& event);
|
||||
|
||||
OPJMarkerTreeHash m_treehash;
|
||||
OPJChildFrameHash m_childhash;
|
||||
OPJMarkerTreeHash m_treehash;
|
||||
OPJChildFrameHash m_childhash;
|
||||
wxSashLayoutWindow* markerTreeWindow;
|
||||
wxSashLayoutWindow* loggingWindow;
|
||||
wxToolBar* tool_bar;
|
||||
wxToolBar* tool_bar;
|
||||
void Resize(int number);
|
||||
wxNotebook *m_bookCtrl;
|
||||
wxNotebook *m_bookCtrlbottom;
|
||||
wxNotebook *m_bookCtrl;
|
||||
wxNotebook *m_bookCtrlbottom;
|
||||
wxTextCtrl *m_textCtrlbrowse;
|
||||
|
||||
private:
|
||||
private:
|
||||
void TogStyle(int id, long flag);
|
||||
|
||||
void DoSort(bool reverse = false);
|
||||
@@ -474,70 +510,69 @@ protected:
|
||||
wxSashLayoutWindow* m_topWindow;
|
||||
wxSashLayoutWindow* m_leftWindow2;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class OPJChildFrame: public wxMDIChildFrame
|
||||
{
|
||||
public:
|
||||
public:
|
||||
OPJCanvas *m_canvas;
|
||||
OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~OPJChildFrame(void);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnGotFocus(wxFocusEvent& event);
|
||||
void OnLostFocus(wxFocusEvent& event);
|
||||
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnGotFocus(wxFocusEvent& event);
|
||||
void OnLostFocus(wxFocusEvent& event);
|
||||
OPJFrame *m_frame;
|
||||
wxFileName m_fname;
|
||||
int m_winnumber;
|
||||
wxFileName m_fname;
|
||||
int m_winnumber;
|
||||
|
||||
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
||||
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// frame and main menu ids
|
||||
enum {
|
||||
OPJFRAME_FILEEXIT = wxID_EXIT,
|
||||
OPJFRAME_HELPABOUT = wxID_ABOUT,
|
||||
OPJFRAME_FILEOPEN,
|
||||
OPJFRAME_MEMORYOPEN,
|
||||
OPJFRAME_FILESAVEAS,
|
||||
OPJFRAME_FILETOGGLEB,
|
||||
OPJFRAME_FILETOGGLEP,
|
||||
OPJFRAME_FILETOGGLET,
|
||||
OPJFRAME_VIEWZOOM,
|
||||
OPJFRAME_VIEWFIT,
|
||||
OPJFRAME_VIEWRELOAD,
|
||||
OPJFRAME_VIEWPREVFRAME,
|
||||
OPJFRAME_VIEWHOMEFRAME,
|
||||
OPJFRAME_VIEWNEXTFRAME,
|
||||
OPJFRAME_VIEWLESSLAYERS,
|
||||
OPJFRAME_VIEWALLLAYERS,
|
||||
OPJFRAME_VIEWMORELAYERS,
|
||||
OPJFRAME_VIEWLESSRES,
|
||||
OPJFRAME_VIEWFULLRES,
|
||||
OPJFRAME_VIEWMORERES,
|
||||
OPJFRAME_VIEWPREVCOMP,
|
||||
OPJFRAME_VIEWALLCOMPS,
|
||||
OPJFRAME_VIEWNEXTCOMP,
|
||||
OPJFRAME_FILECLOSE,
|
||||
OPJFRAME_SETSENCO,
|
||||
OPJFRAME_SETSDECO,
|
||||
OPJFRAME_FILEEXIT = wxID_EXIT,
|
||||
OPJFRAME_HELPABOUT = wxID_ABOUT,
|
||||
OPJFRAME_FILEOPEN,
|
||||
OPJFRAME_MEMORYOPEN,
|
||||
OPJFRAME_FILESAVEAS,
|
||||
OPJFRAME_FILETOGGLEB,
|
||||
OPJFRAME_FILETOGGLEP,
|
||||
OPJFRAME_FILETOGGLET,
|
||||
OPJFRAME_VIEWZOOM,
|
||||
OPJFRAME_VIEWFIT,
|
||||
OPJFRAME_VIEWRELOAD,
|
||||
OPJFRAME_VIEWPREVFRAME,
|
||||
OPJFRAME_VIEWHOMEFRAME,
|
||||
OPJFRAME_VIEWNEXTFRAME,
|
||||
OPJFRAME_VIEWLESSLAYERS,
|
||||
OPJFRAME_VIEWALLLAYERS,
|
||||
OPJFRAME_VIEWMORELAYERS,
|
||||
OPJFRAME_VIEWLESSRES,
|
||||
OPJFRAME_VIEWFULLRES,
|
||||
OPJFRAME_VIEWMORERES,
|
||||
OPJFRAME_VIEWPREVCOMP,
|
||||
OPJFRAME_VIEWALLCOMPS,
|
||||
OPJFRAME_VIEWNEXTCOMP,
|
||||
OPJFRAME_FILECLOSE,
|
||||
OPJFRAME_SETSENCO,
|
||||
OPJFRAME_SETSDECO,
|
||||
|
||||
OPJFRAME_BROWSEWIN = 10000,
|
||||
OPJFRAME_LOGWIN,
|
||||
OPJFRAME_TOOLBAR,
|
||||
OPJFRAME_BROWSEWIN = 10000,
|
||||
OPJFRAME_LOGWIN,
|
||||
OPJFRAME_TOOLBAR,
|
||||
|
||||
OPJFRAME_THREADLOGMSG,
|
||||
OPJCANVAS_THREADSIGNAL
|
||||
OPJFRAME_THREADLOGMSG,
|
||||
OPJCANVAS_THREADSIGNAL
|
||||
};
|
||||
|
||||
|
||||
// menu and control ids
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
TreeTest_Quit = wxID_EXIT,
|
||||
TreeTest_About = wxID_ABOUT,
|
||||
TreeTest_TogButtons = wxID_HIGHEST,
|
||||
@@ -582,8 +617,8 @@ enum
|
||||
TreeTest_Unselect,
|
||||
TreeTest_SelectRoot,
|
||||
TreeTest_Ctrl = 1000,
|
||||
BOTTOM_NOTEBOOK_ID,
|
||||
LEFT_NOTEBOOK_ID
|
||||
BOTTOM_NOTEBOOK_ID,
|
||||
LEFT_NOTEBOOK_ID
|
||||
};
|
||||
|
||||
class OPJEncoThread : public wxThread
|
||||
@@ -640,19 +675,19 @@ public:
|
||||
|
||||
// write something to the text control
|
||||
void WriteText(const wxString& text);
|
||||
void LoadFile(wxFileName fname);
|
||||
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
||||
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
||||
void LoadFile(wxFileName fname);
|
||||
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
||||
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
||||
|
||||
unsigned m_count;
|
||||
OPJMarkerTree *m_tree;
|
||||
wxTreeItemId m_parentid;
|
||||
wxTreeItemId m_parentid;
|
||||
|
||||
private:
|
||||
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
|
||||
};
|
||||
|
||||
@@ -661,7 +696,10 @@ private:
|
||||
class OPJDnDFile: public wxFileDropTarget
|
||||
{
|
||||
public:
|
||||
OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
|
||||
OPJDnDFile(OPJFrame *pOwner)
|
||||
{
|
||||
m_pOwner = pOwner;
|
||||
}
|
||||
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
||||
|
||||
private:
|
||||
@@ -673,137 +711,137 @@ private:
|
||||
// Property sheet dialog: encoder
|
||||
class OPJEncoderDialog: public wxPropertySheetDialog
|
||||
{
|
||||
DECLARE_CLASS(OPJEncoderDialog)
|
||||
DECLARE_CLASS(OPJEncoderDialog)
|
||||
public:
|
||||
OPJEncoderDialog(wxWindow* parent, int dialogType);
|
||||
~OPJEncoderDialog();
|
||||
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
|
||||
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
|
||||
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
|
||||
void OnEnableComm(wxCommandEvent& event);
|
||||
void OnEnableIdx(wxCommandEvent& event);
|
||||
void OnEnablePoc(wxCommandEvent& event);
|
||||
void OnRadioQualityRate(wxCommandEvent& event);
|
||||
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
|
||||
void OnEnableComm(wxCommandEvent& event);
|
||||
void OnEnableIdx(wxCommandEvent& event);
|
||||
void OnEnablePoc(wxCommandEvent& event);
|
||||
void OnRadioQualityRate(wxCommandEvent& event);
|
||||
#ifdef USE_JPWL
|
||||
void OnEnableJPWL(wxCommandEvent& event);
|
||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||
/*wxCheckBox *m_enablejpwlCheck;*/
|
||||
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
void OnHprotSelect(wxCommandEvent& event);
|
||||
void OnPprotSelect(wxCommandEvent& event);
|
||||
void OnSensiSelect(wxCommandEvent& event);
|
||||
void OnEnableJPWL(wxCommandEvent& event);
|
||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||
/*wxCheckBox *m_enablejpwlCheck;*/
|
||||
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||
void OnHprotSelect(wxCommandEvent& event);
|
||||
void OnPprotSelect(wxCommandEvent& event);
|
||||
void OnSensiSelect(wxCommandEvent& event);
|
||||
#endif // USE_JPWL
|
||||
|
||||
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
|
||||
wxRadioButton *m_rateRadio, *m_qualityRadio;
|
||||
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
|
||||
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
|
||||
wxRadioBox *progressionBox;
|
||||
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
|
||||
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
|
||||
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
|
||||
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
|
||||
wxSpinCtrl *m_resolutionsCtrl;
|
||||
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
|
||||
wxRadioButton *m_rateRadio, *m_qualityRadio;
|
||||
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
|
||||
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
|
||||
wxRadioBox *progressionBox;
|
||||
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
|
||||
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
|
||||
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
|
||||
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
|
||||
wxSpinCtrl *m_resolutionsCtrl;
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
OPJENCO_ENABLEJPWL = 100,
|
||||
OPJENCO_RATEFACTOR,
|
||||
OPJENCO_RATERADIO,
|
||||
OPJENCO_QUALITYFACTOR,
|
||||
OPJENCO_QUALITYRADIO,
|
||||
OPJENCO_RESNUMBER,
|
||||
OPJENCO_CODEBLOCKSIZE,
|
||||
OPJENCO_PRECINCTSIZE,
|
||||
OPJENCO_TILESIZE,
|
||||
OPJENCO_PROGRESSION,
|
||||
OPJENCO_SUBSAMPLING,
|
||||
OPJENCO_ENABLESOP,
|
||||
OPJENCO_ENABLEEPH,
|
||||
OPJENCO_ENABLEBYPASS,
|
||||
OPJENCO_ENABLERESET,
|
||||
OPJENCO_ENABLERESTART,
|
||||
OPJENCO_ENABLEVSC,
|
||||
OPJENCO_ENABLEERTERM,
|
||||
OPJENCO_ENABLESEGMARK,
|
||||
OPJENCO_ENABLEPOC,
|
||||
OPJENCO_ROICOMP,
|
||||
OPJENCO_ROISHIFT,
|
||||
OPJENCO_IMORIG,
|
||||
OPJENCO_TILORIG,
|
||||
OPJENCO_ENABLEMCT,
|
||||
OPJENCO_ENABLEIRREV,
|
||||
OPJENCO_ENABLEINDEX,
|
||||
OPJENCO_INDEXNAME,
|
||||
OPJENCO_POCSPEC,
|
||||
OPJENCO_ENABLECOMM,
|
||||
OPJENCO_COMMENTTEXT,
|
||||
OPJENCO_HPROT,
|
||||
OPJENCO_HTILE,
|
||||
OPJENCO_PPROT,
|
||||
OPJENCO_PTILE,
|
||||
OPJENCO_PPACK,
|
||||
OPJENCO_SENSI,
|
||||
OPJENCO_STILE
|
||||
OPJENCO_ENABLEJPWL = 100,
|
||||
OPJENCO_RATEFACTOR,
|
||||
OPJENCO_RATERADIO,
|
||||
OPJENCO_QUALITYFACTOR,
|
||||
OPJENCO_QUALITYRADIO,
|
||||
OPJENCO_RESNUMBER,
|
||||
OPJENCO_CODEBLOCKSIZE,
|
||||
OPJENCO_PRECINCTSIZE,
|
||||
OPJENCO_TILESIZE,
|
||||
OPJENCO_PROGRESSION,
|
||||
OPJENCO_SUBSAMPLING,
|
||||
OPJENCO_ENABLESOP,
|
||||
OPJENCO_ENABLEEPH,
|
||||
OPJENCO_ENABLEBYPASS,
|
||||
OPJENCO_ENABLERESET,
|
||||
OPJENCO_ENABLERESTART,
|
||||
OPJENCO_ENABLEVSC,
|
||||
OPJENCO_ENABLEERTERM,
|
||||
OPJENCO_ENABLESEGMARK,
|
||||
OPJENCO_ENABLEPOC,
|
||||
OPJENCO_ROICOMP,
|
||||
OPJENCO_ROISHIFT,
|
||||
OPJENCO_IMORIG,
|
||||
OPJENCO_TILORIG,
|
||||
OPJENCO_ENABLEMCT,
|
||||
OPJENCO_ENABLEIRREV,
|
||||
OPJENCO_ENABLEINDEX,
|
||||
OPJENCO_INDEXNAME,
|
||||
OPJENCO_POCSPEC,
|
||||
OPJENCO_ENABLECOMM,
|
||||
OPJENCO_COMMENTTEXT,
|
||||
OPJENCO_HPROT,
|
||||
OPJENCO_HTILE,
|
||||
OPJENCO_PPROT,
|
||||
OPJENCO_PTILE,
|
||||
OPJENCO_PPACK,
|
||||
OPJENCO_SENSI,
|
||||
OPJENCO_STILE
|
||||
};
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// Property sheet dialog: decoder
|
||||
class OPJDecoderDialog: public wxPropertySheetDialog
|
||||
{
|
||||
DECLARE_CLASS(OPJDecoderDialog)
|
||||
DECLARE_CLASS(OPJDecoderDialog)
|
||||
public:
|
||||
OPJDecoderDialog(wxWindow* parent, int dialogType);
|
||||
~OPJDecoderDialog();
|
||||
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
||||
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
||||
wxRadioBox* m_resizeBox;
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
||||
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
||||
wxRadioBox* m_resizeBox;
|
||||
|
||||
void OnEnableDeco(wxCommandEvent& event);
|
||||
void OnEnableDeco(wxCommandEvent& event);
|
||||
|
||||
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart3SettingsPage(wxWindow* parent);
|
||||
#ifdef USE_JPWL
|
||||
void OnEnableJPWL(wxCommandEvent& event);
|
||||
void OnEnableJPWL(wxCommandEvent& event);
|
||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
||||
wxCheckBox *m_enablejpwlCheck;
|
||||
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
||||
wxCheckBox *m_enablejpwlCheck;
|
||||
#endif // USE_JPWL
|
||||
wxSpinCtrl *m_framenumCtrl;
|
||||
wxSpinCtrl *m_framenumCtrl;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
OPJDECO_RESMETHOD = 100,
|
||||
OPJDECO_REDUCEFACTOR,
|
||||
OPJDECO_QUALITYLAYERS,
|
||||
OPJDECO_NUMCOMPS,
|
||||
OPJDECO_ENABLEDECO,
|
||||
OPJDECO_ENABLEPARSE,
|
||||
OPJDECO_ENABLEJPWL,
|
||||
OPJDECO_EXPCOMPS,
|
||||
OPJDECO_MAXTILES,
|
||||
OPJDECO_FRAMENUM
|
||||
OPJDECO_RESMETHOD = 100,
|
||||
OPJDECO_REDUCEFACTOR,
|
||||
OPJDECO_QUALITYLAYERS,
|
||||
OPJDECO_NUMCOMPS,
|
||||
OPJDECO_ENABLEDECO,
|
||||
OPJDECO_ENABLEPARSE,
|
||||
OPJDECO_ENABLEJPWL,
|
||||
OPJDECO_EXPCOMPS,
|
||||
OPJDECO_MAXTILES,
|
||||
OPJDECO_FRAMENUM
|
||||
};
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif //__OPJ_VIEWER_H__
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
wxString htmlaboutpage = wxT(
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
#include "build.h"
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
#ifdef USE_JPWL
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
#endif // USE_JPWL
|
||||
#ifdef USE_JPSEC
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
#endif // USE_JPSEC
|
||||
wxT(")</font><br>")
|
||||
wxT(")</font><br>")
|
||||
#ifdef USE_MXF
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
#endif // USE_MXF
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -59,105 +64,105 @@ public:
|
||||
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||
m_mime = wxT("image/mj2");
|
||||
|
||||
/* decoding */
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
/* decoding */
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
|
||||
/* encoding */
|
||||
m_subsampling = wxT("1,1");
|
||||
m_origin = wxT("0,0");
|
||||
m_rates = wxT("20,10,5");
|
||||
m_quality = wxT("30,35,40");
|
||||
m_enablequality = false;
|
||||
m_multicomp = false;
|
||||
m_irreversible = false;
|
||||
m_resolutions = 6;
|
||||
m_progression = 0;
|
||||
m_cbsize = wxT("32,32");
|
||||
m_prsize = wxT("[128,128],[128,128]");
|
||||
m_tsize = wxT("");
|
||||
m_torigin = wxT("0,0");
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
m_enablesop = false;
|
||||
m_enableeph = false;
|
||||
m_enablereset = false;
|
||||
m_enablesegmark = false;
|
||||
m_enablevsc = false;
|
||||
m_enablerestart = false;
|
||||
m_enableerterm = false;
|
||||
m_enablebypass = false;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
m_enableidx = false;
|
||||
m_index = wxT("index.txt");
|
||||
m_enablepoc = false;
|
||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||
m_enablecomm = true;
|
||||
/* encoding */
|
||||
m_subsampling = wxT("1,1");
|
||||
m_origin = wxT("0,0");
|
||||
m_rates = wxT("20,10,5");
|
||||
m_quality = wxT("30,35,40");
|
||||
m_enablequality = false;
|
||||
m_multicomp = false;
|
||||
m_irreversible = false;
|
||||
m_resolutions = 6;
|
||||
m_progression = 0;
|
||||
m_cbsize = wxT("32,32");
|
||||
m_prsize = wxT("[128,128],[128,128]");
|
||||
m_tsize = wxT("");
|
||||
m_torigin = wxT("0,0");
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
m_enablesop = false;
|
||||
m_enableeph = false;
|
||||
m_enablereset = false;
|
||||
m_enablesegmark = false;
|
||||
m_enablevsc = false;
|
||||
m_enablerestart = false;
|
||||
m_enableerterm = false;
|
||||
m_enablebypass = false;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
m_enableidx = false;
|
||||
m_index = wxT("index.txt");
|
||||
m_enablepoc = false;
|
||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||
m_enablecomm = true;
|
||||
|
||||
#if defined __WXMSW__
|
||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||
#elif defined __WXGTK__
|
||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||
#else
|
||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||
#endif
|
||||
|
||||
#ifdef USE_JPWL
|
||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||
#else
|
||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling;
|
||||
wxString m_origin;
|
||||
wxString m_rates;
|
||||
wxString m_quality;
|
||||
bool m_enablequality;
|
||||
bool m_multicomp;
|
||||
bool m_irreversible;
|
||||
int m_resolutions;
|
||||
int m_progression;
|
||||
wxString m_cbsize;
|
||||
wxString m_prsize;
|
||||
wxString m_tsize;
|
||||
wxString m_torigin;
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
bool m_enablesop;
|
||||
bool m_enableeph;
|
||||
bool m_enablebypass;
|
||||
bool m_enableerterm;
|
||||
bool m_enablerestart;
|
||||
bool m_enablereset;
|
||||
bool m_enablesegmark;
|
||||
bool m_enablevsc;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
bool m_enableidx;
|
||||
wxString m_index;
|
||||
bool m_enablecomm;
|
||||
wxString m_comment;
|
||||
bool m_enablepoc;
|
||||
wxString m_poc;
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling;
|
||||
wxString m_origin;
|
||||
wxString m_rates;
|
||||
wxString m_quality;
|
||||
bool m_enablequality;
|
||||
bool m_multicomp;
|
||||
bool m_irreversible;
|
||||
int m_resolutions;
|
||||
int m_progression;
|
||||
wxString m_cbsize;
|
||||
wxString m_prsize;
|
||||
wxString m_tsize;
|
||||
wxString m_torigin;
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
bool m_enablesop;
|
||||
bool m_enableeph;
|
||||
bool m_enablebypass;
|
||||
bool m_enableerterm;
|
||||
bool m_enablerestart;
|
||||
bool m_enablereset;
|
||||
bool m_enablesegmark;
|
||||
bool m_enablevsc;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
bool m_enableidx;
|
||||
wxString m_index;
|
||||
bool m_enablecomm;
|
||||
wxString m_comment;
|
||||
bool m_enablepoc;
|
||||
wxString m_poc;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||
@@ -167,7 +172,7 @@ protected:
|
||||
#endif
|
||||
|
||||
private:
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -61,23 +66,23 @@ public:
|
||||
m_type = wxBITMAP_TYPE_MXF;
|
||||
m_mime = wxT("image/mxf");
|
||||
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
m_filename = wxT("");
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
m_filename = wxT("");
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
wxFileName m_filename;
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
wxFileName m_filename;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
Copyright (c) 2002-2003, Yannick Verschueren
|
||||
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
|
||||
@@ -8,4 +8,4 @@ Anybody. As the OpenJPEG library is released under the BSD license, anybody can
|
||||
|
||||
Who is developing the library ?
|
||||
===============================
|
||||
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit<69> Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit<69> Catholique de Louvain (UCL). The JPWL module is developed and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -10,37 +10,69 @@ include_directories(
|
||||
# Defines the source code for the library
|
||||
set(OPENJPEG_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bio.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cio.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dwt.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dwt.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/event.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/event.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/invert.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/invert.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/j2k.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/j2k.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jp2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jp2.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mct.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mct.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pi.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pi.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raw.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/t1.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/t1.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/t2.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tcd.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tgt.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tgt.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/function_list.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_codec.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_includes.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_intmath.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
|
||||
)
|
||||
if(BUILD_JPIP)
|
||||
add_definitions(-DUSE_JPIP)
|
||||
set(OPENJPEG_SRCS
|
||||
${OPENJPEG_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/indexbox_manager.h
|
||||
)
|
||||
endif()
|
||||
|
||||
option(OPJ_DISABLE_TPSOT_FIX "Disable TPsot==TNsot fix. See https://github.com/uclouvain/openjpeg/issues/254." OFF)
|
||||
if(OPJ_DISABLE_TPSOT_FIX)
|
||||
add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
|
||||
endif()
|
||||
|
||||
# Build the library
|
||||
if(WIN32)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@@ -54,6 +86,9 @@ if(UNIX)
|
||||
target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
|
||||
endif()
|
||||
set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
|
||||
target_compile_options(${OPENJPEG_LIBRARY_NAME} PRIVATE ${OPENJPEG_LIBRARY_COMPILE_OPTIONS})
|
||||
endif()
|
||||
|
||||
# Install library
|
||||
install(TARGETS ${OPENJPEG_LIBRARY_NAME}
|
||||
@@ -68,10 +103,12 @@ install(FILES openjpeg.h opj_stdint.h
|
||||
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
|
||||
)
|
||||
|
||||
if(BUILD_DOC)
|
||||
# install man page of the library
|
||||
install(
|
||||
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjp2.3
|
||||
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
|
||||
endif()
|
||||
|
||||
# internal utilities to generate t1_luts.h (part of the jp2 lib)
|
||||
# no need to install:
|
||||
@@ -96,3 +133,12 @@ if(OPENJPEG_CPPCHECK)
|
||||
COMMAND ${CPPCHECK_EXECUTABLE} -DWIN32 ${f})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(OPJ_USE_DSYMUTIL)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME} POST_BUILD
|
||||
COMMAND "dsymutil" "$<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
||||
COMMENT "dsymutil $<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
||||
DEPENDS ${OPENJPEG_LIBRARY_NAME})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -72,40 +78,44 @@ static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) {
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if (bio->bp >= bio->end) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
*bio->bp++ = (OPJ_BYTE)(bio->buf >> 8);
|
||||
return OPJ_TRUE;
|
||||
static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio)
|
||||
{
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
*bio->bp++ = (OPJ_BYTE)(bio->buf >> 8);
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) {
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if (bio->bp >= bio->end) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
bio->buf |= *bio->bp++;
|
||||
return OPJ_TRUE;
|
||||
static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio)
|
||||
{
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
bio->buf |= *bio->bp++;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
|
||||
if (bio->ct == 0) {
|
||||
opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */
|
||||
}
|
||||
bio->ct--;
|
||||
bio->buf |= b << bio->ct;
|
||||
static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b)
|
||||
{
|
||||
if (bio->ct == 0) {
|
||||
opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */
|
||||
}
|
||||
bio->ct--;
|
||||
bio->buf |= b << bio->ct;
|
||||
}
|
||||
|
||||
OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
|
||||
if (bio->ct == 0) {
|
||||
opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */
|
||||
}
|
||||
bio->ct--;
|
||||
return (bio->buf >> bio->ct) & 1;
|
||||
static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio)
|
||||
{
|
||||
if (bio->ct == 0) {
|
||||
opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */
|
||||
}
|
||||
bio->ct--;
|
||||
return (bio->buf >> bio->ct) & 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -114,75 +124,81 @@ OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
opj_bio_t* opj_bio_create(void) {
|
||||
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
|
||||
return bio;
|
||||
opj_bio_t* opj_bio_create(void)
|
||||
{
|
||||
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
|
||||
return bio;
|
||||
}
|
||||
|
||||
void opj_bio_destroy(opj_bio_t *bio) {
|
||||
if(bio) {
|
||||
opj_free(bio);
|
||||
}
|
||||
void opj_bio_destroy(opj_bio_t *bio)
|
||||
{
|
||||
if(bio) {
|
||||
opj_free(bio);
|
||||
}
|
||||
}
|
||||
|
||||
ptrdiff_t opj_bio_numbytes(opj_bio_t *bio) {
|
||||
return (bio->bp - bio->start);
|
||||
ptrdiff_t opj_bio_numbytes(opj_bio_t *bio)
|
||||
{
|
||||
return (bio->bp - bio->start);
|
||||
}
|
||||
|
||||
void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 8;
|
||||
void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
|
||||
{
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 8;
|
||||
}
|
||||
|
||||
void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 0;
|
||||
void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len)
|
||||
{
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 0;
|
||||
}
|
||||
|
||||
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
opj_bio_putbit(bio, (v >> i) & 1);
|
||||
}
|
||||
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
opj_bio_putbit(bio, (v >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 v;
|
||||
v = 0;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
v += opj_bio_getbit(bio) << i;
|
||||
}
|
||||
return v;
|
||||
v = 0;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
v += opj_bio_getbit(bio) << i;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_bio_flush(opj_bio_t *bio) {
|
||||
bio->ct = 0;
|
||||
if (! opj_bio_byteout(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (bio->ct == 7) {
|
||||
bio->ct = 0;
|
||||
if (! opj_bio_byteout(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
OPJ_BOOL opj_bio_flush(opj_bio_t *bio)
|
||||
{
|
||||
if (! opj_bio_byteout(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (bio->ct == 7) {
|
||||
if (! opj_bio_byteout(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) {
|
||||
bio->ct = 0;
|
||||
if ((bio->buf & 0xff) == 0xff) {
|
||||
if (! opj_bio_bytein(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
bio->ct = 0;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
OPJ_BOOL opj_bio_inalign(opj_bio_t *bio)
|
||||
{
|
||||
if ((bio->buf & 0xff) == 0xff) {
|
||||
if (! opj_bio_bytein(bio)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
bio->ct = 0;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -48,16 +54,16 @@ The functions in BIO.C have for goal to realize an individual bit input - output
|
||||
Individual bit input-output stream (BIO)
|
||||
*/
|
||||
typedef struct opj_bio {
|
||||
/** pointer to the start of the buffer */
|
||||
OPJ_BYTE *start;
|
||||
/** pointer to the end of the buffer */
|
||||
OPJ_BYTE *end;
|
||||
/** pointer to the present position in the buffer */
|
||||
OPJ_BYTE *bp;
|
||||
/** temporary place where each byte is read or written */
|
||||
OPJ_UINT32 buf;
|
||||
/** coder : number of bits free to write. decoder : number of bits read */
|
||||
OPJ_UINT32 ct;
|
||||
/** pointer to the start of the buffer */
|
||||
OPJ_BYTE *start;
|
||||
/** pointer to the end of the buffer */
|
||||
OPJ_BYTE *end;
|
||||
/** pointer to the present position in the buffer */
|
||||
OPJ_BYTE *bp;
|
||||
/** temporary place where each byte is read or written */
|
||||
OPJ_UINT32 buf;
|
||||
/** coder : number of bits free to write. decoder : number of bits read */
|
||||
OPJ_UINT32 ct;
|
||||
} opj_bio_t;
|
||||
|
||||
/** @name Exported functions */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
@@ -41,102 +41,102 @@
|
||||
*/
|
||||
|
||||
void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager );
|
||||
opj_event_mgr_t * p_manager );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t cstr_info, int j2klen,
|
||||
opj_event_mgr_t * p_manager )
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
int i;
|
||||
OPJ_OFF_T lenp;
|
||||
OPJ_UINT32 len;
|
||||
opj_jp2_box_t *box;
|
||||
int num_box = 0;
|
||||
OPJ_BOOL EPHused;
|
||||
OPJ_BYTE l_data_header [4];
|
||||
int i;
|
||||
OPJ_OFF_T lenp;
|
||||
OPJ_UINT32 len;
|
||||
opj_jp2_box_t *box;
|
||||
int num_box = 0;
|
||||
OPJ_BOOL EPHused;
|
||||
OPJ_BYTE l_data_header [4];
|
||||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
|
||||
|
||||
for (i=0;i<2;i++){
|
||||
for (i=0; i<2; i++) {
|
||||
|
||||
if(i)
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
if(i)
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
|
||||
|
||||
lenp = opj_stream_tell (cio);
|
||||
lenp = opj_stream_tell (cio);
|
||||
|
||||
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
|
||||
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
|
||||
|
||||
opj_write_bytes(l_data_header,JPIP_CIDX,4); /* CIDX */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_write_bytes(l_data_header,JPIP_CIDX,4); /* CIDX */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
|
||||
opj_write_cptr( offset, cstr_info.codestream_size, cio,p_manager);
|
||||
opj_write_cptr( offset, cstr_info.codestream_size, cio,p_manager);
|
||||
|
||||
opj_write_manf( i, num_box, box, cio,p_manager);
|
||||
opj_write_manf( i, num_box, box, cio,p_manager);
|
||||
|
||||
num_box = 0;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_mainmhix( offset, cstr_info, cio,p_manager);
|
||||
box[num_box].type = JPIP_MHIX;
|
||||
num_box++;
|
||||
num_box = 0;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_mainmhix( offset, cstr_info, cio,p_manager);
|
||||
box[num_box].type = JPIP_MHIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_tpix( offset, cstr_info, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_TPIX;
|
||||
num_box++;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_tpix( offset, cstr_info, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_TPIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_thix( offset, cstr_info, cio, p_manager);
|
||||
box[num_box].type = JPIP_THIX;
|
||||
num_box++;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_thix( offset, cstr_info, cio, p_manager);
|
||||
box[num_box].type = JPIP_THIX;
|
||||
num_box++;
|
||||
|
||||
EPHused = opj_check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio,p_manager);
|
||||
EPHused = opj_check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio,p_manager);
|
||||
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_ppix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_PPIX;
|
||||
num_box++;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_ppix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_PPIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_phix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_PHIX;
|
||||
num_box++;
|
||||
box[num_box].length = (OPJ_UINT32)opj_write_phix( offset, cstr_info, EPHused, j2klen, cio,p_manager);
|
||||
box[num_box].type = JPIP_PHIX;
|
||||
num_box++;
|
||||
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
|
||||
opj_stream_seek(cio, lenp,p_manager);
|
||||
opj_write_bytes(l_data_header,len,4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
}
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
|
||||
opj_stream_seek(cio, lenp,p_manager);
|
||||
opj_write_bytes(l_data_header,len,4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
}
|
||||
|
||||
opj_free( box);
|
||||
opj_free( box);
|
||||
|
||||
return (int)len;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager )
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_BYTE l_data_header [3*8];
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
OPJ_BYTE l_data_header [3*8];
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
|
||||
|
||||
lenp = opj_stream_tell(cio);
|
||||
opj_stream_skip( cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes( l_data_header, JPIP_CPTR, 4); /* T */
|
||||
opj_write_bytes( l_data_header+4, 0, 2); /* DR A PRECISER !! */
|
||||
opj_write_bytes( l_data_header+6, 0, 2); /* CONT */
|
||||
opj_write_bytes( l_data_header+8, (OPJ_UINT32)coff, 8); /* COFF A PRECISER !! */
|
||||
opj_write_bytes( l_data_header+16, (OPJ_UINT32)clen, 8); /* CLEN */
|
||||
opj_stream_write_data(cio,l_data_header,3*8,p_manager);
|
||||
lenp = opj_stream_tell(cio);
|
||||
opj_stream_skip( cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes( l_data_header, JPIP_CPTR, 4); /* T */
|
||||
opj_write_bytes( l_data_header+4, 0, 2); /* DR A PRECISER !! */
|
||||
opj_write_bytes( l_data_header+6, 0, 2); /* CONT */
|
||||
opj_write_bytes( l_data_header+8, (OPJ_UINT32)coff, 8); /* COFF A PRECISER !! */
|
||||
opj_write_bytes( l_data_header+16, (OPJ_UINT32)clen, 8); /* CLEN */
|
||||
opj_stream_write_data(cio,l_data_header,3*8,p_manager);
|
||||
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
opj_write_bytes(l_data_header, len, 4); /* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
opj_write_bytes(l_data_header, len, 4); /* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
|
||||
}
|
||||
|
||||
@@ -148,92 +148,90 @@ void opj_write_manf(int second,
|
||||
opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_BYTE l_data_header [4];
|
||||
int i;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
OPJ_BYTE l_data_header [4];
|
||||
int i;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
|
||||
lenp = opj_stream_tell(cio);
|
||||
opj_stream_skip( cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes( l_data_header, JPIP_MANF, 4); /* T */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
lenp = opj_stream_tell(cio);
|
||||
opj_stream_skip( cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes( l_data_header, JPIP_MANF, 4); /* T */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
|
||||
if (second){ /* Write only during the second pass */
|
||||
for( i=0; i<v; i++){
|
||||
opj_write_bytes( l_data_header, box[i].length, 4); /* Box length */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_write_bytes( l_data_header, box[i].type, 4); /* Box type */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
if (second) { /* Write only during the second pass */
|
||||
for( i=0; i<v; i++) {
|
||||
opj_write_bytes( l_data_header, box[i].length, 4); /* Box length */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_write_bytes( l_data_header, box[i].type, 4); /* Box type */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
opj_write_bytes(l_data_header, len, 4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio,lenp+len,p_manager);
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio) - lenp);
|
||||
opj_stream_seek(cio,lenp,p_manager);
|
||||
opj_write_bytes(l_data_header, len, 4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio,lenp+len,p_manager);
|
||||
}
|
||||
|
||||
|
||||
int opj_write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager )
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_BYTE l_data_header [8];
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
OPJ_BYTE l_data_header [8];
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_OFF_T lenp;
|
||||
|
||||
lenp = opj_stream_tell (cio);
|
||||
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes(l_data_header,JPIP_MHIX,4); /* MHIX */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
|
||||
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.main_head_end-cstr_info.main_head_start+1), 8); /* TLEN */
|
||||
opj_stream_write_data(cio,l_data_header,8,p_manager);
|
||||
|
||||
for(i = 1; i < (OPJ_UINT32)cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */
|
||||
opj_write_bytes( l_data_header, cstr_info.marker[i].type, 2);
|
||||
opj_write_bytes( l_data_header+2, 0, 2);
|
||||
lenp = opj_stream_tell (cio);
|
||||
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
|
||||
opj_write_bytes(l_data_header,JPIP_MHIX,4); /* MHIX */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_write_bytes( l_data_header,(OPJ_UINT32) (cstr_info.marker[i].pos-coff), 8);
|
||||
|
||||
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.main_head_end-cstr_info.main_head_start+1), 8); /* TLEN */
|
||||
opj_stream_write_data(cio,l_data_header,8,p_manager);
|
||||
opj_write_bytes( l_data_header, (OPJ_UINT32)cstr_info.marker[i].len, 2);
|
||||
opj_stream_write_data(cio,l_data_header,2,p_manager);
|
||||
}
|
||||
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
|
||||
opj_stream_seek(cio, lenp,p_manager);
|
||||
opj_write_bytes(l_data_header,len,4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
for(i = 1; i < (OPJ_UINT32)cstr_info.marknum; i++) { /* Marker restricted to 1 apparition, skip SOC marker */
|
||||
opj_write_bytes( l_data_header, cstr_info.marker[i].type, 2);
|
||||
opj_write_bytes( l_data_header+2, 0, 2);
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_write_bytes( l_data_header,(OPJ_UINT32) (cstr_info.marker[i].pos-coff), 8);
|
||||
opj_stream_write_data(cio,l_data_header,8,p_manager);
|
||||
opj_write_bytes( l_data_header, (OPJ_UINT32)cstr_info.marker[i].len, 2);
|
||||
opj_stream_write_data(cio,l_data_header,2,p_manager);
|
||||
}
|
||||
|
||||
return (int)len;
|
||||
len = (OPJ_UINT32) (opj_stream_tell(cio)-lenp);
|
||||
opj_stream_seek(cio, lenp,p_manager);
|
||||
opj_write_bytes(l_data_header,len,4);/* L */
|
||||
opj_stream_write_data(cio,l_data_header,4,p_manager);
|
||||
opj_stream_seek(cio, lenp+len,p_manager);
|
||||
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager )
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_BYTE l_data_header [4];
|
||||
OPJ_BOOL EPHused = OPJ_FALSE;
|
||||
int i=0;
|
||||
OPJ_OFF_T org_pos;
|
||||
unsigned int Scod;
|
||||
OPJ_BYTE l_data_header [4];
|
||||
OPJ_BOOL EPHused = OPJ_FALSE;
|
||||
int i=0;
|
||||
OPJ_OFF_T org_pos;
|
||||
unsigned int Scod;
|
||||
|
||||
for(i = 0; i < marknum; i++)
|
||||
{
|
||||
if( markers[i].type == J2K_MS_COD)
|
||||
{
|
||||
org_pos = opj_stream_tell(cio);
|
||||
opj_stream_seek(cio, coff+markers[i].pos+2,p_manager);
|
||||
for(i = 0; i < marknum; i++) {
|
||||
if( markers[i].type == J2K_MS_COD) {
|
||||
org_pos = opj_stream_tell(cio);
|
||||
opj_stream_seek(cio, coff+markers[i].pos+2,p_manager);
|
||||
|
||||
opj_stream_read_data(cio,l_data_header,1,p_manager);
|
||||
opj_read_bytes(l_data_header,&Scod,1);
|
||||
if( ((Scod >> 2) & 1))
|
||||
EPHused = OPJ_TRUE;
|
||||
opj_stream_seek( cio, org_pos, p_manager);
|
||||
opj_stream_read_data(cio,l_data_header,1,p_manager);
|
||||
opj_read_bytes(l_data_header,&Scod,1);
|
||||
if( ((Scod >> 2) & 1))
|
||||
EPHused = OPJ_TRUE;
|
||||
opj_stream_seek( cio, org_pos, p_manager);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return EPHused;
|
||||
return EPHused;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
@@ -51,7 +51,7 @@
|
||||
* @return length of cidx box
|
||||
*/
|
||||
int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t cstr_info, int j2klen,
|
||||
opj_event_mgr_t * p_manager );
|
||||
opj_event_mgr_t * p_manager );
|
||||
|
||||
/*
|
||||
* Check if EPH option is used
|
||||
@@ -63,6 +63,6 @@ int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t
|
||||
* @return true if EPH is used
|
||||
*/
|
||||
OPJ_BOOL opj_check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_stream_private_t *cio,
|
||||
opj_event_mgr_t * p_manager );
|
||||
opj_event_mgr_t * p_manager );
|
||||
|
||||
#endif /* !CIDX_MANAGER_H_ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2008;2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||
* Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
|
||||
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -43,121 +49,115 @@ The functions in CIO.C have for goal to realize a byte input / output process.
|
||||
/** @defgroup CIO CIO - byte input-output stream */
|
||||
/*@{*/
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "opj_config_private.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
#if defined(OPJ_BIG_ENDIAN)
|
||||
#define opj_write_bytes opj_write_bytes_BE
|
||||
#define opj_read_bytes opj_read_bytes_BE
|
||||
#define opj_write_double opj_write_double_BE
|
||||
#define opj_read_double opj_read_double_BE
|
||||
#define opj_write_float opj_write_float_BE
|
||||
#define opj_read_float opj_read_float_BE
|
||||
#define opj_write_bytes opj_write_bytes_BE
|
||||
#define opj_read_bytes opj_read_bytes_BE
|
||||
#define opj_write_double opj_write_double_BE
|
||||
#define opj_read_double opj_read_double_BE
|
||||
#define opj_write_float opj_write_float_BE
|
||||
#define opj_read_float opj_read_float_BE
|
||||
#else
|
||||
#define opj_write_bytes opj_write_bytes_LE
|
||||
#define opj_read_bytes opj_read_bytes_LE
|
||||
#define opj_write_double opj_write_double_LE
|
||||
#define opj_read_double opj_read_double_LE
|
||||
#define opj_write_float opj_write_float_LE
|
||||
#define opj_read_float opj_read_float_LE
|
||||
#define opj_write_bytes opj_write_bytes_LE
|
||||
#define opj_read_bytes opj_read_bytes_LE
|
||||
#define opj_write_double opj_write_double_LE
|
||||
#define opj_read_double opj_read_double_LE
|
||||
#define opj_write_float opj_write_float_LE
|
||||
#define opj_read_float opj_read_float_LE
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
opj_signed_sentinel = -1, /* do not use in code */
|
||||
opj_stream_e_output = 0x1,
|
||||
opj_stream_e_input = 0x2,
|
||||
opj_stream_e_end = 0x4,
|
||||
opj_stream_e_error = 0x8
|
||||
}
|
||||
opj_stream_flag ;
|
||||
#define OPJ_STREAM_STATUS_OUTPUT 0x1U
|
||||
#define OPJ_STREAM_STATUS_INPUT 0x2U
|
||||
#define OPJ_STREAM_STATUS_END 0x4U
|
||||
#define OPJ_STREAM_STATUS_ERROR 0x8U
|
||||
|
||||
/**
|
||||
Byte input-output stream.
|
||||
*/
|
||||
typedef struct opj_stream_private
|
||||
{
|
||||
/**
|
||||
* User data, be it files, ... The actual data depends on the type of the stream.
|
||||
*/
|
||||
void * m_user_data;
|
||||
typedef struct opj_stream_private {
|
||||
/**
|
||||
* User data, be it files, ... The actual data depends on the type of the stream.
|
||||
*/
|
||||
void * m_user_data;
|
||||
|
||||
/**
|
||||
* Pointer to function to free m_user_data (NULL at initialization)
|
||||
* when destroying the stream. If pointer is NULL the function is not
|
||||
* called and the m_user_data is not freed (even if non-NULL).
|
||||
*/
|
||||
opj_stream_free_user_data_fn m_free_user_data_fn;
|
||||
/**
|
||||
* Pointer to function to free m_user_data (NULL at initialization)
|
||||
* when destroying the stream. If pointer is NULL the function is not
|
||||
* called and the m_user_data is not freed (even if non-NULL).
|
||||
*/
|
||||
opj_stream_free_user_data_fn m_free_user_data_fn;
|
||||
|
||||
/**
|
||||
* User data length
|
||||
*/
|
||||
OPJ_UINT64 m_user_data_length;
|
||||
/**
|
||||
* User data length
|
||||
*/
|
||||
OPJ_UINT64 m_user_data_length;
|
||||
|
||||
/**
|
||||
* Pointer to actual read function (NULL at the initialization of the cio.
|
||||
*/
|
||||
opj_stream_read_fn m_read_fn;
|
||||
/**
|
||||
* Pointer to actual read function (NULL at the initialization of the cio.
|
||||
*/
|
||||
opj_stream_read_fn m_read_fn;
|
||||
|
||||
/**
|
||||
* Pointer to actual write function (NULL at the initialization of the cio.
|
||||
*/
|
||||
opj_stream_write_fn m_write_fn;
|
||||
/**
|
||||
* Pointer to actual write function (NULL at the initialization of the cio.
|
||||
*/
|
||||
opj_stream_write_fn m_write_fn;
|
||||
|
||||
/**
|
||||
* Pointer to actual skip function (NULL at the initialization of the cio.
|
||||
* There is no seek function to prevent from back and forth slow procedures.
|
||||
*/
|
||||
opj_stream_skip_fn m_skip_fn;
|
||||
/**
|
||||
* Pointer to actual skip function (NULL at the initialization of the cio.
|
||||
* There is no seek function to prevent from back and forth slow procedures.
|
||||
*/
|
||||
opj_stream_skip_fn m_skip_fn;
|
||||
|
||||
/**
|
||||
* Pointer to actual seek function (if available).
|
||||
*/
|
||||
opj_stream_seek_fn m_seek_fn;
|
||||
/**
|
||||
* Pointer to actual seek function (if available).
|
||||
*/
|
||||
opj_stream_seek_fn m_seek_fn;
|
||||
|
||||
/**
|
||||
* Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
|
||||
* you should never access this data directly.
|
||||
*/
|
||||
OPJ_BYTE * m_stored_data;
|
||||
/**
|
||||
* Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
|
||||
* you should never access this data directly.
|
||||
*/
|
||||
OPJ_BYTE * m_stored_data;
|
||||
|
||||
/**
|
||||
* Pointer to the current read data.
|
||||
*/
|
||||
OPJ_BYTE * m_current_data;
|
||||
/**
|
||||
* Pointer to the current read data.
|
||||
*/
|
||||
OPJ_BYTE * m_current_data;
|
||||
|
||||
/**
|
||||
* FIXME DOC.
|
||||
*/
|
||||
OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *);
|
||||
OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *);
|
||||
|
||||
/**
|
||||
* FIXME DOC.
|
||||
*/
|
||||
OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
|
||||
OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
|
||||
|
||||
/**
|
||||
* number of bytes containing in the buffer.
|
||||
*/
|
||||
OPJ_SIZE_T m_bytes_in_buffer;
|
||||
/**
|
||||
* number of bytes containing in the buffer.
|
||||
*/
|
||||
OPJ_SIZE_T m_bytes_in_buffer;
|
||||
|
||||
/**
|
||||
* The number of bytes read/written from the beginning of the stream
|
||||
*/
|
||||
OPJ_OFF_T m_byte_offset;
|
||||
/**
|
||||
* The number of bytes read/written from the beginning of the stream
|
||||
*/
|
||||
OPJ_OFF_T m_byte_offset;
|
||||
|
||||
/**
|
||||
* The size of the buffer.
|
||||
*/
|
||||
OPJ_SIZE_T m_buffer_size;
|
||||
/**
|
||||
* The size of the buffer.
|
||||
*/
|
||||
OPJ_SIZE_T m_buffer_size;
|
||||
|
||||
/**
|
||||
* Flags to tell the status of the stream.
|
||||
*/
|
||||
opj_stream_flag m_status;
|
||||
/**
|
||||
* Flags to tell the status of the stream.
|
||||
* Used with OPJ_STREAM_STATUS_* defines.
|
||||
*/
|
||||
OPJ_UINT32 m_status;
|
||||
|
||||
}
|
||||
opj_stream_private_t;
|
||||
@@ -178,7 +178,7 @@ void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n
|
||||
* @param p_buffer pointer the data buffer to read data from.
|
||||
* @param p_value pointer to the value that will store the data.
|
||||
* @param p_nb_bytes the nb bytes to read.
|
||||
* @return the number of bytes read or -1 if an error occured.
|
||||
* @return the number of bytes read or -1 if an error occurred.
|
||||
*/
|
||||
void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
|
||||
|
||||
@@ -187,7 +187,7 @@ void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT
|
||||
* @param p_buffer pointer the data buffer to write data to.
|
||||
* @param p_value the value to write
|
||||
* @param p_nb_bytes the number of bytes to write
|
||||
* @return the number of bytes written or -1 if an error occured
|
||||
* @return the number of bytes written or -1 if an error occurred
|
||||
*/
|
||||
void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
|
||||
|
||||
@@ -196,7 +196,7 @@ void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n
|
||||
* @param p_buffer pointer the data buffer to read data from.
|
||||
* @param p_value pointer to the value that will store the data.
|
||||
* @param p_nb_bytes the nb bytes to read.
|
||||
* @return the number of bytes read or -1 if an error occured.
|
||||
* @return the number of bytes read or -1 if an error occurred.
|
||||
*/
|
||||
void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
|
||||
|
||||
@@ -263,7 +263,7 @@ void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
|
||||
* @param p_buffer pointer to the data buffer that will receive the data.
|
||||
* @param p_size number of bytes to read.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes read, or -1 if an error occured or if the stream is at the end.
|
||||
* @return the number of bytes read, or -1 if an error occurred or if the stream is at the end.
|
||||
*/
|
||||
OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -273,7 +273,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
|
||||
* @param p_buffer pointer to the data buffer holds the data to be writtent.
|
||||
* @param p_size number of bytes to write.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes writtent, or -1 if an error occured.
|
||||
* @return the number of bytes writtent, or -1 if an error occurred.
|
||||
*/
|
||||
OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -290,7 +290,7 @@ OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr
|
||||
* @param p_stream the stream to skip data from.
|
||||
* @param p_size the number of bytes to skip.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes skipped, or -1 if an error occured.
|
||||
* @return the number of bytes skipped, or -1 if an error occurred.
|
||||
*/
|
||||
OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -318,7 +318,7 @@ OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream
|
||||
* @param p_stream the stream to skip data from.
|
||||
* @param p_size the number of bytes to skip.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes skipped, or -1 if an error occured.
|
||||
* @return the number of bytes skipped, or -1 if an error occurred.
|
||||
*/
|
||||
OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -327,7 +327,7 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si
|
||||
* @param p_stream the stream to skip data from.
|
||||
* @param p_size the number of bytes to skip.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes skipped, or -1 if an error occured.
|
||||
* @return the number of bytes skipped, or -1 if an error occurred.
|
||||
*/
|
||||
OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -336,7 +336,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
|
||||
* @param p_stream the stream to skip data from.
|
||||
* @param p_size the number of bytes to skip.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return OPJ_TRUE if success, or OPJ_FALSE if an error occured.
|
||||
* @return OPJ_TRUE if success, or OPJ_FALSE if an error occurred.
|
||||
*/
|
||||
OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
@@ -345,7 +345,7 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size
|
||||
* @param p_stream the stream to skip data from.
|
||||
* @param p_size the number of bytes to skip.
|
||||
* @param p_event_mgr the user event manager to be notified of special events.
|
||||
* @return the number of bytes skipped, or -1 if an error occured.
|
||||
* @return the number of bytes skipped, or -1 if an error occurred.
|
||||
*/
|
||||
OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -48,14 +54,14 @@ DWT.C are used by some function in TCD.C.
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/**
|
||||
Forward 5-3 wavelet tranform in 2-D.
|
||||
Forward 5-3 wavelet transform in 2-D.
|
||||
Apply a reversible DWT transform to a component of an image.
|
||||
@param tilec Tile component information (current tile)
|
||||
*/
|
||||
OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec);
|
||||
|
||||
/**
|
||||
Inverse 5-3 wavelet tranform in 2-D.
|
||||
Inverse 5-3 wavelet transform in 2-D.
|
||||
Apply a reversible inverse DWT transform to a component of an image.
|
||||
@param tilec Tile component information (current tile)
|
||||
@param numres Number of resolution levels to decode
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2008;2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||
* Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
|
||||
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -35,10 +40,11 @@
|
||||
#ifdef OPJ_CODE_NOT_USED
|
||||
#ifndef _WIN32
|
||||
static char*
|
||||
i2a(unsigned i, char *a, unsigned r) {
|
||||
if (i/r > 0) a = i2a(i/r,a,r);
|
||||
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
|
||||
return a+1;
|
||||
i2a(unsigned i, char *a, unsigned r)
|
||||
{
|
||||
if (i/r > 0) a = i2a(i/r,a,r);
|
||||
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
|
||||
return a+1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,14 +56,14 @@ i2a(unsigned i, char *a, unsigned r) {
|
||||
@return Returns a
|
||||
*/
|
||||
static char *
|
||||
_itoa(int i, char *a, int r) {
|
||||
r = ((r < 2) || (r > 36)) ? 10 : r;
|
||||
if(i < 0) {
|
||||
*a = '-';
|
||||
*i2a(-i, a+1, r) = 0;
|
||||
}
|
||||
else *i2a(i, a, r) = 0;
|
||||
return a;
|
||||
_itoa(int i, char *a, int r)
|
||||
{
|
||||
r = ((r < 2) || (r > 36)) ? 10 : r;
|
||||
if(i < 0) {
|
||||
*a = '-';
|
||||
*i2a(-i, a+1, r) = 0;
|
||||
} else *i2a(i, a, r) = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif /* !_WIN32 */
|
||||
@@ -78,64 +84,65 @@ static void opj_default_callback (const char *msg, void *client_data)
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type, const char *fmt, ...) {
|
||||
OPJ_BOOL opj_event_msg(opj_event_mgr_t* p_event_mgr, OPJ_INT32 event_type, const char *fmt, ...)
|
||||
{
|
||||
#define OPJ_MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
|
||||
opj_msg_callback msg_handler = 00;
|
||||
void * l_data = 00;
|
||||
opj_msg_callback msg_handler = 00;
|
||||
void * l_data = 00;
|
||||
|
||||
if(p_event_mgr != 00) {
|
||||
switch(event_type) {
|
||||
case EVT_ERROR:
|
||||
msg_handler = p_event_mgr->error_handler;
|
||||
l_data = p_event_mgr->m_error_data;
|
||||
break;
|
||||
case EVT_WARNING:
|
||||
msg_handler = p_event_mgr->warning_handler;
|
||||
l_data = p_event_mgr->m_warning_data;
|
||||
break;
|
||||
case EVT_INFO:
|
||||
msg_handler = p_event_mgr->info_handler;
|
||||
l_data = p_event_mgr->m_info_data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(msg_handler == 00) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
} else {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if(p_event_mgr != 00) {
|
||||
switch(event_type) {
|
||||
case EVT_ERROR:
|
||||
msg_handler = p_event_mgr->error_handler;
|
||||
l_data = p_event_mgr->m_error_data;
|
||||
break;
|
||||
case EVT_WARNING:
|
||||
msg_handler = p_event_mgr->warning_handler;
|
||||
l_data = p_event_mgr->m_warning_data;
|
||||
break;
|
||||
case EVT_INFO:
|
||||
msg_handler = p_event_mgr->info_handler;
|
||||
l_data = p_event_mgr->m_info_data;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(msg_handler == 00) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
} else {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if ((fmt != 00) && (p_event_mgr != 00)) {
|
||||
va_list arg;
|
||||
size_t str_length/*, i, j*/; /* UniPG */
|
||||
char message[OPJ_MSG_SIZE];
|
||||
memset(message, 0, OPJ_MSG_SIZE);
|
||||
/* initialize the optional parameter list */
|
||||
va_start(arg, fmt);
|
||||
/* check the length of the format string */
|
||||
str_length = (strlen(fmt) > OPJ_MSG_SIZE) ? OPJ_MSG_SIZE : strlen(fmt);
|
||||
if ((fmt != 00) && (p_event_mgr != 00)) {
|
||||
va_list arg;
|
||||
size_t str_length/*, i, j*/; /* UniPG */
|
||||
char message[OPJ_MSG_SIZE];
|
||||
memset(message, 0, OPJ_MSG_SIZE);
|
||||
/* initialize the optional parameter list */
|
||||
va_start(arg, fmt);
|
||||
/* check the length of the format string */
|
||||
str_length = (strlen(fmt) > OPJ_MSG_SIZE) ? OPJ_MSG_SIZE : strlen(fmt);
|
||||
(void)str_length;
|
||||
/* parse the format string and put the result in 'message' */
|
||||
vsnprintf(message, OPJ_MSG_SIZE, fmt, arg); /* UniPG */
|
||||
/* deinitialize the optional parameter list */
|
||||
va_end(arg);
|
||||
/* parse the format string and put the result in 'message' */
|
||||
vsnprintf(message, OPJ_MSG_SIZE, fmt, arg); /* UniPG */
|
||||
/* deinitialize the optional parameter list */
|
||||
va_end(arg);
|
||||
|
||||
/* output the message to the user program */
|
||||
msg_handler(message, l_data);
|
||||
}
|
||||
/* output the message to the user program */
|
||||
msg_handler(message, l_data);
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
void opj_set_default_event_handler(opj_event_mgr_t * p_manager)
|
||||
{
|
||||
p_manager->m_error_data = 00;
|
||||
p_manager->m_warning_data = 00;
|
||||
p_manager->m_info_data = 00;
|
||||
p_manager->error_handler = opj_default_callback;
|
||||
p_manager->info_handler = opj_default_callback;
|
||||
p_manager->warning_handler = opj_default_callback;
|
||||
p_manager->m_error_data = 00;
|
||||
p_manager->m_warning_data = 00;
|
||||
p_manager->m_info_data = 00;
|
||||
p_manager->error_handler = opj_default_callback;
|
||||
p_manager->info_handler = opj_default_callback;
|
||||
p_manager->warning_handler = opj_default_callback;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user