Compare commits
1493 Commits
version.1.
...
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 | ||
|
|
666f71b2a1 | ||
|
|
2b7d5b18f3 | ||
|
|
18d5d25cb6 | ||
|
|
492d8ab7d9 | ||
|
|
2b93727bea | ||
|
|
18c5be69e9 | ||
|
|
5a70e97f51 | ||
|
|
f4707da97a | ||
|
|
51ab074d50 | ||
|
|
6d9e8a5a63 | ||
|
|
008de86533 | ||
|
|
ae49fd1aa9 | ||
|
|
79d18f7fd0 | ||
|
|
99d1859a44 | ||
|
|
866cd28ad4 | ||
|
|
71a9f498b5 | ||
|
|
b607da8ae9 | ||
|
|
a43d206b93 | ||
|
|
15863e7170 | ||
|
|
5e91877636 | ||
|
|
7e1d012161 | ||
|
|
de74605777 | ||
|
|
e8abf1fb25 | ||
|
|
b7fe7d25e1 | ||
|
|
138a65d6c1 | ||
|
|
9d0bdf69e5 | ||
|
|
9194dfb94b | ||
|
|
b7ebf54a29 | ||
|
|
3a80b72ac8 | ||
|
|
3e33012bd9 | ||
|
|
fd3f7ca2bb | ||
|
|
6e22c4f68a | ||
|
|
565ef29ae3 | ||
|
|
68398b2a5a | ||
|
|
5624e4a25f | ||
|
|
92e07f3b74 | ||
|
|
8447f0a323 | ||
|
|
f0a2fdd508 | ||
|
|
320784659d | ||
|
|
51ab8cd67d | ||
|
|
237253d83b | ||
|
|
fe100fb490 | ||
|
|
c7b646e23a | ||
|
|
41add6882b | ||
|
|
dd0d2c2f0a | ||
|
|
d38e32c036 | ||
|
|
73315c2edc | ||
|
|
6b51d11d08 | ||
|
|
59270c39a7 | ||
|
|
db82cf7778 | ||
|
|
ddb1d57766 | ||
|
|
5dd770746b | ||
|
|
fa436eb368 | ||
|
|
fcc658f106 | ||
|
|
2e7b8fb9a1 | ||
|
|
1778e2576e | ||
|
|
73c9e85642 | ||
|
|
76557d2eb3 | ||
|
|
9095c7361e | ||
|
|
c02c1432e8 | ||
|
|
8411ed4f80 | ||
|
|
4de95f320f | ||
|
|
aea18173d1 | ||
|
|
856fc0652f | ||
|
|
b01c1240cf | ||
|
|
836ec05920 | ||
|
|
9a52b30c3d | ||
|
|
76af73bc72 | ||
|
|
f7bc0b49cb | ||
|
|
9155e98911 | ||
|
|
7aee50de97 | ||
|
|
24966ffbda | ||
|
|
666ef53fd2 | ||
|
|
e02ba05034 | ||
|
|
b478912910 | ||
|
|
2001932c56 | ||
|
|
f54de95802 | ||
|
|
fa1c2454e6 | ||
|
|
6b94237679 | ||
|
|
aedff8a000 | ||
|
|
a0aa8dd851 | ||
|
|
440ef4873b | ||
|
|
ffad2fbe55 | ||
|
|
cc1354ebfa | ||
|
|
581d2ba8b4 | ||
|
|
61348b20b4 | ||
|
|
e619e06078 | ||
|
|
4f84d1693a | ||
|
|
71d244a5b6 | ||
|
|
f9a0f869e3 | ||
|
|
33c472d734 | ||
|
|
a8eb122c1f | ||
|
|
956b1a7697 | ||
|
|
472ce19183 | ||
|
|
740924fa61 | ||
|
|
01b4bb5447 | ||
|
|
ee3b02932a | ||
|
|
2a07d3d26b | ||
|
|
e238148d42 | ||
|
|
9d21695476 | ||
|
|
22d11a9ccb | ||
|
|
fc9248ea2b | ||
|
|
c302979738 | ||
|
|
e4d077bc98 | ||
|
|
76cd9b7f72 | ||
|
|
e71431ec78 | ||
|
|
7b335eb635 | ||
|
|
c0c086388b | ||
|
|
048c8302fe | ||
|
|
a7b051b172 | ||
|
|
5f7ad58f48 | ||
|
|
016b9fc052 | ||
|
|
99b40e8257 | ||
|
|
a734e447b5 | ||
|
|
37128c34a9 | ||
|
|
f5630ab88e | ||
|
|
6790587db8 | ||
|
|
445f696dc6 | ||
|
|
dd5c3a9c8e | ||
|
|
0f45e38b52 | ||
|
|
93bc3cb628 | ||
|
|
79faedfb9b | ||
|
|
17d9caae83 | ||
|
|
eea18e856e | ||
|
|
7e64eb5414 | ||
|
|
8a959bb1f4 | ||
|
|
8d3ef0729c | ||
|
|
275680bdb7 | ||
|
|
4d5d1f0f66 | ||
|
|
1ef677f264 | ||
|
|
07193e2a34 | ||
|
|
f7da94610d | ||
|
|
872368d25c | ||
|
|
36320b4bf4 | ||
|
|
7185faa857 | ||
|
|
0c80fcff2a | ||
|
|
51caff5dcf | ||
|
|
d643ff5dbc | ||
|
|
44ca89eff7 | ||
|
|
7afad19c77 | ||
|
|
765c4ab4f4 | ||
|
|
24eca792ff | ||
|
|
b1b17ee264 | ||
|
|
74600cfb14 | ||
|
|
171ec1583d | ||
|
|
80c5106015 | ||
|
|
e92fe4c1a4 | ||
|
|
11f402b44a | ||
|
|
18049fe3e0 | ||
|
|
b330c10492 | ||
|
|
25255c4ed1 | ||
|
|
16febebd28 | ||
|
|
339952c2af | ||
|
|
75715635e8 | ||
|
|
9863d8d1d2 | ||
|
|
3ecccb7410 | ||
|
|
3c7a7a1675 | ||
|
|
d14c475de7 | ||
|
|
a68a3feb60 | ||
|
|
43382a9b9c | ||
|
|
a149502c01 | ||
|
|
decace60da | ||
|
|
2c876b6765 | ||
|
|
6d0785a78f | ||
|
|
ec593a2549 | ||
|
|
978de6fb97 | ||
|
|
c53e2960a0 | ||
|
|
cf91ebf278 | ||
|
|
fd5f21af00 | ||
|
|
1b93cb8c0a | ||
|
|
a9e6268766 | ||
|
|
fc855084a0 | ||
|
|
b7bccf86c3 | ||
|
|
6ee2a51edc | ||
|
|
d2dc1597fe | ||
|
|
82647e79c7 | ||
|
|
ecbebe2847 | ||
|
|
816db977fd | ||
|
|
cbe77e2412 | ||
|
|
1eb67ca49d | ||
|
|
7a89d731f7 | ||
|
|
65503dad73 | ||
|
|
a347262468 | ||
|
|
6a6fa7027a | ||
|
|
86cdc91180 | ||
|
|
094465a710 | ||
|
|
6ae56f302e | ||
|
|
ad895fadb1 | ||
|
|
7c120281c7 | ||
|
|
8a4095b405 | ||
|
|
a7cc5b6a5d | ||
|
|
ac1dfd4662 | ||
|
|
abf2f7f05e | ||
|
|
1c209d711e | ||
|
|
91f521ef92 | ||
|
|
9ac3ae1270 | ||
|
|
d74579aa38 | ||
|
|
6deb1a83b5 | ||
|
|
6f3a7ef3c8 | ||
|
|
9f3687f917 | ||
|
|
5e77c4e936 | ||
|
|
97c376e06d | ||
|
|
8f4d674442 | ||
|
|
7f277fea94 | ||
|
|
52440cc2e6 | ||
|
|
3fe9243e1c | ||
|
|
05dae25a22 | ||
|
|
23ea270881 | ||
|
|
7247543da3 | ||
|
|
37a8d2acc1 | ||
|
|
4a7ba87d99 | ||
|
|
51e3764519 | ||
|
|
533d92aa8e | ||
|
|
19887b7b8c | ||
|
|
005e75bdc3 | ||
|
|
5f3470fcd0 | ||
|
|
adb237cfa8 | ||
|
|
29a29d6210 | ||
|
|
3a155ceda6 | ||
|
|
7195a23a9d | ||
|
|
0ae6ff8018 | ||
|
|
241769dc2f | ||
|
|
4a39ee9bbc | ||
|
|
1dedf7f0cd | ||
|
|
70ede09310 | ||
|
|
3da30304fc | ||
|
|
820c04c679 | ||
|
|
9d848e3f5e | ||
|
|
d5f71c2e1d | ||
|
|
36a7d23273 | ||
|
|
c4317177f3 | ||
|
|
e231a84b2f | ||
|
|
b56fb96b1b | ||
|
|
163c7e3460 | ||
|
|
4c1023dac6 | ||
|
|
563d238fa0 | ||
|
|
9021776963 | ||
|
|
18771f1b6a | ||
|
|
ed2af11102 | ||
|
|
7dd65e84e6 | ||
|
|
e260ec6e9d | ||
|
|
7ce3f3c1a6 | ||
|
|
a466755bbb | ||
|
|
901c9d8ae0 | ||
|
|
6145c82804 | ||
|
|
876c02206d | ||
|
|
3ca312033f | ||
|
|
1378475573 | ||
|
|
00b049866b | ||
|
|
d847e477f0 | ||
|
|
c55e164e87 | ||
|
|
531cd5dd14 | ||
|
|
ff0a9f763e | ||
|
|
228e0a3d79 | ||
|
|
f38e29d00a | ||
|
|
963283d7d0 | ||
|
|
c91044a4a7 | ||
|
|
f42c26adbd | ||
|
|
9efad43509 | ||
|
|
33d8f08964 | ||
|
|
e826e9281e | ||
|
|
780120c9a2 | ||
|
|
d6c0c85125 | ||
|
|
c81fb397bb | ||
|
|
caf4e46e06 | ||
|
|
ff1a30d80a | ||
|
|
d143f49a66 | ||
|
|
58698b789a | ||
|
|
ee3f2ffa19 | ||
|
|
c59124dfe2 | ||
|
|
7b14cf8558 | ||
|
|
05f796d2fa | ||
|
|
bd8c91b37d | ||
|
|
7294cdef3e | ||
|
|
4d7b6374c8 | ||
|
|
5855da5a15 | ||
|
|
34fd493512 | ||
|
|
da4bd9b110 | ||
|
|
7fbf6df09e | ||
|
|
68415d040f | ||
|
|
8ee74f6bff | ||
|
|
bf0fa4089f | ||
|
|
07ae149955 | ||
|
|
ecb93d97a5 | ||
|
|
f769d5e27f | ||
|
|
1e414c8f37 | ||
|
|
07e6994be1 | ||
|
|
0abf4f8fbb | ||
|
|
a13e4a77e0 | ||
|
|
6de2271e2a | ||
|
|
021e255282 | ||
|
|
92b1e038c1 | ||
|
|
a8c33ae219 | ||
|
|
e7bc30b409 | ||
|
|
efaefa21fc | ||
|
|
42bd417acf | ||
|
|
af58e8e8f9 | ||
|
|
4bf4a7668e | ||
|
|
c03ca9c73c | ||
|
|
d5884afcf3 | ||
|
|
a2aeafe85b | ||
|
|
0109b39f58 | ||
|
|
752e978d56 | ||
|
|
8b36a11f2b | ||
|
|
ccd448d626 | ||
|
|
44fb38949b | ||
|
|
ad1532ed57 | ||
|
|
caaec3bb05 | ||
|
|
df47fae287 | ||
|
|
b65bf48369 | ||
|
|
4c02acb728 | ||
|
|
8c9151c86b | ||
|
|
c075742bc8 | ||
|
|
b42cf317d6 | ||
|
|
f5429e4ce8 | ||
|
|
82dad8e629 | ||
|
|
59aa37fe2b | ||
|
|
0adb43f06e | ||
|
|
87e09a09da | ||
|
|
ba630816bc | ||
|
|
863fdafcd5 | ||
|
|
be5e6941bf | ||
|
|
7980115412 | ||
|
|
cab86a0deb | ||
|
|
be3a1da14a | ||
|
|
650c587875 | ||
|
|
d29c5760bd | ||
|
|
ee9d777d69 | ||
|
|
59582bafa3 | ||
|
|
1ad85ac9ee | ||
|
|
999a84c77a | ||
|
|
48e0d167aa | ||
|
|
f14da66ce5 | ||
|
|
14ab311d2f | ||
|
|
02ab4363b6 | ||
|
|
e1f7c73324 | ||
|
|
3042fc2a29 | ||
|
|
a622c1c2fe | ||
|
|
b3e467dcba | ||
|
|
c0259255b0 | ||
|
|
9398bc1764 | ||
|
|
fcf9fa3651 | ||
|
|
583df79be9 | ||
|
|
0e0b892493 | ||
|
|
78a8d64a92 | ||
|
|
5433e4dab8 | ||
|
|
c3c59b010b | ||
|
|
8eb481b6c6 | ||
|
|
d5efeb7df5 | ||
|
|
f663042893 | ||
|
|
f07c1a11a0 | ||
|
|
ce297bfa9e | ||
|
|
ba1682c120 | ||
|
|
e212154d8d | ||
|
|
ec0fe09138 | ||
|
|
8562ed3018 | ||
|
|
21b0ccf859 | ||
|
|
84c93c2fea | ||
|
|
e3c2305ff4 | ||
|
|
0e3c467a5b | ||
|
|
94880d8f36 | ||
|
|
7307bb6e9a | ||
|
|
4263410fe8 | ||
|
|
cb0eb855ca | ||
|
|
569d0ec7cc | ||
|
|
1021e87522 | ||
|
|
dc34cf362f | ||
|
|
e71749428c | ||
|
|
8f58b776b0 | ||
|
|
fb0a11636f | ||
|
|
7bf09734d7 | ||
|
|
853bcb3c64 | ||
|
|
4d32395fe1 | ||
|
|
a6a141d326 | ||
|
|
e0161e03db | ||
|
|
82d29d4c2a | ||
|
|
1a5791750b | ||
|
|
482d9b58b3 | ||
|
|
5903dd7d82 | ||
|
|
301b1ffbc7 | ||
|
|
759be64115 | ||
|
|
ece2a2d6c2 | ||
|
|
f31957c502 | ||
|
|
fb69541cfa | ||
|
|
e189679ebc | ||
|
|
18e7fcc37f | ||
|
|
1c8a657044 | ||
|
|
cdea5c8eef | ||
|
|
bcc386e3bb | ||
|
|
a2bd3bb75b | ||
|
|
b63d618e48 | ||
|
|
8864c2d59b | ||
|
|
c75073fbf4 | ||
|
|
cf4529d058 | ||
|
|
9b6900b058 | ||
|
|
7f7ef068fc | ||
|
|
a41790ce8a | ||
|
|
06615a556d | ||
|
|
94a69c2b31 | ||
|
|
425ff2f81d | ||
|
|
2257166e61 | ||
|
|
56cf5f4f67 | ||
|
|
668484ba8f | ||
|
|
f824078c14 | ||
|
|
3250833a62 | ||
|
|
8bc24912d1 | ||
|
|
52f6f7e0c7 | ||
|
|
ee8ee69c30 | ||
|
|
4941ebcc91 | ||
|
|
9adbea785b | ||
|
|
fd19413196 | ||
|
|
6300a8a0a2 | ||
|
|
66c1228c95 | ||
|
|
4585b23552 | ||
|
|
23a624f73a | ||
|
|
f3d7d2f7b1 | ||
|
|
0358983ee6 | ||
|
|
a0977266b4 | ||
|
|
76947f0074 | ||
|
|
f649754018 | ||
|
|
b1c5ce2517 | ||
|
|
f2db5ec4fb | ||
|
|
db08494776 | ||
|
|
9166d595e6 | ||
|
|
f1061c8763 | ||
|
|
fca9803bee | ||
|
|
0d841b5e05 | ||
|
|
216791c3fb | ||
|
|
12c4e68058 | ||
|
|
b4b451863d | ||
|
|
f2808de855 | ||
|
|
9b2897ccd9 | ||
|
|
3c4698435c | ||
|
|
98682e1073 | ||
|
|
d6bcb8b7e0 | ||
|
|
a501237ae3 | ||
|
|
f6622c2fbb | ||
|
|
b08b90d71c | ||
|
|
b46ed8c7a3 | ||
|
|
45869ce843 | ||
|
|
dff377a741 | ||
|
|
b24cf8d157 | ||
|
|
2ad90b7c41 | ||
|
|
a40fc41988 | ||
|
|
3416c6d91b | ||
|
|
54c2bcb60f | ||
|
|
44a5108e1d | ||
|
|
d8715871fa | ||
|
|
772fcc963c | ||
|
|
75b7104724 | ||
|
|
fe3c1f9061 | ||
|
|
e30818ce39 | ||
|
|
2e30886a0d | ||
|
|
b18ffbd08a | ||
|
|
16d2dc662f | ||
|
|
9832c911b3 | ||
|
|
23f5eeec20 | ||
|
|
16106b2978 | ||
|
|
c66e6be4a4 | ||
|
|
eda4c26d24 | ||
|
|
4b140e060b | ||
|
|
1fefa03329 | ||
|
|
37ff9b029c | ||
|
|
e798fe37e1 | ||
|
|
f4a8f7165c | ||
|
|
2d52e409c2 | ||
|
|
1b5e677d0c | ||
|
|
c508923f04 | ||
|
|
6c4024796e | ||
|
|
bd2c6cfa55 | ||
|
|
bd74db932e | ||
|
|
439337fb1b | ||
|
|
5ffe6f5acf | ||
|
|
f281f8cb75 | ||
|
|
3a46e2d86b | ||
|
|
6a84a1788b | ||
|
|
df870e5241 | ||
|
|
82afd3a891 | ||
|
|
514fc72050 | ||
|
|
4dba9aed22 | ||
|
|
a46dbe6941 | ||
|
|
394db7b738 | ||
|
|
3ad58ee1f5 | ||
|
|
00aa77f2d9 | ||
|
|
60fc79c717 | ||
|
|
f501186b18 | ||
|
|
fe6d9ed9ba | ||
|
|
c450d418ef | ||
|
|
c3b1af023b | ||
|
|
bf37be46b8 | ||
|
|
4466c31fc2 | ||
|
|
b2bebcf5ce | ||
|
|
de33ba029b | ||
|
|
465db44499 | ||
|
|
abdb8ee3f7 | ||
|
|
aa6b4b4970 | ||
|
|
25cbfcf34a | ||
|
|
cffc33a51c | ||
|
|
5db7b01fa2 | ||
|
|
1ca5ca8392 | ||
|
|
93761d9ab5 | ||
|
|
bb16d8816c | ||
|
|
e1cd500ac5 | ||
|
|
2d09cbfd21 | ||
|
|
d84b16caf9 | ||
|
|
95f06f0591 | ||
|
|
3bf4d635f2 | ||
|
|
a4fa18e92d | ||
|
|
f71af2a2ef | ||
|
|
3e62f8d9b7 | ||
|
|
028720c9ec | ||
|
|
d518970039 | ||
|
|
8363a6ab1e | ||
|
|
a540dcd2e2 | ||
|
|
58b2c6c4a5 | ||
|
|
34ffde6799 | ||
|
|
e7cd945000 | ||
|
|
ccf0f05e98 | ||
|
|
36672ad50e | ||
|
|
8bee3d89c5 | ||
|
|
cf212e55ac | ||
|
|
a00f61bd5d | ||
|
|
dca76de872 | ||
|
|
70540f9563 | ||
|
|
a545cb7cff | ||
|
|
9a86a3bd23 | ||
|
|
69673635ef | ||
|
|
77e6971bbb | ||
|
|
a9a1336502 | ||
|
|
9103674950 | ||
|
|
2af39ac017 | ||
|
|
d47b8fef18 | ||
|
|
f8fc214b11 | ||
|
|
7861bfa45e | ||
|
|
02734264a1 | ||
|
|
4a845f3d04 | ||
|
|
0452ebdfcd | ||
|
|
c8b8c4cf30 | ||
|
|
1ff1401ff1 | ||
|
|
3991bbe595 | ||
|
|
20beb093a1 | ||
|
|
3135642ff5 | ||
|
|
d5bb3b0039 | ||
|
|
f16216e270 | ||
|
|
de9e1a0693 | ||
|
|
47b18d89f6 | ||
|
|
3f5b474b16 | ||
|
|
b103fec939 | ||
|
|
728be68bfe | ||
|
|
5820e97abe | ||
|
|
4e81ea2a8a | ||
|
|
7bfdb31c77 | ||
|
|
44cec04294 | ||
|
|
c60a84b6f5 | ||
|
|
3b953cc763 | ||
|
|
859ce39666 | ||
|
|
7c6ea4ed00 | ||
|
|
3dab3be859 | ||
|
|
062ed99894 | ||
|
|
d275fc90cf | ||
|
|
dbc4c47b15 | ||
|
|
e6d97ce928 | ||
|
|
b7473285ec | ||
|
|
8b7107b81f | ||
|
|
d1251b2850 | ||
|
|
e972589554 | ||
|
|
0f19c958da | ||
|
|
2935fbc089 | ||
|
|
f47fc4f111 | ||
|
|
01c95cb07e | ||
|
|
1f94541732 | ||
|
|
ff43b4dca0 | ||
|
|
5d494e940f | ||
|
|
30de580afe | ||
|
|
0c13350ea4 | ||
|
|
83a661c360 | ||
|
|
38ec1325c4 | ||
|
|
2ca2e83ce5 | ||
|
|
a9908ba7bd | ||
|
|
9f874c00aa | ||
|
|
b52cdf6a95 | ||
|
|
40e637d9e1 | ||
|
|
21c76d97bb | ||
|
|
4b3147ede7 | ||
|
|
a037a66ea4 | ||
|
|
c071819c26 | ||
|
|
28e018de8a | ||
|
|
65102c0ba5 | ||
|
|
ff8e97310d | ||
|
|
2546661aeb | ||
|
|
fdeed49637 | ||
|
|
fab7693da5 | ||
|
|
582323d63c | ||
|
|
a6522d3706 | ||
|
|
28a0028762 | ||
|
|
ec19c32b63 | ||
|
|
ec9aceb96f | ||
|
|
0e1c2e3378 | ||
|
|
094b952d70 | ||
|
|
3821a4e054 | ||
|
|
d24404ca9a | ||
|
|
fb2d6e8870 | ||
|
|
e421cbac2a | ||
|
|
a71310f58b | ||
|
|
43c392626b | ||
|
|
d286573958 | ||
|
|
ff889c40da | ||
|
|
0ecdbe8614 | ||
|
|
8b3500a2a9 | ||
|
|
c5fd56606d | ||
|
|
dd86b85664 | ||
|
|
3ec9f5fa0b | ||
|
|
3bf3ce06f7 | ||
|
|
cc1d601722 | ||
|
|
e8c1b849b7 | ||
|
|
de44b71b12 | ||
|
|
df70c7136d | ||
|
|
bf2b9ea539 | ||
|
|
b0b46c331e | ||
|
|
b3269581ea | ||
|
|
699edd4393 | ||
|
|
9128c6c17b | ||
|
|
f121223ed8 | ||
|
|
3c0e360df1 | ||
|
|
1de6f5fcf6 | ||
|
|
5bf4b718d4 | ||
|
|
f912007fe8 | ||
|
|
377809a35b | ||
|
|
f0f981b80d | ||
|
|
2b9302632c | ||
|
|
a59a1552ad | ||
|
|
4a80e821df | ||
|
|
6822291f91 | ||
|
|
863aacaee3 | ||
|
|
00a2bf7120 | ||
|
|
6ac5acf765 | ||
|
|
ce7583f173 | ||
|
|
24b10ac585 | ||
|
|
706371e24f | ||
|
|
5de8639685 | ||
|
|
d42e26d59c | ||
|
|
6ea06e87bb | ||
|
|
5eb8a44317 | ||
|
|
c89fb0b828 | ||
|
|
52e111dbb7 | ||
|
|
36b5109387 | ||
|
|
c07b085c81 | ||
|
|
065c442141 | ||
|
|
83b570d981 | ||
|
|
2afdee9c7d | ||
|
|
a7e809e1f7 | ||
|
|
deb7cb708f | ||
|
|
fcd7db6cd1 | ||
|
|
68adbd2e05 | ||
|
|
b6258d612b | ||
|
|
93cb76a292 | ||
|
|
6191f69f0c | ||
|
|
d416e6c854 | ||
|
|
3a63d978dd | ||
|
|
d2a78c33df | ||
|
|
679f91482e | ||
|
|
d380a8554d | ||
|
|
4f36ad0cc1 | ||
|
|
90ba7fbf1f | ||
|
|
76658477af | ||
|
|
ffb6a9c74b | ||
|
|
21d334389f | ||
|
|
94a5e081e5 | ||
|
|
5e78d72ef2 | ||
|
|
5c303e2bb5 | ||
|
|
4c1cb388af | ||
|
|
144bd4a878 | ||
|
|
91737aff68 | ||
|
|
2391b40f47 | ||
|
|
6a8aff5a74 | ||
|
|
c0ec5d404b | ||
|
|
10e9a6b6cd | ||
|
|
a51aed7ce2 | ||
|
|
71e0106846 | ||
|
|
3ce9af7fce | ||
|
|
05e8aae95e | ||
|
|
381de6b7cb | ||
|
|
c077645f77 | ||
|
|
ebc3263987 | ||
|
|
cf6e5bf01f | ||
|
|
958c615a83 | ||
|
|
8e5070f469 | ||
|
|
4397b675cb | ||
|
|
9ed88f6a8d | ||
|
|
f12fde9132 | ||
|
|
1c4ea6d246 | ||
|
|
a6d76b3c48 | ||
|
|
5d0ace0577 | ||
|
|
7b88544d46 | ||
|
|
6767ea2456 | ||
|
|
459db3d64b | ||
|
|
d009cf618a | ||
|
|
9a9897a9de | ||
|
|
3f9fb13df6 | ||
|
|
52f414669a | ||
|
|
b34215906c | ||
|
|
fb768ac792 | ||
|
|
35289bffe2 | ||
|
|
ef00fdf472 | ||
|
|
3de7e8358f | ||
|
|
28ac2f49dc | ||
|
|
c38b5d5eb9 | ||
|
|
180d06613a | ||
|
|
c3ee4212f0 | ||
|
|
efafbe9a5c | ||
|
|
e38680a4df | ||
|
|
f28fc6f2e1 | ||
|
|
5ba8d36687 | ||
|
|
178236cc5f | ||
|
|
79a0533c69 | ||
|
|
64363995be | ||
|
|
426ad6e3a3 | ||
|
|
0d0e7a1008 | ||
|
|
806545df34 | ||
|
|
b8cc257ac5 | ||
|
|
bdb4d96678 | ||
|
|
0c5fb4a81b | ||
|
|
3ff48f27cf | ||
|
|
f0c732452f | ||
|
|
a4d1b1ba21 | ||
|
|
0447ea94c1 | ||
|
|
38fd7a84c7 | ||
|
|
ee17910ec5 | ||
|
|
717a7dbfde | ||
|
|
0fb6576511 | ||
|
|
383495c863 | ||
|
|
b55abf5730 | ||
|
|
3e1aa456b9 | ||
|
|
00558adda8 | ||
|
|
1c3273aab2 | ||
|
|
589b247926 | ||
|
|
6965e3e03c | ||
|
|
202d5ab754 | ||
|
|
1023be33fb | ||
|
|
595c00f55c | ||
|
|
5aaa5eab70 | ||
|
|
70b24b021a | ||
|
|
af96c721c4 | ||
|
|
a9b653db26 | ||
|
|
80c23d4519 | ||
|
|
821d7a8941 | ||
|
|
e7c8a22c67 | ||
|
|
5652ccc780 | ||
|
|
055d429ae1 | ||
|
|
8231897b26 | ||
|
|
df7e656034 | ||
|
|
d045409b9f | ||
|
|
7f3f4cfdd0 | ||
|
|
ef044d9f17 | ||
|
|
9642c7f990 | ||
|
|
0c5193c588 | ||
|
|
f2c2b3fc7a | ||
|
|
1228e0e925 | ||
|
|
3a3820bedc | ||
|
|
91ee6ed60f | ||
|
|
7e28fdc176 | ||
|
|
569bc02649 | ||
|
|
178309be47 | ||
|
|
2fb7ac9a58 | ||
|
|
2e493cb89a | ||
|
|
cdf0d77b20 | ||
|
|
ccdfaa9115 | ||
|
|
34af05ec30 | ||
|
|
6bd41e47ac | ||
|
|
45d11c53f0 | ||
|
|
50a68d7d59 | ||
|
|
cc47b5a78c | ||
|
|
34b4ec3624 | ||
|
|
86ed364dc0 | ||
|
|
438cde4e70 | ||
|
|
3b268d1656 | ||
|
|
0a97782339 | ||
|
|
1cf1d6146c | ||
|
|
f3217ac170 | ||
|
|
c8125f8710 | ||
|
|
1e3bc7c069 | ||
|
|
34df9f3dbf | ||
|
|
72bb159a7e | ||
|
|
afe4e345d2 | ||
|
|
855b5b513d | ||
|
|
b9d271c1a8 | ||
|
|
b3931741ef | ||
|
|
ede48e285f | ||
|
|
8890539f47 | ||
|
|
ff72dd8d2c | ||
|
|
e07b265009 | ||
|
|
8d0e5899b9 | ||
|
|
e6f8b59010 | ||
|
|
8e65846f32 | ||
|
|
96d4d3f3be | ||
|
|
811c01cc2e | ||
|
|
e24127771e | ||
|
|
b3f00d05a8 | ||
|
|
652d34b0a8 | ||
|
|
7539577b46 | ||
|
|
41ee6006c4 | ||
|
|
813ba42cfc | ||
|
|
80076276e1 | ||
|
|
3a78e8010d | ||
|
|
d9940f416b | ||
|
|
dd998e7fd3 | ||
|
|
747db4d940 | ||
|
|
ecd5c523dc | ||
|
|
3de14fc63e | ||
|
|
7f166eaee7 | ||
|
|
ab7b5e48c4 | ||
|
|
345b5cfc5c | ||
|
|
1ac93c3a72 | ||
|
|
4b8c29a708 | ||
|
|
04b057d22c | ||
|
|
fcfb8dd2ed | ||
|
|
4a2673772a | ||
|
|
b9e216ac6f | ||
|
|
e78e2885fe | ||
|
|
777f2e7547 | ||
|
|
27e494d25c | ||
|
|
d88156d998 | ||
|
|
44a3af51f0 | ||
|
|
79f090d92b | ||
|
|
54c65fdad0 | ||
|
|
e917802316 | ||
|
|
6a19a31171 | ||
|
|
a06b7f2ae0 | ||
|
|
405b1067e2 | ||
|
|
10cb93283a | ||
|
|
d28e8f537a | ||
|
|
24d7f54662 | ||
|
|
687a43e199 | ||
|
|
07ef7d750b | ||
|
|
ea2b1d36aa | ||
|
|
c7540fba94 | ||
|
|
3d9198592b | ||
|
|
d6357bacdd | ||
|
|
647551b8e4 | ||
|
|
b158c25dc3 | ||
|
|
bc8a3c5b6f | ||
|
|
c149db2205 | ||
|
|
b5495ec972 | ||
|
|
472c390e75 | ||
|
|
3d9a41e4b4 | ||
|
|
9f77b065d3 | ||
|
|
7abbe1e8d8 | ||
|
|
004b6ed60f | ||
|
|
d12f30f90c | ||
|
|
c433c2f2e2 | ||
|
|
9e52c330ae | ||
|
|
564deec2c4 | ||
|
|
6fd0ffccbf | ||
|
|
ee957a4285 | ||
|
|
c63331a303 | ||
|
|
4d2c44ca87 | ||
|
|
596b5cd732 | ||
|
|
8ff1ba325d | ||
|
|
a19d7e3680 | ||
|
|
90eeb25770 | ||
|
|
bfe8b81d18 | ||
|
|
ec71c19be7 | ||
|
|
cce1fc9c65 | ||
|
|
79fee501af | ||
|
|
12dfaa2d74 | ||
|
|
d4e5366fe6 | ||
|
|
d7388d7e80 | ||
|
|
5c363b76ee | ||
|
|
440adddcde | ||
|
|
af9ad1580a | ||
|
|
d569430cc6 | ||
|
|
c39bea2017 | ||
|
|
a361f618a1 | ||
|
|
8c2d8bc85f | ||
|
|
563b56e09c | ||
|
|
455f675806 | ||
|
|
3932e860ca | ||
|
|
b3368a85da | ||
|
|
defe0b25dd | ||
|
|
b68ed904b1 | ||
|
|
2eba4fb96b | ||
|
|
27ba604ad7 | ||
|
|
769982d058 | ||
|
|
674d702257 | ||
|
|
c974cb1b8e | ||
|
|
20c05a3add | ||
|
|
c27322ff04 | ||
|
|
6e624946d2 | ||
|
|
ab9a63bbea | ||
|
|
3a8438e1f8 | ||
|
|
0e49c6affd | ||
|
|
8bcf78cd78 | ||
|
|
ffc944976b | ||
|
|
1b52be6246 | ||
|
|
e7e1ec6e84 | ||
|
|
ff3c441023 | ||
|
|
aaf6e84373 | ||
|
|
380a357b08 | ||
|
|
8026d0b2e7 | ||
|
|
b41cad58cb | ||
|
|
39e12244cc | ||
|
|
c4c01b61e6 | ||
|
|
eb3cd22aa3 | ||
|
|
5b35f5fb69 | ||
|
|
11d875d043 | ||
|
|
ac946a4602 | ||
|
|
815e2f3d03 | ||
|
|
bd8bca87b2 | ||
|
|
9110aa09a4 | ||
|
|
fe085a631d | ||
|
|
c7489af844 | ||
|
|
32a653e67e | ||
|
|
d16c93aa08 | ||
|
|
46367a7a7b | ||
|
|
83a25c06ef | ||
|
|
db7db67851 | ||
|
|
8d7073abf6 | ||
|
|
f1c8dd887b | ||
|
|
08bc3b0386 | ||
|
|
2808de6084 | ||
|
|
028088f5f0 | ||
|
|
21178c3571 | ||
|
|
b8214e260c | ||
|
|
45d813b62c | ||
|
|
73b3e0e50e | ||
|
|
255fcbc3a5 | ||
|
|
47d93279ff | ||
|
|
5b93ae8628 | ||
|
|
436318a8c8 | ||
|
|
57a328c7a9 | ||
|
|
2cd3f046e5 | ||
|
|
5c88c1376c | ||
|
|
2d39e5d7a5 | ||
|
|
27e255fa75 | ||
|
|
195190b612 | ||
|
|
aeabfaf417 | ||
|
|
f62201ba9d | ||
|
|
5cf331d881 | ||
|
|
28c90cce6c | ||
|
|
ca5b10938a | ||
|
|
acd4cc6f5c | ||
|
|
7ac3a36229 | ||
|
|
a6178c1de6 | ||
|
|
990dd18474 | ||
|
|
c4642d4fda | ||
|
|
c7d3b83164 | ||
|
|
7c87bb35c4 | ||
|
|
f20530dce2 | ||
|
|
5d5adf7c7e | ||
|
|
fc01873d60 | ||
|
|
81b9e78565 | ||
|
|
cee4505172 | ||
|
|
4d4b29ea94 | ||
|
|
efd780f82a | ||
|
|
cc0ff6b0bf | ||
|
|
35e13cf5e8 | ||
|
|
238652b36c | ||
|
|
e4b728ccb9 | ||
|
|
68967aef72 | ||
|
|
fd67d46be7 | ||
|
|
ee0e8a3aad | ||
|
|
f4734d6b4d | ||
|
|
656628e69b | ||
|
|
6b1bca80ee | ||
|
|
537a50214a | ||
|
|
67d04dd9ba | ||
|
|
b8efd02c7f | ||
|
|
a600d8f4e2 | ||
|
|
de7793e918 | ||
|
|
a5e442d490 | ||
|
|
51513c4e6b | ||
|
|
5d0b813cec | ||
|
|
ba0c271774 | ||
|
|
7062c01b68 | ||
|
|
c0bad42eb1 | ||
|
|
af7ebd96a0 | ||
|
|
ac59fd1476 | ||
|
|
6561d70664 | ||
|
|
1a5c59326a | ||
|
|
d44375aece | ||
|
|
cf37058d7c | ||
|
|
dcb3fcbfa7 | ||
|
|
6ece3f6792 | ||
|
|
3b30e42551 | ||
|
|
b0ef524b9e | ||
|
|
b138aaae08 | ||
|
|
3953661078 | ||
|
|
b551844cc2 | ||
|
|
93f3e2b007 | ||
|
|
0a42a8bc46 | ||
|
|
8097b07661 | ||
|
|
1475cabfa0 | ||
|
|
6a1573c228 | ||
|
|
d26e1d783f | ||
|
|
fa720c1858 | ||
|
|
bc7c3e44d5 | ||
|
|
480ca88b68 | ||
|
|
aba0e602ed | ||
|
|
22a2f98ced | ||
|
|
aaa47850c3 | ||
|
|
7c2feb78d2 | ||
|
|
0c65d2cc0c | ||
|
|
13c5f806c6 | ||
|
|
84d3b4de46 | ||
|
|
925a772dce | ||
|
|
95015f1104 | ||
|
|
dcbc727813 | ||
|
|
3b9d4c8d50 | ||
|
|
40fe9e6d67 | ||
|
|
4da816e459 | ||
|
|
9c475467d5 | ||
|
|
0310cbad0a | ||
|
|
ef258914b2 | ||
|
|
c025f363f5 | ||
|
|
51187d06b3 | ||
|
|
8210b3c873 | ||
|
|
883e0826e2 | ||
|
|
003f9f7953 | ||
|
|
2880a679f0 | ||
|
|
4d6cff7eb8 | ||
|
|
d8806649ab | ||
|
|
dc9a65923a | ||
|
|
751d2a0fe7 |
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
|
||||
4
AUTHORS
4
AUTHORS
@@ -3,8 +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 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,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# Look for the header file.
|
||||
FIND_PATH(FCGI_INCLUDE_DIR NAMES fastcgi.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(FCGI_LIBRARY NAMES fcgi)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(FCGI_FOUND)
|
||||
SET(FCGI_LIBRARIES ${FCGI_LIBRARY})
|
||||
SET(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
|
||||
ELSE(FCGI_FOUND)
|
||||
SET(FCGI_LIBRARIES)
|
||||
SET(FCGI_INCLUDE_DIRS)
|
||||
ENDIF(FCGI_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(FCGI_INCLUDE_DIRS FCGI_LIBRARIES)
|
||||
@@ -1,20 +0,0 @@
|
||||
# Look for the header file.
|
||||
FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set PTHREAD_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTHREAD DEFAULT_MSG PTHREAD_LIBRARY PTHREAD_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(PTHREAD_FOUND)
|
||||
SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
|
||||
SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
|
||||
ELSE(PTHREAD_FOUND)
|
||||
SET(PTHREAD_LIBRARIES)
|
||||
SET(PTHREAD_INCLUDE_DIRS)
|
||||
ENDIF(PTHREAD_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIRS PTHREAD_LIBRARIES)
|
||||
404
CMakeLists.txt
404
CMakeLists.txt
@@ -6,54 +6,78 @@
|
||||
# you will eventually like to prefix the library to avoid linking confusion
|
||||
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||
# e.g.:
|
||||
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||
cmake_minimum_required(VERSION 2.8.2)
|
||||
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
if(COMMAND CMAKE_POLICY)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_NAMESPACE)
|
||||
SET(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||
SET(OPENJPEG_STANDALONE 1)
|
||||
ENDIF(NOT OPENJPEG_NAMESPACE)
|
||||
if(NOT OPENJPEG_NAMESPACE)
|
||||
set(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||
set(OPENJPEG_STANDALONE 1)
|
||||
endif()
|
||||
# In all cases:
|
||||
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||
set(OPENJPEG_LIBRARY_NAME openjp2)
|
||||
|
||||
PROJECT(${OPENJPEG_NAMESPACE} C)
|
||||
project(${OPENJPEG_NAMESPACE} C)
|
||||
|
||||
# Do full dependency headers.
|
||||
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
include_regular_expression("^.*$")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||
SET(OPENJPEG_VERSION_MINOR 5)
|
||||
SET(OPENJPEG_VERSION_BUILD 0)
|
||||
SET(OPENJPEG_VERSION
|
||||
set(OPENJPEG_VERSION_MAJOR 2)
|
||||
set(OPENJPEG_VERSION_MINOR 1)
|
||||
set(OPENJPEG_VERSION_BUILD 0)
|
||||
set(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
SET(PACKAGE_VERSION
|
||||
set(PACKAGE_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||
|
||||
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||
# two numbering, one for the openjpeg version and one for openjpeg soversion
|
||||
# version | soversion
|
||||
# 1.0 | 0
|
||||
# 1.1 | 1
|
||||
# 1.2 | 2
|
||||
# 1.3 | 3
|
||||
# 1.4 | 4
|
||||
# 1.5 | 5
|
||||
# 1.5.1 | 5
|
||||
# 2.0 | 6
|
||||
# 2.0.1 | 6
|
||||
# 2.1 | 7
|
||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||
if(NOT OPENJPEG_SOVERSION)
|
||||
SET(OPENJPEG_SOVERSION 7)
|
||||
endif(NOT OPENJPEG_SOVERSION)
|
||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||
SOVERSION "${OPENJPEG_VERSION_MAJOR}"
|
||||
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Path to additional CMake modules
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${CMAKE_SOURCE_DIR}/CMake
|
||||
set(CMAKE_MODULE_PATH
|
||||
${CMAKE_SOURCE_DIR}/cmake
|
||||
${CMAKE_MODULE_PATH})
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||
# warnings
|
||||
IF(WIN32)
|
||||
IF(NOT BORLAND)
|
||||
IF(NOT CYGWIN)
|
||||
IF(NOT MINGW)
|
||||
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ADD_DEFINITIONS(
|
||||
if(WIN32)
|
||||
if(NOT BORLAND)
|
||||
if(NOT CYGWIN)
|
||||
if(NOT MINGW)
|
||||
if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
add_definitions(
|
||||
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||
@@ -65,198 +89,296 @@ IF(WIN32)
|
||||
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||
-D_SCL_SECURE_NO_DEPRECATE
|
||||
)
|
||||
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ENDIF(NOT MINGW)
|
||||
ENDIF(NOT CYGWIN)
|
||||
ENDIF(NOT BORLAND)
|
||||
ENDIF(WIN32)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Install directories
|
||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||
|
||||
STRING(TOLOWER ${PROJECT_NAME} projectname)
|
||||
SET(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||
string(TOLOWER ${PROJECT_NAME} projectname)
|
||||
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||
SET(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||
set(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
set(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
set(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
SET(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
SET(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
if(BUILD_DOC)
|
||||
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||
if(WIN32)
|
||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
||||
else()
|
||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
# We could install *.cmake files in share/ however those files contains
|
||||
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
||||
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
||||
set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
|
||||
option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Big endian test:
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup file for setting custom ctest vars
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
||||
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OpenJPEG build configuration options.
|
||||
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||
SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
||||
SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
|
||||
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
||||
option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||
set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
||||
set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
|
||||
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# configure name mangling to allow multiple libraries to coexist
|
||||
# peacefully
|
||||
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||
@ONLY)
|
||||
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# pkgconfig support
|
||||
IF(UNIX)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig )
|
||||
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
\"libopenjpeg1.pc\"
|
||||
\"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||
ENDIF(UNIX)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags:
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
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.
|
||||
# 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}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# opj_config.h generation (1/2)
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
|
||||
# Check if some include files are provided by the system
|
||||
include(EnsureFileInclude)
|
||||
# These files are mandatory
|
||||
ensure_file_include("string.h" HAVE_STRING_H YES)
|
||||
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
|
||||
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
|
||||
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
|
||||
ensure_file_include("math.h" HAVE_MATH_H YES)
|
||||
ensure_file_include("float.h" HAVE_FLOAT_H YES)
|
||||
ensure_file_include("time.h" HAVE_TIME_H YES)
|
||||
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
|
||||
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
|
||||
ensure_file_include("assert.h" HAVE_ASSERT_H YES)
|
||||
|
||||
# For the following files, we provide an alternative, they are not mandatory
|
||||
ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
|
||||
ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
|
||||
|
||||
# why check this one ? for openjpip ?
|
||||
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
||||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
|
||||
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
|
||||
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
|
||||
# Enable Large file support
|
||||
include(TestLargeFiles)
|
||||
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||
|
||||
# Allocating Aligned Memory Blocks
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||
include(CheckSymbolExists)
|
||||
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
||||
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
|
||||
# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
|
||||
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
# memalign (obsolete)
|
||||
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Library
|
||||
INCLUDE_DIRECTORIES(BEFORE ${OPENJPEG_BINARY_DIR})
|
||||
ADD_SUBDIRECTORY(libopenjpeg)
|
||||
if(BUILD_JPIP_SERVER)
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(FCGI REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
if(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
message(FATAL_ERROR "Only pthread are supported")
|
||||
endif()
|
||||
endif()
|
||||
add_subdirectory(src/lib)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Applications
|
||||
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
|
||||
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||
OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||
OPTION(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||
IF(BUILD_JPIP)
|
||||
OPTION(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||
ENDIF(BUILD_JPIP)
|
||||
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||
MARK_AS_ADVANCED(BUILD_VIEWER)
|
||||
MARK_AS_ADVANCED(BUILD_JAVA)
|
||||
option(BUILD_CODEC "Build the CODEC executables" ON)
|
||||
option(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||
option(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||
if(BUILD_JPIP)
|
||||
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||
endif()
|
||||
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||
option(BUILD_JP3D "Build the JP3D comp" OFF)
|
||||
mark_as_advanced(BUILD_VIEWER)
|
||||
mark_as_advanced(BUILD_JAVA)
|
||||
mark_as_advanced(BUILD_JP3D)
|
||||
|
||||
IF(BUILD_CODEC OR BUILD_MJ2)
|
||||
if(BUILD_CODEC OR BUILD_MJ2)
|
||||
# OFF: It will only build 3rd party libs if they are not found on the system
|
||||
# ON: 3rd party libs will ALWAYS be build, and used
|
||||
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
||||
ADD_SUBDIRECTORY(thirdparty)
|
||||
ADD_SUBDIRECTORY(applications)
|
||||
ENDIF (BUILD_CODEC OR BUILD_MJ2)
|
||||
option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
||||
add_subdirectory(thirdparty)
|
||||
add_subdirectory(src/bin)
|
||||
endif ()
|
||||
add_subdirectory(wrapping)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# opj_config.h generation (2/2)
|
||||
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
|
||||
"${OPENJPEG_BINARY_DIR}/opj_config.h"
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||
OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||
IF(BUILD_DOC)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF(BUILD_DOC)
|
||||
# build documentation in doc subdir:
|
||||
if(BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Buld Testing
|
||||
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||
IF(BUILD_TESTING)
|
||||
IF(BUILD_CODEC)
|
||||
ENABLE_TESTING()
|
||||
INCLUDE(CTest)
|
||||
|
||||
option(BUILD_TESTING "Build the tests." OFF)
|
||||
if(BUILD_TESTING)
|
||||
if(BUILD_CODEC)
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
|
||||
# Search openjpeg data needed for the tests
|
||||
# They could be found via svn on the OpenJPEG google code project
|
||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
||||
PATHS
|
||||
$ENV{OPJ_DATA_ROOT}
|
||||
${CMAKE_SOURCE_DIR}/../data
|
||||
# They could be found via git on the OpenJPEG GitHub code project
|
||||
# git clone https://github.com/uclouvain/openjpeg-data.git
|
||||
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
# Add repository where to find tests
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
|
||||
ELSE(BUILD_CODEC)
|
||||
add_subdirectory(tests)
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "You need build codec to run the tests")
|
||||
ENDIF(BUILD_CODEC)
|
||||
ENDIF(BUILD_TESTING)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install all targets referenced as OPENJPEGTargets
|
||||
INSTALL(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||
CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
|
||||
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||
configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
||||
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
@ONLY
|
||||
)
|
||||
INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install CHANGES and LICENSE
|
||||
INSTALL(
|
||||
FILES CHANGES
|
||||
LICENSE
|
||||
DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
if(BUILD_DOC)
|
||||
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
endif()
|
||||
|
||||
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||
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)
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||
#
|
||||
if(BUILD_JPWL)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpwl/libopenjpwl.pc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc @ONLY)
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||
endif()
|
||||
#
|
||||
if(BUILD_JPIP)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpip/libopenjpip.pc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc @ONLY)
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||
endif()
|
||||
#
|
||||
if(BUILD_JP3D)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp3d/libopenjp3d.pc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc @ONLY)
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
86
INSTALL
86
INSTALL
@@ -2,63 +2,10 @@
|
||||
How to build and install openjpeg binaries
|
||||
==========================================
|
||||
|
||||
UNIX/LINUX similar systems
|
||||
UNIX/LINUX/MacOSX/Windows systems
|
||||
--------------------------
|
||||
|
||||
1) Using autotools
|
||||
|
||||
It is highly recommended that pkg-config is installed. If needed, you have to
|
||||
properly set the environment variable PKG_CONFIG_PATH so that the .pc files
|
||||
are found.
|
||||
|
||||
To build from top-level directory, you can simply type:
|
||||
./bootstrap.sh
|
||||
./configure
|
||||
make
|
||||
|
||||
To keep all build files in a separate directory, you can type instead:
|
||||
./bootstrap.sh
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
|
||||
To install:
|
||||
sudo make install
|
||||
|
||||
To clean:
|
||||
make clean
|
||||
make distclean
|
||||
|
||||
To build doc (requires 'doxygen' to be found on your system):
|
||||
(this will create an html directory in TOP_LEVEL/doc)
|
||||
make doc
|
||||
|
||||
Main './configure' options (type './configure --help' for more details)
|
||||
'--enable-mj2'
|
||||
'--enable-jpwl'
|
||||
'--enable-jpip'
|
||||
'--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed')
|
||||
'--enable-debug' (default : disabled)
|
||||
|
||||
You can also specify your own CFLAGS and LDFLAGS with (for example):
|
||||
CFLAGS="-O3 -pipe" LDFLAGS="-Wl,-s" ./configure
|
||||
|
||||
The (optional) dependencies of some binaries are libpng, libtiff, libcms 1 or 2
|
||||
and FastCGI. Only libtiff and FastCGI have no .pc file. There should be some
|
||||
automatic detection if they are installed in /usr, /usr/local or /opt/local.
|
||||
Otherwise, you can tune their detection (as well as for libpng and libcms1 or 2
|
||||
too) with the environment variables:
|
||||
|
||||
TIFF_CFLAGS
|
||||
TIFF_LIBS
|
||||
FCGI_CFLAGS
|
||||
FCGI_LIBS
|
||||
|
||||
See './configure --help' output for more details.
|
||||
|
||||
|
||||
2) Using cmake (see www.cmake.org)
|
||||
Using cmake (see www.cmake.org)
|
||||
|
||||
Type:
|
||||
cmake .
|
||||
@@ -66,12 +13,13 @@ Type:
|
||||
|
||||
If you are root:
|
||||
make install
|
||||
make clean
|
||||
|
||||
else:
|
||||
else if you have sudo power:
|
||||
sudo make install
|
||||
make clean
|
||||
|
||||
|
||||
else
|
||||
DESTDIR=$HOME/local make install
|
||||
|
||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
(A 'html' directory is generated in the 'doc' directory)
|
||||
make doc
|
||||
@@ -79,18 +27,24 @@ To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
Binaries are located in the 'bin' directory.
|
||||
|
||||
Main available cmake flags:
|
||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path'
|
||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path', or use DESTDIR env variable (see above)
|
||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
||||
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||
* To build the documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
|
||||
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
||||
** To build the JPIP server: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
|
||||
* To build the JP3D library and utilities: '-DBUILD_JP3D:bool=on' (default: 'OFF') (experimental)
|
||||
* To build the Java binding: '-DBUILD_JAVA:bool=on' (default: 'OFF') (experimental).
|
||||
** to choose which java implementation, you can set your JAVA_HOME env var.
|
||||
* To build the wxWidgets/C++ viewer: 'BUILD_VIEWER:BOOL=ON' (default OFF) (experimental)
|
||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||
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).
|
||||
@@ -98,7 +52,7 @@ Main available cmake flags:
|
||||
MACOSX
|
||||
------
|
||||
|
||||
The same building procedures as above (autotools and cmake) work for MACOSX.
|
||||
The same building procedures as above work for MACOSX.
|
||||
The xcode project file can also be used.
|
||||
|
||||
If it does not work, try adding the following flag to the cmake command :
|
||||
@@ -107,7 +61,9 @@ If it does not work, try adding the following flag to the cmake command :
|
||||
WINDOWS
|
||||
-------
|
||||
|
||||
If you're using cygwin or MinGW+MSYS, the same procedures as for Unix can be used.
|
||||
|
||||
Otherwise you can use cmake to generate project files for the IDE you are using (VC2010, etc).
|
||||
You can use cmake to generate project files for the IDE you are using (VS2010, NMake, etc).
|
||||
Type 'cmake --help' for available generators on your platform.
|
||||
|
||||
Make sure to build the third party libs (png, zlib ...):
|
||||
|
||||
'-DBUILD_THIRDPARTY:BOOL=ON'
|
||||
|
||||
14
LICENSE
14
LICENSE
@@ -1,11 +1,19 @@
|
||||
/*
|
||||
* 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
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
75
Makefile.am
75
Makefile.am
@@ -1,75 +0,0 @@
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpip-server=yes --enable-jpwl=yes --enable-mj2=yes
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = libopenjpeg applications doc
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libopenjpeg1.pc
|
||||
|
||||
if WANT_JPWL
|
||||
pkgconfig_DATA += libopenjpeg-jpwl.pc
|
||||
endif
|
||||
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in \
|
||||
aclocal.m4 \
|
||||
config.guess \
|
||||
opj_config.h.in \
|
||||
opj_config.h.in~ \
|
||||
config.sub \
|
||||
configure \
|
||||
depcomp \
|
||||
install-sh \
|
||||
ltmain.sh \
|
||||
missing
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMake/CTestCustom.cmake.in \
|
||||
CMake/FindFCGI.cmake \
|
||||
CMake/FindLCMS2.cmake \
|
||||
CMake/FindLCMS.cmake \
|
||||
CMake/OpenJPEGConfig.cmake.in \
|
||||
CMakeLists.txt \
|
||||
CTestConfig.cmake \
|
||||
AUTHORS \
|
||||
CHANGES \
|
||||
INSTALL \
|
||||
LICENSE \
|
||||
NEWS \
|
||||
README \
|
||||
THANKS \
|
||||
bootstrap.sh \
|
||||
libopenjpeg1.pc.cmake \
|
||||
libopenjpeg1.pc.in \
|
||||
libopenjpeg-jpwl.pc.in \
|
||||
opj_config.h.cmake.in \
|
||||
m4/opj_check_lib.m4 \
|
||||
m4/opj_doxygen.m4 \
|
||||
m4/pkg.m4
|
||||
|
||||
.PHONY: doc
|
||||
|
||||
# Documentation
|
||||
|
||||
doc:
|
||||
@echo "entering doc/"
|
||||
@cd doc && make doc
|
||||
|
||||
install-data-hook:
|
||||
if HAVE_WIN32
|
||||
$(LN_S) -f libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
else
|
||||
$(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
endif
|
||||
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
|
||||
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.pc" >> $(top_builddir)/report.txt
|
||||
if WANT_JPWL
|
||||
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg-jpwl.pc" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
@cat $(top_builddir)/report.txt
|
||||
@rm $(top_builddir)/report.txt
|
||||
|
||||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
69
NEWS
69
NEWS
@@ -2,33 +2,60 @@
|
||||
OpenJPEG NEWS - user visible changes
|
||||
====================================
|
||||
|
||||
Changes from OpenJPEG 1.4.0 to OpenJPEG 1.5.0
|
||||
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.X.X
|
||||
----------------------------------------------
|
||||
|
||||
New Features:
|
||||
|
||||
* openjpip:
|
||||
- complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||
- located in 'applications/jpip'.
|
||||
- see corresponding README for more details.
|
||||
* 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)
|
||||
|
||||
API modifications:
|
||||
|
||||
* 'bool' type has been replaced by 'opj_bool' type. 'stdbool.h' is no more required.
|
||||
* 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:
|
||||
|
||||
* added this NEWS file.
|
||||
* improved cmake and autotools build methods.
|
||||
* removed manual makefiles, VS project files and XCode project files.
|
||||
* added a 'thirdparty' directory to contain all dependencies.
|
||||
- These libraries will be build only if there are not found on the system.
|
||||
- Note that libopenjpeg itself does not have any dependency.
|
||||
* changed the directory hierarchy of the whole project. See README files for details.
|
||||
* tests : a complete test suite has been setup.
|
||||
- both JPEG 2000 conformance tests and non-regressions tests are configured.
|
||||
- results are submitted to the OpenJPEG dashboard (http://my.cdash.org/index.php?project=OPENJPEG)
|
||||
- images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||
- configuration files and utilities are located in 'tests' folder.
|
||||
* OPJViewer re-activated (need wxWidgets)
|
||||
* 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
|
||||
----------------------------------------------
|
||||
|
||||
New Features:
|
||||
|
||||
* streaming capabilities
|
||||
* merge JP3D
|
||||
|
||||
API modifications:
|
||||
|
||||
* Use a 64bits capable API
|
||||
|
||||
Misc:
|
||||
|
||||
* removed autotools build system
|
||||
* folders hierarchies reorganisation
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
|
||||
25
README
25
README
@@ -1,25 +0,0 @@
|
||||
|
||||
OPENJPEG LIBRARY and APPLICATIONS
|
||||
----------------------------------
|
||||
|
||||
Details on folders hierarchy:
|
||||
|
||||
* libopenjpeg: contains the sources of the openjpeg library
|
||||
* jpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||
* applications: contains all applications that use the openjpeg library
|
||||
* common: common files to all applications
|
||||
* codec: a basic codec
|
||||
* mj2: motion jpeg 2000 executables
|
||||
* JavaOpenJPEG: java jni to use openjpeg in a java program
|
||||
* jpip: complete client-server architecture for remote browsing of jpeg 2000 images. See corresponding README for more details.
|
||||
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||
* doc: doxygen documentation setup file and man pages
|
||||
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||
* CMake: cmake related files
|
||||
* m4: autotools related files
|
||||
|
||||
see LICENSE for license and copyright information.
|
||||
see INSTALL for installation procedures.
|
||||
see NEWS for user visible changes in successive releases.
|
||||
see CHANGES for per-revision changes.
|
||||
79
README.md
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.
|
||||
|
||||
Mathieu Malaterre
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Bob Friesenhahn
|
||||
Callum Lerwick
|
||||
Dzonatas Sol
|
||||
Mickaël Savinaud
|
||||
Julien Malik
|
||||
Jerôme Fimes
|
||||
Herve Drolon
|
||||
Yannick Verschueren
|
||||
Sebastien Lugan
|
||||
Kaori Hagihara
|
||||
Peter Wimmer
|
||||
Francois-Olivier Devaux
|
||||
Antonin Descampe
|
||||
David Janssens
|
||||
Pr. Benoit Macq
|
||||
Luis Ibanez
|
||||
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
|
||||
Dzonatas Sol
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Yannick Verschueren
|
||||
Peter Wimmer
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Build the each application if it needed
|
||||
|
||||
IF(BUILD_CODEC)
|
||||
ADD_SUBDIRECTORY(codec)
|
||||
ENDIF(BUILD_CODEC)
|
||||
|
||||
IF(BUILD_MJ2)
|
||||
ADD_SUBDIRECTORY(mj2)
|
||||
ENDIF(BUILD_MJ2)
|
||||
|
||||
# Client & Server:
|
||||
IF(BUILD_JPIP)
|
||||
ADD_SUBDIRECTORY(jpip)
|
||||
ENDIF(BUILD_JPIP)
|
||||
|
||||
IF(BUILD_VIEWER)
|
||||
ADD_SUBDIRECTORY(OPJViewer)
|
||||
ENDIF(BUILD_VIEWER)
|
||||
|
||||
IF(BUILD_JAVA)
|
||||
ADD_SUBDIRECTORY(JavaOpenJPEG)
|
||||
ENDIF(BUILD_JAVA)
|
||||
@@ -1,19 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = codec
|
||||
|
||||
if WANT_MJ2
|
||||
SUBDIRS += mj2
|
||||
endif
|
||||
|
||||
if WANT_JPIP_CODE
|
||||
SUBDIRS += jpip
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
common/color.c \
|
||||
common/color.h \
|
||||
common/format_defs.h \
|
||||
common/opj_getopt.c \
|
||||
common/opj_getopt.h
|
||||
@@ -1,54 +0,0 @@
|
||||
wxString htmlaboutpage = wxT(
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
#include "build.h"
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
#ifdef USE_JPWL
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
#endif // USE_JPWL
|
||||
#ifdef USE_JPSEC
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
#endif // USE_JPSEC
|
||||
wxT(")</font><br>")
|
||||
#ifdef USE_MXF
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
#endif // USE_MXF
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
wxT("491")
|
||||
@@ -1,113 +0,0 @@
|
||||
# Build the demo app, small examples
|
||||
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
convert.c
|
||||
index.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${LCMS_INCLUDE_DIRNAME}
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||
${Z_INCLUDE_DIRNAME}
|
||||
${PNG_INCLUDE_DIRNAME}
|
||||
${TIFF_INCLUDE_DIRNAME}
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Loop over all executables:
|
||||
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
|
||||
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
|
||||
)
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(${exe} z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(${exe} ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} m)
|
||||
ENDIF(UNIX)
|
||||
# Install exe
|
||||
INSTALL(TARGETS ${exe}
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDFOREACH(exe)
|
||||
|
||||
# Install man pages
|
||||
INSTALL(
|
||||
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/image_to_j2k.1
|
||||
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_dump.1
|
||||
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_to_image.1
|
||||
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||
#
|
||||
|
||||
IF(BUILD_JPWL)
|
||||
ADD_EXECUTABLE(JPWL_j2k_to_image
|
||||
j2k_to_image.c
|
||||
${common_SRCS}
|
||||
)
|
||||
|
||||
SET_PROPERTY(
|
||||
TARGET JPWL_j2k_to_image
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
ADD_EXECUTABLE(JPWL_image_to_j2k
|
||||
image_to_j2k.c
|
||||
${common_SRCS}
|
||||
)
|
||||
|
||||
SET_PROPERTY(
|
||||
TARGET JPWL_image_to_j2k
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDIF(BUILD_JPWL)
|
||||
@@ -1,118 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump
|
||||
|
||||
if WANT_JPWL
|
||||
bin_PROGRAMS += JPWL_j2k_to_image JPWL_image_to_j2k
|
||||
endif
|
||||
|
||||
j2k_to_image_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
@PNG_CFLAGS@ \
|
||||
@TIFF_CFLAGS@ \
|
||||
@LCMS1_CFLAGS@ \
|
||||
@LCMS2_CFLAGS@
|
||||
j2k_to_image_CFLAGS =
|
||||
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
j2k_to_image_SOURCES = \
|
||||
../common/color.c \
|
||||
../common/opj_getopt.c \
|
||||
convert.c \
|
||||
index.c \
|
||||
j2k_to_image.c \
|
||||
../common/color.h
|
||||
|
||||
image_to_j2k_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
@PNG_CFLAGS@ \
|
||||
@TIFF_CFLAGS@
|
||||
image_to_j2k_CFLAGS =
|
||||
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
image_to_j2k_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
convert.c \
|
||||
index.c \
|
||||
image_to_j2k.c \
|
||||
convert.h \
|
||||
../common/format_defs.h \
|
||||
index.h
|
||||
|
||||
j2k_dump_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg
|
||||
j2k_dump_CFLAGS =
|
||||
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||
j2k_dump_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
j2k_dump.c \
|
||||
../common/opj_getopt.h \
|
||||
index.h
|
||||
|
||||
JPWL_j2k_to_image_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DUSE_JPWL \
|
||||
@TIFF_CFLAGS@ \
|
||||
@PNG_CFLAGS@ \
|
||||
@LCMS1_CFLAGS@ \
|
||||
@LCMS2_CFLAGS@
|
||||
JPWL_j2k_to_image_CFLAGS =
|
||||
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@
|
||||
JPWL_j2k_to_image_SOURCES = \
|
||||
../common/color.c \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
convert.c \
|
||||
j2k_to_image.c
|
||||
|
||||
JPWL_image_to_j2k_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DUSE_JPWL \
|
||||
@TIFF_CFLAGS@ \
|
||||
@PNG_CFLAGS@
|
||||
JPWL_image_to_j2k_CFLAGS =
|
||||
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
|
||||
|
||||
JPWL_image_to_j2k_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
convert.c \
|
||||
image_to_j2k.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
windirent.h
|
||||
|
||||
install-data-hook:
|
||||
@echo -e " (B)\t$(bindir)/j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/j2k_dump$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
if WANT_JPWL
|
||||
@echo -e " (B)\t$(bindir)/JPWL_j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/JPWL_image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
@@ -1,8 +0,0 @@
|
||||
Simple codec compilation
|
||||
------------------------
|
||||
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
|
||||
|
||||
gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||
gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||
|
||||
You should add '-L..' to those lines if you did not use the 'install' target when building the library.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,677 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 20010, Mathieu Malaterre, GDCM
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#define _stricmp strcasecmp
|
||||
#define _strnicmp strncasecmp
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "opj_getopt.h"
|
||||
#include "convert.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "format_defs.h"
|
||||
|
||||
typedef struct dircnt{
|
||||
/** Buffer for holding images read from Directory*/
|
||||
char *filename_buf;
|
||||
/** Pointer to the buffer*/
|
||||
char **filename;
|
||||
}dircnt_t;
|
||||
|
||||
|
||||
typedef struct img_folder{
|
||||
/** The directory path of the folder containing input images*/
|
||||
char *imgdirpath;
|
||||
/** Output format*/
|
||||
const char *out_format;
|
||||
/** Enable option*/
|
||||
char set_imgdir;
|
||||
/** Enable Cod Format for output*/
|
||||
char set_out_format;
|
||||
|
||||
}img_fol_t;
|
||||
|
||||
void decode_help_display(void) {
|
||||
fprintf(stdout,"HELP for j2k_dump\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
/* UniPG>> */
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||
#ifdef USE_JPWL
|
||||
"+ JPWL "
|
||||
#endif /* USE_JPWL */
|
||||
"decoder:\n");
|
||||
/* <<UniPG */
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -ImgDir \n");
|
||||
fprintf(stdout," Image file Directory path \n");
|
||||
fprintf(stdout," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||
fprintf(stdout," is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <output file>\n");
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Output file where file info will be dump.\n");
|
||||
fprintf(stdout," By default it will be in the stdout.\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||
|
||||
int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
return num_images;
|
||||
}
|
||||
|
||||
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 1;
|
||||
}else {
|
||||
fprintf(stderr,"Folder opened successfully\n");
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
|
||||
strcpy(image_filename,dirptr->filename[imageno]);
|
||||
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||
parameters->decod_format = get_file_format(image_filename);
|
||||
if (parameters->decod_format == -1)
|
||||
return 1;
|
||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||
|
||||
/*Set output file*/
|
||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||
while((temp_p = strtok(NULL,".")) != NULL){
|
||||
strcat(temp_ofname,temp1);
|
||||
sprintf(temp1,".%s",temp_p);
|
||||
}
|
||||
if(img_fol->set_out_format==1){
|
||||
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||
/* parse the command line */
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
};
|
||||
const char optlist[] = "i:o:h";
|
||||
|
||||
OPJ_ARG_NOT_USED(indexfilename);
|
||||
|
||||
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 = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J2K_CFMT:
|
||||
case JP2_CFMT:
|
||||
case JPT_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||
infile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = opj_optarg;
|
||||
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
|
||||
/* check for possible errors */
|
||||
if(img_fol->set_imgdir==1){
|
||||
if(!(parameters->infile[0]==0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
if(img_fol->set_out_format == 0){
|
||||
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||
return 1;
|
||||
}
|
||||
if(!((parameters->outfile[0] == 0))){
|
||||
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
if((parameters->infile[0] == 0) ) {
|
||||
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
img_fol_t img_fol;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL, *fout = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int num_images;
|
||||
int i,imageno;
|
||||
dircnt_t *dirptr = NULL;
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||
|
||||
/* configure the event callbacks (not required) */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Initialize indexfilename and img_fol */
|
||||
*indexfilename = 0;
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1){
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return 1;
|
||||
}
|
||||
for(i=0;i<num_images;i++){
|
||||
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
return 1;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
}
|
||||
|
||||
/* */
|
||||
if (parameters.outfile[0] != 0)
|
||||
{
|
||||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout)
|
||||
{
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
fout = stdout;
|
||||
|
||||
/*Encoding image one by one*/
|
||||
for(imageno = 0; imageno < num_images ; imageno++)
|
||||
{
|
||||
image = NULL;
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
if(img_fol.set_imgdir==1){
|
||||
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||
fprintf(stderr,"skipping file...\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||
{
|
||||
free(src);
|
||||
fclose(fsrc);
|
||||
fclose(fout);
|
||||
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||
return 1;
|
||||
}
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT:
|
||||
{
|
||||
/* JPEG-2000 codestream */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
/* dump image */
|
||||
j2k_dump_image(fout, image);
|
||||
|
||||
/* dump cp */
|
||||
j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JP2_CFMT:
|
||||
{
|
||||
/* JPEG 2000 compressed image data */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JP2);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
/* dump image */
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||
}
|
||||
j2k_dump_image(fout, image);
|
||||
|
||||
/* dump cp */
|
||||
j2k_dump_cp(fout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JPT_CFMT:
|
||||
{
|
||||
/* JPEG 2000, JPIP */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JPT);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "skipping file..\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
/* free codestream information structure */
|
||||
if (*indexfilename)
|
||||
opj_destroy_cstr_info(&cstr_info);
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
}
|
||||
|
||||
fclose(fout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||
int compno;
|
||||
fprintf(fd, "image {\n");
|
||||
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_image_comp_t *comp = &img->comps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||
fprintf(fd, " prec=%d\n", comp->prec);
|
||||
/*fprintf(fd, " bpp=%d\n", comp->bpp);*/
|
||||
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||
int tileno, compno, layno, bandno, resno, numbands;
|
||||
fprintf(fd, "coding parameters {\n");
|
||||
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||
fprintf(fd, " tile %d {\n", tileno);
|
||||
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||
fprintf(fd, " rates=");
|
||||
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||
fprintf(fd, " stepsizes=");
|
||||
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||
for (bandno = 0; bandno < numbands; bandno++) {
|
||||
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||
tccp->stepsizes[bandno].expn);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
|
||||
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||
fprintf(fd, " prcw=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, " prch=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
@@ -1,854 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#define _stricmp strcasecmp
|
||||
#define _strnicmp strncasecmp
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "opj_getopt.h"
|
||||
#include "convert.h"
|
||||
#include "index.h"
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
#include <lcms2.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
#include <lcms.h>
|
||||
#endif
|
||||
#include "color.h"
|
||||
|
||||
#include "format_defs.h"
|
||||
|
||||
typedef struct dircnt{
|
||||
/** Buffer for holding images read from Directory*/
|
||||
char *filename_buf;
|
||||
/** Pointer to the buffer*/
|
||||
char **filename;
|
||||
}dircnt_t;
|
||||
|
||||
|
||||
typedef struct img_folder{
|
||||
/** The directory path of the folder containing input images*/
|
||||
char *imgdirpath;
|
||||
/** Output format*/
|
||||
const char *out_format;
|
||||
/** Enable option*/
|
||||
char set_imgdir;
|
||||
/** Enable Cod Format for output*/
|
||||
char set_out_format;
|
||||
|
||||
}img_fol_t;
|
||||
|
||||
void decode_help_display(void) {
|
||||
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
/* UniPG>> */
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||
#ifdef USE_JPWL
|
||||
"+ JPWL "
|
||||
#endif /* USE_JPWL */
|
||||
"decoder:\n");
|
||||
/* <<UniPG */
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -ImgDir \n");
|
||||
fprintf(stdout," Image file Directory path \n");
|
||||
fprintf(stdout," -OutFor \n");
|
||||
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
|
||||
fprintf(stdout," Need to specify only format without filename <BMP> \n");
|
||||
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
|
||||
fprintf(stdout," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||
fprintf(stdout," is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <decompressed file>\n");
|
||||
fprintf(stdout," REQUIRED\n");
|
||||
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA files\n");
|
||||
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
|
||||
fprintf(stdout," filename is given, there will be as many output files as there are\n");
|
||||
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
|
||||
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
|
||||
fprintf(stdout," is given and there are more than one component, only the first component\n");
|
||||
fprintf(stdout," will be written to the file.\n");
|
||||
fprintf(stdout," -r <reduce factor>\n");
|
||||
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
|
||||
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
|
||||
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
|
||||
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
|
||||
fprintf(stdout," -l <number of quality layers to decode>\n");
|
||||
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
|
||||
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
|
||||
fprintf(stdout," are decoded.\n");
|
||||
fprintf(stdout," -x \n");
|
||||
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
|
||||
fprintf(stdout,"\n");
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
fprintf(stdout," -W <options>\n");
|
||||
fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
|
||||
fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
|
||||
fprintf(stdout," c, c=numcomps\n");
|
||||
fprintf(stdout," numcomps is the number of expected components in the codestream\n");
|
||||
fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
return num_images;
|
||||
}
|
||||
|
||||
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 1;
|
||||
}else {
|
||||
fprintf(stderr,"Folder opened successfully\n");
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
|
||||
strcpy(image_filename,dirptr->filename[imageno]);
|
||||
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||
parameters->decod_format = get_file_format(image_filename);
|
||||
if (parameters->decod_format == -1)
|
||||
return 1;
|
||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||
|
||||
/*Set output file*/
|
||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||
while((temp_p = strtok(NULL,".")) != NULL){
|
||||
strcat(temp_ofname,temp1);
|
||||
sprintf(temp1,".%s",temp_p);
|
||||
}
|
||||
if(img_fol->set_out_format==1){
|
||||
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||
/* parse the command line */
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||
};
|
||||
|
||||
const char optlist[] = "i:o:r:l:x:"
|
||||
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
"W:"
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
"h" ;
|
||||
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 = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J2K_CFMT:
|
||||
case JP2_CFMT:
|
||||
case JPT_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||
infile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = opj_optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
case PXM_DFMT:
|
||||
case BMP_DFMT:
|
||||
case TIF_DFMT:
|
||||
case RAW_DFMT:
|
||||
case TGA_DFMT:
|
||||
case PNG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'O': /* output format */
|
||||
{
|
||||
char outformat[50];
|
||||
char *of = opj_optarg;
|
||||
sprintf(outformat,".%s",of);
|
||||
img_fol->set_out_format = 1;
|
||||
parameters->cod_format = get_file_format(outformat);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
img_fol->out_format = "pgx";
|
||||
break;
|
||||
case PXM_DFMT:
|
||||
img_fol->out_format = "ppm";
|
||||
break;
|
||||
case BMP_DFMT:
|
||||
img_fol->out_format = "bmp";
|
||||
break;
|
||||
case TIF_DFMT:
|
||||
img_fol->out_format = "tif";
|
||||
break;
|
||||
case RAW_DFMT:
|
||||
img_fol->out_format = "raw";
|
||||
break;
|
||||
case TGA_DFMT:
|
||||
img_fol->out_format = "raw";
|
||||
break;
|
||||
case PNG_DFMT:
|
||||
img_fol->out_format = "png";
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
|
||||
case 'r': /* reduce option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'x': /* Creation of index file */
|
||||
{
|
||||
char *index = opj_optarg;
|
||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
|
||||
case 'W': /* activate JPWL correction */
|
||||
{
|
||||
char *token = NULL;
|
||||
|
||||
token = strtok(opj_optarg, ",");
|
||||
while(token != NULL) {
|
||||
|
||||
/* search expected number of components */
|
||||
if (*token == 'c') {
|
||||
|
||||
static int compno;
|
||||
|
||||
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
|
||||
|
||||
if(sscanf(token, "c=%d", &compno) == 1) {
|
||||
/* Specified */
|
||||
if ((compno < 1) || (compno > 256)) {
|
||||
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
|
||||
return 1;
|
||||
}
|
||||
parameters->jpwl_exp_comps = compno;
|
||||
|
||||
} else if (!strcmp(token, "c")) {
|
||||
/* default */
|
||||
parameters->jpwl_exp_comps = compno; /* auto for default size */
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
/* search maximum number of tiles */
|
||||
if (*token == 't') {
|
||||
|
||||
static int tileno;
|
||||
|
||||
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
|
||||
|
||||
if(sscanf(token, "t=%d", &tileno) == 1) {
|
||||
/* Specified */
|
||||
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
|
||||
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
|
||||
return 1;
|
||||
}
|
||||
parameters->jpwl_max_tiles = tileno;
|
||||
|
||||
} else if (!strcmp(token, "t")) {
|
||||
/* default */
|
||||
parameters->jpwl_max_tiles = tileno; /* auto for default size */
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
/* next token or bust */
|
||||
token = strtok(NULL, ",");
|
||||
};
|
||||
parameters->jpwl_correct = OPJ_TRUE;
|
||||
fprintf(stdout, "JPWL correction capability activated\n");
|
||||
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
|
||||
}
|
||||
break;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
|
||||
/* check for possible errors */
|
||||
if(img_fol->set_imgdir==1){
|
||||
if(!(parameters->infile[0]==0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
if(img_fol->set_out_format == 0){
|
||||
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||
return 1;
|
||||
}
|
||||
if(!((parameters->outfile[0] == 0))){
|
||||
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
|
||||
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
img_fol_t img_fol;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int num_images;
|
||||
int i,imageno;
|
||||
dircnt_t *dirptr = NULL;
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||
|
||||
/* configure the event callbacks (not required) */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Initialize indexfilename and img_fol */
|
||||
*indexfilename = 0;
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1){
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return 1;
|
||||
}
|
||||
for(i=0;i<num_images;i++){
|
||||
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
return 1;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
}
|
||||
|
||||
/*Encoding image one by one*/
|
||||
for(imageno = 0; imageno < num_images ; imageno++) {
|
||||
image = NULL;
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
if(img_fol.set_imgdir==1){
|
||||
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||
fprintf(stderr,"skipping file...\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||
{
|
||||
free(src);
|
||||
fclose(fsrc);
|
||||
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||
return 1;
|
||||
}
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT:
|
||||
{
|
||||
/* JPEG-2000 codestream */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JP2_CFMT:
|
||||
{
|
||||
/* JPEG 2000 compressed image data */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JP2);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JPT_CFMT:
|
||||
{
|
||||
/* JPEG 2000, JPIP */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JPT);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "skipping file..\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
if(image->color_space == CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(image);
|
||||
}
|
||||
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||
color_apply_icc_profile(image);
|
||||
#endif
|
||||
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||
}
|
||||
|
||||
/* create output image */
|
||||
/* ------------------- */
|
||||
switch (parameters.cod_format) {
|
||||
case PXM_DFMT: /* PNM PGM PPM */
|
||||
if (imagetopnm(image, parameters.outfile)) {
|
||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
|
||||
case PGX_DFMT: /* PGX */
|
||||
if(imagetopgx(image, parameters.outfile)){
|
||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
|
||||
case BMP_DFMT: /* BMP */
|
||||
if(imagetobmp(image, parameters.outfile)){
|
||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_LIBTIFF
|
||||
case TIF_DFMT: /* TIFF */
|
||||
if(imagetotif(image, parameters.outfile)){
|
||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
#endif /* HAVE_LIBTIFF */
|
||||
case RAW_DFMT: /* RAW */
|
||||
if(imagetoraw(image, parameters.outfile)){
|
||||
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
|
||||
case TGA_DFMT: /* TGA */
|
||||
if(imagetotga(image, parameters.outfile)){
|
||||
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_LIBPNG
|
||||
case PNG_DFMT: /* PNG */
|
||||
if(imagetopng(image, parameters.outfile)){
|
||||
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||
}
|
||||
break;
|
||||
#endif /* HAVE_LIBPNG */
|
||||
/* Can happen if output file is TIFF or PNG
|
||||
* and HAVE_LIBTIF or HAVE_LIBPNG is undefined
|
||||
*/
|
||||
default:
|
||||
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
|
||||
}
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
/* free codestream information structure */
|
||||
if (*indexfilename)
|
||||
opj_destroy_cstr_info(&cstr_info);
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*end main*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "color.h"
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
#include <lcms2.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
#include <lcms.h>
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------
|
||||
Matrix f<>r sYCC, Amendment 1 to IEC 61966-2-1
|
||||
|
||||
Y : 0.299 0.587 0.114 :R
|
||||
Cb: -0.1687 -0.3312 0.5 :G
|
||||
Cr: 0.5 -0.4187 -0.0812 :B
|
||||
|
||||
Inverse:
|
||||
|
||||
R: 1 -3.68213e-05 1.40199 :Y
|
||||
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||
|
||||
-----------------------------------------------------------*/
|
||||
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||
int *out_r, int *out_g, int *out_b)
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
cb -= offset; cr -= offset;
|
||||
r = y + (int)(1.402 * (float)cr);
|
||||
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
|
||||
|
||||
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
|
||||
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
|
||||
|
||||
b = y + (int)(1.772 * (float)cb);
|
||||
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
|
||||
}
|
||||
|
||||
static void sycc444_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
int maxw, maxh, max, i, offset, upb;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i=0; i < maxh; ++i)
|
||||
{
|
||||
for(j=0; j < maxw; j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i=0; i < maxh; i += 2)
|
||||
{
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
for(j=0; j < maxw; j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
{
|
||||
if(img->numcomps < 3)
|
||||
{
|
||||
img->color_space = CLRSPC_GRAY;
|
||||
return;
|
||||
}
|
||||
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 2)
|
||||
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||
{
|
||||
sycc420_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||
{
|
||||
sycc422_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 1)
|
||||
&& (img->comps[2].dx == 1)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||
{
|
||||
sycc444_to_rgb(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n",
|
||||
__FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
img->color_space = CLRSPC_SRGB;
|
||||
|
||||
}/* color_sycc_to_rgb() */
|
||||
|
||||
#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
/* Bob Friesenhahn proposed:*/
|
||||
#define cmsSigXYZData icSigXYZData
|
||||
#define cmsSigLabData icSigLabData
|
||||
#define cmsSigCmykData icSigCmykData
|
||||
#define cmsSigYCbCrData icSigYCbCrData
|
||||
#define cmsSigLuvData icSigLuvData
|
||||
#define cmsSigGrayData icSigGrayData
|
||||
#define cmsSigRgbData icSigRgbData
|
||||
#define cmsUInt32Number DWORD
|
||||
|
||||
#define cmsColorSpaceSignature icColorSpaceSignature
|
||||
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
|
||||
|
||||
#endif /* HAVE_LIBLCMS1 */
|
||||
|
||||
void color_apply_icc_profile(opj_image_t *image)
|
||||
{
|
||||
cmsHPROFILE in_prof, out_prof;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsColorSpaceSignature in_space, out_space;
|
||||
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
|
||||
if(in_prof == NULL) return;
|
||||
|
||||
in_space = cmsGetPCS(in_prof);
|
||||
out_space = cmsGetColorSpace(in_prof);
|
||||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
|
||||
max_w = image->comps[0].w; max_h = image->comps[0].h;
|
||||
prec = image->comps[0].prec;
|
||||
oldspace = image->color_space;
|
||||
|
||||
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
|
||||
in_type,out_type
|
||||
);
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
|
||||
if(transform == NULL)
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if(image->numcomps > 2)/* RGB, RGBA */
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned short);
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
|
||||
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
image->comps = (opj_image_comp_t*)
|
||||
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc(max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc(max, sizeof(int));
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
|
||||
}/* if(image->numcomps */
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
}/* color_apply_icc_profile() */
|
||||
|
||||
#endif /* HAVE_LIBLCMS2 || HAVE_LIBLCMS1 */
|
||||
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "opj_getopt.h"
|
||||
|
||||
int opj_opterr = 1, /* if error message should be printed */
|
||||
opj_optind = 1, /* index into parent argv vector */
|
||||
opj_optopt, /* character checked for validity */
|
||||
opj_optreset; /* reset getopt */
|
||||
char *opj_optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
static char EMSG[]={""};
|
||||
|
||||
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||
void reset_options_reading(void) {
|
||||
opj_opterr = 1;
|
||||
opj_optind = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
# define __progname nargv[0]
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli = NULL; /* option letter list index */
|
||||
|
||||
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||
opj_optreset = 0;
|
||||
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++opj_optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
||||
!(oli = strchr(ostr, opj_optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (opj_optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
if (opj_opterr && *ostr != ':') {
|
||||
fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
opj_optarg = NULL;
|
||||
if (!*place)
|
||||
++opj_optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
opj_optarg = place;
|
||||
else if (nargc <= ++opj_optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, opj_optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
} else /* white space */
|
||||
opj_optarg = nargv[opj_optind];
|
||||
place = EMSG;
|
||||
++opj_optind;
|
||||
}
|
||||
return (opj_optopt); /* dump back option letter */
|
||||
}
|
||||
|
||||
|
||||
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||
const opj_option_t *longopts, int totlen) {
|
||||
static int lastidx,lastofs;
|
||||
char *tmp;
|
||||
int i,len;
|
||||
char param = 1;
|
||||
|
||||
again:
|
||||
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
||||
return -1;
|
||||
|
||||
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
||||
if(opj_optind >= (argc - 1)){ /* no more input parameters */
|
||||
param = 0;
|
||||
}
|
||||
else{ /* more input parameters */
|
||||
if(argv[opj_optind + 1][0] == '-'){
|
||||
param = 0; /* Missing parameter after '-' */
|
||||
}
|
||||
else{
|
||||
param = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (param == 0) {
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}
|
||||
|
||||
if (argv[opj_optind][0]=='-') { /* long option */
|
||||
char* arg=argv[opj_optind]+1;
|
||||
const opj_option_t* o;
|
||||
o=longopts;
|
||||
len=sizeof(longopts[0]);
|
||||
|
||||
if (param > 1){
|
||||
arg = argv[opj_optind+1];
|
||||
opj_optind++;
|
||||
}
|
||||
else
|
||||
arg = argv[opj_optind]+1;
|
||||
|
||||
if(strlen(arg)>1){
|
||||
for (i=0;i<totlen;i=i+len,o++) {
|
||||
if (!strcmp(o->name,arg)) { /* match */
|
||||
if (o->has_arg == 0) {
|
||||
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))){
|
||||
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
||||
++opj_optind;
|
||||
}
|
||||
}else{
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg){
|
||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
}
|
||||
++opj_optind;
|
||||
if (o->flag)
|
||||
*(o->flag)=o->val;
|
||||
else
|
||||
return o->val;
|
||||
return 0;
|
||||
}
|
||||
}/*(end for)String not found in the list*/
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}else{ /*Single character input parameter*/
|
||||
if (*optstring==':') return ':';
|
||||
if (lastidx!=opj_optind) {
|
||||
lastidx=opj_optind; lastofs=0;
|
||||
}
|
||||
opj_optopt=argv[opj_optind][lastofs+1];
|
||||
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
||||
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||
++opj_optind;
|
||||
goto again;
|
||||
}
|
||||
if (tmp[1]==':') { /* argument expected */
|
||||
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
||||
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
||||
goto found;
|
||||
}
|
||||
opj_optarg=argv[opj_optind+1];
|
||||
if(opj_optarg){
|
||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opj_optarg) { /* missing argument */
|
||||
if (opj_opterr) {
|
||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||
return (BADCH);
|
||||
}
|
||||
}
|
||||
++opj_optind;
|
||||
}else {/*Argument not expected*/
|
||||
++lastofs;
|
||||
return opj_optopt;
|
||||
}
|
||||
found:
|
||||
++opj_optind;
|
||||
return opj_optopt;
|
||||
} else { /* not found */
|
||||
fprintf(stderr,"Invalid option %s\n",arg);
|
||||
++opj_optind;
|
||||
return (BADCH);
|
||||
}/*end of not found*/
|
||||
|
||||
}/* end of single character*/
|
||||
}/*end '-'*/
|
||||
fprintf(stderr,"Invalid option\n");
|
||||
++opj_optind;
|
||||
return (BADCH);;
|
||||
}/*end function*/
|
||||
@@ -1,120 +0,0 @@
|
||||
What's New for OpenJPIP
|
||||
|
||||
* : fixed
|
||||
- : removed
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
January 26, 2011
|
||||
! [kaori] unapplied auxtrans_manager to the local mode
|
||||
|
||||
December 24, 2011
|
||||
* [kaori] additional modification for the warning
|
||||
|
||||
December 22, 2011
|
||||
* [kaori] fixed auxtrans_manager to enable MAC
|
||||
* [kaori] warnings due to disregarding return value are removed
|
||||
|
||||
November 30, 2011
|
||||
+ [kaori] TCP return (http-tcp) implemented
|
||||
|
||||
November 16, 2011
|
||||
* [kaori] fixed Region of Interest option, and memory leak of opj_dec_server
|
||||
+ [kaori] new feature to target JP2 files from www (libcurl required)
|
||||
* [kaori] fixed opj_server execusion error (instant terminating) with autotool, cmake still need to be fixed
|
||||
|
||||
November 8, 2011
|
||||
! [kaori] updated main page of doxygen
|
||||
|
||||
November 3, 2011
|
||||
* [kaori] solved memory leak of opj_server
|
||||
! [kaori] removed redundant defines
|
||||
|
||||
November 2, 2011
|
||||
* [antonin] additional patches for autotools and cmake
|
||||
|
||||
October 26, 2011
|
||||
* [kaori] additional patches for autotool are applied
|
||||
|
||||
October 25, 2011
|
||||
* [kaori] patches for cmake and autotool are applied
|
||||
* [kaori] fixed client viewer to be compatible with server response header both Content-type and Content-Type
|
||||
|
||||
October 20, 2011
|
||||
+ [added] API style in openJPIP library
|
||||
! [kaori] rearranged directories, applications are all under util/ directory, currently only 'make -f Makefile.nix' works
|
||||
|
||||
October 18, 2011
|
||||
! [kaori] rearranged opj_server, opj_dec_server directory
|
||||
|
||||
October 14, 2011
|
||||
+ [kaori] enable all progression orders
|
||||
|
||||
October 12, 2011
|
||||
+ [kaori] enable layers requests; restricting the number of codesream quality layers
|
||||
|
||||
October 11, 2011
|
||||
+ [antonin] enable JPT-stream request from client viewer option (credit to kaori)
|
||||
|
||||
October 10, 2011
|
||||
- [antonin] removed obsolete indexer utility (credit to kaori)
|
||||
+ [antonin] enabled JPP-stream (credit to kaori)
|
||||
|
||||
September 16, 2011
|
||||
+ [kaori] enabled stateless requests from the opj_viewers
|
||||
|
||||
Septempber 1, 2011
|
||||
* [kaori] changed terminating status of opj_server in debug/non-server mode
|
||||
|
||||
August 27, 2011
|
||||
* [antonin] fixed missing include directory in opj_client/opj_dec_server/CMakeLists.txt
|
||||
|
||||
August 26, 2011
|
||||
* [antonin] fixed cmake and autotools files to reflect recent indexer changes in JPIP
|
||||
! [kaori] indexer using the latest openjpeg library
|
||||
* [antonin] fixed cmake and autotools files to reflect recent changes in JPIP
|
||||
! [kaori] fixed Makefile.nix to load openjpeg library from this archive
|
||||
|
||||
August 25, 2011
|
||||
+ [kaori] added tid request support to JPIP client
|
||||
+ [kaori] added quit JPIP server request
|
||||
|
||||
August 24, 2011
|
||||
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||
+ [kaori] added tid request support to JPIP server
|
||||
|
||||
August 16, 2011
|
||||
* [antonin] fixed cmake support for openjpip
|
||||
|
||||
August 12, 2011
|
||||
+ [antonin] added cmake support to openjpip
|
||||
|
||||
July 6, 2011
|
||||
* [antonin] JPIP : fixed autotools to work with recent name changes
|
||||
|
||||
July 5, 2011
|
||||
! [kaori] changed parameter, file names, message names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||
|
||||
May 26, 2011
|
||||
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||
|
||||
May 23, 2011
|
||||
+ [antonin] added autotools for the 'tools' directory
|
||||
+ [antonin] added autotools as a build method for jpip (credit to Vincent Torri)
|
||||
|
||||
May 10, 2011
|
||||
! [kaori] opj_viewer removed the xml functions (for users without Xersus2)
|
||||
+ [kaori] renamed opj_viewer to opj_viewer_xerces ( needs Xersus2)
|
||||
! [kaori] Modification of opj_dec_server to be portable to windows
|
||||
|
||||
May 9, 2011
|
||||
* [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
|
||||
|
||||
May 9, 2011
|
||||
* [antonin] OpenJPIP: small bug fixes to compile on win platform
|
||||
|
||||
May 8, 2011
|
||||
* [antonin] OpenJPIP: fixed several bugs in opj_server (removal of strsep function, duplication of query string) + some changes to compile opj_server under windows (replacement of strcasecmp(), bzero()).
|
||||
|
||||
April 14, 2011
|
||||
+ [antonin] initial commit of OpenJPIP 1.0, a JPIP client-server architecture based on OpenJPEG (see README file in jpip directory for more details)
|
||||
@@ -1,13 +0,0 @@
|
||||
# required dep for server:
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
FIND_PACKAGE(CURL REQUIRED)
|
||||
FIND_PACKAGE(FCGI REQUIRED)
|
||||
FIND_PACKAGE(PTHREAD REQUIRED)
|
||||
ENDIF(BUILD_JPIP_SERVER)
|
||||
|
||||
# JPIP library:
|
||||
ADD_SUBDIRECTORY(libopenjpip)
|
||||
|
||||
# JPIP binaries:
|
||||
ADD_SUBDIRECTORY(util)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = libopenjpip util
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,151 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
|
||||
includes_HEADERS =
|
||||
|
||||
lib_LTLIBRARIES =
|
||||
|
||||
if WANT_JPIP
|
||||
lib_LTLIBRARIES += libopenjpip_local.la
|
||||
endif
|
||||
|
||||
if WANT_JPIP_SERVER
|
||||
lib_LTLIBRARIES += libopenjpip_server.la
|
||||
endif
|
||||
|
||||
JPIP_SRC = \
|
||||
openjpip.c \
|
||||
query_parser.c \
|
||||
channel_manager.c \
|
||||
session_manager.c \
|
||||
jpip_parser.c \
|
||||
boxheader_manager.c \
|
||||
codestream_manager.c \
|
||||
imgreg_manager.c \
|
||||
marker_manager.c \
|
||||
msgqueue_manager.c \
|
||||
box_manager.c \
|
||||
faixbox_manager.c \
|
||||
index_manager.c \
|
||||
metadata_manager.c \
|
||||
placeholder_manager.c \
|
||||
byte_manager.c \
|
||||
ihdrbox_manager.c \
|
||||
manfbox_manager.c \
|
||||
mhixbox_manager.c \
|
||||
target_manager.c \
|
||||
cachemodel_manager.c \
|
||||
j2kheader_manager.c \
|
||||
jp2k_encoder.c \
|
||||
sock_manager.c \
|
||||
openjpip.h \
|
||||
bool.h \
|
||||
boxheader_manager.h \
|
||||
box_manager.h \
|
||||
byte_manager.h \
|
||||
codestream_manager.h \
|
||||
faixbox_manager.h \
|
||||
ihdrbox_manager.h \
|
||||
imgreg_manager.h \
|
||||
index_manager.h \
|
||||
manfbox_manager.h \
|
||||
marker_manager.h \
|
||||
metadata_manager.h \
|
||||
mhixbox_manager.h \
|
||||
msgqueue_manager.h \
|
||||
placeholder_manager.h \
|
||||
target_manager.h \
|
||||
cachemodel_manager.h \
|
||||
j2kheader_manager.h \
|
||||
jp2k_encoder.h \
|
||||
query_parser.h \
|
||||
channel_manager.h \
|
||||
session_manager.h \
|
||||
jpip_parser.h \
|
||||
jp2k_decoder.h \
|
||||
sock_manager.h
|
||||
|
||||
SERVER_SRC = auxtrans_manager.c \
|
||||
auxtrans_manager.h
|
||||
|
||||
LOCAL_SRC = jp2k_decoder.c \
|
||||
imgsock_manager.c \
|
||||
jpipstream_manager.c \
|
||||
cache_manager.c \
|
||||
dec_clientmsg_handler.c \
|
||||
imgsock_manager.h \
|
||||
jpipstream_manager.h \
|
||||
cache_manager.h \
|
||||
dec_clientmsg_handler.h
|
||||
|
||||
libopenjpip_server_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
@FCGI_CFLAGS@ \
|
||||
@LIBCURL_CFLAGS@ \
|
||||
-DSERVER
|
||||
libopenjpip_server_la_CFLAGS = @THREAD_CFLAGS@
|
||||
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ @LIBCURL_LIBS@ @THREAD_LIBS@ -lm
|
||||
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||
libopenjpip_server_la_SOURCES = $(JPIP_SRC) $(SERVER_SRC)
|
||||
|
||||
libopenjpip_local_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
@LIBCURL_CFLAGS@
|
||||
libopenjpip_local_la_CFLAGS =
|
||||
libopenjpip_local_la_LIBADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||
libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
|
||||
|
||||
install-data-hook:
|
||||
if WANT_JPIP_SERVER
|
||||
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
|
||||
if BUILD_SHARED
|
||||
@( $(call solist_s) ) >> $(top_builddir)/report.txt
|
||||
endif
|
||||
if BUILD_STATIC
|
||||
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
endif
|
||||
if WANT_JPIP
|
||||
@echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
|
||||
if BUILD_SHARED
|
||||
@( $(call solist_c) ) >> $(top_builddir)/report.txt
|
||||
endif
|
||||
if BUILD_STATIC
|
||||
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
endif
|
||||
|
||||
solist_s = $(foreach f, $(dll_s) $(so_s), echo -e ' $(SO_PREFIX)\t$(base_s)/$(f)' ;)
|
||||
get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)
|
||||
base_s = $(call get_tok_s,libdir)
|
||||
so_s = $(call get_tok_s,library_names)
|
||||
a_s = $(call get_tok_s,old_library)
|
||||
|
||||
solist_c = $(foreach f, $(dll_c) $(so_c), echo -e ' $(SO_PREFIX)\t$(base_c)/$(f)' ;)
|
||||
get_tok_c = $(shell grep -E "^$(1)=" libopenjpip_local.la | cut -d "'" -f 2)
|
||||
base_c = $(call get_tok_c,libdir)
|
||||
so_c = $(call get_tok_c,library_names)
|
||||
a_c = $(call get_tok_c,old_library)
|
||||
|
||||
if HAVE_WIN32
|
||||
SO_PREFIX = (DLL)
|
||||
dll_s = $(call get_tok_s,dlname)
|
||||
dll_c = $(call get_tok_c,dlname)
|
||||
else
|
||||
if HAVE_DARWIN
|
||||
SO_PREFIX = (DY)
|
||||
dll_s =
|
||||
dll_c =
|
||||
else
|
||||
SO_PREFIX = (SO)
|
||||
dll_s =
|
||||
dll_c =
|
||||
endif
|
||||
endif
|
||||
@@ -1,267 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "auxtrans_manager.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
{
|
||||
auxtrans_param_t auxtrans;
|
||||
|
||||
auxtrans.tcpauxport = tcp_auxport;
|
||||
auxtrans.udpauxport = udp_auxport;
|
||||
|
||||
if( 49152 <= tcp_auxport && tcp_auxport <= 65535)
|
||||
auxtrans.tcplistensock = open_listeningsocket( tcp_auxport);
|
||||
else
|
||||
auxtrans.tcplistensock = -1;
|
||||
|
||||
auxtrans.udplistensock = -1;
|
||||
// open listening socket for udp later
|
||||
|
||||
return auxtrans;
|
||||
}
|
||||
|
||||
void close_aux_transport( auxtrans_param_t auxtrans)
|
||||
{
|
||||
if( auxtrans.tcplistensock != -1)
|
||||
if( close_socket( auxtrans.tcplistensock) != 0)
|
||||
perror("close");
|
||||
|
||||
if( auxtrans.udplistensock != -1)
|
||||
if( close_socket( auxtrans.udplistensock) != 0)
|
||||
perror("close");
|
||||
}
|
||||
|
||||
|
||||
//!< auxiliary response parameters
|
||||
typedef struct aux_response_param{
|
||||
char *cid; //!< channel ID
|
||||
unsigned char *data; //!< sending data
|
||||
int datalen; //!< length of data
|
||||
int maxlenPerFrame; //!< maximum data length to send per frame
|
||||
SOCKET listensock; //!< listeing socket
|
||||
#ifdef _WIN32
|
||||
HANDLE hTh; //!< thread handle
|
||||
#endif
|
||||
} aux_response_param_t;
|
||||
|
||||
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame);
|
||||
|
||||
void delete_auxresponse( aux_response_param_t **auxresponse);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
unsigned __stdcall aux_streaming( void *arg);
|
||||
#else
|
||||
void * aux_streaming( void *arg);
|
||||
#endif
|
||||
|
||||
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||
{
|
||||
aux_response_param_t *auxresponse;
|
||||
#ifdef _WIN32
|
||||
unsigned int threadId;
|
||||
#else
|
||||
pthread_t thread;
|
||||
int status;
|
||||
#endif
|
||||
|
||||
if( istcp){
|
||||
if( auxtrans.tcplistensock == -1){
|
||||
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), tcp listening socket no open\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame);
|
||||
|
||||
#ifdef _WIN32
|
||||
auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId);
|
||||
if( auxresponse->hTh == 0)
|
||||
fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh));
|
||||
#else
|
||||
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
|
||||
if( status != 0)
|
||||
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n");
|
||||
}
|
||||
|
||||
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||
{
|
||||
aux_response_param_t *auxresponse;
|
||||
|
||||
auxresponse = (aux_response_param_t *)malloc( sizeof(aux_response_param_t));
|
||||
|
||||
auxresponse->cid = strdup( cid);
|
||||
auxresponse->data = data;
|
||||
auxresponse->datalen = datalen;
|
||||
auxresponse->maxlenPerFrame = maxlenPerFrame;
|
||||
auxresponse->listensock = istcp ? auxtrans.tcplistensock : auxtrans.udplistensock;
|
||||
|
||||
return auxresponse;
|
||||
}
|
||||
|
||||
void delete_auxresponse( aux_response_param_t **auxresponse)
|
||||
{
|
||||
free( (*auxresponse)->cid);
|
||||
free( (*auxresponse)->data);
|
||||
free( *auxresponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify cid sent from client
|
||||
*
|
||||
* @param [in] connected_socket file descriptor of the connected socket
|
||||
* @param [in] refcid refenrece channel ID
|
||||
* @param [in] fp file pointer for log of aux stream
|
||||
* @return true if identified, false otherwise
|
||||
*/
|
||||
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp);
|
||||
|
||||
bool recv_ack( SOCKET connected_socket, void *data);
|
||||
|
||||
#ifdef _WIN32
|
||||
unsigned __stdcall aux_streaming( void *arg)
|
||||
#else
|
||||
void * aux_streaming( void *arg)
|
||||
#endif
|
||||
{
|
||||
SOCKET connected_socket;
|
||||
unsigned char *chunk, *ptr;
|
||||
int maxLenOfBody, remlen, chunklen;
|
||||
const int headlen = 8;
|
||||
|
||||
aux_response_param_t *auxresponse = (aux_response_param_t *)arg;
|
||||
|
||||
#ifdef _WIN32
|
||||
CloseHandle( auxresponse->hTh);
|
||||
#else
|
||||
pthread_detach( pthread_self());
|
||||
#endif
|
||||
|
||||
chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame);
|
||||
maxLenOfBody = auxresponse->maxlenPerFrame - headlen;
|
||||
remlen = auxresponse->datalen;
|
||||
|
||||
while((connected_socket = accept_socket( auxresponse->listensock)) != -1){
|
||||
if( identify_cid( connected_socket, auxresponse->cid, FCGI_stderr)){
|
||||
ptr = auxresponse->data;
|
||||
while( 0 < remlen){
|
||||
memset( chunk, 0, auxresponse->maxlenPerFrame);
|
||||
|
||||
chunklen = remlen<maxLenOfBody?remlen:maxLenOfBody;
|
||||
chunklen += headlen;
|
||||
|
||||
chunk[0] = (chunklen >> 8) & 0xff;
|
||||
chunk[1] = chunklen & 0xff;
|
||||
|
||||
memcpy( chunk+headlen, ptr, chunklen-headlen);
|
||||
|
||||
do{
|
||||
send_stream( connected_socket, chunk, chunklen);
|
||||
}while( !recv_ack( connected_socket, chunk));
|
||||
|
||||
remlen -= maxLenOfBody;
|
||||
ptr += maxLenOfBody;
|
||||
}
|
||||
if( close_socket( connected_socket) != 0)
|
||||
perror("close");
|
||||
break;
|
||||
}
|
||||
}
|
||||
free( chunk);
|
||||
|
||||
delete_auxresponse( &auxresponse);
|
||||
|
||||
#ifdef _WIN32
|
||||
_endthreadex(0);
|
||||
#else
|
||||
pthread_exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp)
|
||||
{
|
||||
char *cid;
|
||||
bool succeed;
|
||||
|
||||
if(!(cid = receive_string( connected_socket))){
|
||||
fprintf( fp, "Error: error in identify_cid(), while receiving cid from client\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
succeed = false;
|
||||
if( strncmp( refcid, cid, strlen( refcid)) == 0)
|
||||
succeed = true;
|
||||
|
||||
free( cid);
|
||||
|
||||
return succeed;
|
||||
}
|
||||
|
||||
bool recv_ack( SOCKET connected_socket, void *data)
|
||||
{
|
||||
char *header;
|
||||
bool succeed;
|
||||
|
||||
header = receive_stream( connected_socket, 8);
|
||||
|
||||
if( memcmp( header, data, 8) != 0)
|
||||
succeed = false;
|
||||
else
|
||||
succeed = true;
|
||||
|
||||
free( header);
|
||||
|
||||
return succeed;
|
||||
}
|
||||
@@ -1,415 +0,0 @@
|
||||
/*
|
||||
* $Id: box_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "box_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
boxlist_param_t * gene_boxlist()
|
||||
{
|
||||
boxlist_param_t *boxlist;
|
||||
|
||||
boxlist = (boxlist_param_t *)malloc( sizeof(boxlist_param_t));
|
||||
|
||||
boxlist->first = NULL;
|
||||
boxlist->last = NULL;
|
||||
|
||||
return boxlist;
|
||||
}
|
||||
|
||||
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
|
||||
{
|
||||
boxlist_param_t *boxlist;
|
||||
box_param_t *box;
|
||||
int pos;
|
||||
|
||||
boxlist = NULL;
|
||||
pos = offset;
|
||||
do{
|
||||
if(!(box = gene_boxbyOffset( fd, pos)))
|
||||
break;
|
||||
|
||||
pos += box->length;
|
||||
|
||||
if( !boxlist)
|
||||
boxlist = gene_boxlist();
|
||||
insert_box_into_list( box, boxlist);
|
||||
}while( pos < (int)(offset+length));
|
||||
|
||||
return boxlist;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *box;
|
||||
|
||||
/* read LBox and TBox*/
|
||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
/* box type constraint*/
|
||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||
free( data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( boxlen == 1){
|
||||
Byte_t *data2;
|
||||
headlen = 16;
|
||||
/* read XLBox*/
|
||||
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
||||
boxlen = big8(data2);
|
||||
free(data2);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||
free( data);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
box->fd = fd;
|
||||
box->offset = offset;
|
||||
box->headlen = headlen;
|
||||
box->length = boxlen;
|
||||
strncpy( box->type, boxtype, 4);
|
||||
box->next = NULL;
|
||||
free( data);
|
||||
return box;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||
{
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *box;
|
||||
|
||||
/* read LBox and TBox*/
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4( stream);
|
||||
boxtype = (char *)( stream+4);
|
||||
|
||||
/* box type constraint*/
|
||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( boxlen == 1){
|
||||
headlen = 16;
|
||||
boxlen = big8( stream+8); /* read XLBox*/
|
||||
}
|
||||
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
box->fd = -1;
|
||||
box->offset = offset;
|
||||
box->headlen = headlen;
|
||||
box->length = boxlen;
|
||||
strncpy( box->type, boxtype, 4);
|
||||
box->next = NULL;
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *foundbox;
|
||||
|
||||
|
||||
if( length==0){ /* set the max length*/
|
||||
if( (length = get_filesize( fd) - offset) <= 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = offset;
|
||||
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||
|
||||
/* read LBox and TBox*/
|
||||
if((data = fetch_bytes( fd, pos, 8))){
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
if( boxlen == 1){
|
||||
Byte_t *data2;
|
||||
headlen = 16;
|
||||
/* read XLBox*/
|
||||
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
||||
boxlen = big8(data2);
|
||||
free(data2);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
foundbox->fd = fd;
|
||||
foundbox->offset = pos;
|
||||
foundbox->headlen = headlen;
|
||||
foundbox->length = boxlen;
|
||||
strncpy( foundbox->type, TBox, 4);
|
||||
foundbox->next = NULL;
|
||||
free( data);
|
||||
return foundbox;
|
||||
}
|
||||
free( data);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||
return NULL;
|
||||
}
|
||||
pos+= boxlen;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *foundbox;
|
||||
|
||||
|
||||
if( length<=0){ /* set the max length*/
|
||||
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = offset;
|
||||
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||
|
||||
/* read LBox and TBox*/
|
||||
data = stream + pos;
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
if( boxlen == 1){
|
||||
/* read XLBox*/
|
||||
headlen = 16;
|
||||
boxlen = big8( data+8);
|
||||
}
|
||||
|
||||
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
foundbox->fd = -1;
|
||||
foundbox->offset = pos;
|
||||
foundbox->headlen = headlen;
|
||||
foundbox->length = boxlen;
|
||||
strncpy( foundbox->type, TBox, 4);
|
||||
foundbox->next = NULL;
|
||||
return foundbox;
|
||||
}
|
||||
pos+= boxlen;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||
{
|
||||
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||
}
|
||||
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[])
|
||||
{
|
||||
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||
}
|
||||
|
||||
Byte8_t get_DBoxoff( box_param_t *box)
|
||||
{
|
||||
return box->offset+box->headlen;
|
||||
}
|
||||
|
||||
Byte8_t get_DBoxlen( box_param_t *box)
|
||||
{
|
||||
return box->length-box->headlen;
|
||||
}
|
||||
|
||||
Byte_t * fetch_headbytes( box_param_t *box)
|
||||
{
|
||||
return fetch_bytes( box->fd, box->offset, box->headlen);
|
||||
}
|
||||
|
||||
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size)
|
||||
{
|
||||
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
||||
}
|
||||
|
||||
Byte_t fetch_DBox1byte( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
box_param_t * search_box( char type[], boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *foundbox;
|
||||
|
||||
foundbox = boxlist->first;
|
||||
|
||||
while( foundbox != NULL){
|
||||
|
||||
if( strncmp( type, foundbox->type, 4) == 0)
|
||||
return foundbox;
|
||||
|
||||
foundbox = foundbox->next;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", type);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void print_box( box_param_t *box)
|
||||
{
|
||||
fprintf( logstream, "box info:\n"
|
||||
"\t type: %.4s\n"
|
||||
"\t offset: %lld %#llx\n"
|
||||
"\t header length: %d\n"
|
||||
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
|
||||
}
|
||||
|
||||
void print_allbox( boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *ptr;
|
||||
|
||||
if( !boxlist)
|
||||
return;
|
||||
|
||||
ptr = boxlist->first;
|
||||
if( !ptr)
|
||||
fprintf( logstream, "no box\n");
|
||||
|
||||
fprintf( logstream, "all box info: \n");
|
||||
while( ptr != NULL){
|
||||
print_box( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *ptr;
|
||||
|
||||
if( *box == boxlist->first)
|
||||
boxlist->first = (*box)->next;
|
||||
else{
|
||||
ptr = boxlist->first;
|
||||
while( ptr->next != *box){
|
||||
ptr=ptr->next;
|
||||
}
|
||||
ptr->next = (*box)->next;
|
||||
|
||||
if( *box == boxlist->last)
|
||||
boxlist->last = ptr;
|
||||
}
|
||||
free( *box);
|
||||
}
|
||||
|
||||
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *box;
|
||||
|
||||
box = search_box( type, boxlist);
|
||||
delete_box_in_list( &box, boxlist);
|
||||
}
|
||||
|
||||
void delete_boxlist( boxlist_param_t **boxlist)
|
||||
{
|
||||
box_param_t *boxPtr, *boxNext;
|
||||
|
||||
if(!(*boxlist))
|
||||
return;
|
||||
|
||||
boxPtr = (*boxlist)->first;
|
||||
while( boxPtr != NULL){
|
||||
boxNext=boxPtr->next;
|
||||
free( boxPtr);
|
||||
boxPtr=boxNext;
|
||||
}
|
||||
free( *boxlist);
|
||||
}
|
||||
|
||||
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist)
|
||||
{
|
||||
if( boxlist->first)
|
||||
boxlist->last->next = box;
|
||||
else
|
||||
boxlist->first = box;
|
||||
boxlist->last = box;
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* $Id: byte_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include "byte_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
Byte_t * fetch_bytes( int fd, long offset, int size)
|
||||
{
|
||||
Byte_t *data;
|
||||
|
||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (Byte_t *)malloc( size);
|
||||
|
||||
if( read( fd, data, size) != size){
|
||||
free( data);
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||
return NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Byte_t fetch_1byte( int fd, long offset)
|
||||
{
|
||||
Byte_t code;
|
||||
|
||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( read( fd, &code, 1) != 1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte2_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big2(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte4_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big4(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte8_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big8(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
Byte2_t big2( Byte_t *buf)
|
||||
{
|
||||
return (((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]);
|
||||
}
|
||||
|
||||
Byte4_t big4( Byte_t *buf)
|
||||
{
|
||||
return (((((((Byte4_t) buf[0]) << 8) + ((Byte4_t) buf[1])) << 8)
|
||||
+ ((Byte4_t) buf[2])) << 8) + ((Byte4_t) buf[3]);
|
||||
}
|
||||
|
||||
Byte8_t big8( Byte_t *buf)
|
||||
{
|
||||
return (((Byte8_t) big4 (buf)) << 32)
|
||||
+ ((Byte8_t) big4 (buf + 4));
|
||||
}
|
||||
|
||||
void modify_4Bytecode( Byte4_t code, Byte_t *stream)
|
||||
{
|
||||
*stream = (Byte_t) ((Byte4_t)(code & 0xff000000) >> 24);
|
||||
*(stream+1) = (Byte_t) ((Byte4_t)(code & 0x00ff0000) >> 16);
|
||||
*(stream+2) = (Byte_t) ((Byte4_t)(code & 0x0000ff00) >> 8);
|
||||
*(stream+3) = (Byte_t) (code & 0x000000ff);
|
||||
}
|
||||
|
||||
Byte8_t get_filesize( int fd)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if( fstat( fd, &sb) == -1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in get_filesize( %d)\n", fd);
|
||||
return 0;
|
||||
}
|
||||
return (Byte8_t)sb.st_size;
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* $Id: cache_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cache_manager.h"
|
||||
|
||||
cachelist_param_t * gene_cachelist()
|
||||
{
|
||||
cachelist_param_t *cachelist;
|
||||
|
||||
cachelist = (cachelist_param_t *)malloc( sizeof(cachelist_param_t));
|
||||
|
||||
cachelist->first = NULL;
|
||||
cachelist->last = NULL;
|
||||
|
||||
return cachelist;
|
||||
}
|
||||
|
||||
void delete_cachelist(cachelist_param_t **cachelist)
|
||||
{
|
||||
cache_param_t *cachePtr, *cacheNext;
|
||||
|
||||
cachePtr = (*cachelist)->first;
|
||||
while( cachePtr != NULL){
|
||||
cacheNext=cachePtr->next;
|
||||
delete_cache( &cachePtr);
|
||||
cachePtr=cacheNext;
|
||||
}
|
||||
free( *cachelist);
|
||||
}
|
||||
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
|
||||
{
|
||||
cache_param_t *cache;
|
||||
|
||||
cache = (cache_param_t *)malloc( sizeof(cache_param_t));
|
||||
cache->filename = strdup( targetname);
|
||||
cache->tid = strdup( tid);
|
||||
cache->csn = csn;
|
||||
cache->cid = (char **)malloc( sizeof(char *));
|
||||
*cache->cid = strdup( cid);
|
||||
cache->numOfcid = 1;
|
||||
#if 1
|
||||
cache->metadatalist = NULL;
|
||||
#else
|
||||
cache->metadatalist = gene_metadatalist();
|
||||
#endif
|
||||
cache->ihdrbox = NULL;
|
||||
cache->next = NULL;
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
void delete_cache( cache_param_t **cache)
|
||||
{
|
||||
int i;
|
||||
|
||||
free( (*cache)->filename);
|
||||
free( (*cache)->tid);
|
||||
|
||||
delete_metadatalist( &(*cache)->metadatalist);
|
||||
|
||||
if((*cache)->ihdrbox)
|
||||
free((*cache)->ihdrbox);
|
||||
for( i=0; i<(*cache)->numOfcid; i++)
|
||||
free( (*cache)->cid[i]);
|
||||
free( (*cache)->cid);
|
||||
free( *cache);
|
||||
}
|
||||
|
||||
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist)
|
||||
{
|
||||
if( cachelist->first)
|
||||
cachelist->last->next = cache;
|
||||
else
|
||||
cachelist->first = cache;
|
||||
cachelist->last = cache;
|
||||
}
|
||||
|
||||
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
if( !targetname)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
|
||||
if( strcmp( targetname, foundcache->filename) == 0)
|
||||
return foundcache;
|
||||
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
|
||||
if( csn == foundcache->csn)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
int i;
|
||||
|
||||
if( !cid)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
for( i=0; i<foundcache->numOfcid; i++)
|
||||
if( strcmp( cid, foundcache->cid[i]) == 0)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
if( !tid)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
if( strcmp( tid, foundcache->tid) == 0)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_cachecid( char *cid, cache_param_t *cache)
|
||||
{
|
||||
if( !cid)
|
||||
return;
|
||||
|
||||
if( (cache->cid = realloc( cache->cid, (cache->numOfcid+1)*sizeof(char *))) == NULL){
|
||||
fprintf( stderr, "failed to add new cid to cache table in add_cachecid()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cache->cid[ cache->numOfcid] = strdup( cid);
|
||||
|
||||
cache->numOfcid ++;
|
||||
}
|
||||
|
||||
void update_cachetid( char *tid, cache_param_t *cache)
|
||||
{
|
||||
if( !tid)
|
||||
return;
|
||||
|
||||
if( tid[0] != '0' && strcmp( tid, cache->tid) !=0){
|
||||
fprintf( stderr, "tid is updated to %s for %s\n", tid, cache->filename);
|
||||
free( cache->tid);
|
||||
cache->tid = strdup( tid);
|
||||
}
|
||||
}
|
||||
|
||||
void remove_cidInCache( char *cid, cache_param_t *cache);
|
||||
|
||||
void remove_cachecid( char *cid, cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *cache;
|
||||
|
||||
cache = search_cacheBycid( cid, cachelist);
|
||||
remove_cidInCache( cid, cache);
|
||||
}
|
||||
|
||||
void remove_cidInCache( char *cid, cache_param_t *cache)
|
||||
{
|
||||
int idx = -1;
|
||||
char **tmp;
|
||||
int i, j;
|
||||
|
||||
for( i=0; i<cache->numOfcid; i++)
|
||||
if( strcmp( cid, cache->cid[i]) == 0){
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if( idx == -1){
|
||||
fprintf( stderr, "cid: %s not found\n", cid);
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = cache->cid;
|
||||
|
||||
cache->cid = (char **)malloc( (cache->numOfcid-1)*sizeof(char *));
|
||||
|
||||
for( i=0, j=0; i<cache->numOfcid; i++){
|
||||
if( i != idx){
|
||||
cache->cid[j] = strdup( tmp[i]);
|
||||
j++;
|
||||
}
|
||||
free( tmp[i]);
|
||||
}
|
||||
free( tmp);
|
||||
|
||||
cache->numOfcid --;
|
||||
}
|
||||
|
||||
void print_cache( cache_param_t *cache)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( stdout,"cache\n");
|
||||
fprintf( stdout,"\t filename: %s\n", cache->filename);
|
||||
fprintf( stdout,"\t tid: %s\n", cache->tid);
|
||||
fprintf( stdout,"\t csn: %d\n", cache->csn);
|
||||
fprintf( stdout,"\t cid:");
|
||||
|
||||
for( i=0; i<cache->numOfcid; i++)
|
||||
fprintf( stdout," %s", cache->cid[i]);
|
||||
fprintf( stdout,"\n");
|
||||
}
|
||||
|
||||
void print_allcache( cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *ptr;
|
||||
|
||||
fprintf( stdout,"cache list\n");
|
||||
|
||||
ptr = cachelist->first;
|
||||
while( ptr != NULL){
|
||||
print_cache( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "cachemodel_manager.h"
|
||||
#include "faixbox_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
cachemodellist_param_t * gene_cachemodellist()
|
||||
{
|
||||
cachemodellist_param_t *cachemodellist;
|
||||
|
||||
cachemodellist = (cachemodellist_param_t *)malloc( sizeof(cachemodellist_param_t));
|
||||
|
||||
cachemodellist->first = NULL;
|
||||
cachemodellist->last = NULL;
|
||||
|
||||
return cachemodellist;
|
||||
}
|
||||
|
||||
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
faixbox_param_t *tilepart;
|
||||
faixbox_param_t *precpacket;
|
||||
size_t numOfelem;
|
||||
Byte8_t numOftiles;
|
||||
int i;
|
||||
|
||||
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
|
||||
|
||||
refer_target( target, &cachemodel->target);
|
||||
|
||||
if( reqJPP){
|
||||
if( target->jppstream)
|
||||
cachemodel->jppstream = true;
|
||||
else
|
||||
cachemodel->jppstream = false;
|
||||
} else{ // reqJPT
|
||||
if( target->jptstream)
|
||||
cachemodel->jppstream = false;
|
||||
else
|
||||
cachemodel->jppstream = true;
|
||||
}
|
||||
|
||||
cachemodel->mhead_model = false;
|
||||
|
||||
tilepart = target->codeidx->tilepart;
|
||||
numOftiles = get_m( tilepart);
|
||||
numOfelem = get_nmax( tilepart)*numOftiles;
|
||||
cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
|
||||
cachemodel->th_model = (bool *)calloc( 1, numOftiles*sizeof(bool));
|
||||
cachemodel->pp_model = (bool **)malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
|
||||
for( i=0; i<target->codeidx->SIZ.Csiz; i++){
|
||||
precpacket = target->codeidx->precpacket[i];
|
||||
cachemodel->pp_model[i] = (bool *)calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
|
||||
}
|
||||
cachemodel->next = NULL;
|
||||
|
||||
if( cachemodellist){
|
||||
if( cachemodellist->first) // there are one or more entries
|
||||
cachemodellist->last->next = cachemodel;
|
||||
else // first entry
|
||||
cachemodellist->first = cachemodel;
|
||||
cachemodellist->last = cachemodel;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: cachemodel generated\n");
|
||||
#endif
|
||||
|
||||
return cachemodel;
|
||||
}
|
||||
|
||||
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; // num of tile parts in each tile
|
||||
Byte8_t Pmax; // max num of packets per tile
|
||||
int i, j, k, n;
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
fprintf( logstream, "target: %s\n", target->targetname);
|
||||
fprintf( logstream, "\t main header model: %d\n", cachemodel.mhead_model);
|
||||
|
||||
fprintf( logstream, "\t tile part model:\n");
|
||||
TPnum = get_nmax( target->codeidx->tilepart);
|
||||
|
||||
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++){
|
||||
for( j=0; j<target->codeidx->SIZ.XTnum; j++){
|
||||
for( k=0; k<TPnum; k++)
|
||||
fprintf( logstream, "%d", cachemodel.tp_model[n++]);
|
||||
fprintf( logstream, " ");
|
||||
}
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
|
||||
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||
fprintf( logstream, "\t tile.%d %d\n", i, cachemodel.th_model[i]);
|
||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||
fprintf( logstream, "\t compo.%d: ", j);
|
||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||
for( k=0; k<Pmax; k++)
|
||||
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist)
|
||||
{
|
||||
cachemodel_param_t *foundcachemodel;
|
||||
|
||||
foundcachemodel = cachemodellist->first;
|
||||
|
||||
while( foundcachemodel != NULL){
|
||||
|
||||
if( foundcachemodel->target == target)
|
||||
return foundcachemodel;
|
||||
|
||||
foundcachemodel = foundcachemodel->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void delete_cachemodellist( cachemodellist_param_t **cachemodellist)
|
||||
{
|
||||
cachemodel_param_t *cachemodelPtr, *cachemodelNext;
|
||||
|
||||
cachemodelPtr = (*cachemodellist)->first;
|
||||
while( cachemodelPtr != NULL){
|
||||
cachemodelNext=cachemodelPtr->next;
|
||||
delete_cachemodel( &cachemodelPtr);
|
||||
cachemodelPtr=cachemodelNext;
|
||||
}
|
||||
free(*cachemodellist);
|
||||
}
|
||||
|
||||
void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||
{
|
||||
int i;
|
||||
|
||||
unrefer_target( (*cachemodel)->target);
|
||||
|
||||
free( (*cachemodel)->tp_model);
|
||||
free( (*cachemodel)->th_model);
|
||||
|
||||
for( i=0; i<(*cachemodel)->target->codeidx->SIZ.Csiz; i++)
|
||||
free( (*cachemodel)->pp_model[i]);
|
||||
free( (*cachemodel)->pp_model);
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: cachemodel deleted\n");
|
||||
#endif
|
||||
free( *cachemodel);
|
||||
}
|
||||
|
||||
bool is_allsent( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; // num of tile parts in each tile
|
||||
Byte8_t Pmax; // max num of packets per tile
|
||||
int i, j, k, n;
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
if( !cachemodel.mhead_model)
|
||||
return false;
|
||||
|
||||
TPnum = get_nmax( target->codeidx->tilepart);
|
||||
|
||||
if( cachemodel.jppstream){
|
||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||
if( !cachemodel.th_model[i])
|
||||
return false;
|
||||
|
||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||
for( k=0; k<Pmax; k++)
|
||||
if( !cachemodel.pp_model[j][i*Pmax+k])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
|
||||
for( j=0; j<target->codeidx->SIZ.XTnum; j++)
|
||||
for( k=0; k<TPnum; k++)
|
||||
if( !cachemodel.tp_model[n++])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* $Id: channel_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "channel_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
channellist_param_t * gene_channellist()
|
||||
{
|
||||
channellist_param_t *channellist;
|
||||
|
||||
channellist = (channellist_param_t *)malloc( sizeof(channellist_param_t));
|
||||
|
||||
channellist->first = NULL;
|
||||
channellist->last = NULL;
|
||||
|
||||
return channellist;
|
||||
}
|
||||
|
||||
channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist)
|
||||
{
|
||||
channel_param_t *channel;
|
||||
char transport[4][10] = { "non", "http", "http-tcp", "http-udp"};
|
||||
|
||||
if( !cachemodel){
|
||||
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||
channel->cachemodel = cachemodel;
|
||||
|
||||
// set channel ID and get present time
|
||||
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||
|
||||
channel->aux = query_param.cnew;
|
||||
|
||||
// only tcp implemented for now
|
||||
if( channel->aux == udp)
|
||||
channel->aux = tcp;
|
||||
|
||||
channel->next=NULL;
|
||||
|
||||
set_channel_variable_param( query_param, channel);
|
||||
|
||||
if( channellist->first != NULL)
|
||||
channellist->last->next = channel;
|
||||
else
|
||||
channellist->first = channel;
|
||||
channellist->last = channel;
|
||||
|
||||
fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid);
|
||||
fprintf( FCGI_stdout, ",transport=%s", transport[channel->aux]);
|
||||
|
||||
if( channel->aux == tcp || channel->aux == udp)
|
||||
fprintf( FCGI_stdout, ",auxport=%d", channel->aux==tcp ? auxtrans.tcpauxport : auxtrans.udpauxport);
|
||||
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
||||
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||
{
|
||||
// set roi information
|
||||
}
|
||||
|
||||
|
||||
void delete_channel( channel_param_t **channel, channellist_param_t *channellist)
|
||||
{
|
||||
channel_param_t *ptr;
|
||||
|
||||
if( *channel == channellist->first)
|
||||
channellist->first = (*channel)->next;
|
||||
else{
|
||||
ptr = channellist->first;
|
||||
while( ptr->next != *channel){
|
||||
ptr=ptr->next;
|
||||
}
|
||||
|
||||
ptr->next = (*channel)->next;
|
||||
|
||||
if( *channel == channellist->last)
|
||||
channellist->last = ptr;
|
||||
}
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: channel: %s deleted\n", (*channel)->cid);
|
||||
#endif
|
||||
free(*channel);
|
||||
}
|
||||
|
||||
void delete_channellist( channellist_param_t **channellist)
|
||||
{
|
||||
channel_param_t *channelPtr, *channelNext;
|
||||
|
||||
channelPtr = (*channellist)->first;
|
||||
while( channelPtr != NULL){
|
||||
channelNext=channelPtr->next;
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: channel %s deleted!\n", channelPtr->cid);
|
||||
#endif
|
||||
free(channelPtr);
|
||||
channelPtr=channelNext;
|
||||
}
|
||||
free( *channellist);
|
||||
}
|
||||
|
||||
void print_allchannel( channellist_param_t *channellist)
|
||||
{
|
||||
channel_param_t *ptr;
|
||||
|
||||
ptr = channellist->first;
|
||||
while( ptr != NULL){
|
||||
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->cachemodel->target->targetname);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
channel_param_t * search_channel( char cid[], channellist_param_t *channellist)
|
||||
{
|
||||
channel_param_t *foundchannel;
|
||||
|
||||
foundchannel = channellist->first;
|
||||
|
||||
while( foundchannel != NULL){
|
||||
|
||||
if( strcmp( cid, foundchannel->cid) == 0)
|
||||
return foundchannel;
|
||||
|
||||
foundchannel = foundchannel->next;
|
||||
}
|
||||
fprintf( FCGI_stdout, "Status: 503\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: Channel %s not found in this session\r\n", cid);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
ifdef jpipserver
|
||||
CFLAGS = -O3 -Wall -m32 -DSERVER
|
||||
LIBNAME = libopenjpip_server.a
|
||||
else
|
||||
J2KINCDIR = ../../../libopenjpeg
|
||||
CFLAGS = -O3 -Wall -I$(J2KINCDIR)
|
||||
LIBNAME = libopenjpip_local.a
|
||||
endif
|
||||
|
||||
all: $(LIBNAME)
|
||||
|
||||
ifdef jpipserver
|
||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
||||
session_manager.o jpip_parser.o sock_manager.o auxtrans_manager.o
|
||||
ar r $@ $^
|
||||
else
|
||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
||||
session_manager.o jpip_parser.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o \
|
||||
dec_clientmsg_handler.o sock_manager.o
|
||||
ar r $@ $^
|
||||
endif
|
||||
clean:
|
||||
rm -f $(LIBNAME) *.o *~
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "dec_clientmsg_handler.h"
|
||||
#include "ihdrbox_manager.h"
|
||||
#include "jpipstream_manager.h"
|
||||
#include "jp2k_encoder.h"
|
||||
|
||||
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
|
||||
Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
Byte_t *newjpipstream;
|
||||
int newstreamlen = 0;
|
||||
cache_param_t *cache;
|
||||
char *target, *tid, *cid;
|
||||
metadatalist_param_t *metadatalist;
|
||||
|
||||
newjpipstream = receive_JPIPstream( connected_socket, &target, &tid, &cid, &newstreamlen);
|
||||
|
||||
fprintf( stderr, "newjpipstream length: %d\n", newstreamlen);
|
||||
|
||||
parse_JPIPstream( newjpipstream, newstreamlen, *streamlen, msgqueue);
|
||||
|
||||
*jpipstream = update_JPIPstream( newjpipstream, newstreamlen, *jpipstream, streamlen);
|
||||
free( newjpipstream);
|
||||
|
||||
metadatalist = gene_metadatalist();
|
||||
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
|
||||
|
||||
/* cid registration*/
|
||||
if( target != NULL){
|
||||
if((cache = search_cache( target, cachelist))){
|
||||
if( tid != NULL)
|
||||
update_cachetid( tid, cache);
|
||||
if( cid != NULL)
|
||||
add_cachecid( cid, cache);
|
||||
}
|
||||
else{
|
||||
cache = gene_cache( target, msgqueue->last->csn, tid, cid);
|
||||
insert_cache_into_list( cache, cachelist);
|
||||
}
|
||||
}
|
||||
else
|
||||
cache = search_cacheBycsn( msgqueue->last->csn, cachelist);
|
||||
|
||||
if( cache->metadatalist)
|
||||
delete_metadatalist( &cache->metadatalist);
|
||||
cache->metadatalist = metadatalist;
|
||||
|
||||
if( target) free( target);
|
||||
if( tid) free( tid);
|
||||
if( cid) free( cid);
|
||||
|
||||
response_signal( connected_socket, true);
|
||||
}
|
||||
|
||||
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
|
||||
{
|
||||
Byte_t *pnmstream;
|
||||
ihdrbox_param_t *ihdrbox;
|
||||
char *CIDorTID, tmp[10];
|
||||
cache_param_t *cache;
|
||||
int fw, fh;
|
||||
|
||||
CIDorTID = receive_string( connected_socket);
|
||||
|
||||
if(!(cache = search_cacheBycid( CIDorTID, cachelist)))
|
||||
if(!(cache = search_cacheBytid( CIDorTID, cachelist))){
|
||||
free( CIDorTID);
|
||||
return;
|
||||
}
|
||||
|
||||
free( CIDorTID);
|
||||
|
||||
receive_line( connected_socket, tmp);
|
||||
fw = atoi( tmp);
|
||||
|
||||
receive_line( connected_socket, tmp);
|
||||
fh = atoi( tmp);
|
||||
|
||||
ihdrbox = NULL;
|
||||
pnmstream = jpipstream_to_pnm( jpipstream, msgqueue, cache->csn, fw, fh, &ihdrbox);
|
||||
|
||||
send_PNMstream( connected_socket, pnmstream, ihdrbox->width, ihdrbox->height, ihdrbox->nc, ihdrbox->bpc > 8 ? 255 : (1 << ihdrbox->bpc) - 1);
|
||||
|
||||
free( ihdrbox);
|
||||
free( pnmstream);
|
||||
}
|
||||
|
||||
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist)
|
||||
{
|
||||
char *cid;
|
||||
cache_param_t *cache;
|
||||
boxcontents_param_t *boxcontents;
|
||||
Byte_t *xmlstream;
|
||||
|
||||
cid = receive_string( connected_socket);
|
||||
|
||||
if(!(cache = search_cacheBycid( cid, cachelist))){
|
||||
free( cid);
|
||||
return;
|
||||
}
|
||||
|
||||
free( cid);
|
||||
|
||||
boxcontents = cache->metadatalist->last->boxcontents;
|
||||
xmlstream = (Byte_t *)malloc( boxcontents->length);
|
||||
memcpy( xmlstream, jpipstream+boxcontents->offset, boxcontents->length);
|
||||
send_XMLstream( connected_socket, xmlstream, boxcontents->length);
|
||||
free( xmlstream);
|
||||
}
|
||||
|
||||
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||
{
|
||||
char *target, *tid = NULL;
|
||||
cache_param_t *cache;
|
||||
int tidlen = 0;
|
||||
|
||||
target = receive_string( connected_socket);
|
||||
cache = search_cache( target, cachelist);
|
||||
|
||||
free( target);
|
||||
|
||||
if( cache){
|
||||
tid = cache->tid;
|
||||
tidlen = strlen(tid);
|
||||
}
|
||||
send_TIDstream( connected_socket, tid, tidlen);
|
||||
}
|
||||
|
||||
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||
{
|
||||
char *target, *cid = NULL;
|
||||
cache_param_t *cache;
|
||||
int cidlen = 0;
|
||||
|
||||
target = receive_string( connected_socket);
|
||||
cache = search_cache( target, cachelist);
|
||||
|
||||
free( target);
|
||||
|
||||
if( cache){
|
||||
if( cache->numOfcid > 0){
|
||||
cid = cache->cid[ cache->numOfcid-1];
|
||||
cidlen = strlen(cid);
|
||||
}
|
||||
}
|
||||
send_CIDstream( connected_socket, cid, cidlen);
|
||||
}
|
||||
|
||||
void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
|
||||
{
|
||||
char *cid;
|
||||
|
||||
cid = receive_string( connected_socket);
|
||||
remove_cachecid( cid, cachelist);
|
||||
response_signal( connected_socket, true);
|
||||
|
||||
free( cid);
|
||||
}
|
||||
|
||||
void handle_SIZreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
|
||||
{
|
||||
char *tid, *cid;
|
||||
cache_param_t *cache;
|
||||
Byte4_t width, height;
|
||||
|
||||
tid = receive_string( connected_socket);
|
||||
cid = receive_string( connected_socket);
|
||||
|
||||
cache = NULL;
|
||||
|
||||
if( tid[0] != '0')
|
||||
cache = search_cacheBytid( tid, cachelist);
|
||||
|
||||
if( !cache && cid[0] != '0')
|
||||
cache = search_cacheBycid( cid, cachelist);
|
||||
|
||||
free( tid);
|
||||
free( cid);
|
||||
|
||||
width = height = 0;
|
||||
if( cache){
|
||||
if( !cache->ihdrbox)
|
||||
cache->ihdrbox = get_SIZ_from_jpipstream( jpipstream, msgqueue, cache->csn);
|
||||
width = cache->ihdrbox->width;
|
||||
height = cache->ihdrbox->height;
|
||||
}
|
||||
send_SIZstream( connected_socket, width, height);
|
||||
}
|
||||
|
||||
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream)
|
||||
{
|
||||
char *cid;
|
||||
cache_param_t *cache;
|
||||
Byte_t *jp2stream;
|
||||
Byte8_t jp2len;
|
||||
|
||||
cid = receive_string( connected_socket);
|
||||
if(!(cache = search_cacheBycid( cid, cachelist))){
|
||||
free( cid);
|
||||
return;
|
||||
}
|
||||
|
||||
free( cid);
|
||||
|
||||
jp2stream = recons_jp2( msgqueue, jpipstream, cache->csn, &jp2len);
|
||||
|
||||
if( jp2stream){
|
||||
save_codestream( jp2stream, jp2len, "jp2");
|
||||
free( jp2stream);
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* $Id: faixbox_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "faixbox_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
faixbox_param_t * gene_faixbox( box_param_t *box)
|
||||
{
|
||||
faixbox_param_t *faix;
|
||||
size_t numOfelem;
|
||||
long pos = 0;
|
||||
|
||||
faix = ( faixbox_param_t *)malloc( sizeof(faixbox_param_t));
|
||||
|
||||
faix->version = fetch_DBox1byte( box, (pos+=1)-1);
|
||||
|
||||
if( 3< faix->version){
|
||||
fprintf( FCGI_stderr, "Error: version %d in faix box is reserved for ISO use.\n", faix->version);
|
||||
free(faix);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( faix->version%2){
|
||||
subfaixbox8_param_t *subfaixbox;
|
||||
size_t i;
|
||||
|
||||
faix->subfaixbox.byte8_params = (subfaixbox8_param_t *)malloc( sizeof(subfaixbox8_param_t));
|
||||
|
||||
subfaixbox = faix->subfaixbox.byte8_params;
|
||||
subfaixbox->nmax = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
subfaixbox->m = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
|
||||
numOfelem = subfaixbox->nmax*subfaixbox->m;
|
||||
|
||||
subfaixbox->elem = ( faixelem8_param_t *)malloc( numOfelem*sizeof(faixelem8_param_t));
|
||||
|
||||
if( faix->version == 3)
|
||||
subfaixbox->aux = ( Byte4_t *)malloc( numOfelem*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<numOfelem; i++){
|
||||
subfaixbox->elem[i].off = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
subfaixbox->elem[i].len = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
if( faix->version == 3)
|
||||
subfaixbox->aux[i] = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
}
|
||||
}
|
||||
else{
|
||||
subfaixbox4_param_t *subfaixbox;
|
||||
size_t i;
|
||||
|
||||
faix->subfaixbox.byte4_params = (subfaixbox4_param_t *)malloc( sizeof(subfaixbox4_param_t));
|
||||
|
||||
subfaixbox = faix->subfaixbox.byte4_params;
|
||||
subfaixbox->nmax = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
subfaixbox->m = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
|
||||
numOfelem = subfaixbox->nmax*subfaixbox->m;
|
||||
|
||||
subfaixbox->elem = ( faixelem4_param_t *)malloc( numOfelem*sizeof(faixelem4_param_t));
|
||||
|
||||
if( faix->version == 2)
|
||||
subfaixbox->aux = ( Byte4_t *)malloc( numOfelem*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<numOfelem; i++){
|
||||
subfaixbox->elem[i].off = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
subfaixbox->elem[i].len = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
if( faix->version == 2)
|
||||
subfaixbox->aux[i] = fetch_DBox4bytebigendian( box, (pos+=4)-4);
|
||||
}
|
||||
}
|
||||
return faix;
|
||||
}
|
||||
|
||||
void print_faixbox( faixbox_param_t *faix)
|
||||
{
|
||||
Byte8_t i, j;
|
||||
|
||||
fprintf( logstream, "faix box info\n");
|
||||
fprintf( logstream, "\tversion: %d\n", faix->version);
|
||||
|
||||
fprintf( logstream, "\t nmax: %#llx = %lld\n", get_nmax( faix), get_nmax( faix));
|
||||
fprintf( logstream, "\t m: %#llx = %lld\n", get_m( faix), get_m( faix));
|
||||
|
||||
for( i=0; i<get_m( faix); i++){
|
||||
for( j=0; j<get_nmax( faix); j++){
|
||||
fprintf( logstream, "\t off = %#llx, len = %#llx", get_elemOff( faix, j, i), get_elemLen( faix, j, i));
|
||||
if( 2 <= faix->version)
|
||||
fprintf( logstream, ", aux = %#x", get_elemAux( faix, j, i));
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void delete_faixbox( faixbox_param_t **faix)
|
||||
{
|
||||
if((*faix)->version%2){
|
||||
free((*faix)->subfaixbox.byte8_params->elem);
|
||||
if( (*faix)->version == 3)
|
||||
free((*faix)->subfaixbox.byte8_params->aux);
|
||||
free((*faix)->subfaixbox.byte8_params);
|
||||
}
|
||||
else{
|
||||
free((*faix)->subfaixbox.byte4_params->elem);
|
||||
if( (*faix)->version == 2)
|
||||
free((*faix)->subfaixbox.byte4_params->aux);
|
||||
free((*faix)->subfaixbox.byte4_params);
|
||||
}
|
||||
free( *faix);
|
||||
}
|
||||
|
||||
Byte8_t get_nmax( faixbox_param_t *faix)
|
||||
{
|
||||
if( faix->version%2)
|
||||
return faix->subfaixbox.byte8_params->nmax;
|
||||
else
|
||||
return (Byte8_t)faix->subfaixbox.byte4_params->nmax;
|
||||
}
|
||||
|
||||
Byte8_t get_m( faixbox_param_t *faix)
|
||||
{
|
||||
if( faix->version%2)
|
||||
return faix->subfaixbox.byte8_params->m;
|
||||
else
|
||||
return (Byte8_t)faix->subfaixbox.byte4_params->m;
|
||||
}
|
||||
|
||||
Byte8_t get_elemOff( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id)
|
||||
{
|
||||
Byte8_t nmax = get_nmax( faix);
|
||||
if( faix->version%2)
|
||||
return faix->subfaixbox.byte8_params->elem[ row_id*nmax+elem_id].off;
|
||||
else
|
||||
return (Byte8_t)faix->subfaixbox.byte4_params->elem[ row_id*nmax+elem_id].off;
|
||||
}
|
||||
|
||||
Byte8_t get_elemLen( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id)
|
||||
{
|
||||
Byte8_t nmax = get_nmax( faix);
|
||||
if( faix->version%2)
|
||||
return faix->subfaixbox.byte8_params->elem[ row_id*nmax+elem_id].len;
|
||||
else
|
||||
return (Byte8_t)faix->subfaixbox.byte4_params->elem[ row_id*nmax+elem_id].len;
|
||||
}
|
||||
|
||||
Byte4_t get_elemAux( faixbox_param_t *faix, Byte8_t elem_id, Byte8_t row_id)
|
||||
{
|
||||
Byte8_t nmax;
|
||||
if( faix->version <2)
|
||||
return -1;
|
||||
|
||||
nmax = get_nmax( faix);
|
||||
if( faix->version%2)
|
||||
return faix->subfaixbox.byte8_params->aux[ row_id*nmax+elem_id];
|
||||
else
|
||||
return faix->subfaixbox.byte4_params->aux[ row_id*nmax+elem_id];
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* $Id: imgreg_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "imgreg_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
|
||||
const int rx, const int ry,
|
||||
const int rw, const int rh,
|
||||
const int XOsiz, const int YOsiz,
|
||||
const int Xsiz, const int Ysiz,
|
||||
const int numOfreslev)
|
||||
{
|
||||
imgreg_param_t imgreg;
|
||||
int px,py;
|
||||
int xmax, ymax;
|
||||
|
||||
imgreg.xosiz = XOsiz;
|
||||
imgreg.yosiz = YOsiz;
|
||||
imgreg.fx = fx;
|
||||
imgreg.fy = fy;
|
||||
imgreg.level = 0;
|
||||
xmax = Xsiz;
|
||||
ymax = Ysiz;
|
||||
|
||||
find_level( numOfreslev, &imgreg.level, &imgreg.fx, &imgreg.fy, &imgreg.xosiz, &imgreg.yosiz, &xmax, &ymax);
|
||||
|
||||
if( rx == -1 || ry == -1){
|
||||
imgreg.ox = 0;
|
||||
imgreg.oy = 0;
|
||||
}
|
||||
else{
|
||||
imgreg.ox = rx*imgreg.fx/fx;
|
||||
imgreg.oy = ry*imgreg.fy/fy;
|
||||
}
|
||||
|
||||
if( rw == -1 || rh == -1){
|
||||
imgreg.sx = imgreg.fx;
|
||||
imgreg.sy = imgreg.fy;
|
||||
}
|
||||
else{
|
||||
px = ceil((double)((rx+rw)*imgreg.fx)/(double)fx);
|
||||
py = ceil((double)((ry+rh)*imgreg.fy)/(double)fy);
|
||||
|
||||
if( imgreg.fx < px)
|
||||
px = imgreg.fx;
|
||||
if( imgreg.fy < py)
|
||||
py = imgreg.fy;
|
||||
|
||||
imgreg.sx = px - imgreg.ox;
|
||||
imgreg.sy = py - imgreg.oy;
|
||||
}
|
||||
|
||||
if( fx != imgreg.fx || fy != imgreg.fy)
|
||||
fprintf( FCGI_stdout, "JPIP-fsiz: %d,%d\r\n", imgreg.fx, imgreg.fy);
|
||||
|
||||
if( rw != imgreg.sx || rh != imgreg.sy)
|
||||
fprintf( FCGI_stdout, "JPIP-rsiz: %d,%d\r\n", imgreg.sx, imgreg.sy);
|
||||
|
||||
if( rx != imgreg.ox || ry != imgreg.oy)
|
||||
fprintf( FCGI_stdout, "JPIP-roff: %d,%d\r\n", imgreg.ox, imgreg.oy);
|
||||
|
||||
return imgreg;
|
||||
}
|
||||
|
||||
void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, int *xmax, int *ymax)
|
||||
{
|
||||
int xwidth = *xmax - *xmin;
|
||||
int ywidth = *ymax - *ymin;
|
||||
|
||||
/// Find smaller frame size for now (i.e. assume "round-down").
|
||||
if ((*fx < 1 && xwidth != 0) || (*fy < 1 && ywidth != 0)){
|
||||
fprintf( FCGI_stderr, "Frame size must be strictly positive");
|
||||
exit(-1);
|
||||
}
|
||||
else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
|
||||
// Simulate the ceil function.
|
||||
*xmin = ceil((double)*xmin/(double)2.0);
|
||||
*ymin = ceil((double)*ymin/(double)2.0);
|
||||
*xmax = ceil((double)*xmax/(double)2.0);
|
||||
*ymax = ceil((double)*ymax/(double)2.0);
|
||||
|
||||
(*lev) ++;
|
||||
find_level ( maxlev, lev, fx, fy, xmin, ymin, xmax, ymax);
|
||||
} else {
|
||||
*fx = xwidth;
|
||||
*fy = ywidth;
|
||||
}
|
||||
}
|
||||
|
||||
int comp_decomplev( int fw, int fh, int Xsiz, int Ysiz)
|
||||
{
|
||||
int level;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
|
||||
level = 0;
|
||||
xmin = ymin = 0;
|
||||
xmax = Xsiz;
|
||||
ymax = Ysiz;
|
||||
|
||||
find_level( 1000, &level, &fw, &fh, &xmin, &ymin, &xmax, &ymax);
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
void print_imgreg( imgreg_param_t imgreg)
|
||||
{
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "codestream image region:\n");
|
||||
fprintf( logstream, "\t fsiz: %d, %d\n", imgreg.fx, imgreg.fy);
|
||||
fprintf( logstream, "\t roff: %d, %d\n", imgreg.ox, imgreg.oy);
|
||||
fprintf( logstream, "\t rsiz: %d, %d\n", imgreg.sx, imgreg.sy);
|
||||
fprintf( logstream, "\t level: %d\n", imgreg.level);
|
||||
#endif
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* $Id: imgsock_manager.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) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "imgsock_manager.h"
|
||||
#if _WIN32
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
|
||||
msgtype_t identify_clientmsg( SOCKET connected_socket)
|
||||
{
|
||||
int receive_size;
|
||||
char buf[BUF_LEN];
|
||||
static const char *magicid[] = { "JPIP-stream", "PNM request", "XML request",
|
||||
"TID request", "CID request", "CID destroy", "SIZ request", "JP2 save",
|
||||
"QUIT"};
|
||||
int i;
|
||||
|
||||
receive_size = receive_line( connected_socket, buf);
|
||||
|
||||
if( receive_size == 0){
|
||||
fprintf( stderr, "Error to receive the header of client message\n");
|
||||
return MSGERROR;
|
||||
}
|
||||
|
||||
for( i=0; i<NUM_OF_MSGTYPES; i++){
|
||||
if( strncasecmp( magicid[i], buf, strlen(magicid[i])) == 0){
|
||||
fprintf( stderr, "%s\n", magicid[i]);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( stderr, "Cannot identify client message type %s\n", buf);
|
||||
return MSGERROR;
|
||||
}
|
||||
|
||||
Byte_t * receive_JPIPstream( SOCKET connected_socket, char **target, char **tid, char **cid, int *streamlen)
|
||||
{
|
||||
char buf[BUF_LEN], versionstring[] = "version 1.2";
|
||||
int linelen, datalen;
|
||||
Byte_t *jpipstream;
|
||||
|
||||
*target = *cid = *tid = NULL;
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
if( strncmp( versionstring, buf, strlen(versionstring))!=0){
|
||||
fprintf( stderr, "Wrong format\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
|
||||
if( strstr( buf, "jp2")){
|
||||
/* register cid option*/
|
||||
*target = strdup( buf);
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
if( strcmp( buf, "0") != 0)
|
||||
*tid = strdup( buf);
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
if( strcmp( buf, "0") != 0)
|
||||
*cid = strdup( buf);
|
||||
|
||||
if((linelen = receive_line( connected_socket, buf)) == 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
datalen = atoi( buf);
|
||||
fprintf( stderr, "Receive Data: %d Bytes\n", datalen);
|
||||
|
||||
jpipstream = receive_stream( connected_socket, datalen);
|
||||
|
||||
/* check EOR*/
|
||||
if( jpipstream[datalen-3] == 0x00 && ( jpipstream[datalen-2] == 0x01 || jpipstream[datalen-2] == 0x02))
|
||||
*streamlen = datalen -3;
|
||||
else
|
||||
*streamlen = datalen;
|
||||
|
||||
return jpipstream;
|
||||
}
|
||||
|
||||
void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
|
||||
{
|
||||
Byte_t header[5];
|
||||
|
||||
header[0] = 'X';
|
||||
header[1] = 'M';
|
||||
header[2] = 'L';
|
||||
header[3] = (length >> 8) & 0xff;
|
||||
header[4] = length & 0xff;
|
||||
|
||||
send_stream( connected_socket, header, 5);
|
||||
send_stream( connected_socket, xmlstream, length);
|
||||
}
|
||||
|
||||
void send_IDstream( SOCKET connected_socket, char *id, int idlen, const char *label);
|
||||
|
||||
void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen)
|
||||
{
|
||||
send_IDstream( connected_socket, cid, cidlen, "CID");
|
||||
}
|
||||
|
||||
void send_TIDstream( SOCKET connected_socket, char *tid, int tidlen)
|
||||
{
|
||||
send_IDstream( connected_socket, tid, tidlen, "TID");
|
||||
}
|
||||
|
||||
void send_IDstream( SOCKET connected_socket, char *id, int idlen, const char *label)
|
||||
{
|
||||
Byte_t header[4];
|
||||
|
||||
header[0] = label[0];
|
||||
header[1] = label[1];
|
||||
header[2] = label[2];
|
||||
header[3] = idlen & 0xff;
|
||||
|
||||
send_stream( connected_socket, header, 4);
|
||||
send_stream( connected_socket, id, idlen);
|
||||
}
|
||||
|
||||
void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
|
||||
{
|
||||
int pnmlen = 0;
|
||||
Byte_t header[7];
|
||||
|
||||
pnmlen = width*height*numofcomp;
|
||||
|
||||
header[0] = 'P';
|
||||
header[1] = numofcomp==3 ? 6:5;
|
||||
header[2] = (width >> 8) & 0xff;
|
||||
header[3] = width & 0xff;
|
||||
header[4] = (height >> 8) & 0xff;
|
||||
header[5] = height & 0xff;
|
||||
header[6] = maxval;
|
||||
|
||||
send_stream( connected_socket, header, 7);
|
||||
send_stream( connected_socket, pnmstream, pnmlen);
|
||||
}
|
||||
|
||||
void send_SIZstream( SOCKET connected_socket, unsigned int width, unsigned int height)
|
||||
{
|
||||
Byte_t responce[9];
|
||||
|
||||
responce[0] = 'S';
|
||||
responce[1] = 'I';
|
||||
responce[2] = 'Z';
|
||||
responce[3] = (width >> 16) & 0xff;
|
||||
responce[4] = (width >> 8) & 0xff;
|
||||
responce[5] = width & 0xff;
|
||||
responce[6] = (height >> 16) & 0xff;
|
||||
responce[7] = (height >> 8) & 0xff;
|
||||
responce[8] = height & 0xff;
|
||||
|
||||
send_stream( connected_socket, responce, 9);
|
||||
}
|
||||
|
||||
void response_signal( SOCKET connected_socket, bool succeed)
|
||||
{
|
||||
Byte_t code;
|
||||
|
||||
if( succeed)
|
||||
code = 1;
|
||||
else
|
||||
code = 0;
|
||||
|
||||
send_stream( connected_socket, &code, 1);
|
||||
}
|
||||
@@ -1,731 +0,0 @@
|
||||
/*
|
||||
* $Id: index_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bool.h"
|
||||
#include "index_manager.h"
|
||||
#include "box_manager.h"
|
||||
#include "manfbox_manager.h"
|
||||
#include "mhixbox_manager.h"
|
||||
#include "codestream_manager.h"
|
||||
#include "marker_manager.h"
|
||||
#include "faixbox_manager.h"
|
||||
#include "boxheader_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
/**
|
||||
* chekc JP2 box indexing
|
||||
*
|
||||
* @param[in] toplev_boxlist top level box list
|
||||
* @return if correct (true) or wrong (false)
|
||||
*/
|
||||
bool check_JP2boxidx( boxlist_param_t *toplev_boxlist);
|
||||
|
||||
/**
|
||||
* set code index parameters (parse cidx box)
|
||||
* Annex I
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[out] codeidx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_cidxdata( box_param_t *cidx_box, index_param_t *codeidx);
|
||||
|
||||
index_param_t * parse_jp2file( int fd)
|
||||
{
|
||||
index_param_t *jp2idx;
|
||||
box_param_t *cidx;
|
||||
metadatalist_param_t *metadatalist;
|
||||
boxlist_param_t *toplev_boxlist;
|
||||
Byte8_t filesize;
|
||||
|
||||
if( !(filesize = get_filesize( fd)))
|
||||
return NULL;
|
||||
|
||||
if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))){
|
||||
fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !check_JP2boxidx( toplev_boxlist)){
|
||||
fprintf( FCGI_stderr, "Index format not supported\n");
|
||||
delete_boxlist( &toplev_boxlist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !(cidx = search_box( "cidx", toplev_boxlist))){
|
||||
fprintf( FCGI_stderr, "Box cidx not found\n");
|
||||
delete_boxlist( &toplev_boxlist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jp2idx = (index_param_t *)malloc( sizeof(index_param_t));
|
||||
|
||||
if( !set_cidxdata( cidx, jp2idx)){
|
||||
fprintf( FCGI_stderr, "Error: Not correctl format in cidx box\n");
|
||||
free(jp2idx);
|
||||
delete_boxlist( &toplev_boxlist);
|
||||
return NULL;
|
||||
}
|
||||
delete_boxlist( &toplev_boxlist);
|
||||
|
||||
metadatalist = const_metadatalist( fd);
|
||||
jp2idx->metadatalist = metadatalist;
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: code index created\n");
|
||||
#endif
|
||||
|
||||
return jp2idx;
|
||||
}
|
||||
|
||||
void print_index( index_param_t index)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( logstream, "index info:\n");
|
||||
fprintf( logstream, "\tCodestream Offset: %#llx\n", index.offset);
|
||||
fprintf( logstream, "\t Length: %#llx\n", index.length);
|
||||
fprintf( logstream, "\tMain header Length: %#llx\n", index.mhead_length);
|
||||
|
||||
print_SIZ( index.SIZ);
|
||||
print_COD( index.COD);
|
||||
|
||||
fprintf( logstream, "Tile part information: \n");
|
||||
print_faixbox( index.tilepart);
|
||||
|
||||
fprintf( logstream, "Tile header information: \n");
|
||||
for( i=0; i<(int)(index.SIZ.XTnum*index.SIZ.YTnum);i++)
|
||||
print_mhixbox( index.tileheader[i]);
|
||||
|
||||
fprintf( logstream, "Precinct packet information: \n");
|
||||
for( i=0; i<index.SIZ.Csiz; i++){
|
||||
fprintf( logstream, "Component %d\n", i);
|
||||
print_faixbox( index.precpacket[i]);
|
||||
}
|
||||
|
||||
print_allmetadata( index.metadatalist);
|
||||
}
|
||||
|
||||
void print_SIZ( SIZmarker_param_t SIZ)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( logstream, "\tImage and Tile SIZ parameters\n");
|
||||
fprintf( logstream, "\t Rsiz: %#x\n", SIZ.Rsiz);
|
||||
fprintf( logstream, "\t Xsiz, Ysiz: (%d,%d) = (%#x, %#x)\n", SIZ.Xsiz, SIZ.Ysiz, SIZ.Xsiz, SIZ.Ysiz);
|
||||
fprintf( logstream, "\t XOsiz, YOsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XOsiz, SIZ.YOsiz, SIZ.XOsiz, SIZ.YOsiz);
|
||||
fprintf( logstream, "\t XTsiz, YTsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XTsiz, SIZ.YTsiz, SIZ.XTsiz, SIZ.YTsiz);
|
||||
fprintf( logstream, "\t XTOsiz, YTOsiz: (%d,%d) = (%#x, %#x)\n", SIZ.XTOsiz, SIZ.YTOsiz, SIZ.XTOsiz, SIZ.YTOsiz);
|
||||
fprintf( logstream, "\t XTnum, YTnum: (%d,%d)\n", SIZ.XTnum, SIZ.YTnum);
|
||||
fprintf( logstream, "\t Num of Components: %d\n", SIZ.Csiz);
|
||||
|
||||
for( i=0; i<SIZ.Csiz; i++)
|
||||
fprintf( logstream, "\t[%d] (Ssiz, XRsiz, YRsiz): (%d, %d, %d) = (%#x, %#x, %#x)\n", i, SIZ.Ssiz[i], SIZ.XRsiz[i], SIZ.YRsiz[i], SIZ.Ssiz[i], SIZ.XRsiz[i], SIZ.YRsiz[i]);
|
||||
}
|
||||
|
||||
void print_COD( CODmarker_param_t COD)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( logstream, "\tCoding style default COD parameters\n");
|
||||
fprintf( logstream, "\t Progression order: %d [ LRCP=0, RLCP=1, RPCL=2, PCRL=3, CPRL=4]\n", COD.prog_order);
|
||||
fprintf( logstream, "\t Num of layers: %d\n", COD.numOflayers);
|
||||
fprintf( logstream, "\t Decomposition lvl: %d\n", COD.numOfdecomp);
|
||||
|
||||
for( i=0; i<=((COD.Scod & 0x01) ? COD.numOfdecomp:0); i++){
|
||||
fprintf( logstream, "\t [%d] XPsiz, YPsiz: (%d,%d) = (%#x, %#x)\n",i, COD.XPsiz[i], COD.YPsiz[i], COD.XPsiz[i], COD.YPsiz[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void delete_index( index_param_t **index)
|
||||
{
|
||||
int i;
|
||||
|
||||
delete_metadatalist( &((*index)->metadatalist));
|
||||
|
||||
delete_COD( (*index)->COD);
|
||||
|
||||
delete_faixbox( &((*index)->tilepart));
|
||||
|
||||
for( i=0; i< (int)((*index)->SIZ.XTnum*(*index)->SIZ.YTnum);i++)
|
||||
delete_mhixbox( &((*index)->tileheader[i]));
|
||||
free( (*index)->tileheader);
|
||||
|
||||
for( i=0; i<(*index)->SIZ.Csiz; i++)
|
||||
delete_faixbox( &((*index)->precpacket[i]));
|
||||
free( (*index)->precpacket);
|
||||
|
||||
free(*index);
|
||||
}
|
||||
|
||||
void delete_COD( CODmarker_param_t COD)
|
||||
{
|
||||
if( COD.XPsiz) free( COD.XPsiz);
|
||||
if( COD.YPsiz) free( COD.YPsiz);
|
||||
}
|
||||
|
||||
bool check_JP2boxidx( boxlist_param_t *toplev_boxlist)
|
||||
{
|
||||
box_param_t *iptr, *fidx, *prxy;
|
||||
box_param_t *cidx, *jp2c;
|
||||
Byte8_t off;
|
||||
Byte8_t len;
|
||||
int pos;
|
||||
Byte8_t ooff;
|
||||
boxheader_param_t *obh;
|
||||
Byte_t ni;
|
||||
Byte8_t ioff;
|
||||
boxheader_param_t *ibh;
|
||||
|
||||
iptr = search_box( "iptr", toplev_boxlist);
|
||||
fidx = search_box( "fidx", toplev_boxlist);
|
||||
cidx = search_box( "cidx", toplev_boxlist);
|
||||
jp2c = search_box( "jp2c", toplev_boxlist);
|
||||
prxy = gene_childboxbyType( fidx, 0, "prxy");
|
||||
|
||||
off = fetch_DBox8bytebigendian( iptr, 0);
|
||||
if( off != fidx->offset)
|
||||
fprintf( FCGI_stderr, "Reference File Index box offset in Index Finder box not correct\n");
|
||||
|
||||
len = fetch_DBox8bytebigendian( iptr, 8);
|
||||
if( len != fidx->length)
|
||||
fprintf( FCGI_stderr, "Reference File Index box length in Index Finder box not correct\n");
|
||||
|
||||
pos = 0;
|
||||
ooff = fetch_DBox8bytebigendian( prxy, pos);
|
||||
if( ooff != jp2c->offset)
|
||||
fprintf( FCGI_stderr, "Reference jp2c offset in prxy box not correct\n");
|
||||
pos += 8;
|
||||
|
||||
obh = gene_childboxheader( prxy, pos);
|
||||
if( obh->length != jp2c->length || strncmp( obh->type, "jp2c",4)!=0)
|
||||
fprintf( FCGI_stderr, "Reference jp2c header in prxy box not correct\n");
|
||||
pos += obh->headlen;
|
||||
free(obh);
|
||||
|
||||
ni = fetch_DBox1byte( prxy, pos);
|
||||
if( ni != 1){
|
||||
fprintf( FCGI_stderr, "Multiple indexes not supported\n");
|
||||
return false;
|
||||
}
|
||||
pos += 1;
|
||||
|
||||
ioff = fetch_DBox8bytebigendian( prxy, pos);
|
||||
if( ioff != cidx->offset)
|
||||
fprintf( FCGI_stderr, "Reference cidx offset in prxy box not correct\n");
|
||||
pos += 8;
|
||||
|
||||
ibh = gene_childboxheader( prxy, pos);
|
||||
if( ibh->length != cidx->length || strncmp( ibh->type, "cidx",4)!=0)
|
||||
fprintf( FCGI_stderr, "Reference cidx header in prxy box not correct\n");
|
||||
pos += ibh->headlen;
|
||||
free(ibh);
|
||||
|
||||
free(prxy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* set code index parameters from cptr box
|
||||
* I.3.2.2 Codestream Finder box
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[out] jp2idx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx);
|
||||
|
||||
/**
|
||||
* set code index parameters from mhix box for main header
|
||||
* I.3.2.4.3 Header Index Table box
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[in] codestream codestream parameters
|
||||
* @param[out] jp2idx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx);
|
||||
|
||||
/**
|
||||
* set code index parameters from tpix box
|
||||
* I.3.2.4.4 Tile-part Index Table box
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[out] jp2idx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx);
|
||||
|
||||
/**
|
||||
* set code index parameters from thix box
|
||||
* I.3.2.4.5 Tile Header Index Table box
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[out] jp2idx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx);
|
||||
|
||||
/**
|
||||
* set code index parameters from ppix box
|
||||
* I.3.2.4.6 Precinct Packet Index Table box
|
||||
*
|
||||
* @param[in] cidx_box pointer to the reference cidx_box
|
||||
* @param[out] jp2idx pointer to index parameters
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx);
|
||||
|
||||
bool set_cidxdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *manf_box;
|
||||
manfbox_param_t *manf;
|
||||
codestream_param_t codestream;
|
||||
|
||||
set_cptrdata( cidx_box, jp2idx);
|
||||
|
||||
codestream = set_codestream( cidx_box->fd, jp2idx->offset, jp2idx->length);
|
||||
|
||||
manf_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "manf");
|
||||
manf = gene_manfbox( manf_box);
|
||||
|
||||
if( !search_boxheader( "mhix", manf)){
|
||||
fprintf( FCGI_stderr, "Error: mhix box not present in manfbox\n");
|
||||
free(jp2idx);
|
||||
return false;
|
||||
}
|
||||
set_mainmhixdata( cidx_box, codestream, jp2idx);
|
||||
|
||||
if( !search_boxheader( "tpix", manf)){
|
||||
fprintf( FCGI_stderr, "Error: tpix box not present in manfbox\n");
|
||||
free(jp2idx);
|
||||
return false;
|
||||
}
|
||||
set_tpixdata( cidx_box, jp2idx);
|
||||
|
||||
if( !search_boxheader( "thix", manf)){
|
||||
fprintf( FCGI_stderr, "Error: thix box not present in manfbox\n");
|
||||
free(jp2idx);
|
||||
return false;
|
||||
}
|
||||
set_thixdata( cidx_box, jp2idx);
|
||||
|
||||
if( !search_boxheader( "ppix", manf)){
|
||||
fprintf( FCGI_stderr, "Error: ppix box not present in manfbox\n");
|
||||
free(jp2idx);
|
||||
return false;
|
||||
}
|
||||
set_ppixdata( cidx_box, jp2idx);
|
||||
|
||||
delete_manfbox( &manf);
|
||||
free( manf_box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_cptrdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *box; /**< cptr box*/
|
||||
Byte2_t dr, cont;
|
||||
|
||||
if( !(box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "cptr")))
|
||||
return false;
|
||||
|
||||
/* DR: Data Reference. */
|
||||
/* If 0, the codestream or its Fragment Table box exists in the current file*/
|
||||
if(( dr = fetch_DBox2bytebigendian( box, 0))){
|
||||
fprintf( FCGI_stderr, "Error: Codestream not present in current file\n");
|
||||
free( box);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* CONT: Container Type*/
|
||||
/* If 0, the entire codestream appears as a contiguous range of*/
|
||||
/* bytes within its file or resource.*/
|
||||
if(( cont = fetch_DBox2bytebigendian( box, 2))){
|
||||
fprintf( FCGI_stderr, "Error: Can't cope with fragmented codestreams yet\n");
|
||||
free( box);
|
||||
return false;
|
||||
}
|
||||
|
||||
jp2idx->offset = fetch_DBox8bytebigendian( box, 4);
|
||||
jp2idx->length = fetch_DBox8bytebigendian( box, 12);
|
||||
|
||||
free( box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set SIZ marker information
|
||||
* A.5 Fixed information marker segment
|
||||
* A.5.1 Image and tile size (SIZ)
|
||||
*
|
||||
* @param[in] sizmkidx pointer to SIZ marker index in mhix box
|
||||
* @param[in] codestream codestream parameters
|
||||
* @param[out] SIZ SIZ marker parameters pointer
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ);
|
||||
|
||||
/**
|
||||
* set code index parameters from COD marker in codestream
|
||||
* A.6 Functional marker segments
|
||||
* A.6.1 Coding style default (COD)
|
||||
*
|
||||
* @param[in] codmkidx pointer to COD marker index in mhix box
|
||||
* @param[in] codestream codestream parameters
|
||||
* @param[out] COD COD marker parameters pointer
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD);
|
||||
|
||||
bool set_mainmhixdata( box_param_t *cidx_box, codestream_param_t codestream, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *mhix_box;
|
||||
mhixbox_param_t *mhix;
|
||||
markeridx_param_t *sizmkidx;
|
||||
markeridx_param_t *codmkidx;
|
||||
|
||||
if( !(mhix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "mhix")))
|
||||
return false;
|
||||
|
||||
jp2idx->mhead_length = fetch_DBox8bytebigendian( mhix_box, 0);
|
||||
|
||||
mhix = gene_mhixbox( mhix_box);
|
||||
free( mhix_box);
|
||||
|
||||
sizmkidx = search_markeridx( 0xff51, mhix);
|
||||
set_SIZmkrdata( sizmkidx, codestream, &(jp2idx->SIZ));
|
||||
|
||||
codmkidx = search_markeridx( 0xff52, mhix);
|
||||
set_CODmkrdata( codmkidx, codestream, &(jp2idx->COD));
|
||||
|
||||
delete_mhixbox( &mhix);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_tpixdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *tpix_box; /**< tpix box*/
|
||||
box_param_t *faix_box; /**< faix box*/
|
||||
|
||||
if( !(tpix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "tpix"))){
|
||||
fprintf( FCGI_stderr, "Error: tpix box not present in cidx box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !(faix_box = gene_boxbyType( tpix_box->fd, get_DBoxoff( tpix_box), get_DBoxlen( tpix_box), "faix"))){
|
||||
fprintf( FCGI_stderr, "Error: faix box not present in tpix box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
jp2idx->tilepart = gene_faixbox( faix_box);
|
||||
|
||||
free( tpix_box);
|
||||
free( faix_box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_thixdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *thix_box, *manf_box, *mhix_box;
|
||||
manfbox_param_t *manf;
|
||||
boxheader_param_t *ptr;
|
||||
mhixbox_param_t *mhix;
|
||||
Byte8_t pos, mhixseqoff;
|
||||
Byte2_t tile_no;
|
||||
|
||||
if( !(thix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "thix"))){
|
||||
fprintf( FCGI_stderr, "Error: thix box not present in cidx box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !(manf_box = gene_boxbyType( thix_box->fd, get_DBoxoff( thix_box), get_DBoxlen( thix_box), "manf"))){
|
||||
fprintf( FCGI_stderr, "Error: manf box not present in thix box\n");
|
||||
free( thix_box);
|
||||
return false;
|
||||
}
|
||||
|
||||
manf = gene_manfbox( manf_box);
|
||||
ptr = manf->first;
|
||||
mhixseqoff = manf_box->offset+manf_box->length;
|
||||
pos = 0;
|
||||
tile_no = 0;
|
||||
jp2idx->tileheader = (mhixbox_param_t **)malloc( jp2idx->SIZ.XTnum*jp2idx->SIZ.YTnum*sizeof(mhixbox_param_t *));
|
||||
|
||||
while( ptr){
|
||||
if( !(mhix_box = gene_boxbyType( thix_box->fd, mhixseqoff+pos, get_DBoxlen( thix_box)-manf_box->length-pos, "mhix"))){
|
||||
fprintf( FCGI_stderr, "Error: mhix box not present in thix box\n");
|
||||
delete_manfbox( &manf);
|
||||
free( manf_box);
|
||||
free( thix_box);
|
||||
return false;
|
||||
}
|
||||
mhix = gene_mhixbox( mhix_box);
|
||||
|
||||
pos += mhix_box->length;
|
||||
ptr = ptr->next;
|
||||
|
||||
free( mhix_box);
|
||||
jp2idx->tileheader[tile_no++] = mhix;
|
||||
}
|
||||
|
||||
delete_manfbox( &manf);
|
||||
free( manf_box);
|
||||
free( thix_box);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_ppixdata( box_param_t *cidx_box, index_param_t *jp2idx)
|
||||
{
|
||||
box_param_t *ppix_box, *faix_box, *manf_box;
|
||||
manfbox_param_t *manf; /**< manf*/
|
||||
boxheader_param_t *bh; /**< box headers*/
|
||||
faixbox_param_t *faix; /**< faix*/
|
||||
Byte8_t inbox_offset;
|
||||
int comp_idx;
|
||||
|
||||
if( !(ppix_box = gene_boxbyType( cidx_box->fd, get_DBoxoff( cidx_box), get_DBoxlen( cidx_box), "ppix"))){
|
||||
fprintf( FCGI_stderr, "Error: ppix box not present in cidx box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
inbox_offset = get_DBoxoff( ppix_box);
|
||||
if( !(manf_box = gene_boxbyType( ppix_box->fd, inbox_offset, get_DBoxlen( ppix_box), "manf"))){
|
||||
fprintf( FCGI_stderr, "Error: manf box not present in ppix box\n");
|
||||
free( ppix_box);
|
||||
return false;
|
||||
}
|
||||
|
||||
free( ppix_box);
|
||||
|
||||
manf = gene_manfbox( manf_box);
|
||||
bh = search_boxheader( "faix", manf);
|
||||
inbox_offset = manf_box->offset + manf_box->length;
|
||||
|
||||
free( manf_box);
|
||||
|
||||
jp2idx->precpacket = (faixbox_param_t **)malloc( jp2idx->SIZ.Csiz*sizeof(faixbox_param_t *));
|
||||
|
||||
for( comp_idx=0; bh!=NULL; bh=bh->next, comp_idx++){
|
||||
if( jp2idx->SIZ.Csiz <= comp_idx ){
|
||||
fprintf( FCGI_stderr, "Error: num of faix boxes is not identical to num of components in ppix box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !(faix_box = gene_boxbyOffset( cidx_box->fd, inbox_offset))){
|
||||
fprintf( FCGI_stderr, "Error: faix box not present in ppix box\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
faix = gene_faixbox( faix_box);
|
||||
jp2idx->precpacket[comp_idx] = faix;
|
||||
|
||||
inbox_offset = faix_box->offset + faix_box->length;
|
||||
free( faix_box);
|
||||
}
|
||||
|
||||
delete_manfbox( &manf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool set_SIZmkrdata( markeridx_param_t *sizmkidx, codestream_param_t codestream, SIZmarker_param_t *SIZ)
|
||||
{
|
||||
marker_param_t sizmkr;
|
||||
int i;
|
||||
|
||||
sizmkr = set_marker( codestream, sizmkidx->code, sizmkidx->offset, sizmkidx->length);
|
||||
|
||||
SIZ->Lsiz = fetch_marker2bytebigendian( sizmkr, 0);
|
||||
|
||||
if( sizmkidx->length != SIZ->Lsiz){
|
||||
fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", sizmkidx->code);
|
||||
return false;
|
||||
}
|
||||
|
||||
SIZ->Rsiz = fetch_marker2bytebigendian( sizmkr, 2);
|
||||
SIZ->Xsiz = fetch_marker4bytebigendian( sizmkr, 4);
|
||||
SIZ->Ysiz = fetch_marker4bytebigendian( sizmkr, 8);
|
||||
SIZ->XOsiz = fetch_marker4bytebigendian( sizmkr, 12);
|
||||
SIZ->YOsiz = fetch_marker4bytebigendian( sizmkr, 16);
|
||||
SIZ->XTsiz = fetch_marker4bytebigendian( sizmkr, 20);
|
||||
SIZ->YTsiz = fetch_marker4bytebigendian( sizmkr, 24);
|
||||
SIZ->XTOsiz = fetch_marker4bytebigendian( sizmkr, 28);
|
||||
SIZ->YTOsiz = fetch_marker4bytebigendian( sizmkr, 32);
|
||||
SIZ->Csiz = fetch_marker2bytebigendian( sizmkr, 36);
|
||||
|
||||
SIZ->XTnum = ( SIZ->Xsiz-SIZ->XTOsiz+SIZ->XTsiz-1)/SIZ->XTsiz;
|
||||
SIZ->YTnum = ( SIZ->Ysiz-SIZ->YTOsiz+SIZ->YTsiz-1)/SIZ->YTsiz;
|
||||
|
||||
for( i=0; i<(int)SIZ->Csiz; i++){
|
||||
SIZ->Ssiz[i] = fetch_marker1byte( sizmkr, 38+i*3);
|
||||
SIZ->XRsiz[i] = fetch_marker1byte( sizmkr, 39+i*3);
|
||||
SIZ->YRsiz[i] = fetch_marker1byte( sizmkr, 40+i*3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_CODmkrdata( markeridx_param_t *codmkidx, codestream_param_t codestream, CODmarker_param_t *COD)
|
||||
{
|
||||
marker_param_t codmkr;
|
||||
int i;
|
||||
|
||||
codmkr = set_marker( codestream, codmkidx->code, codmkidx->offset, codmkidx->length);
|
||||
|
||||
COD->Lcod = fetch_marker2bytebigendian( codmkr, 0);
|
||||
|
||||
if( codmkidx->length != COD->Lcod){
|
||||
fprintf( FCGI_stderr, "Error: marker %#x index is not correct\n", codmkidx->code);
|
||||
return false;
|
||||
}
|
||||
|
||||
COD->Scod = fetch_marker1byte( codmkr, 2);
|
||||
COD->prog_order = fetch_marker1byte( codmkr, 3);
|
||||
COD->numOflayers = fetch_marker2bytebigendian( codmkr, 4);
|
||||
COD->numOfdecomp = fetch_marker1byte( codmkr, 7);
|
||||
|
||||
if(COD->Scod & 0x01){
|
||||
COD->XPsiz = (Byte4_t *)malloc( (COD->numOfdecomp+1)*sizeof(Byte4_t));
|
||||
COD->YPsiz = (Byte4_t *)malloc( (COD->numOfdecomp+1)*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<=COD->numOfdecomp; i++){
|
||||
/*precinct size*/
|
||||
COD->XPsiz[i] = pow( 2, fetch_marker1byte( codmkr, 12+i) & 0x0F);
|
||||
COD->YPsiz[i] = pow( 2,(fetch_marker1byte( codmkr, 12+i) & 0xF0) >> 4);
|
||||
}
|
||||
}
|
||||
else{
|
||||
COD->XPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
|
||||
COD->YPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
|
||||
|
||||
COD->XPsiz[0] = COD->YPsiz[0] = pow(2,15);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* very very generic name see NOMINMAX */
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
Byte4_t max( Byte4_t n1, Byte4_t n2);
|
||||
Byte4_t min( Byte4_t n1, Byte4_t n2);
|
||||
|
||||
range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_XYid, int level);
|
||||
|
||||
range_param_t get_tile_Xrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
|
||||
{
|
||||
return get_tile_range( SIZ.XOsiz, SIZ.Xsiz, SIZ.XTOsiz, SIZ.XTsiz, tile_id%SIZ.XTnum, level);
|
||||
}
|
||||
|
||||
range_param_t get_tile_Yrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
|
||||
{
|
||||
return get_tile_range( SIZ.YOsiz, SIZ.Ysiz, SIZ.YTOsiz, SIZ.YTsiz, tile_id/SIZ.XTnum, level);
|
||||
}
|
||||
|
||||
range_param_t get_tile_range( Byte4_t Osiz, Byte4_t siz, Byte4_t TOsiz, Byte4_t Tsiz, Byte4_t tile_XYid, int level)
|
||||
{
|
||||
range_param_t range;
|
||||
int n;
|
||||
|
||||
range.minvalue = max( Osiz, TOsiz+tile_XYid*Tsiz);
|
||||
range.maxvalue = min( siz, TOsiz+(tile_XYid+1)*Tsiz);
|
||||
|
||||
for( n=0; n<level; n++){
|
||||
range.minvalue = ceil(range.minvalue/2.0);
|
||||
range.maxvalue = ceil(range.maxvalue/2.0);
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
|
||||
{
|
||||
range_param_t tile_Xrange;
|
||||
|
||||
tile_Xrange = get_tile_Xrange( SIZ, tile_id, level);
|
||||
return tile_Xrange.maxvalue - tile_Xrange.minvalue;
|
||||
}
|
||||
|
||||
Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level)
|
||||
{
|
||||
range_param_t tile_Yrange;
|
||||
|
||||
tile_Yrange = get_tile_Yrange( SIZ, tile_id, level);
|
||||
return tile_Yrange.maxvalue - tile_Yrange.minvalue;
|
||||
}
|
||||
|
||||
/* TODO: what is this code doing ? will all compiler be able to optimize the following ? */
|
||||
Byte4_t max( Byte4_t n1, Byte4_t n2)
|
||||
{
|
||||
if( n1 < n2)
|
||||
return n2;
|
||||
else
|
||||
return n1;
|
||||
}
|
||||
|
||||
Byte4_t min( Byte4_t n1, Byte4_t n2)
|
||||
{
|
||||
if( n1 < n2)
|
||||
return n1;
|
||||
else
|
||||
return n2;
|
||||
}
|
||||
|
||||
bool isJPTfeasible( index_param_t index)
|
||||
{
|
||||
if( 1 < get_nmax( index.tilepart))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "j2kheader_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
|
||||
CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream);
|
||||
|
||||
bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, CODmarker_param_t *COD)
|
||||
{
|
||||
if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){
|
||||
fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SIZ){
|
||||
*SIZ = get_SIZmkrdata_from_j2kstream( j2kstream);
|
||||
if( SIZ->Lsiz == 0)
|
||||
return false;
|
||||
|
||||
j2kstream += (SIZ->Lsiz+2);
|
||||
}
|
||||
|
||||
if( COD){
|
||||
if( !SIZ)
|
||||
j2kstream += (big2( j2kstream+2) + 2);
|
||||
|
||||
*COD = get_CODmkrdata_from_j2kstream( j2kstream);
|
||||
if( COD->Lcod == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
|
||||
{
|
||||
SIZmarker_param_t SIZ ={0};
|
||||
int i;
|
||||
|
||||
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
||||
fprintf( FCGI_stderr, "Error, SIZ marker not found in the reconstructed j2kstream\n");
|
||||
return SIZ;
|
||||
}
|
||||
|
||||
SIZ.Lsiz = big2( SIZstream);
|
||||
SIZ.Rsiz = big2( SIZstream+2);
|
||||
SIZ.Xsiz = big4( SIZstream+4);
|
||||
SIZ.Ysiz = big4( SIZstream+8);
|
||||
SIZ.XOsiz = big4( SIZstream+12);
|
||||
SIZ.YOsiz = big4( SIZstream+16);
|
||||
SIZ.XTsiz = big4( SIZstream+20);
|
||||
SIZ.YTsiz = big4( SIZstream+24);
|
||||
SIZ.XTOsiz = big4( SIZstream+28);
|
||||
SIZ.YTOsiz = big4( SIZstream+32);
|
||||
SIZ.Csiz = big2( SIZstream+36);
|
||||
|
||||
SIZ.XTnum = ( SIZ.Xsiz-SIZ.XTOsiz+SIZ.XTsiz-1)/SIZ.XTsiz;
|
||||
SIZ.YTnum = ( SIZ.Ysiz-SIZ.YTOsiz+SIZ.YTsiz-1)/SIZ.YTsiz;
|
||||
|
||||
for( i=0; i<(int)SIZ.Csiz; i++){
|
||||
SIZ.Ssiz[i] = *(SIZstream+(38+i*3));
|
||||
SIZ.XRsiz[i] = *(SIZstream+(39+i*3));
|
||||
SIZ.YRsiz[i] = *(SIZstream+(40+i*3));
|
||||
}
|
||||
|
||||
return SIZ;
|
||||
}
|
||||
|
||||
CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
||||
{
|
||||
CODmarker_param_t COD;
|
||||
int i;
|
||||
|
||||
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
||||
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
||||
return COD;
|
||||
}
|
||||
|
||||
COD.Lcod = big2( CODstream);
|
||||
COD.Scod = *( CODstream+2);
|
||||
COD.prog_order = *( CODstream+3);
|
||||
COD.numOflayers = big2( CODstream+4);
|
||||
COD.numOfdecomp = *( CODstream+7);
|
||||
|
||||
if(COD.Scod & 0x01){
|
||||
COD.XPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
||||
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<=COD.numOfdecomp; i++){
|
||||
//precinct size
|
||||
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
|
||||
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
|
||||
}
|
||||
}
|
||||
else{
|
||||
COD.XPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
|
||||
COD.YPsiz = (Byte4_t *)malloc( sizeof(Byte4_t));
|
||||
COD.XPsiz[0] = COD.YPsiz[0] = pow(2,15);
|
||||
}
|
||||
return COD;
|
||||
}
|
||||
|
||||
|
||||
bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream);
|
||||
Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *CODstream);
|
||||
|
||||
bool modify_mainheader( Byte_t *j2kstream, int numOfdecomp, SIZmarker_param_t SIZ, CODmarker_param_t COD, Byte8_t *j2klen)
|
||||
{
|
||||
Byte2_t newLcod;
|
||||
|
||||
if( *j2kstream++ != 0xff || *j2kstream++ != 0x4f){
|
||||
fprintf( FCGI_stderr, "Error, j2kstream is not starting with SOC marker\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!modify_SIZmkrstream( SIZ, COD.numOfdecomp-numOfdecomp, j2kstream))
|
||||
return false;
|
||||
|
||||
j2kstream += SIZ.Lsiz+2;
|
||||
if( !(newLcod = modify_CODmkrstream( COD, numOfdecomp, j2kstream)))
|
||||
return false;
|
||||
|
||||
memmove( j2kstream+2+newLcod, j2kstream+2+COD.Lcod, (*j2klen)-(SIZ.Lsiz+COD.Lcod+6));
|
||||
*j2klen -= ( COD.Lcod - newLcod);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZstream)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
||||
fprintf( FCGI_stderr, "Error, SIZ marker not found in the reconstructed j2kstream\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for( i=0; i<difOfdecomplev; i++){
|
||||
SIZ.Xsiz = ceil( (double)SIZ.Xsiz/2.0);
|
||||
SIZ.Ysiz = ceil( (double)SIZ.Ysiz/2.0);
|
||||
SIZ.XOsiz = ceil( (double)SIZ.XOsiz/2.0);
|
||||
SIZ.YOsiz = ceil( (double)SIZ.YOsiz/2.0);
|
||||
SIZ.XTsiz = ceil( (double)SIZ.XTsiz/2.0);
|
||||
SIZ.YTsiz = ceil( (double)SIZ.YTsiz/2.0);
|
||||
SIZ.XTOsiz = ceil( (double)SIZ.XTOsiz/2.0);
|
||||
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
|
||||
}
|
||||
|
||||
SIZstream += 4; // skip Lsiz + Rsiz
|
||||
|
||||
modify_4Bytecode( SIZ.Xsiz, SIZstream);
|
||||
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
|
||||
modify_4Bytecode( SIZ.XOsiz, SIZstream+8);
|
||||
modify_4Bytecode( SIZ.YOsiz, SIZstream+12);
|
||||
modify_4Bytecode( SIZ.XTsiz, SIZstream+16);
|
||||
modify_4Bytecode( SIZ.YTsiz, SIZstream+20);
|
||||
modify_4Bytecode( SIZ.XTOsiz, SIZstream+24);
|
||||
modify_4Bytecode( SIZ.YTOsiz, SIZstream+28);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *CODstream)
|
||||
{
|
||||
Byte2_t newLcod;
|
||||
|
||||
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
||||
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( COD.Scod & 0x01){
|
||||
newLcod = 13+numOfdecomp;
|
||||
|
||||
*CODstream++ = (Byte_t)((Byte2_t)(newLcod & 0xff00) >> 8);
|
||||
*CODstream++ = (Byte_t)(newLcod & 0x00ff);
|
||||
}
|
||||
else{
|
||||
newLcod = COD.Lcod;
|
||||
CODstream += 2;
|
||||
}
|
||||
|
||||
CODstream += 5; // skip Scod & SGcod
|
||||
|
||||
// SPcod
|
||||
*CODstream++ = (Byte_t) numOfdecomp;
|
||||
|
||||
return newLcod;
|
||||
}
|
||||
|
||||
bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte2_t *oldLcoc, Byte2_t *newLcoc);
|
||||
|
||||
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
|
||||
{
|
||||
Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
|
||||
Byte_t *thstream, *SOTstream, *Psot_stream;
|
||||
Byte2_t oldLcoc, newLcoc;
|
||||
|
||||
SOTstream = thstream = j2kstream+SOToffset;
|
||||
|
||||
if( *SOTstream++ != 0xff || *SOTstream++ != 0x90){
|
||||
fprintf( FCGI_stderr, "Error, thstream is not starting with SOT marker\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
SOTstream += 4; // skip Lsot & Isot
|
||||
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
|
||||
Psot_stream = SOTstream;
|
||||
|
||||
thstream += 12; // move to next marker (SOT always 12bytes)
|
||||
|
||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
|
||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
|
||||
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
|
||||
return false;
|
||||
|
||||
memmove( thstream+newLcoc+2, thstream+oldLcoc+2, (*j2klen)-(thstream-j2kstream+oldLcoc+2));
|
||||
*j2klen -= ( oldLcoc - newLcoc);
|
||||
}
|
||||
thstream += 2;
|
||||
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
|
||||
}
|
||||
|
||||
if( (*j2klen)-SOToffset != Psot){
|
||||
Psot = (*j2klen)-SOToffset;
|
||||
modify_4Bytecode( Psot, Psot_stream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte2_t *oldLcoc, Byte2_t *newLcoc)
|
||||
{
|
||||
if( *COCstream++ != 0xff || *COCstream++ != 0x53){
|
||||
fprintf( FCGI_stderr, "Error, COC marker not found in the reconstructed j2kstream\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
*oldLcoc = big2( COCstream);
|
||||
*newLcoc = (Csiz < 257 ? 10 : 11) + numOfdecomp;
|
||||
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
|
||||
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
|
||||
|
||||
if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
|
||||
else COCstream += 3;
|
||||
|
||||
*COCstream = numOfdecomp;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* $Id: jp2k_decoder.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "jp2k_decoder.h"
|
||||
#include "openjpeg.h"
|
||||
|
||||
|
||||
void error_callback(const char *msg, void *client_data);
|
||||
void warning_callback(const char *msg, void *client_data);
|
||||
void info_callback(const char *msg, void *client_data);
|
||||
|
||||
Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox);
|
||||
|
||||
Byte_t * j2k_to_pnm( Byte_t *j2kstream, Byte8_t j2klen, ihdrbox_param_t **ihdrbox)
|
||||
{
|
||||
Byte_t *pnmstream = NULL;
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = 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;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
/* JPEG-2000 codestream */
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress( CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, j2kstream, j2klen);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
image = opj_decode(dinfo, cio);
|
||||
|
||||
fprintf(stderr, "image is decoded!\n");
|
||||
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* create output image */
|
||||
/* ------------------- */
|
||||
if( (pnmstream = imagetopnm( image, ihdrbox))==NULL)
|
||||
fprintf( stderr, "PNM image not generated\n");
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
return pnmstream;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
// fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
|
||||
Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
|
||||
{
|
||||
int adjustR, adjustG=0, adjustB=0;
|
||||
int datasize;
|
||||
Byte_t *pix=NULL, *ptr=NULL;
|
||||
int i;
|
||||
|
||||
if(*ihdrbox){
|
||||
if( (*ihdrbox)->nc != image->numcomps)
|
||||
fprintf( stderr, "Exception: num of components not identical, codestream: %d, ihdrbox: %d\n", image->numcomps, (*ihdrbox)->nc);
|
||||
|
||||
if( (*ihdrbox)->width != image->comps[0].w)
|
||||
(*ihdrbox)->width = image->comps[0].w;
|
||||
|
||||
if( (*ihdrbox)->height != image->comps[0].h)
|
||||
(*ihdrbox)->height = image->comps[0].h;
|
||||
|
||||
if( (*ihdrbox)->bpc != image->comps[0].prec)
|
||||
fprintf( stderr, "Exception: bits per component not identical, codestream: %d, ihdrbox: %d\n", image->comps[0].prec, (*ihdrbox)->bpc);
|
||||
}
|
||||
else{
|
||||
*ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t));
|
||||
(*ihdrbox)->width = image->comps[0].w;
|
||||
(*ihdrbox)->height = image->comps[0].h;
|
||||
(*ihdrbox)->bpc = image->comps[0].prec;
|
||||
(*ihdrbox)->nc = image->numcomps;
|
||||
}
|
||||
|
||||
datasize = (image->numcomps)*(image->comps[0].w)*(image->comps[0].h);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = image->comps[0].prec - 8;
|
||||
printf("PNM CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
}
|
||||
else
|
||||
adjustR = 0;
|
||||
|
||||
if( image->numcomps == 3){
|
||||
if (image->comps[1].prec > 8) {
|
||||
adjustG = image->comps[1].prec - 8;
|
||||
printf("PNM 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 = image->comps[2].prec - 8;
|
||||
printf("PNM CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
|
||||
}
|
||||
else
|
||||
adjustB = 0;
|
||||
}
|
||||
|
||||
pix = (Byte_t *)malloc( datasize);
|
||||
ptr = pix;
|
||||
|
||||
for( i = 0; i < image->comps[0].w * image->comps[0].h; i++){
|
||||
int r, g, b;
|
||||
r = image->comps[0].data[i];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
|
||||
// if( adjustR > 0)
|
||||
*(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
|
||||
if( image->numcomps == 3){
|
||||
g = image->comps[1].data[i];
|
||||
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||
*(ptr++) = (Byte_t) ((g >> adjustG)+((g >> (adjustG-1))%2));
|
||||
|
||||
b = image->comps[2].data[i];
|
||||
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
|
||||
*(ptr++) = (Byte_t) ((b >> adjustB)+((b >> (adjustB-1))%2));
|
||||
}
|
||||
}
|
||||
|
||||
return pix;
|
||||
}
|
||||
@@ -1,797 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "jp2k_encoder.h"
|
||||
#include "j2kheader_manager.h"
|
||||
#include "imgreg_manager.h"
|
||||
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
/**
|
||||
* search a message by class_id
|
||||
*
|
||||
* @param[in] class_id class identifiers
|
||||
* @param[in] in_class_id in-class identifiers, -1 means any
|
||||
* @param[in] csn codestream number
|
||||
* @param[in] msg first message pointer of the searching list
|
||||
* @return found message pointer
|
||||
*/
|
||||
message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg);
|
||||
|
||||
/**
|
||||
* reconstruct j2k codestream from JPT- (in future, JPP-) stream
|
||||
*
|
||||
* @param[in] msgqueue message queue pointer
|
||||
* @param[in] jpipstream original JPT- JPP- stream
|
||||
* @param[in] csn codestream number
|
||||
* @param[in] fw reconstructing image frame width
|
||||
* @param[in] fh reconstructing image frame height
|
||||
* @param[out] codelen codestream length
|
||||
* @return generated reconstructed j2k codestream
|
||||
*/
|
||||
Byte_t * recons_codestream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *codelen);
|
||||
|
||||
Byte_t * recons_j2k( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *j2kstream = NULL;
|
||||
|
||||
if( !msgqueue)
|
||||
return NULL;
|
||||
|
||||
j2kstream = recons_codestream( msgqueue, jpipstream, csn, fw, fh, j2klen);
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * add_emptyboxstream( placeholder_param_t *phld, Byte_t *jp2stream, Byte8_t *jp2len);
|
||||
Byte_t * add_msgstream( message_param_t *message, Byte_t *origstream, Byte_t *j2kstream, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, Byte8_t *jp2len)
|
||||
{
|
||||
message_param_t *ptr;
|
||||
Byte_t *jp2stream = NULL;
|
||||
Byte_t *codestream = NULL;
|
||||
Byte8_t codelen;
|
||||
Byte8_t jp2cDBoxOffset = 0, jp2cDBoxlen = 0;
|
||||
|
||||
*jp2len = 0;
|
||||
|
||||
if( !msgqueue)
|
||||
return NULL;
|
||||
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( METADATA_MSG, -1, csn, ptr))!=NULL){
|
||||
if( ptr->phld){
|
||||
if( strncmp( (char *)ptr->phld->OrigBH+4, "jp2c", 4) == 0){
|
||||
jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen;
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
||||
jp2cDBoxlen = *jp2len - jp2cDBoxOffset;
|
||||
}
|
||||
else
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
||||
}
|
||||
jp2stream = add_msgstream( ptr, jpipstream, jp2stream, jp2len);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
codestream = recons_codestream( msgqueue, jpipstream, csn, 0, 0, &codelen);
|
||||
|
||||
if( jp2cDBoxOffset != 0 && codelen <= jp2cDBoxlen)
|
||||
memcpy( jp2stream+jp2cDBoxOffset, codestream, codelen);
|
||||
|
||||
free( codestream);
|
||||
|
||||
return jp2stream;
|
||||
}
|
||||
|
||||
bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue);
|
||||
|
||||
Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen);
|
||||
Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * add_EOC( Byte_t *j2kstream, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_codestream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *codelen)
|
||||
{
|
||||
if( isJPPstream( csn, msgqueue))
|
||||
return recons_codestream_from_JPPstream( msgqueue, jpipstream, csn, fw, fh, codelen);
|
||||
else
|
||||
return recons_codestream_from_JPTstream( msgqueue, jpipstream, csn, fw, fh, codelen);
|
||||
}
|
||||
|
||||
bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
message_param_t *msg;
|
||||
|
||||
msg = msgqueue->first;
|
||||
while( msg){
|
||||
if( msg->csn == csn){
|
||||
if( msg->class_id <= 2)
|
||||
return true;
|
||||
else
|
||||
if( msg->class_id == 4 || msg->class_id == 5)
|
||||
return false;
|
||||
}
|
||||
msg = msg->next;
|
||||
}
|
||||
|
||||
fprintf( FCGI_stderr, "Error, message of csn %lld not found\n", csn);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Byte_t * add_mainhead_msgstream( msgqueue_param_t *msgqueue, Byte_t *origstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t *j2klen);
|
||||
Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstream);
|
||||
Byte_t * add_emptytilestream( const Byte8_t tileID, Byte_t *j2kstream, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *j2kstream = NULL;
|
||||
Byte8_t last_tileID, tileID;
|
||||
bool found;
|
||||
Byte8_t binOffset;
|
||||
message_param_t *ptr;
|
||||
SIZmarker_param_t SIZ;
|
||||
int mindeclev;
|
||||
|
||||
*j2klen = 0;
|
||||
j2kstream = add_mainhead_msgstream( msgqueue, jpipstream, j2kstream, csn, j2klen);
|
||||
|
||||
if( !get_mainheader_from_j2kstream( j2kstream, &SIZ, NULL))
|
||||
return j2kstream;
|
||||
|
||||
if( fw <= 0 || fh <= 0)
|
||||
mindeclev = 0;
|
||||
else
|
||||
mindeclev = comp_decomplev( fw, fh, SIZ.Xsiz, SIZ.Ysiz);
|
||||
|
||||
last_tileID = get_last_tileID( msgqueue, csn, false);
|
||||
|
||||
for( tileID=0; tileID <= last_tileID; tileID++){
|
||||
found = false;
|
||||
binOffset = 0;
|
||||
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
found = true;
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||
if( ptr->aux > mindeclev){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
found = true;
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if(!found)
|
||||
j2kstream = add_emptytilestream( tileID, j2kstream, j2klen);
|
||||
}
|
||||
|
||||
j2kstream = add_EOC( j2kstream, j2klen);
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * add_SOTmkr( Byte_t *j2kstream, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_bitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_codestream_from_JPPstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *j2kstream = NULL;
|
||||
Byte8_t tileID, last_tileID;
|
||||
Byte8_t SOToffset;
|
||||
bool foundTH;
|
||||
Byte8_t binOffset;
|
||||
message_param_t *ptr;
|
||||
SIZmarker_param_t SIZ;
|
||||
CODmarker_param_t COD;
|
||||
int max_reslev, mindeclev;
|
||||
|
||||
*j2klen = 0;
|
||||
j2kstream = add_mainhead_msgstream( msgqueue, jpipstream, j2kstream, csn, j2klen);
|
||||
|
||||
if( !get_mainheader_from_j2kstream( j2kstream, &SIZ, &COD))
|
||||
return j2kstream;
|
||||
|
||||
if( fw == 0 || fh == 0)
|
||||
mindeclev = 0;
|
||||
else
|
||||
mindeclev = comp_decomplev( fw, fh, SIZ.Xsiz, SIZ.Ysiz);
|
||||
|
||||
max_reslev = -1;
|
||||
last_tileID = get_last_tileID( msgqueue, csn, true);
|
||||
|
||||
for( tileID=0; tileID <= last_tileID; tileID++){
|
||||
|
||||
ptr = msgqueue->first;
|
||||
binOffset = 0;
|
||||
foundTH = false;
|
||||
SOToffset = *j2klen;
|
||||
while(( ptr = search_message( TILE_HEADER_MSG, tileID, csn, ptr))!=NULL){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
j2kstream = add_SOTmkr( j2kstream, j2klen);
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
foundTH = true;
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
if( foundTH){
|
||||
j2kstream = recons_bitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, &max_reslev, j2klen);
|
||||
modify_tileheader( j2kstream, SOToffset, (max_reslev<COD.numOfdecomp ? max_reslev : -1), SIZ.Csiz, j2klen);
|
||||
}
|
||||
else
|
||||
j2kstream = add_emptytilestream( tileID, j2kstream, j2klen);
|
||||
}
|
||||
|
||||
if( max_reslev < COD.numOfdecomp)
|
||||
if( !modify_mainheader( j2kstream, max_reslev, SIZ, COD, j2klen)){
|
||||
delete_COD( COD);
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
j2kstream = add_EOC( j2kstream, j2klen);
|
||||
delete_COD( COD);
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * add_mainhead_msgstream( msgqueue_param_t *msgqueue, Byte_t *origstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t *j2klen)
|
||||
{
|
||||
message_param_t *ptr;
|
||||
Byte8_t binOffset;
|
||||
|
||||
ptr = msgqueue->first;
|
||||
binOffset = 0;
|
||||
|
||||
while(( ptr = search_message( MAINHEADER_MSG, -1, csn, ptr))!=NULL){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
j2kstream = add_msgstream( ptr, origstream, j2kstream, j2klen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * add_SOTmkr( Byte_t *j2kstream, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *buf;
|
||||
const Byte2_t SOT = 0x90ff;
|
||||
|
||||
buf = (Byte_t *)malloc(( *j2klen)+2);
|
||||
|
||||
memcpy( buf, j2kstream, *j2klen);
|
||||
memcpy( buf+(*j2klen), &SOT, 2);
|
||||
|
||||
*j2klen += 2;
|
||||
|
||||
if(j2kstream) free(j2kstream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * recons_LRCPbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_RLCPbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_RPCLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_PCRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_CPRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_bitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
switch( COD.prog_order){
|
||||
case LRCP:
|
||||
return recons_LRCPbitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, max_reslev, j2klen);
|
||||
case RLCP:
|
||||
return recons_RLCPbitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, max_reslev, j2klen);
|
||||
case RPCL:
|
||||
return recons_RPCLbitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, max_reslev, j2klen);
|
||||
case PCRL:
|
||||
return recons_PCRLbitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, max_reslev, j2klen);
|
||||
case CPRL:
|
||||
return recons_CPRLbitstream( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, mindeclev, max_reslev, j2klen);
|
||||
default:
|
||||
fprintf( FCGI_stderr, "Error, progression order not supported\n");
|
||||
}
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
int comp_numOfprcts( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r);
|
||||
Byte8_t comp_seqID( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r, int p);
|
||||
|
||||
Byte_t * recons_packet( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev,
|
||||
int comp_idx, int res_idx, int prct_idx, int lay_idx, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_LRCPbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
int r, p, c, l, numOfprcts;
|
||||
|
||||
for( l=0; l<COD.numOflayers; l++)
|
||||
for( r=0; r<=(COD.numOfdecomp-mindeclev); r++){
|
||||
if( COD.Scod & 0x01)
|
||||
numOfprcts = comp_numOfprcts( tileID, SIZ, COD, r);
|
||||
else
|
||||
numOfprcts = 1;
|
||||
|
||||
for( c=0; c<SIZ.Csiz; c++)
|
||||
for( p=0; p<numOfprcts; p++)
|
||||
j2kstream = recons_packet( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, max_reslev, c, r, p, l, j2klen);
|
||||
}
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * recons_RLCPbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
int r, p, c, l, numOfprcts;
|
||||
|
||||
for( r=0; r<=(COD.numOfdecomp-mindeclev); r++){
|
||||
if( COD.Scod & 0x01)
|
||||
numOfprcts = comp_numOfprcts( tileID, SIZ, COD, r);
|
||||
else
|
||||
numOfprcts = 1;
|
||||
|
||||
for( l=0; l<COD.numOflayers; l++)
|
||||
for( c=0; c<SIZ.Csiz; c++)
|
||||
for( p=0; p<numOfprcts; p++)
|
||||
j2kstream = recons_packet( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, max_reslev, c, r, p, l, j2klen);
|
||||
}
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * recons_precinct( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev,
|
||||
int comp_idx, int res_idx, Byte8_t seqID, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_RPCLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
int r, p, c, numOfprcts;
|
||||
Byte8_t seqID;
|
||||
|
||||
for( r=0, seqID=0; r<=(COD.numOfdecomp-mindeclev); r++){
|
||||
|
||||
if( COD.Scod & 0x01)
|
||||
numOfprcts = comp_numOfprcts( tileID, SIZ, COD, r);
|
||||
else
|
||||
numOfprcts = 1;
|
||||
|
||||
for( p=0; p<numOfprcts; p++, seqID++)
|
||||
for( c=0; c<SIZ.Csiz; c++)
|
||||
j2kstream = recons_precinct( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, max_reslev, c, r, seqID, j2klen);
|
||||
}
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte_t * recons_PCRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
int r, p, c, min_numOfprcts, numOfprcts, min_numOfres;
|
||||
Byte8_t seqID;
|
||||
|
||||
min_numOfres = COD.numOfdecomp-mindeclev + 1;
|
||||
|
||||
if( COD.Scod & 0x01){
|
||||
min_numOfprcts = 0;
|
||||
for( r=0; r<min_numOfres; r++){
|
||||
numOfprcts = comp_numOfprcts( tileID, SIZ, COD, r);
|
||||
|
||||
if( numOfprcts < min_numOfprcts || min_numOfprcts == 0)
|
||||
min_numOfprcts = numOfprcts;
|
||||
}
|
||||
}
|
||||
else
|
||||
min_numOfprcts = 1;
|
||||
|
||||
for( p=0; p<min_numOfprcts; p++)
|
||||
for( c=0; c<SIZ.Csiz; c++)
|
||||
for( r=0; r<min_numOfres; r++){
|
||||
seqID = comp_seqID( tileID, SIZ, COD, r, p);
|
||||
j2kstream = recons_precinct( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, max_reslev, c, r, seqID, j2klen);
|
||||
}
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
|
||||
Byte_t * recons_CPRLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
|
||||
int *max_reslev, Byte8_t *j2klen)
|
||||
{
|
||||
int r, p, c, min_numOfprcts, numOfprcts, min_numOfres;
|
||||
Byte8_t seqID;
|
||||
|
||||
min_numOfres = COD.numOfdecomp-mindeclev + 1;
|
||||
|
||||
if( COD.Scod & 0x01){
|
||||
min_numOfprcts = 0;
|
||||
for( r=0; r<min_numOfres; r++){
|
||||
numOfprcts = comp_numOfprcts( tileID, SIZ, COD, r);
|
||||
|
||||
if( numOfprcts < min_numOfprcts || min_numOfprcts == 0)
|
||||
min_numOfprcts = numOfprcts;
|
||||
}
|
||||
}
|
||||
else
|
||||
min_numOfprcts = 1;
|
||||
|
||||
for( c=0; c<SIZ.Csiz; c++)
|
||||
for( p=0; p<min_numOfprcts; p++)
|
||||
for( r=0; r<min_numOfres; r++){
|
||||
seqID = comp_seqID( tileID, SIZ, COD, r, p);
|
||||
j2kstream = recons_precinct( msgqueue, jpipstream, j2kstream, csn, tileID, SIZ, COD, max_reslev, c, r, seqID, j2klen);
|
||||
}
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
int comp_numOfprcts( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r)
|
||||
{
|
||||
Byte4_t XTsiz, YTsiz;
|
||||
|
||||
XTsiz = get_tile_XSiz( SIZ, tileID, COD.numOfdecomp-r);
|
||||
YTsiz = get_tile_YSiz( SIZ, tileID, COD.numOfdecomp-r);
|
||||
|
||||
return ceil((double)XTsiz/(double)COD.XPsiz[r])*ceil((double)YTsiz/(double)COD.YPsiz[r]);
|
||||
}
|
||||
|
||||
Byte_t * add_padding( Byte8_t padding, Byte_t *j2kstream, Byte8_t *j2klen);
|
||||
|
||||
Byte_t * recons_packet( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev,
|
||||
int comp_idx, int res_idx, int prct_idx, int lay_idx, Byte8_t *j2klen)
|
||||
{
|
||||
Byte8_t seqID, precID, binOffset;
|
||||
message_param_t *ptr;
|
||||
bool foundPrec;
|
||||
int l;
|
||||
|
||||
seqID = comp_seqID( tileID, SIZ, COD, res_idx, prct_idx);
|
||||
precID = comp_precinct_id( tileID, comp_idx, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum);
|
||||
|
||||
ptr = msgqueue->first;
|
||||
binOffset = 0;
|
||||
foundPrec = false;
|
||||
l = 0;
|
||||
|
||||
while(( ptr = search_message( PRECINCT_MSG, precID, csn, ptr))!=NULL){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
if( lay_idx == l){
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
foundPrec = true;
|
||||
if( *max_reslev < res_idx)
|
||||
*max_reslev = res_idx;
|
||||
|
||||
break;
|
||||
}
|
||||
binOffset += ptr->length;
|
||||
l++;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if( !foundPrec && COD.Scod & 0x01)
|
||||
j2kstream = add_padding( 1, j2kstream, j2klen);
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
|
||||
Byte_t * recons_precinct( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn,
|
||||
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev,
|
||||
int comp_idx, int res_idx, Byte8_t seqID, Byte8_t *j2klen)
|
||||
{
|
||||
Byte8_t precID, binOffset;
|
||||
message_param_t *ptr;
|
||||
bool foundPrec;
|
||||
|
||||
precID = comp_precinct_id( tileID, comp_idx, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum);
|
||||
|
||||
ptr = msgqueue->first;
|
||||
binOffset = 0;
|
||||
foundPrec = false;
|
||||
|
||||
while(( ptr = search_message( PRECINCT_MSG, precID, csn, ptr))!=NULL){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
|
||||
foundPrec = true;
|
||||
binOffset += ptr->length;
|
||||
if( *max_reslev < res_idx)
|
||||
*max_reslev = res_idx;
|
||||
|
||||
if( ptr->last_byte)
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if(!foundPrec && COD.Scod & 0x01)
|
||||
j2kstream = add_padding( COD.numOflayers, j2kstream, j2klen);
|
||||
|
||||
return j2kstream;
|
||||
}
|
||||
|
||||
Byte8_t comp_seqID( Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r, int p)
|
||||
{
|
||||
Byte8_t seqID = 0;
|
||||
int rr;
|
||||
|
||||
for( rr=0; rr<r; rr++)
|
||||
seqID += comp_numOfprcts( tileID, SIZ, COD, rr);
|
||||
|
||||
seqID += p;
|
||||
|
||||
return seqID;
|
||||
}
|
||||
|
||||
Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstream)
|
||||
{
|
||||
Byte8_t last_tileID = 0;
|
||||
message_param_t *msg;
|
||||
|
||||
msg = msgqueue->first;
|
||||
while( msg){
|
||||
if( isJPPstream){
|
||||
if((msg->class_id == TILE_HEADER_MSG) && msg->csn == csn && last_tileID < msg->in_class_id)
|
||||
last_tileID = msg->in_class_id;
|
||||
}
|
||||
else{
|
||||
if((msg->class_id == TILE_MSG || msg->class_id == EXT_TILE_MSG) && msg->csn == csn && last_tileID < msg->in_class_id)
|
||||
last_tileID = msg->in_class_id;
|
||||
}
|
||||
msg = msg->next;
|
||||
}
|
||||
return last_tileID;
|
||||
}
|
||||
|
||||
|
||||
message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg)
|
||||
{
|
||||
while( msg != NULL){
|
||||
if( in_class_id == -1){
|
||||
if( msg->class_id == class_id && msg->csn == csn)
|
||||
return msg;
|
||||
}
|
||||
else{
|
||||
if( msg->class_id == class_id && msg->in_class_id == in_class_id && msg->csn == csn)
|
||||
return msg;
|
||||
}
|
||||
msg = msg->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Byte_t * gene_msgstream( message_param_t *message, Byte_t *stream, Byte8_t *length);
|
||||
Byte_t * gene_emptytilestream( const Byte8_t tileID, Byte8_t *length);
|
||||
|
||||
Byte_t * add_msgstream( message_param_t *message, Byte_t *origstream, Byte_t *j2kstream, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *newstream;
|
||||
Byte8_t newlen;
|
||||
Byte_t *buf;
|
||||
|
||||
if( !message)
|
||||
return NULL;
|
||||
|
||||
newstream = gene_msgstream( message, origstream, &newlen);
|
||||
|
||||
buf = (Byte_t *)malloc(( *j2klen)+newlen);
|
||||
|
||||
memcpy( buf, j2kstream, *j2klen);
|
||||
memcpy( buf+(*j2klen), newstream, newlen);
|
||||
|
||||
*j2klen += newlen;
|
||||
|
||||
free( newstream);
|
||||
if(j2kstream) free(j2kstream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
Byte_t * add_emptyboxstream( placeholder_param_t *phld, Byte_t *jp2stream, Byte8_t *jp2len)
|
||||
{
|
||||
Byte_t *newstream;
|
||||
Byte8_t newlen;
|
||||
Byte_t *buf;
|
||||
|
||||
if( phld->OrigBHlen == 8)
|
||||
newlen = big4(phld->OrigBH);
|
||||
else
|
||||
newlen = big8(phld->OrigBH+8);
|
||||
|
||||
newstream = (Byte_t *)malloc( newlen);
|
||||
memset( newstream, 0, newlen);
|
||||
memcpy( newstream, phld->OrigBH, phld->OrigBHlen);
|
||||
|
||||
buf = (Byte_t *)malloc(( *jp2len)+newlen);
|
||||
|
||||
memcpy( buf, jp2stream, *jp2len);
|
||||
memcpy( buf+(*jp2len), newstream, newlen);
|
||||
|
||||
*jp2len += newlen;
|
||||
|
||||
free( newstream);
|
||||
if(jp2stream) free(jp2stream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * add_emptytilestream( const Byte8_t tileID, Byte_t *j2kstream, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *newstream;
|
||||
Byte8_t newlen;
|
||||
Byte_t *buf;
|
||||
|
||||
newstream = gene_emptytilestream( tileID, &newlen);
|
||||
|
||||
buf = (Byte_t *)malloc(( *j2klen)+newlen);
|
||||
|
||||
memcpy( buf, j2kstream, *j2klen);
|
||||
memcpy( buf+(*j2klen), newstream, newlen);
|
||||
|
||||
*j2klen += newlen;
|
||||
|
||||
free( newstream);
|
||||
if(j2kstream) free(j2kstream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * add_padding( Byte8_t padding, Byte_t *j2kstream, Byte8_t *j2klen)
|
||||
{
|
||||
Byte_t *buf;
|
||||
|
||||
buf = (Byte_t *)malloc(( *j2klen)+padding);
|
||||
|
||||
memcpy( buf, j2kstream, *j2klen);
|
||||
memset( buf+(*j2klen), 0, padding);
|
||||
|
||||
*j2klen += padding;
|
||||
|
||||
if(j2kstream) free(j2kstream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * add_EOC( Byte_t *j2kstream, Byte8_t *j2klen)
|
||||
{
|
||||
Byte2_t EOC = 0xd9ff;
|
||||
|
||||
Byte_t *buf;
|
||||
|
||||
buf = (Byte_t *)malloc(( *j2klen)+2);
|
||||
|
||||
memcpy( buf, j2kstream, *j2klen);
|
||||
memcpy( buf+(*j2klen), &EOC, 2);
|
||||
|
||||
*j2klen += 2;
|
||||
|
||||
if(j2kstream) free(j2kstream);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * gene_msgstream( message_param_t *message, Byte_t *stream, Byte8_t *length)
|
||||
{
|
||||
Byte_t *buf;
|
||||
|
||||
if( !message)
|
||||
return NULL;
|
||||
|
||||
*length = message->length;
|
||||
buf = (Byte_t *)malloc( *length);
|
||||
memcpy( buf, stream+message->res_offset, *length);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * gene_emptytilestream( const Byte8_t tileID, Byte8_t *length)
|
||||
{
|
||||
Byte_t *buf;
|
||||
const Byte2_t SOT = 0x90ff;
|
||||
const Byte2_t Lsot = 0xa << 8;
|
||||
Byte2_t Isot;
|
||||
const Byte4_t Psot = 0xe << 24;
|
||||
const Byte_t TPsot = 0, TNsot = 1;
|
||||
const Byte2_t SOD = 0x93ff;
|
||||
|
||||
*length = 14;
|
||||
buf = (Byte_t *)malloc(*length);
|
||||
|
||||
Isot = (((Byte2_t)tileID) << 8) | ((((Byte2_t)tileID) & 0xf0) >> 8);
|
||||
|
||||
memcpy( buf, &SOT, 2);
|
||||
memcpy( buf+2, &Lsot, 2);
|
||||
memcpy( buf+4, &Isot, 2);
|
||||
memcpy( buf+6, &Psot, 4);
|
||||
memcpy( buf+10, &TPsot, 1);
|
||||
memcpy( buf+11, &TNsot, 1);
|
||||
memcpy( buf+12, &SOD, 2);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Byte_t * recons_j2kmainhead( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, Byte8_t *j2klen)
|
||||
{
|
||||
*j2klen = 0;
|
||||
return add_mainhead_msgstream( msgqueue, jpipstream, NULL, csn, j2klen);
|
||||
}
|
||||
@@ -1,436 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "jpip_parser.h"
|
||||
#include "channel_manager.h"
|
||||
#include "imgreg_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
|
||||
{
|
||||
if( query_param.tid){
|
||||
if( strcmp( query_param.tid, "0") != 0 ){
|
||||
if( query_param.cid[0] != '\0'){
|
||||
fprintf( FCGI_stdout, "Reason: Target can not be specified both through tid and cid\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
if( ( *target = search_targetBytid( query_param.tid, targetlist)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( query_param.target)
|
||||
if( !( *target = search_target( query_param.target, targetlist)))
|
||||
if(!( *target = gene_target( targetlist, query_param.target)))
|
||||
return false;
|
||||
|
||||
if( *target){
|
||||
fprintf( FCGI_stdout, "JPIP-tid: %s\r\n", (*target)->tid);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stdout, "Reason: target not found\r\n");
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool associate_channel( query_param_t query_param,
|
||||
sessionlist_param_t *sessionlist,
|
||||
session_param_t **cursession,
|
||||
channel_param_t **curchannel)
|
||||
{
|
||||
if( search_session_and_channel( query_param.cid, sessionlist, cursession, curchannel)){
|
||||
|
||||
if( !query_param.cnew)
|
||||
set_channel_variable_param( query_param, *curchannel);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: process canceled\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool open_channel( query_param_t query_param,
|
||||
sessionlist_param_t *sessionlist,
|
||||
auxtrans_param_t auxtrans,
|
||||
target_param_t *target,
|
||||
session_param_t **cursession,
|
||||
channel_param_t **curchannel)
|
||||
{
|
||||
cachemodel_param_t *cachemodel = NULL;
|
||||
|
||||
if( target){
|
||||
if( !(*cursession))
|
||||
*cursession = gene_session( sessionlist);
|
||||
if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist)))
|
||||
if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target, query_param.return_type==JPPstream)))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if( *curchannel)
|
||||
cachemodel = (*curchannel)->cachemodel;
|
||||
|
||||
*curchannel = gene_channel( query_param, auxtrans, cachemodel, (*cursession)->channellist);
|
||||
if( *curchannel == NULL)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool close_channel( query_param_t query_param,
|
||||
sessionlist_param_t *sessionlist,
|
||||
session_param_t **cursession,
|
||||
channel_param_t **curchannel)
|
||||
{
|
||||
char *cclose;
|
||||
int i;
|
||||
|
||||
if( query_param.cclose[0] =='*'){
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: close all\n");
|
||||
#endif
|
||||
// all channels associatd with the session will be closed
|
||||
if( !delete_session( cursession, sessionlist))
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
// check if all entry belonging to the same session
|
||||
|
||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||
|
||||
// In case of the first entry of close cid
|
||||
if( *cursession == NULL){
|
||||
if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel))
|
||||
return false;
|
||||
}
|
||||
else // second or more entry of close cid
|
||||
if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))){
|
||||
fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// delete channels
|
||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||
*curchannel = search_channel( cclose, (*cursession)->channellist);
|
||||
delete_channel( curchannel, (*cursession)->channellist);
|
||||
}
|
||||
|
||||
if( (*cursession)->channellist->first == NULL || (*cursession)->channellist->last == NULL)
|
||||
// In case of empty session
|
||||
delete_session( cursession, sessionlist);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* enqueue tiles or precincts into the message queue
|
||||
*
|
||||
* @param[in] query_param structured query
|
||||
* @param[in] msgqueue message queue pointer
|
||||
*/
|
||||
void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue);
|
||||
|
||||
/**
|
||||
* enqueue metadata bins into the message queue
|
||||
*
|
||||
* @param[in] query_param structured query
|
||||
* @param[in] metadatalist pointer to metadata bin list
|
||||
* @param[in,out] msgqueue message queue pointer
|
||||
*/
|
||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue);
|
||||
|
||||
|
||||
bool gene_JPIPstream( query_param_t query_param,
|
||||
target_param_t *target,
|
||||
session_param_t *cursession,
|
||||
channel_param_t *curchannel,
|
||||
msgqueue_param_t **msgqueue)
|
||||
{
|
||||
index_param_t *codeidx;
|
||||
cachemodel_param_t *cachemodel;
|
||||
|
||||
if( !cursession || !curchannel){ // stateless
|
||||
if( !target)
|
||||
return false;
|
||||
if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
|
||||
return false;
|
||||
*msgqueue = gene_msgqueue( true, cachemodel);
|
||||
}
|
||||
else{ // session
|
||||
cachemodel = curchannel->cachemodel;
|
||||
target = cachemodel->target;
|
||||
*msgqueue = gene_msgqueue( false, cachemodel);
|
||||
}
|
||||
|
||||
codeidx = target->codeidx;
|
||||
|
||||
if( cachemodel->jppstream)
|
||||
fprintf( FCGI_stdout, "Content-type: image/jpp-stream\r\n");
|
||||
else
|
||||
fprintf( FCGI_stdout, "Content-type: image/jpt-stream\r\n");
|
||||
|
||||
if( query_param.layers != -1){
|
||||
if( query_param.layers > codeidx->COD.numOflayers){
|
||||
fprintf( FCGI_stdout, "JPIP-layers: %d\r\n", codeidx->COD.numOflayers);
|
||||
query_param.layers = codeidx->COD.numOflayers;
|
||||
}
|
||||
}
|
||||
|
||||
//meta
|
||||
if( query_param.box_type[0][0] != 0 && query_param.len != 0)
|
||||
enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue);
|
||||
|
||||
// image codestream
|
||||
if( query_param.fx > 0 && query_param.fy > 0){
|
||||
if( !cachemodel->mhead_model && query_param.len != 0)
|
||||
enqueue_mainheader( *msgqueue);
|
||||
enqueue_imagedata( query_param, *msgqueue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* enqueue precinct data-bins into the queue
|
||||
*
|
||||
* @param[in] xmin min x coordinate in the tile at the decomposition level
|
||||
* @param[in] xmax max x coordinate in the tile at the decomposition level
|
||||
* @param[in] ymin min y coordinate in the tile at the decomposition level
|
||||
* @param[in] ymax max y coordinate in the tile at the decomposition level
|
||||
* @param[in] tile_id tile index
|
||||
* @param[in] level decomposition level
|
||||
* @param[in] lastcomp last component number
|
||||
* @param[in] comps pointer to the array that stores the requested components
|
||||
* @param[in] layers number of quality layers
|
||||
* @param[in] msgqueue message queue
|
||||
* @return
|
||||
*/
|
||||
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue);
|
||||
|
||||
/**
|
||||
* enqueue all precincts inside a tile into the queue
|
||||
*
|
||||
* @param[in] tile_id tile index
|
||||
* @param[in] level decomposition level
|
||||
* @param[in] lastcomp last component number
|
||||
* @param[in] comps pointer to the array that stores the requested components
|
||||
* @param[in] layers number of quality layers
|
||||
* @param[in] msgqueue message queue
|
||||
* @return
|
||||
*/
|
||||
void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue);
|
||||
|
||||
void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
index_param_t *codeidx;
|
||||
imgreg_param_t imgreg;
|
||||
range_param_t tile_Xrange, tile_Yrange;
|
||||
int u, v, tile_id;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
int numOfreslev;
|
||||
|
||||
codeidx = msgqueue->cachemodel->target->codeidx;
|
||||
|
||||
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) // normally not the case
|
||||
numOfreslev = 1;
|
||||
else
|
||||
numOfreslev = codeidx->COD.numOfdecomp+1;
|
||||
|
||||
imgreg = map_viewin2imgreg( query_param.fx, query_param.fy,
|
||||
query_param.rx, query_param.ry, query_param.rw, query_param.rh,
|
||||
codeidx->SIZ.XOsiz, codeidx->SIZ.YOsiz, codeidx->SIZ.Xsiz, codeidx->SIZ.Ysiz,
|
||||
numOfreslev );
|
||||
|
||||
if( query_param.len == 0)
|
||||
return;
|
||||
|
||||
for( u=0, tile_id=0; u<codeidx->SIZ.YTnum; u++){
|
||||
tile_Yrange = get_tile_Yrange( codeidx->SIZ, tile_id, imgreg.level);
|
||||
|
||||
for( v=0; v<codeidx->SIZ.XTnum; v++, tile_id++){
|
||||
tile_Xrange = get_tile_Xrange( codeidx->SIZ, tile_id, imgreg.level);
|
||||
|
||||
if( tile_Xrange.minvalue < tile_Xrange.maxvalue && tile_Yrange.minvalue < tile_Yrange.maxvalue){
|
||||
if( tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox ||
|
||||
tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox + imgreg.sx ||
|
||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy ||
|
||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
||||
//printf("Tile completely excluded from view-window %d\n", tile_id);
|
||||
// Tile completely excluded from view-window
|
||||
}
|
||||
else if( tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox &&
|
||||
tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx &&
|
||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy &&
|
||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
||||
// Tile completely contained within view-window
|
||||
// high priority
|
||||
//printf("Tile completely contained within view-window %d\n", tile_id);
|
||||
if( msgqueue->cachemodel->jppstream){
|
||||
enqueue_tileheader( tile_id, msgqueue);
|
||||
enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||
}
|
||||
else
|
||||
enqueue_tile( tile_id, imgreg.level, msgqueue);
|
||||
}
|
||||
else{
|
||||
// Tile partially overlaps view-window
|
||||
// low priority
|
||||
//printf("Tile partially overlaps view-window %d\n", tile_id);
|
||||
if( msgqueue->cachemodel->jppstream){
|
||||
enqueue_tileheader( tile_id, msgqueue);
|
||||
|
||||
xmin = tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
|
||||
xmax = tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
|
||||
ymin = tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
|
||||
ymax = tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy ? tile_Yrange.maxvalue - tile_Yrange.minvalue -1 : imgreg.yosiz + imgreg.oy + imgreg.sy - tile_Yrange.minvalue -1;
|
||||
enqueue_precincts( xmin, xmax, ymin, ymax, tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||
}
|
||||
else
|
||||
enqueue_tile( tile_id, imgreg.level, msgqueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
index_param_t *codeidx;
|
||||
int c, u, v, res_lev, dec_lev;
|
||||
int seq_id;
|
||||
Byte4_t XTsiz, YTsiz;
|
||||
Byte4_t XPsiz, YPsiz;
|
||||
Byte4_t xminP, xmaxP, yminP, ymaxP;
|
||||
|
||||
codeidx = msgqueue->cachemodel->target->codeidx;
|
||||
|
||||
for( c=0; c<codeidx->SIZ.Csiz; c++)
|
||||
if( lastcomp == -1 /*all*/ || ( c<=lastcomp && comps[c])){
|
||||
seq_id = 0;
|
||||
for( res_lev=0, dec_lev=codeidx->COD.numOfdecomp; dec_lev>=level; res_lev++, dec_lev--){
|
||||
|
||||
XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev);
|
||||
YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev);
|
||||
|
||||
XPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.XPsiz[ res_lev] : XTsiz;
|
||||
YPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.YPsiz[ res_lev] : YTsiz;
|
||||
|
||||
for( u=0; u<ceil((double)YTsiz/(double)YPsiz); u++){
|
||||
yminP = u*YPsiz;
|
||||
ymaxP = (u+1)*YPsiz-1;
|
||||
if( YTsiz <= ymaxP)
|
||||
ymaxP = YTsiz-1;
|
||||
|
||||
for( v=0; v<ceil((double)XTsiz/(double)XPsiz); v++, seq_id++){
|
||||
xminP = v*XPsiz;
|
||||
xmaxP = (v+1)*XPsiz-1;
|
||||
if( XTsiz <= xmaxP)
|
||||
xmaxP = XTsiz-1;
|
||||
|
||||
if( xmaxP < xmin || xminP > xmax || ymaxP < ymin || yminP > ymax){
|
||||
// Precinct completely excluded from view-window
|
||||
}
|
||||
else if( xminP >= xmin && xmaxP <= xmax && yminP >= ymin && ymaxP <= ymax){
|
||||
// Precinct completely contained within view-window
|
||||
// high priority
|
||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||
}
|
||||
else{
|
||||
// Precinct partially overlaps view-window
|
||||
// low priority
|
||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
index_param_t *codeidx;
|
||||
int c, i, res_lev, dec_lev;
|
||||
int seq_id;
|
||||
Byte4_t XTsiz, YTsiz;
|
||||
Byte4_t XPsiz, YPsiz;
|
||||
|
||||
codeidx = msgqueue->cachemodel->target->codeidx;
|
||||
|
||||
for( c=0; c<codeidx->SIZ.Csiz; c++)
|
||||
if( lastcomp == -1 /*all*/ || ( c<=lastcomp && comps[c])){
|
||||
seq_id = 0;
|
||||
for( res_lev=0, dec_lev=codeidx->COD.numOfdecomp; dec_lev>=level; res_lev++, dec_lev--){
|
||||
|
||||
XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev);
|
||||
YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev);
|
||||
|
||||
XPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.XPsiz[ res_lev] : XTsiz;
|
||||
YPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.YPsiz[ res_lev] : YTsiz;
|
||||
|
||||
for( i=0; i<ceil((double)YTsiz/(double)YPsiz)*ceil((double)XTsiz/(double)XPsiz); i++, seq_id++)
|
||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
int i;
|
||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||
if( query_param.box_type[i][0] == '*'){
|
||||
// not implemented
|
||||
}
|
||||
else{
|
||||
int idx = search_metadataidx( query_param.box_type[i], metadatalist);
|
||||
|
||||
if( idx != -1)
|
||||
enqueue_metadata( idx, msgqueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "jpipstream_manager.h"
|
||||
#include "jp2k_encoder.h"
|
||||
#include "jp2k_decoder.h"
|
||||
#include "ihdrbox_manager.h"
|
||||
#include "j2kheader_manager.h"
|
||||
|
||||
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen)
|
||||
{
|
||||
Byte_t *stream = (Byte_t *)malloc( (*streamlen)+newstreamlen);
|
||||
if( *streamlen > 0)
|
||||
memcpy( stream, cache_stream, *streamlen);
|
||||
memcpy( stream+(*streamlen), newstream, newstreamlen);
|
||||
*streamlen += newstreamlen;
|
||||
|
||||
if(cache_stream)
|
||||
free( cache_stream);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
||||
{
|
||||
time_t timer;
|
||||
struct tm *t_st;
|
||||
char filename[20];
|
||||
FILE *fp;
|
||||
|
||||
time(&timer);
|
||||
t_st = localtime( &timer);
|
||||
|
||||
sprintf( filename, "%4d%02d%02d%02d%02d%02d.%.3s", t_st->tm_year+1900, t_st->tm_mon+1, t_st->tm_mday, t_st->tm_hour, t_st->tm_min, t_st->tm_sec, fmt);
|
||||
|
||||
fp = fopen( filename, "wb");
|
||||
if( fwrite( codestream, streamlen, 1, fp) != 1)
|
||||
fprintf( stderr, "Error: failed to write codestream to file %s\n", filename);
|
||||
fclose( fp);
|
||||
}
|
||||
|
||||
|
||||
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
||||
{
|
||||
Byte_t *pnmstream;
|
||||
Byte_t *j2kstream; // j2k or jp2 codestream
|
||||
Byte8_t j2klen;
|
||||
|
||||
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
|
||||
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
|
||||
|
||||
free( j2kstream);
|
||||
|
||||
return pnmstream;
|
||||
}
|
||||
|
||||
ihdrbox_param_t * get_SIZ_from_jpipstream( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn)
|
||||
{
|
||||
ihdrbox_param_t *ihdrbox;
|
||||
Byte_t *j2kstream;
|
||||
Byte8_t j2klen;
|
||||
SIZmarker_param_t SIZ;
|
||||
|
||||
j2kstream = recons_j2kmainhead( msgqueue, jpipstream, csn, &j2klen);
|
||||
if( !get_mainheader_from_j2kstream( j2kstream, &SIZ, NULL)){
|
||||
free( j2kstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t));
|
||||
|
||||
ihdrbox->width = SIZ.Xsiz;
|
||||
ihdrbox->height = SIZ.Ysiz;
|
||||
ihdrbox->nc = SIZ.Csiz;
|
||||
ihdrbox->bpc = SIZ.Ssiz[0];
|
||||
|
||||
free( j2kstream);
|
||||
|
||||
return ihdrbox;
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
/*
|
||||
* $Id: metadata_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "metadata_manager.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
metadatalist_param_t * gene_metadatalist()
|
||||
{
|
||||
metadatalist_param_t *list;
|
||||
|
||||
list = (metadatalist_param_t *)malloc( sizeof(metadatalist_param_t));
|
||||
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
metadatalist_param_t * const_metadatalist( int fd)
|
||||
{
|
||||
metadatalist_param_t *metadatalist;
|
||||
metadata_param_t *metabin;
|
||||
boxlist_param_t *toplev_boxlist;
|
||||
box_param_t *box, *next;
|
||||
placeholderlist_param_t *phldlist;
|
||||
placeholder_param_t *phld;
|
||||
int idx;
|
||||
Byte8_t filesize;
|
||||
|
||||
if(!(filesize = get_filesize( fd)))
|
||||
return NULL;
|
||||
|
||||
if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))){
|
||||
fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
phldlist = gene_placeholderlist();
|
||||
metadatalist = gene_metadatalist();
|
||||
|
||||
delete_box_in_list_by_type( "iptr", toplev_boxlist);
|
||||
delete_box_in_list_by_type( "cidx", toplev_boxlist);
|
||||
delete_box_in_list_by_type( "fidx", toplev_boxlist);
|
||||
|
||||
box = toplev_boxlist->first;
|
||||
idx = 0;
|
||||
while( box){
|
||||
next = box->next;
|
||||
if( strncmp( box->type, "jP ",4)!=0 && strncmp( box->type, "ftyp",4)!=0 && strncmp( box->type, "jp2h",4)!=0){
|
||||
boxlist_param_t *boxlist = NULL;
|
||||
boxcontents_param_t *boxcontents = NULL;
|
||||
|
||||
phld = gene_placeholder( box, ++idx);
|
||||
insert_placeholder_into_list( phld, phldlist);
|
||||
|
||||
boxlist = get_boxstructure( box->fd, get_DBoxoff( box), get_DBoxlen(box));
|
||||
if( !boxlist)
|
||||
boxcontents = gene_boxcontents( get_DBoxoff( box), get_DBoxlen(box));
|
||||
|
||||
delete_box_in_list( &box, toplev_boxlist);
|
||||
metabin = gene_metadata( idx, boxlist, NULL, boxcontents);
|
||||
insert_metadata_into_list( metabin, metadatalist);
|
||||
}
|
||||
box = next;
|
||||
}
|
||||
|
||||
metabin = gene_metadata( 0, toplev_boxlist, phldlist, NULL);
|
||||
insert_metadata_into_list( metabin, metadatalist);
|
||||
|
||||
return metadatalist;
|
||||
}
|
||||
|
||||
void delete_metadatalist( metadatalist_param_t **list)
|
||||
{
|
||||
metadata_param_t *ptr, *next;
|
||||
|
||||
ptr = (*list)->first;
|
||||
|
||||
while( ptr != NULL){
|
||||
next=ptr->next;
|
||||
delete_metadata( &ptr);
|
||||
ptr=next;
|
||||
}
|
||||
free( *list);
|
||||
}
|
||||
|
||||
metadata_param_t * gene_metadata( int idx, boxlist_param_t *boxlist, placeholderlist_param_t *phldlist, boxcontents_param_t *boxcontents)
|
||||
{
|
||||
metadata_param_t *bin;
|
||||
|
||||
bin = (metadata_param_t *)malloc( sizeof(metadata_param_t));
|
||||
bin->idx = idx;
|
||||
bin->boxlist = boxlist;
|
||||
bin->placeholderlist = phldlist;
|
||||
bin->boxcontents = boxcontents;
|
||||
bin->next = NULL;
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
void delete_metadata( metadata_param_t **metadata)
|
||||
{
|
||||
delete_boxlist( &((*metadata)->boxlist));
|
||||
delete_placeholderlist( &((*metadata)->placeholderlist));
|
||||
if((*metadata)->boxcontents)
|
||||
free((*metadata)->boxcontents);
|
||||
#ifndef SERVER
|
||||
/* fprintf( logstream, "local log: Metadata-bin: %d deleted\n", (*metadata)->idx);*/
|
||||
#endif
|
||||
free( *metadata);
|
||||
}
|
||||
|
||||
void insert_metadata_into_list( metadata_param_t *metabin, metadatalist_param_t *metadatalist)
|
||||
{
|
||||
if( metadatalist->first)
|
||||
metadatalist->last->next = metabin;
|
||||
else
|
||||
metadatalist->first = metabin;
|
||||
metadatalist->last = metabin;
|
||||
}
|
||||
|
||||
void print_metadata( metadata_param_t *metadata)
|
||||
{
|
||||
boxcontents_param_t *boxcont;
|
||||
fprintf( logstream, "metadata-bin %d info:\n", metadata->idx);
|
||||
print_allbox( metadata->boxlist);
|
||||
print_allplaceholder( metadata->placeholderlist);
|
||||
|
||||
boxcont = metadata->boxcontents;
|
||||
if( boxcont)
|
||||
fprintf( logstream, "box contents:\n"
|
||||
"\t offset: %lld %#llx\n"
|
||||
"\t length: %lld %#llx\n", boxcont->offset, boxcont->offset, boxcont->length, boxcont->length);
|
||||
}
|
||||
|
||||
void print_allmetadata( metadatalist_param_t *list)
|
||||
{
|
||||
metadata_param_t *ptr;
|
||||
|
||||
fprintf( logstream, "all metadata info: \n");
|
||||
ptr = list->first;
|
||||
while( ptr != NULL){
|
||||
print_metadata( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
boxcontents_param_t * gene_boxcontents( Byte8_t offset, Byte8_t length)
|
||||
{
|
||||
boxcontents_param_t *contents;
|
||||
|
||||
contents = (boxcontents_param_t *)malloc( sizeof(boxcontents_param_t));
|
||||
|
||||
contents->offset = offset;
|
||||
contents->length = length;
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
metadata_param_t * search_metadata( int idx, metadatalist_param_t *list)
|
||||
{
|
||||
metadata_param_t *found;
|
||||
|
||||
found = list->first;
|
||||
|
||||
while( found){
|
||||
|
||||
if( found->idx == idx)
|
||||
return found;
|
||||
|
||||
found = found->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int search_metadataidx( char boxtype[4], metadatalist_param_t *list)
|
||||
{
|
||||
metadata_param_t *ptr;
|
||||
int i;
|
||||
|
||||
for( i=0; i<4; i++)
|
||||
if( boxtype[i] == '_')
|
||||
boxtype[i] = ' ';
|
||||
|
||||
ptr = list->first;
|
||||
while( ptr){
|
||||
if( ptr->boxlist){
|
||||
box_param_t *box = ptr->boxlist->first;
|
||||
while( box){
|
||||
if( strncmp ( boxtype, box->type, 4) == 0)
|
||||
return ptr->idx;
|
||||
box = box->next;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
ptr = list->first;
|
||||
while( ptr){
|
||||
if( ptr->placeholderlist){
|
||||
placeholder_param_t *phld = ptr->placeholderlist->first;
|
||||
while( phld){
|
||||
if( strncmp ( boxtype, (char *)phld->OrigBH+4, 4) == 0){
|
||||
return phld->OrigID;
|
||||
}
|
||||
phld = phld->next;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* $Id: mhixbox_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "mhixbox_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
mhixbox_param_t * gene_mhixbox( box_param_t *box)
|
||||
{
|
||||
mhixbox_param_t *mhix;
|
||||
markeridx_param_t *mkridx, *lastmkidx;
|
||||
long pos = 0;
|
||||
|
||||
mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
|
||||
|
||||
mhix->tlen = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
|
||||
mhix->first = lastmkidx = NULL;
|
||||
while( pos < get_DBoxlen( box)){
|
||||
|
||||
mkridx = ( markeridx_param_t *)malloc( sizeof( markeridx_param_t));
|
||||
mkridx->code = fetch_DBox2bytebigendian( box, (pos+=2)-2);
|
||||
mkridx->num_remain = fetch_DBox2bytebigendian( box, (pos+=2)-2);
|
||||
mkridx->offset = fetch_DBox8bytebigendian( box, (pos+=8)-8);
|
||||
mkridx->length = fetch_DBox2bytebigendian( box, (pos+=2)-2);
|
||||
mkridx->next = NULL;
|
||||
|
||||
if( mhix->first)
|
||||
lastmkidx->next = mkridx;
|
||||
else
|
||||
mhix->first = mkridx;
|
||||
lastmkidx = mkridx;
|
||||
}
|
||||
return mhix;
|
||||
}
|
||||
|
||||
|
||||
markeridx_param_t * search_markeridx( Byte2_t code, mhixbox_param_t *mhix)
|
||||
{
|
||||
markeridx_param_t *found;
|
||||
|
||||
found = mhix->first;
|
||||
|
||||
while( found != NULL){
|
||||
|
||||
if( code == found->code)
|
||||
return found;
|
||||
|
||||
found = found->next;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Marker index %#x not found\n", code);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void print_mhixbox( mhixbox_param_t *mhix)
|
||||
{
|
||||
markeridx_param_t *ptr;
|
||||
|
||||
fprintf( logstream, "mhix box info:\n");
|
||||
fprintf( logstream, "\t tlen: %#llx\n", mhix->tlen);
|
||||
|
||||
ptr = mhix->first;
|
||||
while( ptr != NULL){
|
||||
fprintf( logstream, "marker index info:\n"
|
||||
"\t code: %#x\n"
|
||||
"\t num_remain: %#x\n"
|
||||
"\t offset: %#llx\n"
|
||||
"\t length: %#x\n", ptr->code, ptr->num_remain, ptr->offset, ptr->length);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void print_markeridx( markeridx_param_t *markeridx)
|
||||
{
|
||||
fprintf( logstream, "marker index info:\n"
|
||||
"\t code: %#x\n"
|
||||
"\t num_remain: %#x\n"
|
||||
"\t offset: %#llx\n"
|
||||
"\t length: %#x\n", markeridx->code, markeridx->num_remain, markeridx->offset, markeridx->length);
|
||||
}
|
||||
|
||||
|
||||
void delete_mhixbox( mhixbox_param_t **mhix)
|
||||
{
|
||||
markeridx_param_t *mkPtr, *mkNext;
|
||||
|
||||
mkPtr = (*mhix)->first;
|
||||
while( mkPtr != NULL){
|
||||
mkNext=mkPtr->next;
|
||||
#ifndef SERVER
|
||||
// fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code);
|
||||
#endif
|
||||
free(mkPtr);
|
||||
mkPtr=mkNext;
|
||||
}
|
||||
free(*mhix);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,747 +0,0 @@
|
||||
/*
|
||||
* $Id: msgqueue_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "msgqueue_manager.h"
|
||||
#include "metadata_manager.h"
|
||||
#include "index_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel)
|
||||
{
|
||||
msgqueue_param_t *msgqueue;
|
||||
|
||||
msgqueue = (msgqueue_param_t *)malloc( sizeof(msgqueue_param_t));
|
||||
|
||||
msgqueue->first = NULL;
|
||||
msgqueue->last = NULL;
|
||||
|
||||
msgqueue->stateless = stateless;
|
||||
msgqueue->cachemodel = cachemodel;
|
||||
|
||||
return msgqueue;
|
||||
}
|
||||
|
||||
void delete_msgqueue( msgqueue_param_t **msgqueue)
|
||||
{
|
||||
message_param_t *ptr, *next;
|
||||
|
||||
if( !(*msgqueue))
|
||||
return;
|
||||
|
||||
ptr = (*msgqueue)->first;
|
||||
|
||||
while( ptr){
|
||||
next = ptr->next;
|
||||
free( ptr);
|
||||
ptr = next;
|
||||
}
|
||||
if( (*msgqueue)->stateless && (*msgqueue)->cachemodel)
|
||||
delete_cachemodel( &((*msgqueue)->cachemodel));
|
||||
|
||||
free(*msgqueue);
|
||||
}
|
||||
|
||||
void print_msgqueue( msgqueue_param_t *msgqueue)
|
||||
{
|
||||
message_param_t *ptr;
|
||||
char *message_class[] = { "Precinct", "Ext-Prec", "TileHead", "non", "Tile", "Ext-Tile", "Main", "non", "Meta"};
|
||||
|
||||
if( !msgqueue)
|
||||
return;
|
||||
|
||||
fprintf( logstream, "message queue:\n");
|
||||
ptr = msgqueue->first;
|
||||
|
||||
while( ptr){
|
||||
fprintf( logstream, "\t class_id: %lld %s\n", ptr->class_id, message_class[ptr->class_id]);
|
||||
fprintf( logstream, "\t in_class_id: %lld\n", ptr->in_class_id );
|
||||
fprintf( logstream, "\t csn: %lld\n", ptr->csn );
|
||||
fprintf( logstream, "\t bin_offset: %#llx\n", ptr->bin_offset );
|
||||
fprintf( logstream, "\t length: %#llx\n", ptr->length );
|
||||
if( ptr->class_id%2)
|
||||
fprintf( logstream, "\t aux: %lld\n", ptr->aux );
|
||||
fprintf( logstream, "\t last_byte: %d\n", ptr->last_byte );
|
||||
if( ptr->phld)
|
||||
print_placeholder( ptr->phld);
|
||||
else
|
||||
fprintf( logstream, "\t res_offset: %#llx\n", ptr->res_offset );
|
||||
fprintf( logstream, "\n");
|
||||
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_message( message_param_t *msg, msgqueue_param_t *msgqueue);
|
||||
|
||||
void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
target_param_t *target;
|
||||
index_param_t *codeidx;
|
||||
message_param_t *msg;
|
||||
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
target = cachemodel->target;
|
||||
codeidx = target->codeidx;
|
||||
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
|
||||
msg->last_byte = true;
|
||||
msg->in_class_id = 0;
|
||||
msg->class_id = MAINHEADER_MSG;
|
||||
msg->csn = target->csn;
|
||||
msg->bin_offset = 0;
|
||||
msg->length = codeidx->mhead_length;
|
||||
msg->aux = 0; /* non exist*/
|
||||
msg->res_offset = codeidx->offset;
|
||||
msg->phld = NULL;
|
||||
msg->next = NULL;
|
||||
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
cachemodel->mhead_model = true;
|
||||
}
|
||||
|
||||
void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
target_param_t *target;
|
||||
index_param_t *codeidx;
|
||||
message_param_t *msg;
|
||||
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
target = cachemodel->target;
|
||||
codeidx = target->codeidx;
|
||||
|
||||
if( !cachemodel->th_model[ tile_id]){
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
msg->last_byte = true;
|
||||
msg->in_class_id = tile_id;
|
||||
msg->class_id = TILE_HEADER_MSG;
|
||||
msg->csn = target->csn;
|
||||
msg->bin_offset = 0;
|
||||
msg->length = codeidx->tileheader[tile_id]->tlen-2; /* SOT marker segment is removed*/
|
||||
msg->aux = 0; /* non exist*/
|
||||
msg->res_offset = codeidx->offset + get_elemOff( codeidx->tilepart, 0, tile_id) + 2; /* skip SOT marker seg*/
|
||||
msg->phld = NULL;
|
||||
msg->next = NULL;
|
||||
|
||||
enqueue_message( msg, msgqueue);
|
||||
cachemodel->th_model[ tile_id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
target_param_t *target;
|
||||
bool *tp_model;
|
||||
Byte8_t numOftparts; /* num of tile parts par tile*/
|
||||
Byte8_t numOftiles;
|
||||
index_param_t *codeidx;
|
||||
faixbox_param_t *tilepart;
|
||||
message_param_t *msg;
|
||||
Byte8_t binOffset, binLength, class_id;
|
||||
int i;
|
||||
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
target = cachemodel->target;
|
||||
codeidx = target->codeidx;
|
||||
tilepart = codeidx->tilepart;
|
||||
|
||||
numOftparts = get_nmax( tilepart);
|
||||
numOftiles = get_m( tilepart);
|
||||
|
||||
class_id = (numOftparts==1) ? TILE_MSG : EXT_TILE_MSG;
|
||||
|
||||
if( tile_id < 0 || (int)numOftiles <= tile_id){
|
||||
fprintf( FCGI_stderr, "Error, Invalid tile-id %d\n", tile_id);
|
||||
return;
|
||||
}
|
||||
|
||||
tp_model = &cachemodel->tp_model[ tile_id*numOftparts];
|
||||
|
||||
binOffset=0;
|
||||
for( i=0; i<(int)numOftparts-level; i++){
|
||||
binLength = get_elemLen( tilepart, i, tile_id);
|
||||
|
||||
if( !tp_model[i]){
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
|
||||
msg->last_byte = (i==(int)numOftparts-1);
|
||||
msg->in_class_id = tile_id;
|
||||
msg->class_id = class_id;
|
||||
msg->csn = target->csn;
|
||||
msg->bin_offset = binOffset;
|
||||
msg->length = binLength;
|
||||
msg->aux = numOftparts-i;
|
||||
msg->res_offset = codeidx->offset+get_elemOff( tilepart, i, tile_id)/*-1*/;
|
||||
msg->phld = NULL;
|
||||
msg->next = NULL;
|
||||
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
tp_model[i] = true;
|
||||
}
|
||||
binOffset += binLength;
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_precinct( int seq_id, int tile_id, int comp_id, int layers, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
index_param_t *codeidx;
|
||||
faixbox_param_t *precpacket;
|
||||
message_param_t *msg;
|
||||
Byte8_t nmax, binOffset, binLength;
|
||||
int layer_id, numOflayers;
|
||||
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
codeidx = cachemodel->target->codeidx;
|
||||
precpacket = codeidx->precpacket[ comp_id];
|
||||
numOflayers = codeidx->COD.numOflayers;
|
||||
|
||||
nmax = get_nmax(precpacket);
|
||||
if( layers < 0)
|
||||
layers = numOflayers;
|
||||
|
||||
binOffset = 0;
|
||||
for( layer_id = 0; layer_id < layers; layer_id++){
|
||||
|
||||
binLength = get_elemLen( precpacket, seq_id*numOflayers+layer_id, tile_id);
|
||||
|
||||
if( !cachemodel->pp_model[comp_id][ tile_id*nmax+seq_id*numOflayers+layer_id]){
|
||||
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
msg->last_byte = (layer_id == (numOflayers-1));
|
||||
msg->in_class_id = comp_precinct_id( tile_id, comp_id, seq_id, codeidx->SIZ.Csiz, codeidx->SIZ.XTnum * codeidx->SIZ.YTnum);
|
||||
msg->class_id = PRECINCT_MSG;
|
||||
msg->csn = cachemodel->target->csn;
|
||||
msg->bin_offset = binOffset;
|
||||
msg->length = binLength;
|
||||
msg->aux = 0;
|
||||
msg->res_offset = codeidx->offset+get_elemOff( precpacket, seq_id*numOflayers+layer_id, tile_id);
|
||||
msg->phld = NULL;
|
||||
msg->next = NULL;
|
||||
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
cachemodel->pp_model[comp_id][ tile_id*nmax+seq_id*numOflayers+layer_id] = true;
|
||||
}
|
||||
binOffset += binLength;
|
||||
}
|
||||
}
|
||||
|
||||
Byte8_t comp_precinct_id( int t, int c, int s, int num_components, int num_tiles)
|
||||
{
|
||||
return t + (c + s * num_components ) * num_tiles;
|
||||
}
|
||||
|
||||
void enqueue_box( int meta_id, boxlist_param_t *boxlist, msgqueue_param_t *msgqueue, Byte8_t *binOffset);
|
||||
void enqueue_phld( int meta_id, placeholderlist_param_t *phldlist, msgqueue_param_t *msgqueue, Byte8_t *binOffset);
|
||||
void enqueue_boxcontents( int meta_id, boxcontents_param_t *boxcontents, msgqueue_param_t *msgqueue, Byte8_t *binOffset);
|
||||
|
||||
void enqueue_metadata( int meta_id, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
metadatalist_param_t *metadatalist;
|
||||
metadata_param_t *metadata;
|
||||
Byte8_t binOffset;
|
||||
|
||||
metadatalist = msgqueue->cachemodel->target->codeidx->metadatalist;
|
||||
metadata = search_metadata( meta_id, metadatalist);
|
||||
|
||||
if( !metadata){
|
||||
fprintf( FCGI_stderr, "Error: metadata-bin %d not found\n", meta_id);
|
||||
return;
|
||||
}
|
||||
binOffset = 0;
|
||||
|
||||
if( metadata->boxlist)
|
||||
enqueue_box( meta_id, metadata->boxlist, msgqueue, &binOffset);
|
||||
|
||||
if( metadata->placeholderlist)
|
||||
enqueue_phld( meta_id, metadata->placeholderlist, msgqueue, &binOffset);
|
||||
|
||||
if( metadata->boxcontents)
|
||||
enqueue_boxcontents( meta_id, metadata->boxcontents, msgqueue, &binOffset);
|
||||
|
||||
msgqueue->last->last_byte = true;
|
||||
}
|
||||
|
||||
message_param_t * gene_metamsg( int meta_id, Byte8_t binoffset, Byte8_t length, Byte8_t res_offset, placeholder_param_t *phld, Byte8_t csn);
|
||||
|
||||
void enqueue_box( int meta_id, boxlist_param_t *boxlist, msgqueue_param_t *msgqueue, Byte8_t *binOffset)
|
||||
{
|
||||
box_param_t *box;
|
||||
message_param_t *msg;
|
||||
|
||||
box = boxlist->first;
|
||||
while( box){
|
||||
msg = gene_metamsg( meta_id, *binOffset, box->length, box->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += box->length;
|
||||
box = box->next;
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_phld( int meta_id, placeholderlist_param_t *phldlist, msgqueue_param_t *msgqueue, Byte8_t *binOffset)
|
||||
{
|
||||
placeholder_param_t *phld;
|
||||
message_param_t *msg;
|
||||
|
||||
phld = phldlist->first;
|
||||
while( phld){
|
||||
msg = gene_metamsg( meta_id, *binOffset, phld->LBox, 0, phld, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += phld->LBox;
|
||||
phld = phld->next;
|
||||
}
|
||||
}
|
||||
|
||||
void enqueue_boxcontents( int meta_id, boxcontents_param_t *boxcontents, msgqueue_param_t *msgqueue, Byte8_t *binOffset)
|
||||
{
|
||||
message_param_t *msg;
|
||||
|
||||
msg = gene_metamsg( meta_id, *binOffset, boxcontents->length, boxcontents->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += boxcontents->length;
|
||||
}
|
||||
|
||||
message_param_t * gene_metamsg( int meta_id, Byte8_t binOffset, Byte8_t length, Byte8_t res_offset, placeholder_param_t *phld, Byte8_t csn)
|
||||
{
|
||||
message_param_t *msg;
|
||||
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
|
||||
msg->last_byte = false;
|
||||
msg->in_class_id = meta_id;
|
||||
msg->class_id = METADATA_MSG;
|
||||
msg->csn = csn;
|
||||
msg->bin_offset = binOffset;
|
||||
msg->length = length;
|
||||
msg->aux = 0; /* non exist*/
|
||||
msg->res_offset = res_offset;
|
||||
msg->phld = phld;
|
||||
msg->next = NULL;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void enqueue_message( message_param_t *msg, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
if( msgqueue->first)
|
||||
msgqueue->last->next = msg;
|
||||
else
|
||||
msgqueue->first = msg;
|
||||
|
||||
msgqueue->last = msg;
|
||||
}
|
||||
|
||||
void add_bin_id_vbas_stream( Byte_t bb, Byte_t c, Byte8_t in_class_id, int tmpfd);
|
||||
void add_vbas_stream( Byte8_t code, int tmpfd);
|
||||
void add_body_stream( message_param_t *msg, int fd, int tmpfd);
|
||||
void add_placeholder_stream( placeholder_param_t *phld, int tmpfd);
|
||||
|
||||
void recons_stream_from_msgqueue( msgqueue_param_t *msgqueue, int tmpfd)
|
||||
{
|
||||
message_param_t *msg;
|
||||
Byte8_t class_id, csn;
|
||||
Byte_t bb, c;
|
||||
|
||||
if( !(msgqueue))
|
||||
return;
|
||||
|
||||
msg = msgqueue->first;
|
||||
class_id = -1;
|
||||
csn = -1;
|
||||
while( msg){
|
||||
if( msg->csn == csn){
|
||||
if( msg->class_id == class_id)
|
||||
bb = 1;
|
||||
else{
|
||||
bb = 2;
|
||||
class_id = msg->class_id;
|
||||
}
|
||||
}
|
||||
else{
|
||||
bb = 3;
|
||||
class_id = msg->class_id;
|
||||
csn = msg->csn;
|
||||
}
|
||||
|
||||
c = msg->last_byte ? 1 : 0;
|
||||
|
||||
add_bin_id_vbas_stream( bb, c, msg->in_class_id, tmpfd);
|
||||
|
||||
if( bb >= 2)
|
||||
add_vbas_stream( class_id, tmpfd);
|
||||
if (bb == 3)
|
||||
add_vbas_stream( csn, tmpfd);
|
||||
|
||||
add_vbas_stream( msg->bin_offset, tmpfd);
|
||||
add_vbas_stream (msg->length, tmpfd);
|
||||
|
||||
if( msg->class_id%2) /* Aux is present only if the id is odd*/
|
||||
add_vbas_stream( msg->aux, tmpfd);
|
||||
|
||||
if( msg->phld)
|
||||
add_placeholder_stream( msg->phld, tmpfd);
|
||||
else
|
||||
add_body_stream( msg, msgqueue->cachemodel->target->fd, tmpfd);
|
||||
|
||||
msg = msg->next;
|
||||
}
|
||||
}
|
||||
|
||||
void add_vbas_with_bytelen_stream( Byte8_t code, int bytelength, int tmpfd);
|
||||
void print_binarycode( Byte8_t n, int segmentlen);
|
||||
|
||||
void add_bin_id_vbas_stream( Byte_t bb, Byte_t c, Byte8_t in_class_id, int tmpfd)
|
||||
{
|
||||
int bytelength;
|
||||
Byte8_t tmp;
|
||||
|
||||
/* A.2.3 In-class identifiers */
|
||||
/* 7k-3bits, where k is the number of bytes in the VBAS*/
|
||||
bytelength = 1;
|
||||
tmp = in_class_id >> 4;
|
||||
while( tmp){
|
||||
bytelength ++;
|
||||
tmp >>= 7;
|
||||
}
|
||||
|
||||
in_class_id |= (((bb & 3) << 5) | (c & 1) << 4) << ((bytelength-1)*7);
|
||||
|
||||
add_vbas_with_bytelen_stream( in_class_id, bytelength, tmpfd);
|
||||
}
|
||||
|
||||
void add_vbas_stream( Byte8_t code, int tmpfd)
|
||||
{
|
||||
int bytelength;
|
||||
Byte8_t tmp;
|
||||
|
||||
bytelength = 1;
|
||||
tmp = code;
|
||||
while( tmp >>= 7)
|
||||
bytelength ++;
|
||||
|
||||
add_vbas_with_bytelen_stream( code, bytelength, tmpfd);
|
||||
}
|
||||
|
||||
void add_vbas_with_bytelen_stream( Byte8_t code, int bytelength, int tmpfd)
|
||||
{
|
||||
int n;
|
||||
Byte8_t seg;
|
||||
|
||||
n = bytelength - 1;
|
||||
while( n >= 0) {
|
||||
seg = ( code >> (n*7)) & 0x7f;
|
||||
if( n)
|
||||
seg |= 0x80;
|
||||
if( write( tmpfd, ( Byte4_t *)&seg, 1) != 1){
|
||||
fprintf( FCGI_stderr, "Error: failed to write vbas\n");
|
||||
return;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void add_body_stream( message_param_t *msg, int fd, int tmpfd)
|
||||
{
|
||||
Byte_t *data;
|
||||
|
||||
if( !(data = fetch_bytes( fd, msg->res_offset, msg->length))){
|
||||
fprintf( FCGI_stderr, "Error: fetch_bytes in add_body_stream()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if( write( tmpfd, data, msg->length) < 1){
|
||||
free( data);
|
||||
fprintf( FCGI_stderr, "Error: fwrite in add_body_stream()\n");
|
||||
return;
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
void add_bigendian_bytestream( Byte8_t code, int bytelength, int tmpfd);
|
||||
|
||||
void add_placeholder_stream( placeholder_param_t *phld, int tmpfd)
|
||||
{
|
||||
add_bigendian_bytestream( phld->LBox, 4, tmpfd);
|
||||
if( write( tmpfd, phld->TBox, 4) < 1){
|
||||
fprintf( FCGI_stderr, "Error: fwrite in add_placeholder_stream()\n");
|
||||
return;
|
||||
}
|
||||
add_bigendian_bytestream( phld->Flags, 4, tmpfd);
|
||||
add_bigendian_bytestream( phld->OrigID, 8, tmpfd);
|
||||
|
||||
if( write( tmpfd, phld->OrigBH, phld->OrigBHlen) < 1){
|
||||
fprintf( FCGI_stderr, "Error: fwrite in add_placeholder_stream()\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void add_bigendian_bytestream( Byte8_t code, int bytelength, int tmpfd)
|
||||
{
|
||||
int n;
|
||||
Byte8_t seg;
|
||||
|
||||
n = bytelength - 1;
|
||||
while( n >= 0) {
|
||||
seg = ( code >> (n*8)) & 0xff;
|
||||
if( write( tmpfd, ( Byte4_t *)&seg, 1) != 1){
|
||||
fprintf( FCGI_stderr, "ERROR: failed to write bigendian_bytestream\n");
|
||||
return;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void print_binarycode( Byte8_t n, int segmentlen)
|
||||
{
|
||||
char buf[256];
|
||||
int i=0, j, k;
|
||||
|
||||
do{
|
||||
buf[i++] = n%2 ? '1' : '0';
|
||||
}while((n=n/2));
|
||||
|
||||
for( j=segmentlen-1; j>=i; j--)
|
||||
putchar('0');
|
||||
|
||||
for( j=i-1, k=0; j>=0; j--, k++){
|
||||
putchar( buf[j]);
|
||||
if( !((k+1)%segmentlen))
|
||||
printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
Byte_t * parse_bin_id_vbas( Byte_t *streamptr, Byte_t *bb, Byte_t *c, Byte8_t *in_class_id);
|
||||
Byte_t * parse_vbas( Byte_t *streamptr, Byte8_t *elem);
|
||||
|
||||
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
Byte_t *ptr; /* stream pointer*/
|
||||
message_param_t *msg;
|
||||
Byte_t bb, c;
|
||||
Byte8_t class_id, csn;
|
||||
|
||||
class_id = -1; /* dummy*/
|
||||
csn = -1;
|
||||
ptr = JPIPstream;
|
||||
while( (Byte8_t)(ptr-JPIPstream) < streamlen){
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
|
||||
ptr = parse_bin_id_vbas( ptr, &bb, &c, &msg->in_class_id);
|
||||
|
||||
msg->last_byte = c == 1 ? true : false;
|
||||
|
||||
if( bb >= 2)
|
||||
ptr = parse_vbas( ptr, &class_id);
|
||||
|
||||
msg->class_id = class_id;
|
||||
|
||||
if (bb == 3)
|
||||
ptr = parse_vbas( ptr, &csn);
|
||||
msg->csn = csn;
|
||||
|
||||
ptr = parse_vbas( ptr, &msg->bin_offset);
|
||||
ptr = parse_vbas( ptr, &msg->length);
|
||||
|
||||
if( msg->class_id%2) /* Aux is present only if the id is odd*/
|
||||
ptr = parse_vbas( ptr, &msg->aux);
|
||||
else
|
||||
msg->aux = 0;
|
||||
|
||||
msg->res_offset = ptr-JPIPstream+offset;
|
||||
msg->phld = NULL;
|
||||
msg->next = NULL;
|
||||
|
||||
if(msgqueue->first)
|
||||
msgqueue->last->next = msg;
|
||||
else
|
||||
msgqueue->first = msg;
|
||||
msgqueue->last = msg;
|
||||
|
||||
ptr += msg->length;
|
||||
}
|
||||
}
|
||||
|
||||
void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *stream);
|
||||
|
||||
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist)
|
||||
{
|
||||
message_param_t *msg;
|
||||
(void)streamlen;
|
||||
|
||||
if( metadatalist == NULL)
|
||||
return;
|
||||
|
||||
msg = msgqueue->first;
|
||||
while( msg){
|
||||
if( msg->class_id == METADATA_MSG){
|
||||
metadata_param_t *metadata = gene_metadata( msg->in_class_id, NULL, NULL, NULL);
|
||||
insert_metadata_into_list( metadata, metadatalist);
|
||||
parse_metadata( metadata, msg, stream+msg->res_offset);
|
||||
}
|
||||
msg = msg->next;
|
||||
}
|
||||
}
|
||||
|
||||
placeholder_param_t * parse_phld( Byte_t *datastream, Byte8_t metalength);
|
||||
|
||||
void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *datastream)
|
||||
{
|
||||
box_param_t *box;
|
||||
placeholder_param_t *phld;
|
||||
char *boxtype = (char *)(datastream+4);
|
||||
|
||||
msg->phld = NULL;
|
||||
|
||||
if( strncmp( boxtype, "phld", 4) == 0){
|
||||
if( !metadata->placeholderlist)
|
||||
metadata->placeholderlist = gene_placeholderlist();
|
||||
|
||||
phld = parse_phld( datastream, msg->length);
|
||||
msg->phld = phld;
|
||||
insert_placeholder_into_list( phld, metadata->placeholderlist);
|
||||
}
|
||||
else if( isalpha(boxtype[0]) && isalpha(boxtype[1]) &&
|
||||
(isalnum(boxtype[2])||isspace(boxtype[2])) &&
|
||||
(isalpha(boxtype[3])||isspace(boxtype[3]))){
|
||||
if( !metadata->boxlist)
|
||||
metadata->boxlist = gene_boxlist();
|
||||
|
||||
box = gene_boxbyOffinStream( datastream, msg->res_offset);
|
||||
insert_box_into_list( box, metadata->boxlist);
|
||||
}
|
||||
else
|
||||
metadata->boxcontents = gene_boxcontents( msg->res_offset, msg->length);
|
||||
}
|
||||
|
||||
placeholder_param_t * parse_phld( Byte_t *datastream, Byte8_t metalength)
|
||||
{
|
||||
placeholder_param_t *phld;
|
||||
|
||||
phld = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
||||
|
||||
phld->LBox = big4( datastream);
|
||||
strcpy( phld->TBox, "phld");
|
||||
phld->Flags = big4( datastream+8);
|
||||
phld->OrigID = big8( datastream+12);
|
||||
phld->OrigBHlen = metalength - 20;
|
||||
phld->OrigBH = (Byte_t *)malloc(phld->OrigBHlen);
|
||||
memcpy( phld->OrigBH, datastream+20, phld->OrigBHlen);
|
||||
phld->next = NULL;
|
||||
|
||||
return phld;
|
||||
}
|
||||
|
||||
Byte_t * parse_bin_id_vbas( Byte_t *streamptr, Byte_t *bb, Byte_t *c, Byte8_t *in_class_id)
|
||||
{
|
||||
Byte_t code;
|
||||
Byte_t *ptr;
|
||||
|
||||
ptr = streamptr;
|
||||
code = *(ptr++);
|
||||
|
||||
*bb = (code >> 5) & 3;
|
||||
*c = (code >> 4) & 1;
|
||||
|
||||
*in_class_id = code & 15;
|
||||
|
||||
while(code >> 7){
|
||||
code = *(ptr++);
|
||||
*in_class_id = (*in_class_id << 7) | (code & 0x7f);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
Byte_t * parse_vbas( Byte_t *streamptr, Byte8_t *elem)
|
||||
{
|
||||
Byte_t code;
|
||||
Byte_t *ptr;
|
||||
|
||||
*elem = 0;
|
||||
ptr = streamptr;
|
||||
do{
|
||||
code = *(ptr++);
|
||||
*elem = (*elem << 7) | (code & 0x7f);
|
||||
}while(code >> 7);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void delete_message_in_msgqueue( message_param_t **msg, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
message_param_t *ptr;
|
||||
|
||||
if( !(*msg))
|
||||
return;
|
||||
|
||||
if( *msg == msgqueue->first)
|
||||
msgqueue->first = (*msg)->next;
|
||||
else{
|
||||
ptr = msgqueue->first;
|
||||
while( ptr->next != *msg){
|
||||
ptr=ptr->next;
|
||||
}
|
||||
|
||||
ptr->next = (*msg)->next;
|
||||
|
||||
if( *msg == msgqueue->last)
|
||||
msgqueue->last = ptr;
|
||||
}
|
||||
free( *msg);
|
||||
}
|
||||
@@ -1,446 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "openjpip.h"
|
||||
#include "jpip_parser.h"
|
||||
#include "channel_manager.h"
|
||||
#include "byte_manager.h"
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "auxtrans_manager.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "dec_clientmsg_handler.h"
|
||||
#include "jpipstream_manager.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "jp2k_encoder.h"
|
||||
|
||||
#ifdef SERVER
|
||||
|
||||
server_record_t * init_JPIPserver( int tcp_auxport, int udp_auxport)
|
||||
{
|
||||
server_record_t *record = (server_record_t *)malloc( sizeof(server_record_t));
|
||||
|
||||
record->sessionlist = gene_sessionlist();
|
||||
record->targetlist = gene_targetlist();
|
||||
record->auxtrans = init_aux_transport( tcp_auxport, udp_auxport);
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
void terminate_JPIPserver( server_record_t **rec)
|
||||
{
|
||||
delete_sessionlist( &(*rec)->sessionlist);
|
||||
delete_targetlist( &(*rec)->targetlist);
|
||||
close_aux_transport( (*rec)->auxtrans);
|
||||
|
||||
free( *rec);
|
||||
}
|
||||
|
||||
QR_t * parse_querystring( char *query_string)
|
||||
{
|
||||
QR_t *qr;
|
||||
|
||||
qr = (QR_t *)malloc( sizeof(QR_t));
|
||||
|
||||
qr->query = parse_query( query_string);
|
||||
qr->msgqueue = NULL;
|
||||
qr->channel = NULL;
|
||||
|
||||
return qr;
|
||||
}
|
||||
|
||||
bool process_JPIPrequest( server_record_t *rec, QR_t *qr)
|
||||
{
|
||||
target_param_t *target = NULL;
|
||||
session_param_t *cursession = NULL;
|
||||
channel_param_t *curchannel = NULL;
|
||||
|
||||
if( qr->query->target || qr->query->tid){
|
||||
if( !identify_target( *(qr->query), rec->targetlist, &target))
|
||||
return false;
|
||||
}
|
||||
|
||||
if( qr->query->cid){
|
||||
if( !associate_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
|
||||
return false;
|
||||
qr->channel = curchannel;
|
||||
}
|
||||
|
||||
if( qr->query->cnew != non){
|
||||
if( !open_channel( *(qr->query), rec->sessionlist, rec->auxtrans, target, &cursession, &curchannel))
|
||||
return false;
|
||||
qr->channel = curchannel;
|
||||
}
|
||||
|
||||
if( qr->query->cclose)
|
||||
if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
|
||||
return false;
|
||||
|
||||
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0)
|
||||
if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void add_EORmsg( int fd, QR_t *qr);
|
||||
|
||||
void send_responsedata( server_record_t *rec, QR_t *qr)
|
||||
{
|
||||
int fd;
|
||||
char tmpfname[] = "tmpjpipstream.jpp";
|
||||
Byte_t *jpipstream;
|
||||
Byte8_t len_of_jpipstream;
|
||||
|
||||
if( (fd = open( tmpfname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU)) == -1){
|
||||
fprintf( FCGI_stderr, "file open error %s", tmpfname);
|
||||
fprintf( FCGI_stdout, "Status: 503\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: Implementation failed\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
recons_stream_from_msgqueue( qr->msgqueue, fd);
|
||||
|
||||
add_EORmsg( fd, qr); /* needed at least for tcp and udp */
|
||||
|
||||
len_of_jpipstream = get_filesize( fd);
|
||||
jpipstream = fetch_bytes( fd, 0, len_of_jpipstream);
|
||||
|
||||
close( fd);
|
||||
remove( tmpfname);
|
||||
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
|
||||
if( qr->channel)
|
||||
if( qr->channel->aux == tcp || qr->channel->aux == udp){
|
||||
send_responsedata_on_aux( qr->channel->aux==tcp, rec->auxtrans, qr->channel->cid, jpipstream, len_of_jpipstream, 1000); /* 1KB per frame*/
|
||||
return;
|
||||
}
|
||||
|
||||
if( fwrite( jpipstream, len_of_jpipstream, 1, FCGI_stdout) != 1)
|
||||
fprintf( FCGI_stderr, "Error: failed to write jpipstream\n");
|
||||
|
||||
free( jpipstream);
|
||||
return;
|
||||
}
|
||||
|
||||
void add_EORmsg( int fd, QR_t *qr)
|
||||
{
|
||||
unsigned char EOR[3];
|
||||
|
||||
if( qr->channel){
|
||||
EOR[0] = 0x00;
|
||||
EOR[1] = is_allsent( *(qr->channel->cachemodel)) ? 0x01 : 0x02;
|
||||
EOR[2] = 0x00;
|
||||
if( write( fd, EOR, 3) != 3)
|
||||
fprintf( FCGI_stderr, "Error: failed to write EOR message\n");
|
||||
}
|
||||
}
|
||||
|
||||
void end_QRprocess( server_record_t *rec, QR_t **qr)
|
||||
{
|
||||
/* TODO: record client preferences if necessary*/
|
||||
|
||||
delete_query( &((*qr)->query));
|
||||
delete_msgqueue( &((*qr)->msgqueue));
|
||||
free( *qr);
|
||||
}
|
||||
|
||||
|
||||
void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec)
|
||||
{
|
||||
if( query)
|
||||
print_queryparam( *qr->query);
|
||||
|
||||
if( messages)
|
||||
print_msgqueue( qr->msgqueue);
|
||||
|
||||
if( sessions)
|
||||
print_allsession( rec->sessionlist);
|
||||
|
||||
if( targets)
|
||||
print_alltarget( rec->targetlist);
|
||||
}
|
||||
|
||||
#endif /*SERVER*/
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
dec_server_record_t * init_dec_server( int port)
|
||||
{
|
||||
dec_server_record_t *record = (dec_server_record_t *)malloc( sizeof(dec_server_record_t));
|
||||
|
||||
record->cachelist = gene_cachelist();
|
||||
record->jpipstream = NULL;
|
||||
record->jpipstreamlen = 0;
|
||||
record->msgqueue = gene_msgqueue( true, NULL);
|
||||
record->listening_socket = open_listeningsocket( port);
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
void terminate_dec_server( dec_server_record_t **rec)
|
||||
{
|
||||
delete_cachelist( &(*rec)->cachelist);
|
||||
free( (*rec)->jpipstream);
|
||||
|
||||
if( (*rec)->msgqueue)
|
||||
delete_msgqueue( &((*rec)->msgqueue));
|
||||
|
||||
if( close_socket( (*rec)->listening_socket) != 0)
|
||||
perror("close");
|
||||
|
||||
free( *rec);
|
||||
}
|
||||
|
||||
client_t accept_connection( dec_server_record_t *rec)
|
||||
{
|
||||
client_t client;
|
||||
|
||||
client = accept_socket( rec->listening_socket);
|
||||
if( client == -1)
|
||||
fprintf( stderr, "error: failed to connect to client\n");
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
bool handle_clientreq( client_t client, dec_server_record_t *rec)
|
||||
{
|
||||
bool quit = false;
|
||||
msgtype_t msgtype = identify_clientmsg( client);
|
||||
|
||||
switch( msgtype){
|
||||
case JPIPSTREAM:
|
||||
handle_JPIPstreamMSG( client, rec->cachelist, &rec->jpipstream, &rec->jpipstreamlen, rec->msgqueue);
|
||||
break;
|
||||
|
||||
case PNMREQ:
|
||||
handle_PNMreqMSG( client, rec->jpipstream, rec->msgqueue, rec->cachelist);
|
||||
break;
|
||||
|
||||
case XMLREQ:
|
||||
handle_XMLreqMSG( client, rec->jpipstream, rec->cachelist);
|
||||
break;
|
||||
|
||||
case TIDREQ:
|
||||
handle_TIDreqMSG( client, rec->cachelist);
|
||||
break;
|
||||
|
||||
case CIDREQ:
|
||||
handle_CIDreqMSG( client, rec->cachelist);
|
||||
break;
|
||||
|
||||
case CIDDST:
|
||||
handle_dstCIDreqMSG( client, rec->cachelist);
|
||||
break;
|
||||
|
||||
case SIZREQ:
|
||||
handle_SIZreqMSG( client, rec->jpipstream, rec->msgqueue, rec->cachelist);
|
||||
break;
|
||||
|
||||
case JP2SAVE:
|
||||
handle_JP2saveMSG( client, rec->cachelist, rec->msgqueue, rec->jpipstream);
|
||||
break;
|
||||
|
||||
case QUIT:
|
||||
quit = true;
|
||||
save_codestream( rec->jpipstream, rec->jpipstreamlen, "jpt");
|
||||
break;
|
||||
case MSGERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf( stderr, "\t end of the connection\n\n");
|
||||
if( close_socket(client) != 0){
|
||||
perror("close");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( quit)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
jpip_dec_param_t * init_jpipdecoder( bool jp2)
|
||||
{
|
||||
jpip_dec_param_t *dec;
|
||||
|
||||
dec = (jpip_dec_param_t *)calloc( 1, sizeof(jpip_dec_param_t));
|
||||
|
||||
dec->msgqueue = gene_msgqueue( true, NULL);
|
||||
|
||||
if( jp2)
|
||||
dec->metadatalist = gene_metadatalist();
|
||||
|
||||
return dec;
|
||||
}
|
||||
|
||||
|
||||
bool fread_jpip( char fname[], jpip_dec_param_t *dec)
|
||||
{
|
||||
int infd;
|
||||
|
||||
if(( infd = open( fname, O_RDONLY)) == -1){
|
||||
fprintf( stderr, "file %s not exist\n", fname);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(dec->jpiplen = get_filesize(infd)))
|
||||
return false;
|
||||
|
||||
dec->jpipstream = (Byte_t *)malloc( dec->jpiplen);
|
||||
|
||||
if( read( infd, dec->jpipstream, dec->jpiplen) != (int)dec->jpiplen){
|
||||
fprintf( stderr, "file reading error\n");
|
||||
free( dec->jpipstream);
|
||||
return false;
|
||||
}
|
||||
|
||||
close(infd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void decode_jpip( jpip_dec_param_t *dec)
|
||||
{
|
||||
parse_JPIPstream( dec->jpipstream, dec->jpiplen, 0, dec->msgqueue);
|
||||
|
||||
if( dec->metadatalist){ /* JP2 encoding*/
|
||||
parse_metamsg( dec->msgqueue, dec->jpipstream, dec->jpiplen, dec->metadatalist);
|
||||
dec->ihdrbox = gene_ihdrbox( dec->metadatalist, dec->jpipstream);
|
||||
|
||||
dec->jp2kstream = recons_jp2( dec->msgqueue, dec->jpipstream, dec->msgqueue->first->csn, &dec->jp2klen);
|
||||
}
|
||||
else /* J2k encoding */
|
||||
/* Notice: arguments fw, fh need to be set for LRCP, PCRL, CPRL*/
|
||||
dec->jp2kstream = recons_j2k( dec->msgqueue, dec->jpipstream, dec->msgqueue->first->csn, 0, 0, &dec->jp2klen);
|
||||
}
|
||||
|
||||
bool fwrite_jp2k( char fname[], jpip_dec_param_t *dec)
|
||||
{
|
||||
int outfd;
|
||||
|
||||
#ifdef _WIN32
|
||||
if(( outfd = open( fname, O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
|
||||
#else
|
||||
if(( outfd = open( fname, O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
|
||||
#endif
|
||||
fprintf( stderr, "file %s open error\n", fname);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( write( outfd, dec->jp2kstream, dec->jp2klen) != (int)dec->jp2klen)
|
||||
fprintf( stderr, "j2k file write error\n");
|
||||
|
||||
close(outfd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void output_log( bool messages, bool metadata, bool ihdrbox, jpip_dec_param_t *dec)
|
||||
{
|
||||
if( messages)
|
||||
print_msgqueue( dec->msgqueue);
|
||||
|
||||
if( metadata)
|
||||
print_allmetadata( dec->metadatalist);
|
||||
|
||||
if( ihdrbox){
|
||||
printf("W*H: %d*%d\n", dec->ihdrbox->height, dec->ihdrbox->width);
|
||||
printf("NC: %d, bpc: %d\n", dec->ihdrbox->nc, dec->ihdrbox->bpc);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_jpipdecoder( jpip_dec_param_t **dec)
|
||||
{
|
||||
free( (*dec)->jpipstream);
|
||||
delete_msgqueue( &(*dec)->msgqueue);
|
||||
if( (*dec)->metadatalist){
|
||||
delete_metadatalist( &(*dec)->metadatalist);
|
||||
free( (*dec)->ihdrbox);
|
||||
}
|
||||
|
||||
free( (*dec)->jp2kstream);
|
||||
free( *dec);
|
||||
}
|
||||
|
||||
index_t * get_index_from_JP2file( int fd)
|
||||
{
|
||||
char *data;
|
||||
|
||||
/* Check resource is a JP family file.*/
|
||||
if( lseek( fd, 0, SEEK_SET)==-1){
|
||||
fprintf( stderr, "Error: File broken (lseek error)\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( 12); /* size of header*/
|
||||
if( read( fd, data, 12) != 12){
|
||||
free( data);
|
||||
fprintf( stderr, "Error: File broken (read error)\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( *data || *(data + 1) || *(data + 2) ||
|
||||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
|
||||
free( data);
|
||||
fprintf( stderr, "Error: No JPEG 2000 Signature box in this file\n");
|
||||
return NULL;
|
||||
}
|
||||
free( data);
|
||||
|
||||
return parse_jp2file( fd);
|
||||
}
|
||||
|
||||
void destroy_index( index_t **idx)
|
||||
{
|
||||
delete_index( idx);
|
||||
}
|
||||
|
||||
void output_index( index_t *index)
|
||||
{
|
||||
print_index( *index);
|
||||
}
|
||||
|
||||
#endif /*SERVER*/
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* $Id: placeholder_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "placeholder_manager.h"
|
||||
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
|
||||
placeholderlist_param_t * gene_placeholderlist()
|
||||
{
|
||||
placeholderlist_param_t *list;
|
||||
|
||||
list = (placeholderlist_param_t *)malloc( sizeof(placeholderlist_param_t));
|
||||
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void delete_placeholderlist( placeholderlist_param_t **list)
|
||||
{
|
||||
placeholder_param_t *ptr, *next;
|
||||
|
||||
if(!(*list))
|
||||
return;
|
||||
|
||||
ptr = (*list)->first;
|
||||
|
||||
while( ptr){
|
||||
next=ptr->next;
|
||||
delete_placeholder( &ptr);
|
||||
ptr=next;
|
||||
}
|
||||
free( *list);
|
||||
}
|
||||
|
||||
placeholder_param_t * gene_placeholder( box_param_t *box, int origID)
|
||||
{
|
||||
placeholder_param_t *placeholder;
|
||||
|
||||
placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
||||
|
||||
strncpy( placeholder->TBox, "phld", 4);
|
||||
placeholder->Flags = 1; // only the access to the original contents of this box, for now
|
||||
placeholder->OrigID = origID;
|
||||
placeholder->OrigBH = fetch_headbytes( box);
|
||||
placeholder->OrigBHlen = box->headlen;
|
||||
placeholder->LBox = 20+box->headlen;
|
||||
placeholder->next = NULL;
|
||||
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
void delete_placeholder( placeholder_param_t **placeholder)
|
||||
{
|
||||
if( (*placeholder)->OrigBH)
|
||||
free((*placeholder)->OrigBH);
|
||||
free(*placeholder);
|
||||
}
|
||||
|
||||
void insert_placeholder_into_list( placeholder_param_t *phld, placeholderlist_param_t *phldlist)
|
||||
{
|
||||
if( phldlist->first)
|
||||
phldlist->last->next = phld;
|
||||
else
|
||||
phldlist->first = phld;
|
||||
phldlist->last = phld;
|
||||
}
|
||||
|
||||
void print_placeholder( placeholder_param_t *phld)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( logstream, "placeholder info:\n");
|
||||
fprintf( logstream, "\t LBox: %d %#x\n", phld->LBox, phld->LBox);
|
||||
fprintf( logstream, "\t TBox: %.4s\n", phld->TBox);
|
||||
fprintf( logstream, "\t Flags: %#x %#x\n", phld->Flags, phld->Flags);
|
||||
fprintf( logstream, "\t OrigID: %lld\n", phld->OrigID);
|
||||
fprintf( logstream, "\t OrigBH: ");
|
||||
|
||||
for( i=0; i< phld->OrigBHlen; i++)
|
||||
fprintf( logstream, "%02x ", phld->OrigBH[i]);
|
||||
fprintf( logstream, "\t");
|
||||
|
||||
for( i=0; i< phld->OrigBHlen; i++)
|
||||
fprintf( logstream, "%c", phld->OrigBH[i]);
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
|
||||
void print_allplaceholder( placeholderlist_param_t *list)
|
||||
{
|
||||
placeholder_param_t *ptr;
|
||||
|
||||
if( !list)
|
||||
return;
|
||||
|
||||
fprintf( logstream, "all placeholder info: \n");
|
||||
ptr = list->first;
|
||||
while( ptr != NULL){
|
||||
print_placeholder( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
@@ -1,419 +0,0 @@
|
||||
/*
|
||||
* $Id: query_parser.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "query_parser.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
/**
|
||||
* Get initialized query parameters
|
||||
*
|
||||
* @return initial query parameters
|
||||
*/
|
||||
query_param_t * get_initquery();
|
||||
|
||||
/*
|
||||
* get a pair of field name and value from the string starting fieldname=fieldval&... format
|
||||
*
|
||||
* @param[in] stringptr pointer to the beginning of the parsing string
|
||||
* @param[out] fieldname string to copy the field name, if not found, NULL
|
||||
* @param[out] fieldval string to copy the field value, if not found, NULL
|
||||
* @return pointer to the next field string, if there is none, NULL
|
||||
*/
|
||||
char * get_fieldparam( char *stringptr, char *fieldname, char *fieldval);
|
||||
|
||||
void parse_cclose( char *src, query_param_t *query_param);
|
||||
void parse_metareq( char *field, query_param_t *query_param);
|
||||
|
||||
/* parse the requested components (parses forms like:a; a,b; a-b; a-b,c; a,b-c)*/
|
||||
void parse_comps( char *field, query_param_t *query_param);
|
||||
|
||||
|
||||
/** maximum length of field name*/
|
||||
#define MAX_LENOFFIELDNAME 10
|
||||
|
||||
/** maximum length of field value*/
|
||||
#define MAX_LENOFFIELDVAL 128
|
||||
|
||||
query_param_t * parse_query( char *query_string)
|
||||
{
|
||||
query_param_t *query_param;
|
||||
char *pquery, fieldname[MAX_LENOFFIELDNAME], fieldval[MAX_LENOFFIELDVAL];
|
||||
|
||||
query_param = get_initquery();
|
||||
|
||||
pquery = query_string;
|
||||
|
||||
while( pquery!=NULL) {
|
||||
|
||||
pquery = get_fieldparam( pquery, fieldname, fieldval);
|
||||
|
||||
if( fieldname[0] != '\0'){
|
||||
if( strcasecmp( fieldname, "target") == 0)
|
||||
query_param->target = strdup( fieldval);
|
||||
|
||||
else if( strcasecmp( fieldname, "tid") == 0)
|
||||
query_param->tid = strdup( fieldval);
|
||||
|
||||
else if( strcasecmp( fieldname, "fsiz") == 0)
|
||||
sscanf( fieldval, "%d,%d", &query_param->fx, &query_param->fy);
|
||||
|
||||
else if( strcasecmp( fieldname, "roff") == 0)
|
||||
sscanf( fieldval, "%d,%d", &query_param->rx, &query_param->ry);
|
||||
|
||||
else if( strcasecmp( fieldname, "rsiz") == 0)
|
||||
sscanf( fieldval, "%d,%d", &query_param->rw, &query_param->rh);
|
||||
|
||||
else if( strcasecmp( fieldname, "layers") == 0)
|
||||
sscanf( fieldval, "%d", &query_param->layers);
|
||||
|
||||
else if( strcasecmp( fieldname, "cid") == 0)
|
||||
query_param->cid = strdup( fieldval);
|
||||
|
||||
else if( strcasecmp( fieldname, "cnew") == 0){
|
||||
if( strncasecmp( fieldval, "http-tcp", 8) == 0)
|
||||
query_param->cnew = tcp;
|
||||
else if( strncasecmp( fieldval, "http", 4) == 0)
|
||||
query_param->cnew = http;
|
||||
}
|
||||
|
||||
else if( strcasecmp( fieldname, "cclose") == 0)
|
||||
parse_cclose( fieldval, query_param);
|
||||
|
||||
else if( strcasecmp( fieldname, "metareq") == 0)
|
||||
parse_metareq( fieldval, query_param);
|
||||
|
||||
else if( strcasecmp( fieldname, "comps") == 0)
|
||||
parse_comps( fieldval, query_param);
|
||||
|
||||
else if( strcasecmp( fieldname, "type") == 0){
|
||||
if( strncasecmp( fieldval, "jpp-stream", 10) == 0)
|
||||
query_param->return_type = JPPstream;
|
||||
else if( strncasecmp( fieldval, "jpt-stream", 10) == 0)
|
||||
query_param->return_type = JPTstream;
|
||||
}
|
||||
|
||||
else if( strcasecmp( fieldname, "len") == 0)
|
||||
sscanf( fieldval, "%d", &query_param->len);
|
||||
}
|
||||
}
|
||||
return query_param;
|
||||
}
|
||||
|
||||
query_param_t * get_initquery()
|
||||
{
|
||||
query_param_t *query;
|
||||
int i;
|
||||
|
||||
query = (query_param_t *)malloc( sizeof(query_param_t));
|
||||
|
||||
query->target = NULL;
|
||||
query->tid = NULL;
|
||||
query->fx = -1;
|
||||
query->fy = -1;
|
||||
query->rx = -1;
|
||||
query->ry = -1;
|
||||
query->rw = -1;
|
||||
query->rh = -1;
|
||||
query->layers = -1;
|
||||
query->lastcomp = -1;
|
||||
query->comps = NULL;
|
||||
query->cid = NULL;
|
||||
query->cnew = non;
|
||||
query->cclose = NULL;
|
||||
query->numOfcclose = 0;
|
||||
memset( query->box_type, 0, MAX_NUMOFBOX*4);
|
||||
memset( query->limit, 0, MAX_NUMOFBOX*sizeof(int));
|
||||
for( i=0; i<MAX_NUMOFBOX; i++){
|
||||
query->w[i] = false;
|
||||
query->s[i] = false;
|
||||
query->g[i] = false;
|
||||
query->a[i] = false;
|
||||
query->priority[i] = false;
|
||||
}
|
||||
query->root_bin = 0;
|
||||
query->max_depth = -1;
|
||||
query->metadata_only = false;
|
||||
query->return_type = UNKNOWN;
|
||||
query->len = -1;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
char * get_fieldparam( char *stringptr, char *fieldname, char *fieldval)
|
||||
{
|
||||
char *eqp, *andp, *nexfieldptr;
|
||||
|
||||
if((eqp = strchr( stringptr, '='))==NULL){
|
||||
fprintf( stderr, "= not found\n");
|
||||
strcpy( fieldname, "");
|
||||
strcpy( fieldval, "");
|
||||
return NULL;
|
||||
}
|
||||
if((andp = strchr( stringptr, '&'))==NULL){
|
||||
andp = strchr( stringptr, '\0');
|
||||
nexfieldptr = NULL;
|
||||
}
|
||||
else
|
||||
nexfieldptr = andp+1;
|
||||
|
||||
strncpy( fieldname, stringptr, eqp-stringptr);
|
||||
fieldname[eqp-stringptr]='\0';
|
||||
strncpy( fieldval, eqp+1, andp-eqp-1);
|
||||
fieldval[andp-eqp-1]='\0';
|
||||
|
||||
return nexfieldptr;
|
||||
}
|
||||
|
||||
void print_queryparam( query_param_t query_param)
|
||||
{
|
||||
int i;
|
||||
char *cclose;
|
||||
|
||||
fprintf( logstream, "query parameters:\n");
|
||||
|
||||
if( query_param.target)
|
||||
fprintf( logstream, "\t target: %s\n", query_param.target);
|
||||
|
||||
if( query_param.tid)
|
||||
fprintf( logstream, "\t tid: %s\n", query_param.tid);
|
||||
|
||||
fprintf( logstream, "\t fx,fy: %d, %d\n", query_param.fx, query_param.fy);
|
||||
fprintf( logstream, "\t rx,ry: %d, %d \t rw,rh: %d, %d\n", query_param.rx, query_param.ry, query_param.rw, query_param.rh);
|
||||
fprintf( logstream, "\t layers: %d\n", query_param.layers);
|
||||
fprintf( logstream, "\t components: ");
|
||||
|
||||
if( query_param.lastcomp == -1)
|
||||
fprintf( logstream, "ALL\n");
|
||||
else{
|
||||
for( i=0; i<=query_param.lastcomp; i++)
|
||||
if( query_param.comps[i])
|
||||
fprintf( logstream, "%d ", i);
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
fprintf( logstream, "\t cnew: %d\n", query_param.cnew);
|
||||
|
||||
if( query_param.cid)
|
||||
fprintf( logstream, "\t cid: %s\n", query_param.cid);
|
||||
|
||||
if( query_param.cclose){
|
||||
fprintf( logstream, "\t cclose: ");
|
||||
|
||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++){
|
||||
fprintf( logstream, "%s ", cclose);
|
||||
cclose += (strlen(cclose)+1);
|
||||
}
|
||||
fprintf(logstream, "\n");
|
||||
}
|
||||
|
||||
fprintf( logstream, "\t req-box-prop\n");
|
||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||
fprintf( logstream, "\t\t box_type: %.4s limit: %d w:%d s:%d g:%d a:%d priority:%d\n", query_param.box_type[i], query_param.limit[i], query_param.w[i], query_param.s[i], query_param.g[i], query_param.a[i], query_param.priority[i]);
|
||||
}
|
||||
|
||||
fprintf( logstream, "\t root-bin: %d\n", query_param.root_bin);
|
||||
fprintf( logstream, "\t max-depth: %d\n", query_param.max_depth);
|
||||
fprintf( logstream, "\t metadata-only: %d\n", query_param.metadata_only);
|
||||
fprintf( logstream, "\t image return type: %d, [JPP-stream=0, JPT-stream=1, UNKNOWN=-1]\n", query_param.return_type);
|
||||
fprintf( logstream, "\t len: %d\n", query_param.len);
|
||||
}
|
||||
|
||||
void parse_cclose( char *src, query_param_t *query_param)
|
||||
{
|
||||
size_t i;
|
||||
size_t len;
|
||||
|
||||
len = strlen( src);
|
||||
query_param->cclose = strdup( src);
|
||||
|
||||
for( i=0; i<len; i++)
|
||||
if( query_param->cclose[i] == ','){
|
||||
query_param->cclose[i] = '\0';
|
||||
query_param->numOfcclose ++;
|
||||
}
|
||||
|
||||
query_param->numOfcclose ++;
|
||||
}
|
||||
|
||||
void parse_req_box_prop( char *req_box_prop, int idx, query_param_t *query_param);
|
||||
|
||||
void parse_metareq( char *field, query_param_t *query_param)
|
||||
{
|
||||
char req_box_prop[20];
|
||||
char *ptr, *src;
|
||||
int numofboxreq = 0;
|
||||
|
||||
memset( req_box_prop, 0, 20);
|
||||
|
||||
/* req-box-prop*/
|
||||
ptr = strchr( field, '[');
|
||||
ptr++;
|
||||
src = ptr;
|
||||
while( *ptr != ']'){
|
||||
if( *ptr == ';'){
|
||||
strncpy( req_box_prop, src, ptr-src);
|
||||
parse_req_box_prop( req_box_prop, numofboxreq++, query_param);
|
||||
ptr++;
|
||||
src = ptr;
|
||||
memset( req_box_prop, 0, 20);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
strncpy( req_box_prop, src, ptr-src);
|
||||
|
||||
parse_req_box_prop( req_box_prop, numofboxreq++, query_param);
|
||||
|
||||
if(( ptr = strchr( field, 'R')))
|
||||
sscanf( ptr+1, "%d", &(query_param->root_bin));
|
||||
|
||||
if(( ptr = strchr( field, 'D')))
|
||||
sscanf( ptr+1, "%d", &(query_param->max_depth));
|
||||
|
||||
if(( ptr = strstr( field, "!!")))
|
||||
query_param->metadata_only = true;
|
||||
}
|
||||
|
||||
void parse_req_box_prop( char *req_box_prop, int idx, query_param_t *query_param)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
if( *req_box_prop == '*')
|
||||
query_param->box_type[idx][0]='*';
|
||||
else
|
||||
strncpy( query_param->box_type[idx], req_box_prop, 4);
|
||||
|
||||
if(( ptr = strchr( req_box_prop, ':'))){
|
||||
if( *(ptr+1)=='r')
|
||||
query_param->limit[idx] = -1;
|
||||
else
|
||||
sscanf( ptr+1, "%d", &(query_param->limit[idx]));
|
||||
}
|
||||
|
||||
if(( ptr = strchr( req_box_prop, '/'))){
|
||||
ptr++;
|
||||
while( *ptr=='w' || *ptr=='s' || *ptr=='g' || *ptr=='a'){
|
||||
switch( *ptr){
|
||||
case 'w': query_param->w[idx] = true; break;
|
||||
case 's': query_param->s[idx] = true; break;
|
||||
case 'g': query_param->g[idx] = true; break;
|
||||
case 'a': query_param->a[idx] = true; break;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
query_param->g[idx] = true;
|
||||
query_param->s[idx] = true;
|
||||
query_param->w[idx] = true;
|
||||
}
|
||||
|
||||
if((ptr = strchr( req_box_prop, '!')))
|
||||
query_param->priority[idx] = true;
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
void parse_comps( char *field, query_param_t *query_param)
|
||||
{
|
||||
int i,start,stop,aux = -1;
|
||||
char *ptr1,*ptr2;
|
||||
|
||||
ptr1 = strchr( field, '-');
|
||||
ptr2 = strchr( field, ',');
|
||||
|
||||
if( ptr1 && ptr2)
|
||||
if( ptr1 > ptr2)
|
||||
sscanf( field, "%d,%d-%d",&aux, &start, &stop);
|
||||
else
|
||||
sscanf( field, "%d-%d,%d", &start, &stop, &aux);
|
||||
else
|
||||
if(ptr1)
|
||||
sscanf( field, "%d-%d", &start, &stop);
|
||||
else if(ptr2){
|
||||
sscanf( field, "%d,%d", &start, &stop);
|
||||
aux = start;
|
||||
start = stop;
|
||||
}
|
||||
else{
|
||||
sscanf( field, "%d", &stop);
|
||||
start = stop;
|
||||
}
|
||||
|
||||
query_param->lastcomp = stop > aux ? stop : aux;
|
||||
query_param->comps = (bool *)calloc( 1, (query_param->lastcomp+1)*sizeof(bool));
|
||||
|
||||
for( i=start; i<=stop; i++)
|
||||
query_param->comps[i]=true;
|
||||
|
||||
if(aux!=-1)
|
||||
query_param->comps[aux] = true;
|
||||
}
|
||||
|
||||
void delete_query( query_param_t **query)
|
||||
{
|
||||
if( (*query)->target)
|
||||
free( (*query)->target);
|
||||
|
||||
if( (*query)->tid)
|
||||
free( (*query)->tid);
|
||||
|
||||
if( (*query)->comps)
|
||||
free((*query)->comps);
|
||||
|
||||
if( (*query)->cid)
|
||||
free( (*query)->cid);
|
||||
|
||||
if( (*query)->cclose)
|
||||
free( (*query)->cclose);
|
||||
|
||||
free( *query);
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* $Id: session_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "session_manager.h"
|
||||
#include "target_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
sessionlist_param_t * gene_sessionlist()
|
||||
{
|
||||
sessionlist_param_t *sessionlist;
|
||||
|
||||
sessionlist = (sessionlist_param_t *)malloc( sizeof(sessionlist_param_t));
|
||||
|
||||
sessionlist->first = NULL;
|
||||
sessionlist->last = NULL;
|
||||
|
||||
return sessionlist;
|
||||
}
|
||||
|
||||
session_param_t * gene_session( sessionlist_param_t *sessionlist)
|
||||
{
|
||||
session_param_t *session;
|
||||
|
||||
session = (session_param_t *)malloc( sizeof(session_param_t));
|
||||
|
||||
session->channellist = gene_channellist();
|
||||
session->cachemodellist = gene_cachemodellist();
|
||||
|
||||
session->next = NULL;
|
||||
|
||||
if( sessionlist->first) // there are one or more entries
|
||||
sessionlist->last->next = session;
|
||||
else // first entry
|
||||
sessionlist->first = session;
|
||||
sessionlist->last = session;
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
bool search_session_and_channel( char cid[],
|
||||
sessionlist_param_t *sessionlist,
|
||||
session_param_t **foundsession,
|
||||
channel_param_t **foundchannel)
|
||||
{
|
||||
*foundsession = sessionlist->first;
|
||||
|
||||
while( *foundsession != NULL){
|
||||
|
||||
*foundchannel = (*foundsession)->channellist->first;
|
||||
|
||||
while( *foundchannel != NULL){
|
||||
|
||||
if( strcmp( cid, (*foundchannel)->cid) == 0)
|
||||
return true;
|
||||
|
||||
*foundchannel = (*foundchannel)->next;
|
||||
}
|
||||
*foundsession = (*foundsession)->next;
|
||||
}
|
||||
|
||||
fprintf( FCGI_stdout, "Status: 503\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: Channel %s not found\r\n", cid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void insert_cachemodel_into_session( session_param_t *session, cachemodel_param_t *cachemodel)
|
||||
{
|
||||
if(!cachemodel)
|
||||
return;
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: insert cachemodel into session\n");
|
||||
#endif
|
||||
if( session->cachemodellist->first != NULL)
|
||||
session->cachemodellist->last->next = cachemodel;
|
||||
else
|
||||
session->cachemodellist->first = cachemodel;
|
||||
session->cachemodellist->last = cachemodel;
|
||||
}
|
||||
|
||||
bool delete_session( session_param_t **session, sessionlist_param_t *sessionlist)
|
||||
{
|
||||
session_param_t *ptr;
|
||||
|
||||
if( *session == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
if( *session == sessionlist->first)
|
||||
sessionlist->first = (*session)->next;
|
||||
else{
|
||||
ptr = sessionlist->first;
|
||||
while( ptr->next != *session)
|
||||
ptr = ptr->next;
|
||||
ptr->next = (*session)->next;
|
||||
|
||||
if( *session == sessionlist->last)
|
||||
sessionlist->last = ptr;
|
||||
}
|
||||
|
||||
delete_channellist( &((*session)->channellist));
|
||||
delete_cachemodellist( &((*session)->cachemodellist));
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: session: %p deleted!\n", (void *)(*session));
|
||||
#endif
|
||||
free( *session);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void delete_sessionlist( sessionlist_param_t **sessionlist)
|
||||
{
|
||||
session_param_t *sessionPtr, *sessionNext;
|
||||
|
||||
sessionPtr = (*sessionlist)->first;
|
||||
while( sessionPtr != NULL){
|
||||
sessionNext=sessionPtr->next;
|
||||
|
||||
delete_channellist( &(sessionPtr->channellist));
|
||||
delete_cachemodellist( &(sessionPtr->cachemodellist));
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: session: %p deleted!\n", (void *)sessionPtr);
|
||||
#endif
|
||||
free( sessionPtr);
|
||||
|
||||
sessionPtr=sessionNext;
|
||||
}
|
||||
|
||||
(*sessionlist)->first = NULL;
|
||||
(*sessionlist)->last = NULL;
|
||||
|
||||
free(*sessionlist);
|
||||
}
|
||||
|
||||
void print_allsession( sessionlist_param_t *sessionlist)
|
||||
{
|
||||
session_param_t *ptr;
|
||||
cachemodel_param_t *cachemodel;
|
||||
int i=0;
|
||||
|
||||
fprintf( logstream, "SESSIONS info:\n");
|
||||
|
||||
ptr = sessionlist->first;
|
||||
while( ptr != NULL){
|
||||
fprintf( logstream, "session No.%d\n", i++);
|
||||
print_allchannel( ptr->channellist);
|
||||
cachemodel = ptr->cachemodellist->first;
|
||||
while( cachemodel){
|
||||
print_target( cachemodel->target);
|
||||
cachemodel = cachemodel->next;
|
||||
}
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "sock_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
|
||||
SOCKET open_listeningsocket( int port)
|
||||
{
|
||||
SOCKET listening_socket;
|
||||
struct sockaddr_in sin;
|
||||
int sock_optval = 1;
|
||||
|
||||
listening_socket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if ( listening_socket == -1 ){
|
||||
perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, (const char *)&sock_optval, sizeof(sock_optval)) == -1 ){
|
||||
perror("setsockopt");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
if ( bind(listening_socket, (struct sockaddr *)&sin, sizeof(sin)) < 0 ){
|
||||
perror("bind");
|
||||
close_socket(listening_socket);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if( listen(listening_socket, SOMAXCONN) == -1){
|
||||
perror("listen");
|
||||
close_socket(listening_socket);
|
||||
exit(1);
|
||||
}
|
||||
fprintf( FCGI_stderr, "port %d is listened\n", port);
|
||||
|
||||
return listening_socket;
|
||||
}
|
||||
|
||||
SOCKET accept_socket( SOCKET listening_socket)
|
||||
{
|
||||
struct sockaddr_in peer_sin;
|
||||
unsigned int addrlen = sizeof(peer_sin);
|
||||
|
||||
return accept( listening_socket, (struct sockaddr *)&peer_sin, &addrlen);
|
||||
}
|
||||
|
||||
void send_stream( SOCKET connected_socket, void *stream, int length)
|
||||
{
|
||||
char *ptr = (char*)stream;
|
||||
int remlen = length;
|
||||
|
||||
while( remlen > 0){
|
||||
int sentlen = send( connected_socket, ptr, remlen, 0);
|
||||
if( sentlen == -1){
|
||||
fprintf( FCGI_stderr, "sending stream error\n");
|
||||
break;
|
||||
}
|
||||
remlen = remlen - sentlen;
|
||||
ptr = ptr + sentlen;
|
||||
}
|
||||
}
|
||||
|
||||
void * receive_stream( SOCKET connected_socket, int length)
|
||||
{
|
||||
char *stream, *ptr;
|
||||
int remlen, redlen;
|
||||
|
||||
ptr = stream = malloc( length);
|
||||
remlen = length;
|
||||
|
||||
while( remlen > 0){
|
||||
redlen = recv( connected_socket, ptr, remlen, 0);
|
||||
if( redlen == -1){
|
||||
fprintf( FCGI_stderr, "receive stream error\n");
|
||||
free( stream);
|
||||
stream = NULL;
|
||||
break;
|
||||
}
|
||||
remlen -= redlen;
|
||||
ptr = ptr + redlen;
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
int receive_line(SOCKET connected_socket, char *p)
|
||||
{
|
||||
int len = 0;
|
||||
while (1){
|
||||
int ret;
|
||||
ret = recv( connected_socket, p, 1, 0);
|
||||
if ( ret == -1 ){
|
||||
perror("receive");
|
||||
exit(1);
|
||||
} else if ( ret == 0 ){
|
||||
break;
|
||||
}
|
||||
if ( *p == '\n' )
|
||||
break;
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
if( len == 0)
|
||||
fprintf( FCGI_stderr, "Header receive error\n");
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
char * receive_string( SOCKET connected_socket)
|
||||
{
|
||||
char buf[BUF_LEN];
|
||||
|
||||
receive_line( connected_socket, buf);
|
||||
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int close_socket( SOCKET sock)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return closesocket( sock);
|
||||
#else
|
||||
return close( sock);
|
||||
#endif
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* $Id: target_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf /* Visual Studio */
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include "target_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include <curl/curl.h>
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
targetlist_param_t * gene_targetlist()
|
||||
{
|
||||
targetlist_param_t *targetlist;
|
||||
|
||||
targetlist = (targetlist_param_t *)malloc( sizeof(targetlist_param_t));
|
||||
|
||||
targetlist->first = NULL;
|
||||
targetlist->last = NULL;
|
||||
|
||||
return targetlist;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* open jp2 format image file
|
||||
*
|
||||
* @param[in] filepath file name (.jp2)
|
||||
* @param[out] tmpfname new file name if filepath is a URL
|
||||
* @return file descriptor
|
||||
*/
|
||||
int open_jp2file( char filepath[], char tmpfname[]);
|
||||
|
||||
target_param_t * gene_target( targetlist_param_t *targetlist, char *targetpath)
|
||||
{
|
||||
target_param_t *target;
|
||||
int fd;
|
||||
index_param_t *jp2idx;
|
||||
char tmpfname[MAX_LENOFTID];
|
||||
static int last_csn = 0;
|
||||
|
||||
if( targetpath[0]=='\0'){
|
||||
fprintf( FCGI_stderr, "Error: exception, no targetpath in gene_target()\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((fd = open_jp2file( targetpath, tmpfname)) == -1){
|
||||
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !(jp2idx = parse_jp2file( fd))){
|
||||
fprintf( FCGI_stdout, "Status: 501\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
target = (target_param_t *)malloc( sizeof(target_param_t));
|
||||
snprintf( target->tid, MAX_LENOFTID, "%x-%x", (unsigned int)time(NULL), (unsigned int)rand());
|
||||
target->targetname = strdup( targetpath);
|
||||
target->fd = fd;
|
||||
#ifdef SERVER
|
||||
if( tmpfname[0])
|
||||
target->tmpfname = strdup( tmpfname);
|
||||
else
|
||||
target->tmpfname = NULL;
|
||||
#endif
|
||||
target->csn = last_csn++;
|
||||
target->codeidx = jp2idx;
|
||||
target->num_of_use = 0;
|
||||
target->jppstream = true;
|
||||
target->jptstream = isJPTfeasible( *jp2idx);
|
||||
target->next=NULL;
|
||||
|
||||
if( targetlist->first) /* there are one or more entries*/
|
||||
targetlist->last->next = target;
|
||||
else /* first entry*/
|
||||
targetlist->first = target;
|
||||
targetlist->last = target;
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: target %s generated\n", targetpath);
|
||||
#endif
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
void refer_target( target_param_t *reftarget, target_param_t **ptr)
|
||||
{
|
||||
*ptr = reftarget;
|
||||
reftarget->num_of_use++;
|
||||
}
|
||||
|
||||
void unrefer_target( target_param_t *target)
|
||||
{
|
||||
target->num_of_use--;
|
||||
}
|
||||
|
||||
void delete_target( target_param_t **target)
|
||||
{
|
||||
close( (*target)->fd);
|
||||
|
||||
#ifdef SERVER
|
||||
if( (*target)->tmpfname){
|
||||
fprintf( FCGI_stderr, "Temporal file %s is deleted\n", (*target)->tmpfname);
|
||||
remove( (*target)->tmpfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( (*target)->codeidx)
|
||||
delete_index ( &(*target)->codeidx);
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: target: %s deleted\n", (*target)->targetname);
|
||||
#endif
|
||||
|
||||
free( (*target)->targetname);
|
||||
|
||||
free(*target);
|
||||
}
|
||||
|
||||
void delete_target_in_list( target_param_t **target, targetlist_param_t *targetlist)
|
||||
{
|
||||
target_param_t *ptr;
|
||||
|
||||
if( *target == targetlist->first)
|
||||
targetlist->first = (*target)->next;
|
||||
else{
|
||||
ptr = targetlist->first;
|
||||
while( ptr->next != *target){
|
||||
ptr=ptr->next;
|
||||
}
|
||||
|
||||
ptr->next = (*target)->next;
|
||||
|
||||
if( *target == targetlist->last)
|
||||
targetlist->last = ptr;
|
||||
}
|
||||
delete_target( target);
|
||||
}
|
||||
|
||||
void delete_targetlist(targetlist_param_t **targetlist)
|
||||
{
|
||||
target_param_t *targetPtr, *targetNext;
|
||||
|
||||
targetPtr = (*targetlist)->first;
|
||||
while( targetPtr != NULL){
|
||||
targetNext=targetPtr->next;
|
||||
delete_target( &targetPtr);
|
||||
targetPtr=targetNext;
|
||||
}
|
||||
free( *targetlist);
|
||||
}
|
||||
|
||||
void print_target( target_param_t *target)
|
||||
{
|
||||
fprintf( logstream, "target:\n");
|
||||
fprintf( logstream, "\t tid=%s\n", target->tid);
|
||||
fprintf( logstream, "\t csn=%d\n", target->csn);
|
||||
fprintf( logstream, "\t target=%s\n\n", target->targetname);
|
||||
}
|
||||
|
||||
void print_alltarget( targetlist_param_t *targetlist)
|
||||
{
|
||||
target_param_t *ptr;
|
||||
|
||||
ptr = targetlist->first;
|
||||
while( ptr != NULL){
|
||||
print_target( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
target_param_t * search_target( char targetname[], targetlist_param_t *targetlist)
|
||||
{
|
||||
target_param_t *foundtarget;
|
||||
|
||||
foundtarget = targetlist->first;
|
||||
|
||||
while( foundtarget != NULL){
|
||||
|
||||
if( strcmp( targetname, foundtarget->targetname) == 0)
|
||||
return foundtarget;
|
||||
|
||||
foundtarget = foundtarget->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
target_param_t * search_targetBytid( char tid[], targetlist_param_t *targetlist)
|
||||
{
|
||||
target_param_t *foundtarget;
|
||||
|
||||
foundtarget = targetlist->first;
|
||||
|
||||
while( foundtarget != NULL){
|
||||
|
||||
if( strcmp( tid, foundtarget->tid) == 0)
|
||||
return foundtarget;
|
||||
|
||||
foundtarget = foundtarget->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int open_remotefile( char filepath[], char tmpfname[]);
|
||||
|
||||
int open_jp2file( char filepath[], char tmpfname[])
|
||||
{
|
||||
int fd;
|
||||
char *data;
|
||||
|
||||
/* download remote target file to local storage*/
|
||||
if( strncmp( filepath, "http://", 7) == 0){
|
||||
if( (fd = open_remotefile( filepath, tmpfname)) == -1)
|
||||
return -1;
|
||||
}
|
||||
else{
|
||||
tmpfname[0] = 0;
|
||||
if( (fd = open( filepath, O_RDONLY)) == -1){
|
||||
fprintf( FCGI_stdout, "Reason: Target %s not found\r\n", filepath);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Check resource is a JP family file.*/
|
||||
if( lseek( fd, 0, SEEK_SET)==-1){
|
||||
close(fd);
|
||||
fprintf( FCGI_stdout, "Reason: Target %s broken (lseek error)\r\n", filepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = (char *)malloc( 12); /* size of header*/
|
||||
|
||||
if( read( fd, data, 12) != 12){
|
||||
free( data);
|
||||
close(fd);
|
||||
fprintf( FCGI_stdout, "Reason: Target %s broken (read error)\r\n", filepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( *data || *(data + 1) || *(data + 2) ||
|
||||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
|
||||
free( data);
|
||||
close(fd);
|
||||
fprintf( FCGI_stdout, "Reason: No JPEG 2000 Signature box in target %s\r\n", filepath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free( data);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream);
|
||||
#endif
|
||||
|
||||
int open_remotefile( char filepath[], char tmpfname[])
|
||||
{
|
||||
#ifndef SERVER
|
||||
(void)filepath;
|
||||
(void)tmpfname;
|
||||
fprintf( FCGI_stderr, "Remote file can not be opened in local mode\n");
|
||||
return -1;
|
||||
|
||||
#else
|
||||
|
||||
CURL *curl_handle;
|
||||
int fd;
|
||||
|
||||
curl_handle = curl_easy_init();
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, filepath);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
|
||||
|
||||
snprintf( tmpfname, MAX_LENOFTID, "%x-%x.jp2", (unsigned int)time(NULL), (unsigned int)rand());
|
||||
fprintf( FCGI_stderr, "%s is downloaded to a temporal new file %s\n", filepath, tmpfname);
|
||||
if( (fd = open( tmpfname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU)) == -1){
|
||||
fprintf( FCGI_stdout, "Reason: File open error %s\r\n", tmpfname);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
return -1;
|
||||
}
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &fd);
|
||||
curl_easy_perform(curl_handle);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
|
||||
return fd;
|
||||
#endif /*SERVER*/
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
int *fd = (int *)stream;
|
||||
int written = write( *fd, ptr, size*nmemb);
|
||||
|
||||
return written;
|
||||
}
|
||||
#endif /*SERVER*/
|
||||
@@ -1,127 +0,0 @@
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/applications/jpip/libopenjpip
|
||||
${FCGI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
|
||||
SET(OPJ_SERVER_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_server.c
|
||||
)
|
||||
|
||||
# Build executable
|
||||
ADD_EXECUTABLE(opj_server ${OPJ_SERVER_SRCS})
|
||||
TARGET_LINK_LIBRARIES(opj_server openjpip_server)
|
||||
SET_PROPERTY(
|
||||
TARGET opj_server
|
||||
APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS SERVER QUIT_SIGNAL="quitJPIP"
|
||||
)
|
||||
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(opj_server m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# Install exe
|
||||
INSTALL(TARGETS opj_server
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDIF(BUILD_JPIP_SERVER)
|
||||
|
||||
SET(EXES
|
||||
opj_dec_server
|
||||
jpip_to_jp2
|
||||
jpip_to_j2k
|
||||
test_index
|
||||
)
|
||||
FOREACH(exe ${EXES})
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c)
|
||||
TARGET_LINK_LIBRARIES(${exe} openjpip_local)
|
||||
INSTALL(TARGETS ${exe}
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDFOREACH(exe)
|
||||
|
||||
# Build the two java clients:
|
||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||
|
||||
# 1. opj_viewer
|
||||
# build dep list:
|
||||
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
||||
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
||||
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
||||
DEPENDS ${java1_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OPJViewerJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMENT "building opj_viewer.jar"
|
||||
)
|
||||
|
||||
# 2. opj_viewer_xerces
|
||||
# search for package org.apache.xerces.parsers
|
||||
find_file(APACHE_XERCES_JAR
|
||||
NAMES xerces-j2.jar xercesImpl.jar
|
||||
PATHS /usr/share/java/
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
mark_as_advanced(APACHE_XERCES_JAR)
|
||||
|
||||
if(EXISTS ${APACHE_XERCES_JAR})
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
@ONLY
|
||||
)
|
||||
# build dep list:
|
||||
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
||||
|
||||
# Need some common files:
|
||||
list(APPEND java2_srcs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
||||
)
|
||||
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-classpath ${APACHE_XERCES_JAR}
|
||||
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
||||
DEPENDS ${java2_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OPJViewerXercesJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMENT "building opj_viewer_xerces.jar"
|
||||
)
|
||||
endif()
|
||||
@@ -1,75 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
bin_PROGRAMS =
|
||||
|
||||
if WANT_JPIP
|
||||
bin_PROGRAMS += opj_dec_server test_index jpip_to_j2k jpip_to_jp2
|
||||
endif
|
||||
|
||||
if WANT_JPIP_SERVER
|
||||
bin_PROGRAMS += opj_server
|
||||
endif
|
||||
|
||||
opj_server_CPPFLAGS = \
|
||||
@FCGI_CFLAGS@ \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
-DSERVER \
|
||||
-DQUIT_SIGNAL=\"quitJPIP\"
|
||||
#
|
||||
opj_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_server.la @FCGI_LIBS@ -lm
|
||||
#
|
||||
opj_server_SOURCES = opj_server.c
|
||||
|
||||
#-------------
|
||||
opj_dec_server_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip
|
||||
#
|
||||
opj_dec_server_CFLAGS =
|
||||
opj_dec_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
|
||||
opj_dec_server_SOURCES = opj_dec_server.c
|
||||
|
||||
#-------------
|
||||
jpip_to_jp2_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip
|
||||
#
|
||||
jpip_to_jp2_CFLAGS =
|
||||
jpip_to_jp2_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
|
||||
jpip_to_jp2_SOURCES = jpip_to_jp2.c
|
||||
|
||||
#-------------
|
||||
jpip_to_j2k_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip
|
||||
#
|
||||
jpip_to_j2k_CFLAGS =
|
||||
jpip_to_j2k_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
|
||||
jpip_to_j2k_SOURCES = jpip_to_j2k.c
|
||||
|
||||
#-------------
|
||||
test_index_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip
|
||||
#
|
||||
test_index_CFLAGS =
|
||||
test_index_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
|
||||
test_index_SOURCES = test_index.c
|
||||
|
||||
#-------------
|
||||
install-data-hook:
|
||||
if WANT_JPIP_SERVER
|
||||
@echo -e " (B)\t$(bindir)/opj_server$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
if WANT_JPIP
|
||||
@echo -e " (B)\t$(bindir)/opj_dec_server$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/jpip_to_jp2$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/jpip_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/test_index$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* $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) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief addXMLinJP2 is a program to embed metadata into JP2 file
|
||||
*
|
||||
* \section impinst Implementing instructions
|
||||
* This program takes two arguments. \n
|
||||
* -# Input/output image file in JP2 format, this JP2 file is being modified
|
||||
* -# Input XML file with metadata contents\n
|
||||
* % ./addXMLinJP2 image.jp2 metadata.xml\n
|
||||
*
|
||||
* Currently, this program does not parse XML file, and the XML file contents is directly embedded as a XML Box.\n
|
||||
* The following is an example of XML file contents specifying Region Of Interests with target names.\n
|
||||
* <xmlbox>\n
|
||||
* <roi name="island" x="1890" y="1950" w="770" h="310"/>\n
|
||||
* <roi name="ship" x="750" y="330" w="100" h="60"/>\n
|
||||
* <roi name="airport" x="650" y="1800" w="650" h="800"/>\n
|
||||
* <roi name="harbor" x="4200" y="1650" w="130" h="130"/>\n
|
||||
* </xmlbox>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/**
|
||||
* Open JP2 file with the check of JP2 header
|
||||
*
|
||||
* @param[in] filename file name string
|
||||
* @return file descriptor
|
||||
*/
|
||||
FILE * open_jp2file( char filename[]);
|
||||
|
||||
|
||||
/**
|
||||
* read xml file without any format check for the moment
|
||||
*
|
||||
* @param[in] filename file name string
|
||||
* @param[out] fsize file byte size
|
||||
* @return pointer to the xml file content buffer
|
||||
*/
|
||||
char * read_xmlfile( char filename[], long *fsize);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if( argc<3){
|
||||
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE *fp;
|
||||
char *xmldata, type[]="xml ";
|
||||
long fsize, boxsize;
|
||||
|
||||
fp = open_jp2file( argv[1]);
|
||||
if( !fp)
|
||||
return -1;
|
||||
|
||||
xmldata = read_xmlfile( argv[2], &fsize);
|
||||
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, fsize, 1, fp);
|
||||
|
||||
free( xmldata);
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE * open_jp2file( char filename[])
|
||||
{
|
||||
FILE *fp;
|
||||
char *data;
|
||||
|
||||
if( !(fp = fopen( filename, "a+b"))){
|
||||
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
// Check resource is a JP family file.
|
||||
if( fseek( fp, 0, SEEK_SET)==-1){
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( 12); // size of header
|
||||
if( fread( data, 12, 1, fp) != 1){
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (read error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( *data || *(data + 1) || *(data + 2) ||
|
||||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
|
||||
free( data);
|
||||
fclose(fp);
|
||||
fprintf( stderr, "No JPEG 2000 Signature box in target %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
free( data);
|
||||
return fp;
|
||||
}
|
||||
|
||||
char * read_xmlfile( char filename[], long *fsize)
|
||||
{
|
||||
FILE *fp;
|
||||
char *data;
|
||||
|
||||
// fprintf( stderr, "open %s\n", filename);
|
||||
if(!(fp = fopen( filename, "r"))){
|
||||
fprintf( stderr, "XML file %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( fseek( fp, 0, SEEK_END) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( (*fsize = ftell( fp)) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( fseek( fp, 0, SEEK_SET) == -1){
|
||||
fprintf( stderr, "XML file %s broken (seek error)\n", filename);
|
||||
fclose( fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( *fsize);
|
||||
|
||||
if( fread( data, *fsize, 1, fp) != 1){
|
||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||
free( data);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fclose( fp);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
# Makefile for the MJ2 codecs of the OpenJPEG library: frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2 and wrap_j2k_in_mj2
|
||||
|
||||
SET(common_SRCS ${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c)
|
||||
|
||||
# While mj2 executables do not use the API correctly, we do not link with the library but rather compile the sources files.
|
||||
SET(OPJ_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/bio.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/cio.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/dwt.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/event.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/image.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/j2k_lib.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/jp2.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/jpt.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/mct.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/mqc.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/openjpeg.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/pi.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/raw.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/t1.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/t2.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tcd.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tgt.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/cidx_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/phix_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/ppix_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/thix_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tpix_manager.c
|
||||
)
|
||||
|
||||
SET(MJ2_SRCS mj2.c mj2_convert.c)
|
||||
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||
${LCMS_INCLUDE_DIRNAME}
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(frames_to_mj2
|
||||
frames_to_mj2.c
|
||||
${common_SRCS}
|
||||
${OPJ_SRCS}
|
||||
${MJ2_SRCS}
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(frames_to_mj2 ${LCMS_LIBNAME})
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(frames_to_mj2 m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
ADD_EXECUTABLE(mj2_to_frames
|
||||
mj2_to_frames.c
|
||||
${common_SRCS}
|
||||
${OPJ_SRCS}
|
||||
${MJ2_SRCS}
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(mj2_to_frames ${LCMS_LIBNAME})
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(mj2_to_frames m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
ADD_EXECUTABLE(extract_j2k_from_mj2
|
||||
extract_j2k_from_mj2.c
|
||||
${OPJ_SRCS}
|
||||
${MJ2_SRCS}
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${LCMS_LIBNAME})
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
ADD_EXECUTABLE(wrap_j2k_in_mj2
|
||||
wrap_j2k_in_mj2.c
|
||||
${OPJ_SRCS}
|
||||
${MJ2_SRCS}
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${LCMS_LIBNAME})
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
INSTALL(TARGETS frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR})
|
||||
@@ -1,110 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
OPJ_SRC = \
|
||||
../../libopenjpeg/bio.c \
|
||||
../../libopenjpeg/cio.c \
|
||||
../../libopenjpeg/dwt.c \
|
||||
../../libopenjpeg/event.c \
|
||||
../../libopenjpeg/image.c \
|
||||
../../libopenjpeg/j2k.c \
|
||||
../../libopenjpeg/j2k_lib.c \
|
||||
../../libopenjpeg/jp2.c \
|
||||
../../libopenjpeg/jpt.c \
|
||||
../../libopenjpeg/mct.c \
|
||||
../../libopenjpeg/mqc.c \
|
||||
../../libopenjpeg/openjpeg.c \
|
||||
../../libopenjpeg/pi.c \
|
||||
../../libopenjpeg/raw.c \
|
||||
../../libopenjpeg/t1.c \
|
||||
../../libopenjpeg/t2.c \
|
||||
../../libopenjpeg/tcd.c \
|
||||
../../libopenjpeg/tgt.c \
|
||||
../../libopenjpeg/cidx_manager.c \
|
||||
../../libopenjpeg/phix_manager.c \
|
||||
../../libopenjpeg/ppix_manager.c \
|
||||
../../libopenjpeg/thix_manager.c \
|
||||
../../libopenjpeg/tpix_manager.c
|
||||
|
||||
bin_PROGRAMS = \
|
||||
frames_to_mj2 \
|
||||
mj2_to_frames \
|
||||
extract_j2k_from_mj2 \
|
||||
wrap_j2k_in_mj2
|
||||
|
||||
frames_to_mj2_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DOPJ_STATIC
|
||||
frames_to_mj2_CFLAGS =
|
||||
frames_to_mj2_LDADD = -lm
|
||||
frames_to_mj2_SOURCES = \
|
||||
$(OPJ_SRC) \
|
||||
../common/opj_getopt.c \
|
||||
mj2_convert.c \
|
||||
mj2.c \
|
||||
frames_to_mj2.c \
|
||||
mj2.h \
|
||||
mj2_convert.h
|
||||
|
||||
mj2_to_frames_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
@LCMS2_CFLAGS@ \
|
||||
@LCMS1_CFLAGS@ \
|
||||
-DOPJ_STATIC
|
||||
mj2_to_frames_CFLAGS =
|
||||
mj2_to_frames_LDADD = @LCMS2_LIBS@ @LCMS1_LIBS@ -lm
|
||||
mj2_to_frames_SOURCES = \
|
||||
$(OPJ_SRC) \
|
||||
../common/color.c \
|
||||
../common/opj_getopt.c \
|
||||
mj2_convert.c \
|
||||
mj2.c \
|
||||
mj2_to_frames.c \
|
||||
mj2.h \
|
||||
mj2_convert.h
|
||||
|
||||
extract_j2k_from_mj2_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DOPJ_STATIC
|
||||
extract_j2k_from_mj2_CFLAGS =
|
||||
extract_j2k_from_mj2_LDADD = -lm
|
||||
extract_j2k_from_mj2_SOURCES = \
|
||||
$(OPJ_SRC) \
|
||||
mj2.c \
|
||||
extract_j2k_from_mj2.c \
|
||||
mj2.h
|
||||
|
||||
wrap_j2k_in_mj2_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DOPJ_STATIC
|
||||
wrap_j2k_in_mj2_CFLAGS =
|
||||
wrap_j2k_in_mj2_LDADD = -lm
|
||||
wrap_j2k_in_mj2_SOURCES = \
|
||||
$(OPJ_SRC) \
|
||||
mj2.c \
|
||||
wrap_j2k_in_mj2.c \
|
||||
mj2.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt
|
||||
|
||||
install-data-hook:
|
||||
@echo -e " (B)\t$(bindir)/frames_to_mj2$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/mj2_to_frames$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/extract_j2k_from_mj2$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/wrap_j2k_in_mj2$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "mj2.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
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;
|
||||
}
|
||||
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,843 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004, Fran<61>ois-Olivier Devaux
|
||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "j2k_lib.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "cio.h"
|
||||
#include "mj2.h"
|
||||
#include "mj2_convert.h"
|
||||
#include "opj_getopt.h"
|
||||
|
||||
/**
|
||||
Size of memory first allocated for MOOV box
|
||||
*/
|
||||
#define TEMP_BUF 10000
|
||||
|
||||
#define ENUMCS_GRAY 16
|
||||
#define ENUMCS_SRGB 17
|
||||
#define ENUMCS_SYCC 18
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
void help_display()
|
||||
{
|
||||
fprintf(stdout,"HELP for frames_to_mj2\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
|
||||
fprintf(stdout,"List of parameters for the MJ2 encoder:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"REMARKS:\n");
|
||||
fprintf(stdout,"---------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf
|
||||
(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
|
||||
fprintf
|
||||
(stdout,"COD and QCD never appear in the tile_header.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"By default:\n");
|
||||
fprintf(stdout,"------------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," * Lossless\n");
|
||||
fprintf(stdout," * 1 tile\n");
|
||||
fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
|
||||
fprintf(stdout," * Size of code-block : 64 x 64\n");
|
||||
fprintf(stdout," * Number of resolutions: 6\n");
|
||||
fprintf(stdout," * No SOP marker in the codestream\n");
|
||||
fprintf(stdout," * No EPH marker in the codestream\n");
|
||||
fprintf(stdout," * No sub-sampling in x or y direction\n");
|
||||
fprintf(stdout," * No mode switch activated\n");
|
||||
fprintf(stdout," * Progression order: LRCP\n");
|
||||
fprintf(stdout," * No index file\n");
|
||||
fprintf(stdout," * No ROI upshifted\n");
|
||||
fprintf(stdout," * No offset of the origin of the image\n");
|
||||
fprintf(stdout," * No offset of the origin of the tiles\n");
|
||||
fprintf(stdout," * Reversible DWT 5-3\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Parameters:\n");
|
||||
fprintf(stdout,"------------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf
|
||||
(stdout,"Required Parameters (except with -h):\n");
|
||||
fprintf
|
||||
(stdout,"-i : source file (-i source.yuv) \n");
|
||||
fprintf
|
||||
(stdout,"-o : destination file (-o dest.mj2) \n");
|
||||
fprintf
|
||||
(stdout,"Optional Parameters:\n");
|
||||
fprintf(stdout,"-h : display the help information \n");
|
||||
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n");
|
||||
fprintf(stdout," - The rate specified for each quality level is the desired \n");
|
||||
fprintf(stdout," compression factor.\n");
|
||||
fprintf(stdout," Example: -r 20,10,1 means quality 1: compress 20x, \n");
|
||||
fprintf(stdout," quality 2: compress 10x and quality 3: compress lossless\n");
|
||||
fprintf(stdout," (options -r and -q cannot be used together)\n");
|
||||
|
||||
fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n");
|
||||
fprintf(stdout," (options -r and -q cannot be used together)\n");
|
||||
|
||||
fprintf(stdout,"-n : number of resolutions (-n 3) \n");
|
||||
fprintf(stdout,"-b : size of code block (-b 32,32) \n");
|
||||
fprintf(stdout,"-c : size of precinct (-c 128,128) \n");
|
||||
fprintf(stdout,"-t : size of tile (-t 512,512) \n");
|
||||
fprintf
|
||||
(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
|
||||
fprintf
|
||||
(stdout,"-s : subsampling factor (-s 2,2) [-s X,Y] \n");
|
||||
fprintf(stdout," Remark: subsampling bigger than 2 can produce error\n");
|
||||
fprintf
|
||||
(stdout,"-S : write SOP marker before each packet \n");
|
||||
fprintf
|
||||
(stdout,"-E : write EPH marker after each header packet \n");
|
||||
fprintf
|
||||
(stdout,"-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
|
||||
fprintf
|
||||
(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
|
||||
fprintf
|
||||
(stdout," Indicate multiple modes by adding their values. \n");
|
||||
fprintf
|
||||
(stdout," Example: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||
fprintf
|
||||
(stdout,"-R : c=%%d,U=%%d : quantization indices upshifted \n");
|
||||
fprintf
|
||||
(stdout," for component c=%%d [%%d = 0,1,2]\n");
|
||||
fprintf
|
||||
(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
|
||||
fprintf
|
||||
(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
|
||||
fprintf
|
||||
(stdout,"-T : offset of the origin of the tiles (-T 100,75) \n");
|
||||
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
||||
fprintf(stdout,"-W : image width, height and the dx and dy subsampling \n");
|
||||
fprintf(stdout," of the Cb and Cr components for YUV files \n");
|
||||
fprintf(stdout," (default is '352,288,2,2' for CIF format's 352x288 and 4:2:0)\n");
|
||||
fprintf(stdout,"-F : video frame rate (set to 25 by default)\n");
|
||||
fprintf(stdout,"-D : depth, precision in bits [8 .. 16]; default:8\n");
|
||||
fprintf(stdout,"-C : comment\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"IMPORTANT:\n");
|
||||
fprintf(stdout,"-----------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"The index file has the structure below:\n");
|
||||
fprintf(stdout,"---------------------------------------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Image_height Image_width\n");
|
||||
fprintf(stdout,"progression order\n");
|
||||
fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
|
||||
fprintf(stdout,"Components_nb\n");
|
||||
fprintf(stdout,"Layers_nb\n");
|
||||
fprintf(stdout,"decomposition_levels\n");
|
||||
fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
|
||||
fprintf(stdout," [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
|
||||
fprintf(stdout,"Main_header_end_position\n");
|
||||
fprintf(stdout,"Codestream_size\n");
|
||||
fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
|
||||
fprintf(stdout,"Tile_1 '' '' '' '' '' ''\n");
|
||||
fprintf(stdout,"...\n");
|
||||
fprintf(stdout,"Tile_Nt '' '' '' '' '' ''\n");
|
||||
fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
|
||||
fprintf(stdout,"...\n");
|
||||
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
|
||||
|
||||
fprintf(stdout,"MaxDisto\n");
|
||||
|
||||
fprintf(stdout,"TotalDisto\n\n");
|
||||
}
|
||||
|
||||
OPJ_PROG_ORDER give_progression(char progression[5])
|
||||
{
|
||||
if (progression[0] == 'L' && progression[1] == 'R'
|
||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
||||
return LRCP;
|
||||
} else {
|
||||
if (progression[0] == 'R' && progression[1] == 'L'
|
||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
||||
return RLCP;
|
||||
} else {
|
||||
if (progression[0] == 'R' && progression[1] == 'P'
|
||||
&& progression[2] == 'C' && progression[3] == 'L') {
|
||||
return RPCL;
|
||||
} else {
|
||||
if (progression[0] == 'P' && progression[1] == 'C'
|
||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
||||
return PCRL;
|
||||
} else {
|
||||
if (progression[0] == 'C' && progression[1] == 'P'
|
||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
||||
return CPRL;
|
||||
} else {
|
||||
return PROG_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
mj2_cparameters_t mj2_parameters; /* MJ2 compression parameters */
|
||||
opj_cparameters_t *j2k_parameters; /* J2K compression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_cio_t *cio;
|
||||
int value;
|
||||
opj_mj2_t *movie;
|
||||
opj_image_t *img;
|
||||
int i, j;
|
||||
char *s, S1, S2, S3;
|
||||
unsigned char *buf;
|
||||
int x1, y1, len;
|
||||
long mdat_initpos, offset;
|
||||
FILE *mj2file;
|
||||
int sampleno;
|
||||
opj_cinfo_t* cinfo;
|
||||
opj_bool bSuccess;
|
||||
int numframes;
|
||||
int prec = 8;/* DEFAULT */
|
||||
double total_time = 0;
|
||||
|
||||
memset(&mj2_parameters, 0, sizeof(mj2_cparameters_t));
|
||||
/* default value */
|
||||
/* ------------- */
|
||||
mj2_parameters.w = 352; // CIF default value
|
||||
mj2_parameters.h = 288; // CIF default value
|
||||
mj2_parameters.CbCr_subsampling_dx = 2; // CIF default value
|
||||
mj2_parameters.CbCr_subsampling_dy = 2; // CIF default value
|
||||
mj2_parameters.frame_rate = 25;
|
||||
mj2_parameters.prec = 8; /* DEFAULT */
|
||||
mj2_parameters.enumcs = ENUMCS_SYCC; /* FIXME: ENUMCS_YUV420 */
|
||||
mj2_parameters.meth = 1; /* enumerated color space */
|
||||
|
||||
/*
|
||||
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;
|
||||
|
||||
/* set J2K encoding parameters to default values */
|
||||
opj_set_default_encoder_parameters(&mj2_parameters.j2k_parameters);
|
||||
j2k_parameters = &mj2_parameters.j2k_parameters;
|
||||
|
||||
/* Create comment for codestream */
|
||||
if(j2k_parameters->cp_comment == NULL) {
|
||||
const char comment[] = "Created by OpenJPEG version ";
|
||||
const size_t clen = strlen(comment);
|
||||
const char *version = opj_version();
|
||||
j2k_parameters->cp_comment = (char*)malloc(clen+strlen(version)+1);
|
||||
sprintf(j2k_parameters->cp_comment,"%s%s", comment, version);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int c = opj_getopt(argc, argv,
|
||||
"i:o:r:q:f:t:n:c:b:p:s:d:P:S:E:M:R:T:C:I:W:F:D:h");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* IN fill */
|
||||
{
|
||||
char *infile = opj_optarg;
|
||||
s = opj_optarg;
|
||||
while (*s) {
|
||||
s++;
|
||||
}
|
||||
s--;
|
||||
S3 = *s;
|
||||
s--;
|
||||
S2 = *s;
|
||||
s--;
|
||||
S1 = *s;
|
||||
|
||||
if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
|
||||
|| (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
|
||||
mj2_parameters.decod_format = YUV_DFMT;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
|
||||
S1, S2, S3);
|
||||
return 1;
|
||||
}
|
||||
strncpy(mj2_parameters.infile, infile, sizeof(mj2_parameters.infile)-1);
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'o': /* OUT fill */
|
||||
{
|
||||
char *outfile = opj_optarg;
|
||||
while (*outfile) {
|
||||
outfile++;
|
||||
}
|
||||
outfile--;
|
||||
S3 = *outfile;
|
||||
outfile--;
|
||||
S2 = *outfile;
|
||||
outfile--;
|
||||
S1 = *outfile;
|
||||
|
||||
outfile = opj_optarg;
|
||||
|
||||
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
||||
|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
|
||||
mj2_parameters.cod_format = MJ2_CFMT;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Unknown output format image *.%c%c%c [only *.mj2]!! \n",
|
||||
S1, S2, S3);
|
||||
return 1;
|
||||
}
|
||||
strncpy(mj2_parameters.outfile, outfile, sizeof(mj2_parameters.outfile)-1);
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'r': /* rates rates/distorsion */
|
||||
{
|
||||
float rate;
|
||||
s = opj_optarg;
|
||||
while (sscanf(s, "%f", &rate) == 1) {
|
||||
j2k_parameters->tcp_rates[j2k_parameters->tcp_numlayers] = rate * 2;
|
||||
j2k_parameters->tcp_numlayers++;
|
||||
while (*s && *s != ',') {
|
||||
s++;
|
||||
}
|
||||
if (!*s)
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
j2k_parameters->cp_disto_alloc = 1;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'q': /* add fixed_quality */
|
||||
s = opj_optarg;
|
||||
while (sscanf(s, "%f", &j2k_parameters->tcp_distoratio[j2k_parameters->tcp_numlayers]) == 1) {
|
||||
j2k_parameters->tcp_numlayers++;
|
||||
while (*s && *s != ',') {
|
||||
s++;
|
||||
}
|
||||
if (!*s)
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
j2k_parameters->cp_fixed_quality = 1;
|
||||
break;
|
||||
/* dda */
|
||||
/* ----------------------------------------------------- */
|
||||
case 'f': /* mod fixed_quality (before : -q) */
|
||||
{
|
||||
int *row = NULL, *col = NULL;
|
||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||
|
||||
s = opj_optarg;
|
||||
sscanf(s, "%d", &numlayers);
|
||||
s++;
|
||||
if (numlayers > 9)
|
||||
s++;
|
||||
|
||||
j2k_parameters->tcp_numlayers = numlayers;
|
||||
numresolution = j2k_parameters->numresolution;
|
||||
matrix_width = numresolution * 3;
|
||||
j2k_parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||
s = s + 2;
|
||||
|
||||
for (i = 0; i < numlayers; i++) {
|
||||
row = &j2k_parameters->cp_matrice[i * matrix_width];
|
||||
col = row;
|
||||
j2k_parameters->tcp_rates[i] = 1;
|
||||
sscanf(s, "%d,", &col[0]);
|
||||
s += 2;
|
||||
if (col[0] > 9)
|
||||
s++;
|
||||
col[1] = 0;
|
||||
col[2] = 0;
|
||||
for (j = 1; j < numresolution; j++) {
|
||||
col += 3;
|
||||
sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
|
||||
s += 6;
|
||||
if (col[0] > 9)
|
||||
s++;
|
||||
if (col[1] > 9)
|
||||
s++;
|
||||
if (col[2] > 9)
|
||||
s++;
|
||||
}
|
||||
if (i < numlayers - 1)
|
||||
s++;
|
||||
}
|
||||
j2k_parameters->cp_fixed_alloc = 1;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 't': /* tiles */
|
||||
sscanf(opj_optarg, "%d,%d", &j2k_parameters->cp_tdx, &j2k_parameters->cp_tdy);
|
||||
j2k_parameters->tile_size_on = OPJ_TRUE;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'n': /* resolution */
|
||||
sscanf(opj_optarg, "%d", &j2k_parameters->numresolution);
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'c': /* precinct dimension */
|
||||
{
|
||||
char sep;
|
||||
int res_spec = 0;
|
||||
|
||||
char *s = opj_optarg;
|
||||
do {
|
||||
sep = 0;
|
||||
sscanf(s, "[%d,%d]%c", &j2k_parameters->prcw_init[res_spec],
|
||||
&j2k_parameters->prch_init[res_spec], &sep);
|
||||
j2k_parameters->csty |= 0x01;
|
||||
res_spec++;
|
||||
s = strpbrk(s, "]") + 2;
|
||||
}
|
||||
while (sep == ',');
|
||||
j2k_parameters->res_spec = res_spec;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'b': /* code-block dimension */
|
||||
{
|
||||
int cblockw_init = 0, cblockh_init = 0;
|
||||
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||
fprintf(stderr,
|
||||
"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
|
||||
" * width*height<=4096\n * 4<=width,height<= 1024\n\n");
|
||||
return 1;
|
||||
}
|
||||
j2k_parameters->cblockw_init = cblockw_init;
|
||||
j2k_parameters->cblockh_init = cblockh_init;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'p': /* progression order */
|
||||
{
|
||||
char progression[5];
|
||||
|
||||
strncpy(progression, opj_optarg, 5);
|
||||
j2k_parameters->prog_order = give_progression(progression);
|
||||
if (j2k_parameters->prog_order == -1) {
|
||||
fprintf(stderr, "Unrecognized progression order "
|
||||
"[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 's': /* subsampling factor */
|
||||
{
|
||||
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->subsampling_dx,
|
||||
&j2k_parameters->subsampling_dy) != 2) {
|
||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'd': /* coordonnate of the reference grid */
|
||||
{
|
||||
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->image_offset_x0,
|
||||
&j2k_parameters->image_offset_y0) != 2) {
|
||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||
"error !! [-d x0,y0]\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'h': /* Display an help description */
|
||||
help_display();
|
||||
return 0;
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'P': /* POC */
|
||||
{
|
||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||
|
||||
char *s = opj_optarg;
|
||||
POC = j2k_parameters->POC;
|
||||
|
||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||
&POC[numpocs].resno0, &POC[numpocs].compno0,
|
||||
&POC[numpocs].layno1, &POC[numpocs].resno1,
|
||||
&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
|
||||
POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
|
||||
numpocs++;
|
||||
while (*s && *s != '/') {
|
||||
s++;
|
||||
}
|
||||
if (!*s) {
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
j2k_parameters->numpocs = numpocs;
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'S': /* SOP marker */
|
||||
j2k_parameters->csty |= 0x02;
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'E': /* EPH marker */
|
||||
j2k_parameters->csty |= 0x04;
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'M': /* Mode switch pas tous au point !! */
|
||||
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||
for (i = 0; i <= 5; i++) {
|
||||
int cache = value & (1 << i);
|
||||
if (cache)
|
||||
j2k_parameters->mode |= (1 << i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'R': /* ROI */
|
||||
{
|
||||
if (sscanf(opj_optarg, "OI:c=%d,U=%d", &j2k_parameters->roi_compno,
|
||||
&j2k_parameters->roi_shift) != 2) {
|
||||
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'T': /* Tile offset */
|
||||
{
|
||||
if (sscanf(opj_optarg, "%d,%d", &j2k_parameters->cp_tx0, &j2k_parameters->cp_ty0) != 2) {
|
||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'C': /* Add a comment */
|
||||
{
|
||||
j2k_parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(j2k_parameters->cp_comment) {
|
||||
strcpy(j2k_parameters->cp_comment, opj_optarg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'I': /* reversible or not */
|
||||
{
|
||||
j2k_parameters->irreversible = 1;
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'W': /* Width and Height and Cb and Cr subsampling in case of YUV format files */
|
||||
if (sscanf
|
||||
(opj_optarg, "%d,%d,%d,%d", &mj2_parameters.w, &mj2_parameters.h, &mj2_parameters.CbCr_subsampling_dx,
|
||||
&mj2_parameters.CbCr_subsampling_dy) != 4) {
|
||||
fprintf(stderr, "-W argument error");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'F': /* Video frame rate */
|
||||
if (sscanf(opj_optarg, "%d", &mj2_parameters.frame_rate) != 1) {
|
||||
fprintf(stderr, "-F argument error");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
/* ------------------------------------------------------ */
|
||||
case 'D': /* Depth: the precision */
|
||||
if(sscanf(opj_optarg, "%d", &prec) != 1) prec = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Error messages */
|
||||
/* -------------- */
|
||||
if (!mj2_parameters.cod_format || !mj2_parameters.decod_format) {
|
||||
fprintf(stderr,
|
||||
"Usage: %s -i yuv-file -o mj2-file (+ options)\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
if(prec < 1 || prec > 16)
|
||||
{
|
||||
fprintf(stderr, "Error: Depth %d must be in the range 8 .. 16\n",prec);
|
||||
return 1;
|
||||
}
|
||||
if ((j2k_parameters->cp_disto_alloc || j2k_parameters->cp_fixed_alloc || j2k_parameters->cp_fixed_quality)
|
||||
&& (!(j2k_parameters->cp_disto_alloc ^ j2k_parameters->cp_fixed_alloc ^ j2k_parameters->cp_fixed_quality))) {
|
||||
fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
|
||||
return 1;
|
||||
} /* mod fixed_quality */
|
||||
|
||||
/* if no rate entered, lossless by default */
|
||||
if (j2k_parameters->tcp_numlayers == 0) {
|
||||
j2k_parameters->tcp_rates[0] = 0; /* MOD antonin : losslessbug */
|
||||
j2k_parameters->tcp_numlayers++;
|
||||
j2k_parameters->cp_disto_alloc = 1;
|
||||
}
|
||||
|
||||
if((j2k_parameters->cp_tx0 > j2k_parameters->image_offset_x0) || (j2k_parameters->cp_ty0 > j2k_parameters->image_offset_y0)) {
|
||||
fprintf(stderr,
|
||||
"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
|
||||
j2k_parameters->cp_tx0, j2k_parameters->image_offset_x0, j2k_parameters->cp_ty0, j2k_parameters->image_offset_y0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < j2k_parameters->numpocs; i++) {
|
||||
if (j2k_parameters->POC[i].prg == -1) {
|
||||
fprintf(stderr,
|
||||
"Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
|
||||
i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (j2k_parameters->cp_tdx > mj2_parameters.Dim[0] || j2k_parameters->cp_tdy > mj2_parameters.Dim[1]) {
|
||||
fprintf(stderr,
|
||||
"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
|
||||
j2k_parameters->cp_tdx, mj2_parameters.Dim[0], j2k_parameters->cp_tdy, mj2_parameters.Dim[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* to respect profile - 0 */
|
||||
/* ---------------------- */
|
||||
|
||||
x1 = !mj2_parameters.Dim[0] ? (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx
|
||||
+ 1 : mj2_parameters.Dim[0] + (mj2_parameters.w - 1) * j2k_parameters->subsampling_dx + 1;
|
||||
y1 = !mj2_parameters.Dim[1] ? (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy
|
||||
+ 1 : mj2_parameters.Dim[1] + (mj2_parameters.h - 1) * j2k_parameters->subsampling_dy + 1;
|
||||
mj2_parameters.numcomps = 3; /* YUV files only have 3 components */
|
||||
|
||||
mj2_parameters.prec = prec;
|
||||
|
||||
j2k_parameters->tcp_mct = 0;
|
||||
|
||||
mj2file = fopen(mj2_parameters.outfile, "wb");
|
||||
|
||||
if (!mj2file) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* get a MJ2 decompressor handle */
|
||||
cinfo = mj2_create_compress();
|
||||
movie = (opj_mj2_t*)cinfo->mj2_handle;
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup encoder parameters */
|
||||
mj2_setup_encoder(movie, &mj2_parameters);
|
||||
|
||||
movie->tk[0].num_samples =
|
||||
yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
|
||||
|
||||
if (movie->tk[0].num_samples == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// One sample per chunk
|
||||
movie->tk[0].chunk = (mj2_chunk_t*)
|
||||
malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));
|
||||
movie->tk[0].sample = (mj2_sample_t*)
|
||||
malloc(movie->tk[0].num_samples * sizeof(mj2_sample_t));
|
||||
|
||||
if (mj2_init_stdmovie(movie)) {
|
||||
fprintf(stderr, "Error with movie initialization");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 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((opj_common_ptr)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);
|
||||
|
||||
offset = cio_tell(cio);
|
||||
opj_cio_close(cio);
|
||||
free(buf);
|
||||
|
||||
for(i = 0; i < movie->num_stk + movie->num_htk + movie->num_vtk; i++)
|
||||
{
|
||||
if(movie->tk[i].track_type != 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to write sound or hint tracks\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mj2_tk_t *tk;
|
||||
int buflen = 0;
|
||||
|
||||
tk = &movie->tk[i];
|
||||
tk->num_chunks = tk->num_samples;
|
||||
numframes = tk->num_samples;
|
||||
tk->depth = prec;
|
||||
|
||||
fprintf(stderr, "Video Track number %d\n", i);
|
||||
|
||||
img = mj2_image_create(tk, j2k_parameters);
|
||||
|
||||
buflen = 2 * (tk->w * tk->h * 8);
|
||||
buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));
|
||||
|
||||
for(sampleno = 0; sampleno < numframes; sampleno++)
|
||||
{
|
||||
double init_time = opj_clock();
|
||||
double elapsed_time;
|
||||
|
||||
if(yuvtoimage(tk, img, sampleno, j2k_parameters,
|
||||
mj2_parameters.infile))
|
||||
{
|
||||
fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* setup the encoder parameters using the current image and user parameters */
|
||||
opj_setup_encoder(cinfo, j2k_parameters, img);
|
||||
|
||||
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, buflen);
|
||||
|
||||
cio_skip(cio, 4);
|
||||
cio_write(cio, JP2_JP2C, 4); // JP2C
|
||||
|
||||
/* encode the image */
|
||||
bSuccess = opj_encode(cinfo, cio, img, NULL);
|
||||
|
||||
if (!bSuccess) {
|
||||
opj_cio_close(cio);
|
||||
fprintf(stderr, "failed to encode image\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = cio_tell(cio) - 8;
|
||||
cio_seek(cio, 0);
|
||||
cio_write(cio, len+8,4);
|
||||
opj_cio_close(cio);
|
||||
|
||||
tk->sample[sampleno].sample_size = len+8;
|
||||
tk->sample[sampleno].offset = offset;
|
||||
tk->chunk[sampleno].offset = offset; // There is one sample per chunk
|
||||
fwrite(buf, 1, len+8, mj2file);
|
||||
offset += len+8;
|
||||
|
||||
elapsed_time = opj_clock()-init_time;
|
||||
fprintf(stderr, "Frame number %d/%d encoded in %.2f mseconds\n",
|
||||
sampleno + 1, numframes, elapsed_time*1000);
|
||||
total_time += elapsed_time;
|
||||
} /* for(sampleno */
|
||||
|
||||
free(buf);
|
||||
opj_image_destroy(img);
|
||||
}
|
||||
}/* for(i */
|
||||
|
||||
fseek(mj2file, mdat_initpos, SEEK_SET);
|
||||
|
||||
buf = (unsigned char*) malloc(4*sizeof(unsigned char));
|
||||
|
||||
// Init a cio to write box length variable in a little endian way
|
||||
cio = opj_cio_open(NULL, buf, 4);
|
||||
cio_write(cio, offset - mdat_initpos, 4);
|
||||
fwrite(buf, 4, 1, mj2file);
|
||||
fseek(mj2file,0,SEEK_END);
|
||||
free(buf);
|
||||
|
||||
// Writing MOOV box
|
||||
buf = (unsigned char*)
|
||||
malloc ((TEMP_BUF+numframes*20) * sizeof(unsigned char));
|
||||
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
|
||||
mj2_write_moov(movie, cio);
|
||||
fwrite(buf,cio_tell(cio),1,mj2file);
|
||||
free(buf);
|
||||
|
||||
fprintf(stdout,"Total encoding time: %.2f s for %d frames (%.1f fps)\n",
|
||||
total_time, numframes, (float)numframes/total_time);
|
||||
|
||||
// Ending program
|
||||
|
||||
fclose(mj2file);
|
||||
/* free remaining compression structures */
|
||||
mj2_destroy_compress(movie);
|
||||
free(cinfo);
|
||||
|
||||
if(j2k_parameters->cp_comment) free(j2k_parameters->cp_comment);
|
||||
if(j2k_parameters->cp_matrice) free(j2k_parameters->cp_matrice);
|
||||
opj_cio_close(cio);
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,372 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* 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_includes.h"
|
||||
#include "mj2.h"
|
||||
|
||||
/* ----------------------- */
|
||||
/* */
|
||||
/* */
|
||||
/* Count the number of frames */
|
||||
/* in a YUV file */
|
||||
/* */
|
||||
/* ----------------------- */
|
||||
|
||||
unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
|
||||
{
|
||||
unsigned int prec_size;
|
||||
long end_of_f, frame_size;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(infile,"rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "failed to open %s for reading\n",infile);
|
||||
return 0;
|
||||
}
|
||||
prec_size = (tk->depth + 7)/8;/* bytes of precision */
|
||||
|
||||
frame_size = (long) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
|
||||
frame_size *= prec_size;
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
end_of_f = ftell(f); /* Calculate file size */
|
||||
|
||||
if (end_of_f < frame_size) {
|
||||
fprintf(stderr,
|
||||
"YUV does not contains any frame of %d x %d size\n", tk->w,
|
||||
tk->h);
|
||||
return 0;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
return (unsigned int)(end_of_f / frame_size);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
//
|
||||
//
|
||||
// YUV to IMAGE
|
||||
//
|
||||
// -----------------------
|
||||
|
||||
opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
|
||||
{
|
||||
opj_image_cmptparm_t cmptparm[3];
|
||||
opj_image_t * img;
|
||||
int i;
|
||||
int numcomps = 3;
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
|
||||
for(i = 0; i < numcomps; i++) {
|
||||
cmptparm[i].prec = tk->depth;
|
||||
cmptparm[i].bpp = tk->depth;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = i ? subsampling_dx * tk->CbCr_subsampling_dx : subsampling_dx;
|
||||
cmptparm[i].dy = i ? subsampling_dy * tk->CbCr_subsampling_dy : subsampling_dy;
|
||||
cmptparm[i].w = tk->w;
|
||||
cmptparm[i].h = tk->h;
|
||||
}
|
||||
/* create the image */
|
||||
img = opj_image_create(numcomps, cmptparm, CLRSPC_SRGB);
|
||||
return img;
|
||||
}
|
||||
|
||||
char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile)
|
||||
{
|
||||
int i, compno;
|
||||
int offset, size, max, prec_bytes, is_16, v;
|
||||
long end_of_f, position;
|
||||
int numcomps = 3;
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
FILE *yuvfile;
|
||||
int *data;
|
||||
unsigned char uc;
|
||||
|
||||
yuvfile = fopen(infile,"rb");
|
||||
if (!yuvfile) {
|
||||
fprintf(stderr, "failed to open %s for readings\n",parameters->infile);
|
||||
return 1;
|
||||
}
|
||||
is_16 = (tk->depth > 8);
|
||||
prec_bytes = (is_16?2:1);
|
||||
|
||||
offset = (int) ((double) (frame_num * tk->w * tk->h) * (1.0 +
|
||||
1.0 * (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy)));
|
||||
offset *= prec_bytes;
|
||||
|
||||
fseek(yuvfile, 0, SEEK_END);
|
||||
end_of_f = ftell(yuvfile);
|
||||
fseek(yuvfile, sizeof(unsigned char) * offset, SEEK_SET);
|
||||
position = ftell(yuvfile);
|
||||
if (position >= end_of_f) {
|
||||
fprintf(stderr, "Cannot reach frame number %d in yuv file !!\n",
|
||||
frame_num);
|
||||
fclose(yuvfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
img->x0 = tk->Dim[0];
|
||||
img->y0 = tk->Dim[1];
|
||||
img->x1 = !tk->Dim[0] ? (tk->w - 1) * subsampling_dx + 1 : tk->Dim[0] +
|
||||
(tk->w - 1) * subsampling_dx + 1;
|
||||
img->y1 = !tk->Dim[1] ? (tk->h - 1) * subsampling_dy + 1 : tk->Dim[1] +
|
||||
(tk->h - 1) * subsampling_dy + 1;
|
||||
|
||||
size = tk->w * tk->h * prec_bytes;
|
||||
|
||||
for(compno = 0; compno < numcomps; compno++)
|
||||
{
|
||||
max = size/(img->comps[compno].dx * img->comps[compno].dy);
|
||||
data = img->comps[compno].data;
|
||||
|
||||
for (i = 0; i < max && !feof(yuvfile); i++)
|
||||
{
|
||||
v = 0;
|
||||
fread(&uc, 1, 1, yuvfile);
|
||||
v = uc;
|
||||
|
||||
if(is_16)
|
||||
{
|
||||
fread(&uc, 1, 1, yuvfile);
|
||||
v |= (uc<<8);
|
||||
}
|
||||
*data++ = v;
|
||||
}
|
||||
}
|
||||
fclose(yuvfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------
|
||||
//
|
||||
//
|
||||
// IMAGE to YUV
|
||||
//
|
||||
// -----------------------
|
||||
|
||||
|
||||
opj_bool imagetoyuv(opj_image_t * img, char *outfile)
|
||||
{
|
||||
FILE *f;
|
||||
int *data;
|
||||
int i, v, is_16, prec_bytes;
|
||||
unsigned char buf[2];
|
||||
|
||||
if (img->numcomps == 3) {
|
||||
if (img->comps[0].dx != img->comps[1].dx / 2
|
||||
|| img->comps[1].dx != img->comps[2].dx) {
|
||||
fprintf(stderr,
|
||||
"Error with the input image components size: cannot create yuv file)\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
} else if (!(img->numcomps == 1)) {
|
||||
fprintf(stderr,
|
||||
"Error with the number of image components(must be one or three)\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
f = fopen(outfile, "a+b");
|
||||
if (!f) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", outfile);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
is_16 = (img->comps[0].prec > 8);
|
||||
prec_bytes = (is_16?2:1);
|
||||
data = img->comps[0].data;
|
||||
|
||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h); i++) {
|
||||
v = *data++;
|
||||
buf[0] = (unsigned char)v;
|
||||
|
||||
if(is_16) buf[1] = (unsigned char)(v>>8);
|
||||
|
||||
fwrite(buf, 1, prec_bytes, f);
|
||||
}
|
||||
|
||||
|
||||
if (img->numcomps == 3) {
|
||||
data = img->comps[1].data;
|
||||
|
||||
for (i = 0; i < (img->comps[1].w * img->comps[1].h); i++) {
|
||||
v = *data++;
|
||||
buf[0] = (unsigned char)v;
|
||||
|
||||
if(is_16) buf[1] = (unsigned char)(v>>8);
|
||||
|
||||
fwrite(buf, 1, prec_bytes, f);
|
||||
}
|
||||
data = img->comps[2].data;
|
||||
|
||||
for (i = 0; i < (img->comps[2].w * img->comps[2].h); i++) {
|
||||
v = *data++;
|
||||
buf[0] = (unsigned char)v;
|
||||
|
||||
if(is_16) buf[1] = (unsigned char)(v>>8);
|
||||
|
||||
fwrite(buf, 1, prec_bytes, f);
|
||||
}
|
||||
} else if (img->numcomps == 1) {
|
||||
/* fake CbCr values */
|
||||
if(is_16)
|
||||
{
|
||||
buf[0] = 255;
|
||||
if(img->comps[0].prec == 10) buf[1] = 1;
|
||||
else
|
||||
if(img->comps[0].prec == 12) buf[1] = 3;
|
||||
else
|
||||
buf[1] = 125;
|
||||
}
|
||||
else buf[0] = 125;
|
||||
|
||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
|
||||
fwrite(buf, 1, prec_bytes, f);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
|
||||
fwrite(buf, 1, prec_bytes, f);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
//
|
||||
//
|
||||
// IMAGE to BMP
|
||||
//
|
||||
// -----------------------
|
||||
|
||||
int imagetobmp(opj_image_t * img, char *outfile) {
|
||||
int w,wr,h,hr,i,pad;
|
||||
FILE *f;
|
||||
|
||||
if (img->numcomps == 3 && img->comps[0].dx == img->comps[1].dx
|
||||
&& img->comps[1].dx == img->comps[2].dx
|
||||
&& img->comps[0].dy == img->comps[1].dy
|
||||
&& img->comps[1].dy == img->comps[2].dy
|
||||
&& img->comps[0].prec == img->comps[1].prec
|
||||
&& img->comps[1].prec == img->comps[2].prec) {
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
24 bits color
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
f = fopen(outfile, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
w = img->comps[0].w;
|
||||
wr = int_ceildivpow2(img->comps[0].w, img->comps[0].factor);
|
||||
|
||||
h = img->comps[0].h;
|
||||
hr = int_ceildivpow2(img->comps[0].h, img->comps[0].factor);
|
||||
|
||||
fprintf(f, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(f, "%c%c%c%c",
|
||||
(unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
|
||||
54) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
||||
>> 8) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
||||
>> 16) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
||||
>> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
|
||||
((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
|
||||
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
|
||||
(unsigned char) ((wr) >> 8) & 0xff,
|
||||
(unsigned char) ((wr) >> 16) & 0xff,
|
||||
(unsigned char) ((wr) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
|
||||
(unsigned char) ((hr) >> 8) & 0xff,
|
||||
(unsigned char) ((hr) >> 16) & 0xff,
|
||||
(unsigned char) ((hr) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c",
|
||||
(unsigned char) (3 * hr * wr +
|
||||
3 * hr * (wr % 2)) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
||||
8) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
||||
16) & 0xff,
|
||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
||||
24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
|
||||
for (i = 0; i < wr * hr; i++) {
|
||||
unsigned char R, G, B;
|
||||
/* a modifier */
|
||||
// R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||
// G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||
// B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
||||
fprintf(f, "%c%c%c", B, G, R);
|
||||
|
||||
if ((i + 1) % wr == 0) {
|
||||
for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(f, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004, Fran<61>ois-Olivier Devaux
|
||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "j2k_lib.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "mj2.h"
|
||||
#include "mj2_convert.h"
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
#include <lcms2.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
#include <lcms.h>
|
||||
#endif
|
||||
#include "color.h"
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
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;
|
||||
}
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
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;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
max_codstrm_size = track->sample[0].sample_size-8;
|
||||
frame_codestream = (unsigned char*) malloc(max_codstrm_size * sizeof(unsigned char));
|
||||
|
||||
numframes = track->num_samples;
|
||||
|
||||
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
|
||||
|
||||
/* 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
|
||||
|
||||
#ifdef WANT_SYCC_TO_RGB
|
||||
if(img->color_space == CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(img);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(img->icc_profile_buf)
|
||||
{
|
||||
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||
color_apply_icc_profile(img);
|
||||
#endif
|
||||
|
||||
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 (!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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
/* mj2_to_metadata.c */
|
||||
/* Dump MJ2, JP2 metadata (partial so far) to xml file */
|
||||
/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine.
|
||||
|
||||
The base code in this file was developed by the author as part of a video archiving
|
||||
project for the U.S. National Library of Medicine, Bethesda, MD.
|
||||
It is the policy of NLM (and U.S. government) to not assert copyright.
|
||||
|
||||
A non-exclusive copy of this code has been contributed to the Open JPEG project.
|
||||
Except for copyright, inclusion of the code within Open JPEG for distribution and use
|
||||
can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere.
|
||||
*/
|
||||
|
||||
#include "opj_includes.h"
|
||||
#include "mj2.h"
|
||||
|
||||
#include "mj2_to_metadata.h"
|
||||
#include <string.h>
|
||||
#include "opj_getopt.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
/* ------------- */
|
||||
|
||||
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");
|
||||
|
||||
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" */
|
||||
}
|
||||
|
||||
/* ------------- */
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
opj_dinfo_t* dinfo;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'o': /* OUT file */
|
||||
outfile = optarg;
|
||||
while (*outfile) { outfile++; } /* Run to filename end */
|
||||
outfile--;
|
||||
S3 = *outfile;
|
||||
outfile--;
|
||||
S2 = *outfile;
|
||||
outfile--;
|
||||
S1 = *outfile;
|
||||
|
||||
outfile = optarg;
|
||||
|
||||
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;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'n': /* Suppress comments */
|
||||
notes = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 't': /* Show sample size and chunk offset tables */
|
||||
sampletables = TRUE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'h': /* Display an help description */
|
||||
help_display();
|
||||
return 0;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'r': /* Suppress raw data */
|
||||
raw = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'd': /* Suppress derived data */
|
||||
derived = FALSE;
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
default:
|
||||
return 1;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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] */
|
||||
|
||||
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 */
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
/* 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 */
|
||||
movie = (opj_mj2_t*) dinfo->mj2_handle;
|
||||
mj2_setup_decoder(dinfo->mj2_handle, ¶meters);
|
||||
|
||||
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);
|
||||
|
||||
fprintf(stderr,"Metadata correctly extracted to XML file \n");;
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,516 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "cio.h"
|
||||
#include "mj2.h"
|
||||
|
||||
static int int_ceildiv(int a, int b) {
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
Size of memory first allocated for MOOV box
|
||||
*/
|
||||
#define TEMP_BUF 10000
|
||||
|
||||
#define ENUMCS_GRAY 16
|
||||
#define ENUMCS_SRGB 17
|
||||
#define ENUMCS_SYCC 18
|
||||
|
||||
#define J2K_CODESTREAM_MAGIC "\xff\x4f\xff\x51"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
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;
|
||||
|
||||
success = 0;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
opj_setup_decoder(dinfo, &dparameters);
|
||||
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len);
|
||||
|
||||
image = opj_decode(dinfo, cio);
|
||||
|
||||
free(src); cio->buffer = NULL;
|
||||
opj_cio_close(cio);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
success = 1;
|
||||
fin:
|
||||
if(dinfo)
|
||||
opj_destroy_decompress(dinfo);
|
||||
|
||||
if(image)
|
||||
opj_image_destroy(image);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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];
|
||||
|
||||
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 */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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].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;
|
||||
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;
|
||||
|
||||
if (image->numcomps == 1)
|
||||
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
|
||||
movie->tk[0].jp2_struct.enumcs = 0; // Unkown 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;
|
||||
|
||||
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)
|
||||
{
|
||||
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++;
|
||||
movie->tk[0].sample = (mj2_sample_t*)
|
||||
realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
|
||||
movie->tk[0].chunk = (mj2_chunk_t*)
|
||||
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
||||
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);
|
||||
|
||||
fin:
|
||||
fclose(mj2file);
|
||||
mj2_destroy_compress(movie);
|
||||
free(j2kfilename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
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
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
autoreconf --install --force
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||
|
||||
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||
set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||
|
||||
# Exclude files from the Testing directories
|
||||
@@ -22,11 +22,16 @@ SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||
".*/thirdparty/.*"
|
||||
)
|
||||
|
||||
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
set(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||
|
||||
# Suppress warning caused by intentional messages about deprecation
|
||||
".*warning,.* is deprecated"
|
||||
# supress warnings caused by 3rd party libs:
|
||||
".*/thirdparty/.*"
|
||||
# java also warns about deprecated API
|
||||
".*java.*deprecation"
|
||||
".*deprecation.*"
|
||||
# suppress warnings caused by 3rd party libs:
|
||||
".*thirdparty.*"
|
||||
"libtiff.*has no symbols"
|
||||
"libpng.*has no symbols"
|
||||
)
|
||||
26
cmake/EnsureFileInclude.cmake
Normal file
26
cmake/EnsureFileInclude.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
# Ensure that an include file is provided by the system
|
||||
# Add the check about the mandatory status to the check_include_file macro
|
||||
# provided by cmake
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
|
||||
macro(ensure_file_include INCLUDE_FILENAME VARIABLE_NAME MANDATORY_STATUS)
|
||||
|
||||
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||
|
||||
CHECK_INCLUDE_FILE(${INCLUDE_FILENAME} ${VARIABLE_NAME})
|
||||
|
||||
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||
# "VARIABLE_NAME_VALUE=${${VARIABLE_NAME}} \n"
|
||||
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||
|
||||
if (NOT ${${VARIABLE_NAME}})
|
||||
if (${MANDATORY_STATUS})
|
||||
message(FATAL_ERROR "The file ${INCLUDE_FILENAME} is mandatory but not found on your system")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
16
cmake/FindCPPCHECK.cmake
Normal file
16
cmake/FindCPPCHECK.cmake
Normal file
@@ -0,0 +1,16 @@
|
||||
# cppcheck
|
||||
#
|
||||
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
find_program(CPPCHECK_EXECUTABLE
|
||||
cppcheck
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
CPPCHECK_EXECUTABLE
|
||||
)
|
||||
20
cmake/FindFCGI.cmake
Normal file
20
cmake/FindFCGI.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Look for the header file.
|
||||
find_path(FCGI_INCLUDE_DIR NAMES fastcgi.h)
|
||||
|
||||
# Look for the library.
|
||||
find_library(FCGI_LIBRARY NAMES fcgi)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
if(FCGI_FOUND)
|
||||
set(FCGI_LIBRARIES ${FCGI_LIBRARY})
|
||||
set(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
|
||||
else()
|
||||
set(FCGI_LIBRARIES)
|
||||
set(FCGI_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||
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,19 +1,24 @@
|
||||
#
|
||||
# this module looks for KAKADu
|
||||
# this module looks for KAKADU
|
||||
# http://www.kakadusoftware.com/
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2006-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
# Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
FIND_PROGRAM(KDU_EXPAND_EXECUTABLE
|
||||
find_program(KDU_EXPAND_EXECUTABLE
|
||||
kdu_expand
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
KDU_EXPAND_EXECUTABLE
|
||||
find_program(KDU_COMPRESS_EXECUTABLE
|
||||
kdu_compress
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
KDU_EXPAND_EXECUTABLE
|
||||
KDU_COMPRESS_EXECUTABLE
|
||||
)
|
||||
@@ -12,20 +12,20 @@
|
||||
#=============================================================================
|
||||
#=============================================================================
|
||||
|
||||
FIND_PATH(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
find_path(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
|
||||
SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||
set(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||
|
||||
FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||
find_library(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||
|
||||
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
||||
|
||||
IF(LCMS_FOUND)
|
||||
SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||
SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||
ENDIF(LCMS_FOUND)
|
||||
if(LCMS_FOUND)
|
||||
set( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||
set( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||
endif()
|
||||
@@ -12,20 +12,20 @@
|
||||
#=============================================================================
|
||||
#=============================================================================
|
||||
|
||||
FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
find_path(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
|
||||
SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||
set(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||
|
||||
FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||
find_library(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||
|
||||
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||
mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
||||
|
||||
IF(LCMS2_FOUND)
|
||||
SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||
SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||
ENDIF(LCMS2_FOUND)
|
||||
if(LCMS2_FOUND)
|
||||
set( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||
set( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||
endif()
|
||||
@@ -7,7 +7,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||
endif()
|
||||
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
||||
endif(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||
endif()
|
||||
|
||||
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
||||
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
||||
@@ -28,43 +28,45 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
|
||||
# Make this explicit here, rather than accepting the CPack default value,
|
||||
# so we can refer to it:
|
||||
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||
set(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||
|
||||
IF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||
if(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||
# cygwin is good for the system name
|
||||
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
SET(CPACK_SYSTEM_NAME Cygwin)
|
||||
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||
IF(CMAKE_CL_64)
|
||||
SET(CPACK_SYSTEM_NAME win64-x64)
|
||||
ELSE(CMAKE_CL_64)
|
||||
SET(CPACK_SYSTEM_NAME win32-x86)
|
||||
ENDIF(CMAKE_CL_64)
|
||||
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
set(CPACK_SYSTEM_NAME Cygwin)
|
||||
else()
|
||||
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
endif()
|
||||
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||
if(CMAKE_CL_64)
|
||||
set(CPACK_SYSTEM_NAME win64-x64)
|
||||
else()
|
||||
set(CPACK_SYSTEM_NAME win32-x86)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||
# default to source package - system, on cygwin system is not
|
||||
# default to source package - system, on cygwin system is not
|
||||
# needed
|
||||
IF(CYGWIN)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||
ELSE(CYGWIN)
|
||||
SET(CPACK_PACKAGE_FILE_NAME
|
||||
if(CYGWIN)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||
else()
|
||||
set(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||
ENDIF(CYGWIN)
|
||||
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
SET(CPACK_BUNDLE_PLIST
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
#include(BundleUtilities)
|
||||
if(APPLE)
|
||||
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
set(CPACK_BUNDLE_PLIST
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
#include(BundleUtilities)
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
@@ -6,21 +6,21 @@
|
||||
# module to load OPENJPEG's settings for an external project.
|
||||
@OPENJPEG_CONFIG_INSTALL_ONLY@
|
||||
# The OPENJPEG version number.
|
||||
SET(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
||||
SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||
set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
||||
set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||
set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||
|
||||
# The libraries.
|
||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
|
||||
set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||
|
||||
# The CMake macros dir.
|
||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
|
||||
set(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||
|
||||
# The configuration options.
|
||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
|
||||
set(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||
|
||||
# The "use" file.
|
||||
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||
set(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||
|
||||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
@@ -29,20 +29,20 @@ if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||
|
||||
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
else()
|
||||
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||
# This is a build tree
|
||||
SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||
set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||
|
||||
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||
|
||||
else(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||
else()
|
||||
message(FATAL_ERROR "ooops")
|
||||
endif(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||
endif(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||
|
||||
# Backward compatible part:
|
||||
SET(OPENJPEG_FOUND TRUE)
|
||||
set(OPENJPEG_FOUND TRUE)
|
||||
|
||||
11
cmake/TestFileOffsetBits.c
Normal file
11
cmake/TestFileOffsetBits.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Cause a compile-time error if off_t is smaller than 64 bits */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
23
cmake/TestLargeFiles.c.cmake.in
Normal file
23
cmake/TestLargeFiles.c.cmake.in
Normal file
@@ -0,0 +1,23 @@
|
||||
#cmakedefine _LARGEFILE_SOURCE
|
||||
#cmakedefine _LARGE_FILES
|
||||
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Cause a compile-time error if off_t is smaller than 64 bits,
|
||||
* and make sure we have ftello / fseeko.
|
||||
*/
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||
FILE *fp = fopen(argv[0],"r");
|
||||
off_t offset = ftello( fp );
|
||||
|
||||
fseeko( fp, offset, SEEK_CUR );
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
134
cmake/TestLargeFiles.cmake
Normal file
134
cmake/TestLargeFiles.cmake
Normal file
@@ -0,0 +1,134 @@
|
||||
# - Define macro to check large file support
|
||||
#
|
||||
# OPJ_TEST_LARGE_FILES(VARIABLE)
|
||||
#
|
||||
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
|
||||
# This macro will also defines the necessary variable enable large file support, for instance
|
||||
# _LARGE_FILES
|
||||
# _LARGEFILE_SOURCE
|
||||
# _FILE_OFFSET_BITS 64
|
||||
# OPJ_HAVE_FSEEKO
|
||||
#
|
||||
# However, it is YOUR job to make sure these defines are set in a #cmakedefine so they
|
||||
# end up in a config.h file that is included in your source if necessary!
|
||||
#
|
||||
# Adapted from Gromacs project (http://www.gromacs.org/)
|
||||
# by Julien Malik
|
||||
#
|
||||
|
||||
macro(OPJ_TEST_LARGE_FILES VARIABLE)
|
||||
if(NOT DEFINED ${VARIABLE})
|
||||
|
||||
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
|
||||
# and then separately fseeko. However, in the future we might have 128-bit filesystems
|
||||
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
|
||||
|
||||
message(STATUS "Checking for 64-bit off_t")
|
||||
|
||||
# First check without any special flags
|
||||
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c")
|
||||
if(FILE64_OK)
|
||||
message(STATUS "Checking for 64-bit off_t - present")
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _FILE_OFFSET_BITS=64
|
||||
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
|
||||
if(FILE64_OK)
|
||||
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
||||
set(_FILE_OFFSET_BITS 64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _LARGE_FILES
|
||||
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
|
||||
if(FILE64_OK)
|
||||
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
||||
set(_LARGE_FILES 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
# Test with _LARGEFILE_SOURCE
|
||||
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||
if(FILE64_OK)
|
||||
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
||||
set(_LARGEFILE_SOURCE 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
#if(NOT FILE64_OK)
|
||||
# # now check for Windows stuff
|
||||
# try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||
# "${PROJECT_SOURCE_DIR}/cmake/TestWindowsFSeek.c")
|
||||
# if(FILE64_OK)
|
||||
# message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
||||
# set(HAVE__FSEEKI64 1)
|
||||
# endif()
|
||||
#endif()
|
||||
|
||||
if(NOT FILE64_OK)
|
||||
message(STATUS "Checking for 64-bit off_t - not present")
|
||||
endif()
|
||||
|
||||
set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64")
|
||||
set(_LARGE_FILES ${_LARGE_FILES} CACHE INTERNAL "Result of test for needed _LARGE_FILES")
|
||||
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||
|
||||
# Set the flags we might have determined to be required above
|
||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in"
|
||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
|
||||
message(STATUS "Checking for fseeko/ftello")
|
||||
|
||||
# Test if ftello/fseeko are available
|
||||
try_compile(FSEEKO_COMPILE_OK
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
message(STATUS "Checking for fseeko/ftello - present")
|
||||
endif()
|
||||
|
||||
if(NOT FSEEKO_COMPILE_OK)
|
||||
# glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...)
|
||||
try_compile(FSEEKO_COMPILE_OK
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
||||
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
||||
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FSEEKO_COMPILE_OK)
|
||||
set(OPJ_HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||
else()
|
||||
message(STATUS "Checking for fseeko/ftello - not found")
|
||||
set(OPJ_HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||
endif()
|
||||
|
||||
if(FILE64_OK AND FSEEKO_COMPILE_OK)
|
||||
message(STATUS "Large File support - found")
|
||||
set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support")
|
||||
else()
|
||||
message(STATUS "Large File support - not found")
|
||||
set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
|
||||
11
cmake/TestWindowsFSeek.c
Normal file
11
cmake/TestWindowsFSeek.c
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
__int64 off=0;
|
||||
|
||||
_fseeki64(NULL, off, SEEK_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
cmake/openjpeg_valgrind.supp
Normal file
39
cmake/openjpeg_valgrind.supp
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
{
|
||||
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||
Memcheck:Cond
|
||||
fun:deflate
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
fun:png_write_row
|
||||
fun:imagetopng
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||
Memcheck:Value8
|
||||
fun:crc32
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
fun:png_write_chunk
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
obj:/lib/libpng12.so.0.42.0
|
||||
fun:png_write_row
|
||||
fun:imagetopng
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
fun:__write_nocancel
|
||||
fun:_IO_file_write@@GLIBC_2.2.5
|
||||
fun:_IO_do_write@@GLIBC_2.2.5
|
||||
fun:_IO_file_close_it@@GLIBC_2.2.5
|
||||
fun:fclose@@GLIBC_2.2.5
|
||||
fun:imagetopng
|
||||
fun:main
|
||||
}
|
||||
540
configure.ac
540
configure.ac
@@ -1,540 +0,0 @@
|
||||
|
||||
# According to http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info :
|
||||
#
|
||||
# 1) when bugs are fixed or internal code is changed: increase MICRO
|
||||
# 2) if API is added, increase MINOR and set MICRO to 0
|
||||
# 3) if API or ABI is broken (this case should (must) never happen as it's very bad for a library), or a new designed library, increase MAJOR and set MINOR and MICRO to 0
|
||||
|
||||
m4_define([OPJ_MAJOR], [1])
|
||||
m4_define([OPJ_MINOR], [5])
|
||||
m4_define([OPJ_MICRO], [0])
|
||||
|
||||
m4_define([lt_cur], m4_eval(OPJ_MAJOR + OPJ_MINOR))
|
||||
m4_define([lt_rev], OPJ_MICRO)
|
||||
m4_define([lt_age], OPJ_MINOR)
|
||||
|
||||
AC_PREREQ([2.62])
|
||||
AC_INIT([OpenJPEG],
|
||||
[OPJ_MAJOR.OPJ_MINOR.OPJ_MICRO],
|
||||
[openjpeg@googlegroups.com],
|
||||
[openjpeg],
|
||||
[http://www.openjpeg.org])
|
||||
AC_CONFIG_SRCDIR([configure.ac])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_HEADERS([opj_config.h])
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 dist-xz dist-zip])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
MAJOR_NR=OPJ_MAJOR
|
||||
MINOR_NR=OPJ_MINOR
|
||||
MICRO_NR=OPJ_MICRO
|
||||
AC_SUBST([MAJOR_NR])
|
||||
AC_SUBST([MINOR_NR])
|
||||
AC_SUBST([MICRO_NR])
|
||||
|
||||
LT_PREREQ([2.0])
|
||||
LT_INIT([win32-dll])
|
||||
|
||||
lt_version=lt_cur:lt_rev:lt_age
|
||||
AC_SUBST([lt_version])
|
||||
|
||||
|
||||
### Needed information
|
||||
|
||||
have_win32=no
|
||||
have_darwin="no"
|
||||
case "$host_os" in
|
||||
mingw*)
|
||||
have_win32="yes"
|
||||
;;
|
||||
darwin*)
|
||||
have_darwin="yes"
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL([HAVE_WIN32], [test "x${have_win32}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_DARWIN], [test "x${have_darwin}" = "xyes"])
|
||||
|
||||
|
||||
### Additional options to configure
|
||||
|
||||
# debug
|
||||
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AC_HELP_STRING([--enable-debug], [build with debug symbols @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_debug="yes"
|
||||
else
|
||||
want_debug="no"
|
||||
fi
|
||||
],
|
||||
[want_debug="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build in debug mode])
|
||||
AC_MSG_RESULT([${want_debug}])
|
||||
|
||||
# MJ2
|
||||
|
||||
AC_ARG_ENABLE([mj2],
|
||||
[AC_HELP_STRING([--enable-mj2], [build mj2 binaries @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_mj2="yes"
|
||||
else
|
||||
want_mj2="no"
|
||||
fi
|
||||
],
|
||||
[want_mj2="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build the MJ2 binaries])
|
||||
AC_MSG_RESULT([${want_mj2}])
|
||||
|
||||
if test "x${want_mj2}" = "xyes" ; then
|
||||
AC_DEFINE(USE_MJ2, [1], [define to 1 if you use mj2])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([WANT_MJ2], [test "x${want_mj2}" = "xyes"])
|
||||
|
||||
# JPWL
|
||||
|
||||
AC_ARG_ENABLE([jpwl],
|
||||
[AC_HELP_STRING([--enable-jpwl], [build JPWL library @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_jpwl="yes"
|
||||
else
|
||||
want_jpwl="no"
|
||||
fi
|
||||
],
|
||||
[want_jpwl="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build the JPWL library])
|
||||
AC_MSG_RESULT([${want_jpwl}])
|
||||
|
||||
AM_CONDITIONAL([WANT_JPWL], [test "x${want_jpwl}" = "xyes"])
|
||||
|
||||
# JPIP
|
||||
|
||||
AC_ARG_ENABLE([jpip],
|
||||
[AC_HELP_STRING([--enable-jpip], [build jpip library @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_jpip="yes"
|
||||
else
|
||||
want_jpip="no"
|
||||
fi
|
||||
],
|
||||
[want_jpip="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build the JPIP library])
|
||||
AC_MSG_RESULT([${want_jpip}])
|
||||
|
||||
AC_ARG_ENABLE([jpip-server],
|
||||
[AC_HELP_STRING([--enable-jpip-server], [build jpip server @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_jpip_server="yes"
|
||||
else
|
||||
want_jpip_server="no"
|
||||
fi
|
||||
],
|
||||
[want_jpip_server="no"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build the JPIP server])
|
||||
AC_MSG_RESULT([${want_jpip_server}])
|
||||
|
||||
|
||||
### Checks for programs
|
||||
|
||||
AC_PROG_CC
|
||||
|
||||
# pkg-config
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# Check whether pkg-config supports Requires.private
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.22 ; then
|
||||
pkgconfig_requires_private="Requires.private"
|
||||
else
|
||||
pkgconfig_requires_private="Requires"
|
||||
fi
|
||||
AC_SUBST([pkgconfig_requires_private])
|
||||
AC_SUBST([requirements])
|
||||
|
||||
# doxygen
|
||||
|
||||
OPJ_CHECK_DOXYGEN
|
||||
|
||||
# ln -s
|
||||
|
||||
AC_PROG_LN_S
|
||||
|
||||
|
||||
### Checks for libraries
|
||||
|
||||
# libpng
|
||||
|
||||
have_libpng="no"
|
||||
|
||||
AC_ARG_ENABLE([png],
|
||||
[AC_HELP_STRING([--disable-png], [disable PNG support @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_png="yes"
|
||||
else
|
||||
want_png="no"
|
||||
fi
|
||||
],
|
||||
[want_png="yes"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build with PNG support])
|
||||
AC_MSG_RESULT([${want_png}])
|
||||
|
||||
if test "x${want_png}" = "xyes" ; then
|
||||
|
||||
PKG_CHECK_MODULES([PNG], [libpng15 zlib],
|
||||
[have_libpng="yes"],
|
||||
[
|
||||
PKG_CHECK_MODULES([PNG], [libpng14 zlib],
|
||||
[have_libpng="yes"],
|
||||
[
|
||||
PKG_CHECK_MODULES([PNG], [libpng12 zlib],
|
||||
[have_libpng="yes"],
|
||||
[
|
||||
PKG_CHECK_MODULES([PNG], [libpng zlib],
|
||||
[have_libpng="yes"],
|
||||
[have_libpng="no"])
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
if ! test "x${have_libpng}" = "xyes" ; then
|
||||
|
||||
OPJ_CHECK_LIB([zlib.h],
|
||||
[z],
|
||||
[zlibVersion],
|
||||
[
|
||||
OPJ_CHECK_LIB([png.h],
|
||||
[png],
|
||||
[png_access_version_number],
|
||||
[
|
||||
have_libpng="yes"
|
||||
PNG_CFLAGS="${PNG_CFLAGS} ${Z_CFLAGS}"
|
||||
PNG_LIBS="${PNG_LIBS} ${Z_LIBS}"
|
||||
],
|
||||
[have_libpng="no"])
|
||||
],
|
||||
[have_libpng="no"])
|
||||
|
||||
fi
|
||||
|
||||
if test "x${have_libpng}" = "xno" ; then
|
||||
AC_MSG_WARN([Can not find a usuable PNG library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether PNG is available])
|
||||
AC_MSG_RESULT([${have_libpng}])
|
||||
|
||||
if test "x${have_libpng}" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([with_libpng], [test x${have_libpng} = "xyes"])
|
||||
|
||||
# libtiff
|
||||
|
||||
have_libtiff="no"
|
||||
|
||||
AC_ARG_ENABLE([tiff],
|
||||
[AC_HELP_STRING([--disable-tiff], [disable TIFF support @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_tiff="yes"
|
||||
else
|
||||
want_tiff="no"
|
||||
fi
|
||||
],
|
||||
[want_tiff="yes"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build with TIFF support])
|
||||
AC_MSG_RESULT([${want_tiff}])
|
||||
|
||||
if test "x${want_tiff}" = "xyes" ; then
|
||||
|
||||
OPJ_CHECK_LIB(
|
||||
[tiff.h],
|
||||
[tiff],
|
||||
[TIFFOpen],
|
||||
[have_libtiff="yes"],
|
||||
[have_libtiff="no"])
|
||||
|
||||
if test "x${have_libtiff}" = "xno" ; then
|
||||
AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether TIFF is available])
|
||||
AC_MSG_RESULT([${have_libtiff}])
|
||||
|
||||
if test "x${have_libtiff}" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
|
||||
|
||||
# libcms2
|
||||
|
||||
lcms_output="no"
|
||||
have_lcms2="no"
|
||||
|
||||
AC_ARG_ENABLE([lcms2],
|
||||
[AC_HELP_STRING([--disable-lcms2], [disable LCMS-2 support @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_lcms2="yes"
|
||||
else
|
||||
want_lcms2="no"
|
||||
fi
|
||||
],
|
||||
[want_lcms2="yes"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build with LCMS-2 support])
|
||||
AC_MSG_RESULT([${want_lcms2}])
|
||||
|
||||
if test "x${want_lcms2}" = "xyes" ; then
|
||||
PKG_CHECK_MODULES([LCMS2], [lcms2],
|
||||
[have_lcms2="yes"],
|
||||
[have_lcms2="no"])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether LCMS-2 is available])
|
||||
AC_MSG_RESULT([${have_lcms2}])
|
||||
|
||||
if test "x${have_lcms2}" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
|
||||
lcms_output="lcms version 2.x"
|
||||
fi
|
||||
|
||||
# libcms1
|
||||
|
||||
AC_ARG_ENABLE([lcms1],
|
||||
[AC_HELP_STRING([--disable-lcms1], [disable LCMS-1 support @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_lcms1="yes"
|
||||
else
|
||||
want_lcms1="no"
|
||||
fi
|
||||
],
|
||||
[want_lcms1="yes"])
|
||||
|
||||
AC_MSG_CHECKING([whether to build with LCMS-1 support])
|
||||
AC_MSG_RESULT([${want_lcms1}])
|
||||
|
||||
if test "x${have_lcms2}" = "xno" ; then
|
||||
|
||||
if test "x${want_lcms1}" = "xyes" ; then
|
||||
PKG_CHECK_MODULES([LCMS1], [lcms1],
|
||||
[have_lcms1="yes"],
|
||||
[PKG_CHECK_MODULES([LCMS1], [lcms],
|
||||
[have_lcms1="yes"],
|
||||
[have_lcms1="no"])])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether LCMS-1 is available])
|
||||
AC_MSG_RESULT([${have_lcms1}])
|
||||
|
||||
if test "x${have_lcms1}" = "xyes" ; then
|
||||
AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
|
||||
lcms_output="lcms version 1.x"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# threads
|
||||
|
||||
if test "x${want_jpip_server}" = "xyes" ; then
|
||||
|
||||
if test "x${have_win32}" = "xno" ; then
|
||||
|
||||
SAVE_CFLAGS=${CFLAGS}
|
||||
CFLAGS="${CFLAGS} -pthread"
|
||||
SAVE_LIBS=${LIBS}
|
||||
LIBS="${LIBS} -pthread"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <pthread.h>
|
||||
]],
|
||||
[[
|
||||
pthread_t id;
|
||||
id = pthread_self();
|
||||
]])],
|
||||
[have_pthread="yes"],
|
||||
[have_pthread="no"])
|
||||
CFLAGS=${SAVE_CFLAGS}
|
||||
LIBS=${SAVE_LIBS}
|
||||
|
||||
AC_MSG_CHECKING([whether Pthread library is available])
|
||||
AC_MSG_RESULT([${have_pthread}])
|
||||
|
||||
if ! test "x${have_pthread}" = "xyes" ; then
|
||||
AC_MSG_WARN([Pthread library not found. OpenJPIP server will not be compiled.])
|
||||
want_jpip_server="no"
|
||||
else
|
||||
THREAD_CFLAGS="-pthread"
|
||||
THREAD_LIBS="-pthread"
|
||||
fi
|
||||
|
||||
else
|
||||
THREAD_LIBS="-lws2_32"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
AC_ARG_VAR([THREAD_CFLAGS], [compiler flag for the thread library])
|
||||
AC_SUBST([THREAD_CFLAGS])
|
||||
AC_ARG_VAR([THREAD_LIBS], [linker flags for thread library])
|
||||
AC_SUBST([THREAD_LIBS])
|
||||
|
||||
# libfcgi
|
||||
|
||||
if test "x${want_jpip_server}" = "xyes" ; then
|
||||
|
||||
have_fcgi="no"
|
||||
OPJ_CHECK_LIB(
|
||||
[fcgi_stdio.h],
|
||||
[fcgi],
|
||||
[FCGI_Accept],
|
||||
[have_fcgi="yes"],
|
||||
[have_fcgi="no"])
|
||||
|
||||
if ! test "x${have_fcgi}" = "xyes" ; then
|
||||
AC_MSG_WARN([FastCGI library not found. OpenJPIP server will not be compiled.])
|
||||
want_jpip_server="no"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# libcurl
|
||||
|
||||
if test "x${want_jpip_server}" = "xyes" ; then
|
||||
|
||||
PKG_CHECK_MODULES([LIBCURL], [libcurl],
|
||||
[have_libcurl="yes"],
|
||||
[have_libcurl="no"])
|
||||
|
||||
if ! test "x${have_libcurl}" = "xyes" ; then
|
||||
AC_MSG_WARN([libcurl library not found. OpenJPIP server will not be compiled.])
|
||||
want_jpip_server="no"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test "x${want_jpip}" = "xyes" ; then
|
||||
AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
|
||||
|
||||
if test "x${want_jpip_server}" = "xyes" ; then
|
||||
AC_DEFINE(USE_JPIP_SERVER, [1], [define to 1 if you use jpip server])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([WANT_JPIP_SERVER], [test "x${want_jpip_server}" = "xyes"])
|
||||
|
||||
AM_CONDITIONAL([WANT_JPIP_CODE], [test "x${want_jpip}" = "xyes" || test "x${want_jpip_server}" = "xyes"])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
## FIXME: declarations must be fixed in source code. See autoconf manual
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
|
||||
### Checks for types
|
||||
|
||||
|
||||
### Checks for structures
|
||||
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
AM_PROG_CC_C_O
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
#OPJ_COMPILER_FLAG([-Wall])
|
||||
#OPJ_COMPILER_FLAG([-Wextra])
|
||||
#OPJ_COMPILER_FLAG([-Wshadow])
|
||||
#OPJ_COMPILER_FLAG([-Wpointer-arith])
|
||||
OPJ_COMPILER_FLAG([-Wno-unused-result])
|
||||
|
||||
if test "x${want_debug}" = "xyes" ; then
|
||||
OPJ_COMPILER_FLAG([-g])
|
||||
OPJ_COMPILER_FLAG([-O0])
|
||||
else
|
||||
OPJ_COMPILER_FLAG([-O3])
|
||||
fi
|
||||
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
|
||||
### Checks for library functions
|
||||
|
||||
|
||||
### Post configuration
|
||||
|
||||
AM_CONDITIONAL([BUILD_SHARED], [test "x${enable_shared}" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_STATIC], [test "x${enable_static}" = "xyes"])
|
||||
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
libopenjpeg1.pc
|
||||
libopenjpeg-jpwl.pc
|
||||
libopenjpeg/Makefile
|
||||
libopenjpeg/jpwl/Makefile
|
||||
applications/Makefile
|
||||
applications/codec/Makefile
|
||||
applications/mj2/Makefile
|
||||
applications/jpip/Makefile
|
||||
applications/jpip/libopenjpip/Makefile
|
||||
applications/jpip/util/Makefile
|
||||
doc/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
### Summary
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo "------------------------------------------------------------------------"
|
||||
echo "$PACKAGE $VERSION"
|
||||
echo "------------------------------------------------------------------------"
|
||||
echo
|
||||
echo
|
||||
echo "Configuration Options Summary:"
|
||||
echo
|
||||
echo " Debug...............: ${want_debug}"
|
||||
echo
|
||||
echo " Optional support:"
|
||||
echo " libpng............: ${have_libpng}"
|
||||
echo " libtiff...........: ${have_libtiff}"
|
||||
echo " libcms............: ${lcms_output}"
|
||||
echo
|
||||
echo " Documentation.......: ${opj_have_doxygen}"
|
||||
echo " Build.............: make doc"
|
||||
echo
|
||||
echo " mj2.................: ${want_mj2}"
|
||||
echo " jpwl................: ${want_jpwl}"
|
||||
echo " jpip................: ${want_jpip}"
|
||||
echo " jpip server.........: ${want_jpip_server}"
|
||||
echo
|
||||
@@ -3,19 +3,50 @@
|
||||
# to generate the html documentation in the doc/html repository of the build folder.
|
||||
|
||||
# Try to find the doxygen tool
|
||||
FIND_PACKAGE(Doxygen)
|
||||
find_package(Doxygen)
|
||||
|
||||
IF(DOXYGEN_FOUND)
|
||||
if(DOXYGEN_FOUND)
|
||||
# Configure the doxygen config file with variable from CMake and move it
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
||||
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
|
||||
|
||||
|
||||
# Configure the html mainpage file of the doxygen documentation with variable
|
||||
# from CMake and move it
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox.in
|
||||
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpip.dox.in
|
||||
${CMAKE_BINARY_DIR}/doc/openjpip.dox @ONLY)
|
||||
# copy png file to make local (binary tree) documentation valid:
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_architect.png
|
||||
${CMAKE_BINARY_DIR}/doc/html/jpip_architect.png COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_protocol.png
|
||||
${CMAKE_BINARY_DIR}/doc/html/jpip_protocol.png COPYONLY)
|
||||
|
||||
file(GLOB headers
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.c
|
||||
)
|
||||
# Generate new target to build the html documentation
|
||||
ADD_CUSTOM_TARGET(doc ALL
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||
${CMAKE_BINARY_DIR}/doc/mainpage.dox
|
||||
${CMAKE_BINARY_DIR}/doc/openjpip.dox
|
||||
${headers}
|
||||
)
|
||||
add_custom_target(doc ALL
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
|
||||
COMMENT "Building doxygen documentation"
|
||||
)
|
||||
|
||||
ELSE(DOXYGEN_FOUND)
|
||||
|
||||
MESSAGE(STATUS "Doxygen not found, we cannot generate the documentation")
|
||||
|
||||
ENDIF(DOXYGEN_FOUND)
|
||||
# install HTML documentation (install png files too):
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
|
||||
DESTINATION share/doc
|
||||
PATTERN ".svn" EXCLUDE
|
||||
)
|
||||
else()
|
||||
message(STATUS "Doxygen not found, we cannot generate the documentation")
|
||||
endif()
|
||||
|
||||
290
doc/Doxyfile.dox
290
doc/Doxyfile.dox
@@ -1,290 +0,0 @@
|
||||
# Doxyfile 1.7.3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = OpenJPEG
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = .
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH = C://
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING =
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
SYMBOL_CACHE_SIZE = 0
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../libopenjpeg \
|
||||
../libopenjpeg/jpwl
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.h \
|
||||
*.c
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = ./html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||
DOCSET_PUBLISHER_NAME = Publisher
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
GENERATE_QHP = NO
|
||||
QCH_FILE =
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
QHP_CUST_FILTER_NAME =
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
QHG_LOCATION =
|
||||
GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
USE_INLINE_TREES = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
|
||||
SEARCHENGINE = NO
|
||||
SERVER_BASED_SEARCH = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = USE_JPWL \
|
||||
USE_JPSEC
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
DOT_NUM_THREADS = 0
|
||||
DOT_FONTNAME = Helvetica
|
||||
DOT_FONTSIZE = 10
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.7.3
|
||||
# Doxyfile 1.7.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
@@ -6,8 +6,6 @@
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = OpenJPEG
|
||||
PROJECT_NUMBER = @OPENJPEG_VERSION@
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = @OPENJPEG_BINARY_DIR@/doc
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
@@ -74,7 +72,6 @@ SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
@@ -100,24 +97,25 @@ WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = @OPENJPEG_SOURCE_DIR@/libopenjpeg \
|
||||
@OPENJPEG_SOURCE_DIR@/libopenjpeg/jpwl
|
||||
INPUT = @OPENJPEG_SOURCE_DIR@/src/lib/openjp2 \
|
||||
@OPENJPEG_SOURCE_DIR@/src/lib/openjpip \
|
||||
@OPENJPEG_BINARY_DIR@/doc
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.h \
|
||||
*.c
|
||||
RECURSIVE = NO
|
||||
*.c \
|
||||
*.dox
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = */.svn/*
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
IMAGE_PATH = @OPENJPEG_SOURCE_DIR@/doc
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -147,7 +145,7 @@ HTML_STYLESHEET =
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
@@ -180,8 +178,6 @@ TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
|
||||
SEARCHENGINE = NO
|
||||
SERVER_BASED_SEARCH = NO
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -281,7 +277,6 @@ DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
.PHONY: doc
|
||||
|
||||
PACKAGE_DOCNAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-doc
|
||||
|
||||
if OPJ_BUILD_DOC
|
||||
|
||||
doc-clean:
|
||||
rm -rf $(top_srcdir)/doc/html/ $(top_srcdir)/doc/$(PACKAGE_DOCNAME).tar*
|
||||
|
||||
doc: all
|
||||
cd $(top_srcdir)/doc && \
|
||||
$(opj_doxygen) Doxyfile.dox
|
||||
rm -rf $(PACKAGE_DOCNAME).tar*
|
||||
rm -rf $(top_srcdir)/doc/$(PACKAGE_DOCNAME).tar*
|
||||
mkdir -p $(PACKAGE_DOCNAME)/doc
|
||||
cp -R $(top_srcdir)/doc/html/ $(PACKAGE_DOCNAME)/doc
|
||||
tar cf $(PACKAGE_DOCNAME).tar $(PACKAGE_DOCNAME)/
|
||||
bzip2 -9 $(PACKAGE_DOCNAME).tar
|
||||
rm -rf $(PACKAGE_DOCNAME)/
|
||||
if ! test -f $(top_srcdir)/doc/$(PACKAGE_DOCNAME).tar.bz2 ; then \
|
||||
mv $(PACKAGE_DOCNAME).tar.bz2 $(top_srcdir)/doc; \
|
||||
fi
|
||||
|
||||
clean-local: doc-clean
|
||||
|
||||
else
|
||||
|
||||
doc:
|
||||
@echo "Documentation not built. Run ./configure --help"
|
||||
|
||||
endif
|
||||
|
||||
docsdir = $(docdir)-$(MAJOR_NR).$(MINOR_NR)
|
||||
docs_DATA = $(top_builddir)/LICENSE $(top_builddir)/CHANGES
|
||||
|
||||
dist_man1_MANS = \
|
||||
man/man1/image_to_j2k.1 \
|
||||
man/man1/j2k_dump.1 \
|
||||
man/man1/j2k_to_image.1
|
||||
|
||||
dist_man3_MANS = \
|
||||
man/man3/libopenjpeg.3
|
||||
|
||||
install-data-hook:
|
||||
cd $(DESTDIR)$(man1dir) && \
|
||||
rm -f jpwl_image_to_j2k.1 && \
|
||||
$(LN_S) image_to_j2k.1 jpwl_image_to_j2k.1
|
||||
cd $(DESTDIR)$(man1dir) && \
|
||||
rm -f jpwl_j2k_to_image.1 && \
|
||||
$(LN_S) j2k_to_image.1 jpwl_j2k_to_image.1
|
||||
cd $(DESTDIR)$(man3dir) && \
|
||||
rm -f jpwl_libopenjpeg.3 && \
|
||||
$(LN_S) libopenjpeg.3 jpwl_libopenjpeg.3
|
||||
@echo -e " (MAN)\t$(man1dir)/image_to_j2k.1" >> $(top_builddir)/report.txt
|
||||
@echo -e " (LN)\t$(man1dir)/jpwl_image_to_j2k.1" >> $(top_builddir)/report.txt
|
||||
@echo -e " (MAN)\t$(man1dir)/j2k_dump.1" >> $(top_builddir)/report.txt
|
||||
@echo -e " (MAN)\t$(man1dir)/j2k_to_image.1" >> $(top_builddir)/report.txt
|
||||
@echo -e " (LN)\t$(man1dir)//jpwl_j2k_to_image.1" >> $(top_builddir)/report.txt
|
||||
@echo -e " (MAN)\t$(man3dir)/libopenjpeg.3" >> $(top_builddir)/report.txt
|
||||
@echo -e " (LN)\t$(man3dir)/jpwl_libopenjpeg.3" >> $(top_builddir)/report.txt
|
||||
|
||||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(man1dir)/jpwl_image_to_j2k.1
|
||||
rm -f $(DESTDIR)$(man1dir)/jpwl_j2k_to_image.1
|
||||
rm -f $(DESTDIR)$(man3dir)/jpwl_libopenjpeg.3
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
Doxyfile.dox
|
||||
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
62
doc/mainpage.dox.in
Normal file
62
doc/mainpage.dox.in
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \mainpage OpenJPEG v@OPENJPEG_VERSION@ Documentation
|
||||
*
|
||||
* \section intro Introduction
|
||||
* This manual documents the low-level OpenJPEG C API.\n
|
||||
* The OpenJPEG library is an open-source JPEG 2000 library developed in order to promote the use of JPEG 2000.\n
|
||||
* This documents is focused on the main part of the library which try to implement Part 1 and Part 2 of the JPEG2000 norm.\n
|
||||
*
|
||||
* \section home Home page
|
||||
*
|
||||
* The Home Page of the OpenJPEG project can be found at:
|
||||
*
|
||||
* http://www.openjpeg.org/
|
||||
*
|
||||
* The source code repository is available here:
|
||||
*
|
||||
* http://github.com/uclouvain/openjpeg
|
||||
*
|
||||
* The OpenJPEG mailing list is located here:
|
||||
*
|
||||
* http://groups.google.com/group/openjpeg
|
||||
*
|
||||
* The test files repository is available here:
|
||||
*
|
||||
* http://github.com/uclouvain/openjpeg-data
|
||||
*
|
||||
* \section license License
|
||||
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||
*
|
||||
* \author OpenJPEG Team
|
||||
*
|
||||
*/
|
||||
@@ -29,10 +29,10 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH image_to_j2k 1 "Version 1.4.0" "image_to_j2k" "converts to jpeg2000 files"
|
||||
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
image_to_j2k -
|
||||
opj_compress -
|
||||
This program reads in an image of a certain type and converts it to a
|
||||
jpeg2000 file. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
@@ -43,11 +43,11 @@ Valid output image extensions are
|
||||
.B .j2k, .jp2
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B image_to_j2k -i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||
.B opj_compress -i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||
.P
|
||||
.B image_to_j2k -ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||
.B opj_compress -ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||
.P
|
||||
.B image_to_j2k -h \fRPrint a help message and exit.
|
||||
.B opj_compress -h \fRPrint a help message and exit.
|
||||
.P
|
||||
.R See JPWL OPTIONS for special options
|
||||
.SH OPTIONS
|
||||
@@ -194,18 +194,18 @@ Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||
.P
|
||||
.SH EXAMPLES
|
||||
.P
|
||||
.B image_to_j2k -i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||
.B opj_compress -i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||
.P
|
||||
.B image_to_j2k -i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||
.B opj_compress -i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||
.P
|
||||
.B image_to_j2k -i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||
.B opj_compress -i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||
.P
|
||||
.B image_to_j2k -i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||
.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
|
||||
@@ -218,5 +218,5 @@ Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
.P
|
||||
.SH "SEE ALSO"
|
||||
j2k_to_image(1) j2k_dump(1)
|
||||
opj_decompress(1) opj_dump(1)
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH j2k_to_image 1 "Version 1.4.0" "j2k_to_image" "converts jpeg2000 files"
|
||||
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
j2k_to_image -
|
||||
opj_decompress -
|
||||
This program reads in a jpeg2000 image and converts it to another
|
||||
image type. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
@@ -43,11 +43,11 @@ Valid output image extensions are
|
||||
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B j2k_to_image -i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||
.B opj_decompress -i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||
.P
|
||||
.B j2k_to_image -ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||
.B opj_decompress -ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||
.P
|
||||
.B j2k_to_image -h \fRPrint help message and exit
|
||||
.B opj_decompress -h \fRPrint help message and exit
|
||||
.P
|
||||
.R See JPWL OPTIONS for special options
|
||||
.SH OPTIONS
|
||||
@@ -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
|
||||
@@ -106,4 +116,4 @@ Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
.P
|
||||
.SH "SEE ALSO"
|
||||
image_to_j2k(1) j2k_dump(1)
|
||||
opj_compress(1) opj_dump(1)
|
||||
@@ -29,10 +29,10 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH j2k_dump 1 "Version 1.4.0" "j2k_dump" "dumps jpeg2000 files"
|
||||
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
j2k_dump -
|
||||
opj_dump -
|
||||
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
Valid input image extensions are
|
||||
@@ -40,11 +40,11 @@ Valid input image extensions are
|
||||
.SP
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B j2k_dump -i \fRinfile.j2k
|
||||
.B opj_dump -i \fRinfile.j2k
|
||||
.P
|
||||
.B j2k_dump -ImgDir \fRimages/ \fRDump all files in images/
|
||||
.B opj_dump -ImgDir \fRimages/ \fRDump all files in images/
|
||||
.P
|
||||
.B j2k_dump -h \fRPrint help message and exit
|
||||
.B opj_dump -h \fRPrint help message and exit
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
@@ -56,7 +56,7 @@ Valid input image extensions are
|
||||
.P
|
||||
'\".SH BUGS
|
||||
.SH AUTHORS
|
||||
Copyright (c) 20010, Mathieu Malaterre
|
||||
Copyright (c) 2010, Mathieu Malaterre
|
||||
.P
|
||||
.SH "SEE ALSO"
|
||||
image_to_j2k(1) j2k_to_image(1)
|
||||
opj_compress(1) opj_decompress(1)
|
||||
@@ -29,10 +29,10 @@
|
||||
.SP
|
||||
.fi
|
||||
..
|
||||
.TH libopenjpeg 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
|
||||
.TH libopenjp2 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
|
||||
.P
|
||||
.SH NAME
|
||||
libopenjpeg -
|
||||
libopenjp2 -
|
||||
a library for reading and writing JPEG2000 image files.
|
||||
.SP
|
||||
.SH SYNOPSIS
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user