Compare commits
948 Commits
arelease
...
version.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9586bc669c | ||
|
|
78dc93512b | ||
|
|
6778ef6a25 | ||
|
|
20eb15b760 | ||
|
|
8c71728242 | ||
|
|
4140dfdea8 | ||
|
|
259f629a46 | ||
|
|
c302efcf86 | ||
|
|
e0b5b08f9a | ||
|
|
dac95eff3a | ||
|
|
4f4de7070e | ||
|
|
78d1820881 | ||
|
|
de73cfeec1 | ||
|
|
49044ae2a8 | ||
|
|
6e0162a8a6 | ||
|
|
910af7edec | ||
|
|
69cd4f9211 | ||
|
|
6fc2b56847 | ||
|
|
773bd89130 | ||
|
|
5d356d6fcb | ||
|
|
a2f90ab2cb | ||
|
|
a05a9aa4ed | ||
|
|
af2be2d456 | ||
|
|
96dba34ddc | ||
|
|
6aad1208b2 | ||
|
|
d2be8c5d21 | ||
|
|
b42f76cb7f | ||
|
|
07163be7ed | ||
|
|
4e672cc1e9 | ||
|
|
ced9a50367 | ||
|
|
a1683bd7c2 | ||
|
|
f968a70e22 | ||
|
|
2fe6bac6eb | ||
|
|
15243144c4 | ||
|
|
c0c69d1c36 | ||
|
|
d9d62a77ee | ||
|
|
15488c94d2 | ||
|
|
75175b715c | ||
|
|
46831582b2 | ||
|
|
e55d5e29e0 | ||
|
|
c02f145cd1 | ||
|
|
6280b5ad8d | ||
|
|
7720188fa7 | ||
|
|
20f9f96719 | ||
|
|
4776f48477 | ||
|
|
c2f32bb485 | ||
|
|
bba708462d | ||
|
|
4935eaf773 | ||
|
|
bad9a71e77 | ||
|
|
a74a41b932 | ||
|
|
6b5bbc2645 | ||
|
|
8b5f815925 | ||
|
|
abce31e706 | ||
|
|
8062f74deb | ||
|
|
b8fecbbc99 | ||
|
|
cd8896968d | ||
|
|
b94bc0dbe2 | ||
|
|
083d4c2361 | ||
|
|
6c5a066b20 | ||
|
|
835bf5357f | ||
|
|
8a279881d4 | ||
|
|
6da56bb11a | ||
|
|
8cd13f3a55 | ||
|
|
eeca4a220c | ||
|
|
e17dcf58c9 | ||
|
|
39ac7c479f | ||
|
|
401e9cbb5c | ||
|
|
5dbf771bb9 | ||
|
|
ce9d5083ef | ||
|
|
baa7e32f9c | ||
|
|
097496a9f0 | ||
|
|
6b649f3bf6 | ||
|
|
65f8ae765e | ||
|
|
3aba3e203b | ||
|
|
95cf10e979 | ||
|
|
3a643798bd | ||
|
|
875591f664 | ||
|
|
4e8aea6b5a | ||
|
|
5379ec5715 | ||
|
|
b431cb0a41 | ||
|
|
dfbab28b4d | ||
|
|
3819c1b5f4 | ||
|
|
b09cd38b08 | ||
|
|
da453218a4 | ||
|
|
e0795464c1 | ||
|
|
fab8de59d3 | ||
|
|
dcf78f14f6 | ||
|
|
d1a1653f2a | ||
|
|
5a817eba3d | ||
|
|
ce5bbefff0 | ||
|
|
a5d96e54b9 | ||
|
|
2dddf54f8b | ||
|
|
992409c00c | ||
|
|
ee9c46d350 | ||
|
|
87a1081f7c | ||
|
|
83332e13ad | ||
|
|
675f34fabd | ||
|
|
0c7b21c46f | ||
|
|
590ba6d460 | ||
|
|
6f314ae48e | ||
|
|
24ab49a363 | ||
|
|
ecb36f02c8 | ||
|
|
8c9fd1b351 | ||
|
|
dd999a2840 | ||
|
|
b3b2ee0925 | ||
|
|
58cfcaff9f | ||
|
|
c1c2d24b16 | ||
|
|
cefa643823 | ||
|
|
64e37e2a66 | ||
|
|
545680cdb4 | ||
|
|
23cab09e07 | ||
|
|
8336ace29a | ||
|
|
a794ee233d | ||
|
|
a39e4a2a82 | ||
|
|
b267239603 | ||
|
|
54e4e8f809 | ||
|
|
8fc06de0c5 | ||
|
|
9a5ab44e35 | ||
|
|
4d76145884 | ||
|
|
bdf1343f62 | ||
|
|
52f5452d4d | ||
|
|
a9b7c7b0b4 | ||
|
|
07521a5dc2 | ||
|
|
d1bb3ed1f2 | ||
|
|
6c6cd79820 | ||
|
|
7b6ae8810d | ||
|
|
699f172e6c | ||
|
|
5fbf79e730 | ||
|
|
aa28216f9b | ||
|
|
e449cb706f | ||
|
|
a85c5151ce | ||
|
|
ed58a22d2e | ||
|
|
3408787101 | ||
|
|
948dfd50c0 | ||
|
|
46da9f2294 | ||
|
|
995b145f09 | ||
|
|
451a41064e | ||
|
|
c6b02b10fe | ||
|
|
36b66a8796 | ||
|
|
f1e441596e | ||
|
|
d5fa5605c4 | ||
|
|
427b2427d4 | ||
|
|
09522e65af | ||
|
|
19cfaac52e | ||
|
|
21c38214ef | ||
|
|
577fdbc8a5 | ||
|
|
f93aed8031 | ||
|
|
326c58b4e1 | ||
|
|
ec0c69af7a | ||
|
|
21509a3955 | ||
|
|
5b2ca9caf6 | ||
|
|
529006f136 | ||
|
|
7d96e7c1c0 | ||
|
|
e2948acd92 | ||
|
|
6dc8635e28 | ||
|
|
7d0a419c87 | ||
|
|
0ea0e8b915 | ||
|
|
8e53bad7fb | ||
|
|
9c51a37dbf | ||
|
|
aa00142949 | ||
|
|
87b05f2885 | ||
|
|
baf01b98fd | ||
|
|
6dd7da0e05 | ||
|
|
4949b593be | ||
|
|
0ed7aa7c1b | ||
|
|
02b906f6ad | ||
|
|
6a03e3a438 | ||
|
|
ec33653961 | ||
|
|
133426ddfe | ||
|
|
aab317eb8c | ||
|
|
f3f86e1eb7 | ||
|
|
040c9a68b6 | ||
|
|
2b746a71cb | ||
|
|
ba01e855a3 | ||
|
|
d3c1a49246 | ||
|
|
85bbc6def8 | ||
|
|
5bd5d894eb | ||
|
|
452403d393 | ||
|
|
fc268dff90 | ||
|
|
180dd26df1 | ||
|
|
d27bc19d71 | ||
|
|
b7b72bbf97 | ||
|
|
e1340fe087 | ||
|
|
32e80bc4a7 | ||
|
|
8d18c77a7d | ||
|
|
f492f0a3d6 | ||
|
|
6b43ba091e | ||
|
|
5dfadb2eb1 | ||
|
|
30944454de | ||
|
|
0e7529c272 | ||
|
|
c9986d1b78 | ||
|
|
4bc00a40ca | ||
|
|
80f69364b0 | ||
|
|
2e3900780d | ||
|
|
d530d35024 | ||
|
|
e96f7a5f50 | ||
|
|
79ce6ccce5 | ||
|
|
b7e489c901 | ||
|
|
dbd60c1469 | ||
|
|
007409e2af | ||
|
|
b82b6cbd05 | ||
|
|
f26b96dd5c | ||
|
|
7e6c287d78 | ||
|
|
6b1e9d1b4e | ||
|
|
d88dfc3472 | ||
|
|
64f08e216b | ||
|
|
c9ae2a5fbc | ||
|
|
51ae8b7926 | ||
|
|
3280dc344f | ||
|
|
0b7e0166a7 | ||
|
|
5fe8eed4da | ||
|
|
9d4d3b2cd0 | ||
|
|
02d9f43802 | ||
|
|
00b479cb79 | ||
|
|
6219ad32b0 | ||
|
|
a3a161660a | ||
|
|
2643f79069 | ||
|
|
fba8f701c4 | ||
|
|
4bcd3a1e42 | ||
|
|
594148ae83 | ||
|
|
2a2f169b27 | ||
|
|
e576aa9f06 | ||
|
|
c469e1339f | ||
|
|
abf9809c22 | ||
|
|
3ebdd674d8 | ||
|
|
a13abdaf65 | ||
|
|
72867bc692 | ||
|
|
b081ff2813 | ||
|
|
9d1bd03be4 | ||
|
|
82e539d333 | ||
|
|
548a49bb7f | ||
|
|
dc9a8b03aa | ||
|
|
c6e0b71633 | ||
|
|
0c350f4908 | ||
|
|
01749cb8a2 | ||
|
|
49f1a5ff54 | ||
|
|
ff1f022d47 | ||
|
|
3459199eba | ||
|
|
544e8c9de0 | ||
|
|
735b40989d | ||
|
|
09f2926cd5 | ||
|
|
238b767917 | ||
|
|
49a0f0db8f | ||
|
|
6a1530e4b1 | ||
|
|
8d8841c84f | ||
|
|
1dc6eddf1c | ||
|
|
c1510793e3 | ||
|
|
d728868263 | ||
|
|
8a2af121a4 | ||
|
|
9e60c2f8e9 | ||
|
|
d35f647aaa | ||
|
|
adbccc2e56 | ||
|
|
642d09f5cb | ||
|
|
d1cb786dd8 | ||
|
|
182e4b1882 | ||
|
|
73106fe839 | ||
|
|
40b4ecfaec | ||
|
|
fb82b6d7d9 | ||
|
|
5d6ac5ea72 | ||
|
|
3d06f03072 | ||
|
|
5213675ba8 | ||
|
|
9a89e2f162 | ||
|
|
e89eb575ac | ||
|
|
d15f01b6e3 | ||
|
|
9ec5e8cf9a | ||
|
|
4c9acc22b8 | ||
|
|
6adb5f5070 | ||
|
|
d1d662768d | ||
|
|
4091882dfb | ||
|
|
61e0ed6a96 | ||
|
|
9c7899372b | ||
|
|
a098921d34 | ||
|
|
8ed4cb1a1e | ||
|
|
721904bc26 | ||
|
|
2724f85cad | ||
|
|
e3e2dc1f6e | ||
|
|
4f329cbb45 | ||
|
|
0e8995aa7e | ||
|
|
7812030886 | ||
|
|
6fb9794200 | ||
|
|
9e419fdaf7 | ||
|
|
e634cd0d62 | ||
|
|
676f8f189f | ||
|
|
40b989ce00 | ||
|
|
df44837b07 | ||
|
|
16998b4b6d | ||
|
|
f57c4fd0c2 | ||
|
|
5743cca5f8 | ||
|
|
e716a316f6 | ||
|
|
c2b0a8101b | ||
|
|
f88a57e5d7 | ||
|
|
1776120dba | ||
|
|
f4601aff8b | ||
|
|
14799e25c6 | ||
|
|
eea61ee5e4 | ||
|
|
ff6d246efd | ||
|
|
a7f08e9b36 | ||
|
|
3e1d8d6aef | ||
|
|
fda0cada0e | ||
|
|
06363c01e4 | ||
|
|
ec398229b1 | ||
|
|
a19c8a4ea3 | ||
|
|
f8de2fc8eb | ||
|
|
0380840348 | ||
|
|
9cd5752e38 | ||
|
|
65f7f8dc50 | ||
|
|
a58987d082 | ||
|
|
0f101066f2 | ||
|
|
cbe26cbb88 | ||
|
|
36c8d85f43 | ||
|
|
f753a1c36c | ||
|
|
c0ea54e518 | ||
|
|
d2bfeaa5e2 | ||
|
|
025bc9fbe1 | ||
|
|
c85e1a10cf | ||
|
|
acccedbbb7 | ||
|
|
6106e48397 | ||
|
|
0358177c3f | ||
|
|
875ac79d0e | ||
|
|
9350a47153 | ||
|
|
6230ec13b4 | ||
|
|
0a9cd082db | ||
|
|
3f5b6c7aca | ||
|
|
826fda959c | ||
|
|
a5130aebab | ||
|
|
fa6aea80f5 | ||
|
|
b09051fd79 | ||
|
|
1837d6efa0 | ||
|
|
74583409ec | ||
|
|
3da66d4d79 | ||
|
|
645d7cab86 | ||
|
|
d737981cfe | ||
|
|
dd51c25641 | ||
|
|
b7969ce657 | ||
|
|
5cee7cfc40 | ||
|
|
586581685c | ||
|
|
88f43b15fa | ||
|
|
0c9f6a3ac9 | ||
|
|
18cb325a8e | ||
|
|
ed71feac52 | ||
|
|
7fe3933faa | ||
|
|
9837e01971 | ||
|
|
5b1dc83382 | ||
|
|
42e5077688 | ||
|
|
081178cd9a | ||
|
|
fb29d47f0c | ||
|
|
1dc2654b54 | ||
|
|
2a5a6416a5 | ||
|
|
175fd6692c | ||
|
|
31dba0b4e9 | ||
|
|
27b894dd3f | ||
|
|
6aaaa3eae2 | ||
|
|
16f205d886 | ||
|
|
87e4c72ee4 | ||
|
|
5ef5fc65ae | ||
|
|
e93d5a683f | ||
|
|
91419e0e3e | ||
|
|
74626a17db | ||
|
|
1ab46eeff2 | ||
|
|
70177d55b0 | ||
|
|
1fd9603c55 | ||
|
|
279b67c838 | ||
|
|
19f9147e10 | ||
|
|
6bda73eeb2 | ||
|
|
9f349b0988 | ||
|
|
91ce5625b5 | ||
|
|
a3df1f5c5e | ||
|
|
86edc0a40e | ||
|
|
89456eed51 | ||
|
|
e023107e97 | ||
|
|
af71acb043 | ||
|
|
e12008a718 | ||
|
|
c9bae1fd46 | ||
|
|
3a73ff3bc2 | ||
|
|
99c3c5a4af | ||
|
|
a1920bc5c2 | ||
|
|
9a811cb52a | ||
|
|
55c8c2bc77 | ||
|
|
fbffea94a9 | ||
|
|
c7e17d06c8 | ||
|
|
75fa7a8d87 | ||
|
|
5e3290a486 | ||
|
|
90725df206 | ||
|
|
066bda52c0 | ||
|
|
2514c5b550 | ||
|
|
3f234ac21b | ||
|
|
420750f5ca | ||
|
|
51f7cc6874 | ||
|
|
c4252ed824 | ||
|
|
97c5fe052c | ||
|
|
5f1e13e770 | ||
|
|
d2d6e1fd6f | ||
|
|
08459fd944 | ||
|
|
985a163e33 | ||
|
|
7441340ab5 | ||
|
|
50b3b5c991 | ||
|
|
73a6ed7c21 | ||
|
|
56afd80506 | ||
|
|
398b3f08b0 | ||
|
|
1dd92890d7 | ||
|
|
436d2f4bb9 | ||
|
|
0264197f3f | ||
|
|
b487a3521c | ||
|
|
816d914c4e | ||
|
|
c0fd0c8f89 | ||
|
|
ebcda80583 | ||
|
|
407b95e35f | ||
|
|
d08a96e251 | ||
|
|
59d9b97ffe | ||
|
|
cf39198a9a | ||
|
|
02229c7c2d | ||
|
|
1c2ed5cc33 | ||
|
|
efc709578a | ||
|
|
eb5694ca2a | ||
|
|
389166e86e | ||
|
|
2b31495723 | ||
|
|
d5b44a98bc | ||
|
|
0e5551da99 | ||
|
|
3afd3b1afd | ||
|
|
223a39b51e | ||
|
|
8faf300b6e | ||
|
|
5c76f68168 | ||
|
|
ad970dd9df | ||
|
|
161891a06e | ||
|
|
709068ef5b | ||
|
|
2b7f6f82be | ||
|
|
005b1b1a4b | ||
|
|
3eab8f975e | ||
|
|
2a4563a677 | ||
|
|
af32de46a2 | ||
|
|
f35d25c674 | ||
|
|
0dc7f6a2d3 | ||
|
|
bb9232c9d9 | ||
|
|
87cb9efb99 | ||
|
|
4c9a60d4fd | ||
|
|
e36881487d | ||
|
|
56dd722fb4 | ||
|
|
c2f441840f | ||
|
|
a55ea39677 | ||
|
|
fc668f3ec3 | ||
|
|
c515199674 | ||
|
|
b6102e207c | ||
|
|
ddc9a278aa | ||
|
|
e65ef3a24f | ||
|
|
f4b08bacb0 | ||
|
|
ae6cf3da7d | ||
|
|
03133377fa | ||
|
|
106da2f51e | ||
|
|
72b6fdb04b | ||
|
|
453af11e2c | ||
|
|
eeefefd56c | ||
|
|
531c0cf26f | ||
|
|
b7208fb525 | ||
|
|
dc700d5d50 | ||
|
|
00f7af7748 | ||
|
|
9989de4bd0 | ||
|
|
fcbf45ca64 | ||
|
|
509f7a64ea | ||
|
|
e80d147957 | ||
|
|
2cea89dc7d | ||
|
|
1a79adb3a9 | ||
|
|
8dbd92f6c2 | ||
|
|
d22912349b | ||
|
|
26e8f3fd28 | ||
|
|
86864a2f6c | ||
|
|
7c65e4c14b | ||
|
|
a56fbe42a4 | ||
|
|
9427107b94 | ||
|
|
75c589958a | ||
|
|
3e8cad7e39 | ||
|
|
e4c4d146e1 | ||
|
|
34e592341c | ||
|
|
94b9942cd9 | ||
|
|
d5f9ea9fc2 | ||
|
|
f6ed93253b | ||
|
|
3479749499 | ||
|
|
89eafad589 | ||
|
|
8bb5a19905 | ||
|
|
84f77a71e5 | ||
|
|
da0d29e4ab | ||
|
|
f30f4c744e | ||
|
|
6621494d9d | ||
|
|
2374885ac0 | ||
|
|
784cf66dc2 | ||
|
|
6c641471b2 | ||
|
|
18c30c30d6 | ||
|
|
a1b6f1e096 | ||
|
|
a02c683572 | ||
|
|
8ecce4df3d | ||
|
|
9af159c200 | ||
|
|
b96b24ce8c | ||
|
|
fdf04af271 | ||
|
|
203a264f96 | ||
|
|
b5ff4ffedc | ||
|
|
6628a4df45 | ||
|
|
627f484bce | ||
|
|
d03779ee2a | ||
|
|
3e4b0ee509 | ||
|
|
54214fb65f | ||
|
|
3ecae15da2 | ||
|
|
c2da8234d9 | ||
|
|
20d5c4c1a8 | ||
|
|
34c485169e | ||
|
|
cb4702b4c5 | ||
|
|
c1a51d68a6 | ||
|
|
9324bc4cd4 | ||
|
|
449d7bedb6 | ||
|
|
bfd3fe8a4a | ||
|
|
9dbbc6ca13 | ||
|
|
83abf56736 | ||
|
|
a695c8eb51 | ||
|
|
a69db02b7f | ||
|
|
73d8401465 | ||
|
|
4a90f97639 | ||
|
|
4da178b0d8 | ||
|
|
f4bbad8615 | ||
|
|
cebdbda260 | ||
|
|
1d45d7514b | ||
|
|
846bd364be | ||
|
|
295ad6b112 | ||
|
|
f4d394d932 | ||
|
|
65e5ff0fb4 | ||
|
|
2f3dd4916f | ||
|
|
a92cc111a2 | ||
|
|
52296999f6 | ||
|
|
9652def4de | ||
|
|
6d1f3ecc9f | ||
|
|
396cb1e102 | ||
|
|
ac0cc6df62 | ||
|
|
29ea3dde47 | ||
|
|
e21d865440 | ||
|
|
04966097fc | ||
|
|
8c2ae8b03d | ||
|
|
9947453ea8 | ||
|
|
4514e333c6 | ||
|
|
daff186ceb | ||
|
|
8359fbd5e7 | ||
|
|
13209d2565 | ||
|
|
9a6f0596b0 | ||
|
|
901308cbc8 | ||
|
|
ea6d8f5aaf | ||
|
|
4051e87d06 | ||
|
|
4619a94ebf | ||
|
|
287fb0b8fd | ||
|
|
847b082b64 | ||
|
|
5f995bcf4b | ||
|
|
64ed560f4f | ||
|
|
1a33a09726 | ||
|
|
26606c71c8 | ||
|
|
e06bcd027f | ||
|
|
9e5d165e79 | ||
|
|
efa5f7977c | ||
|
|
c458af9cd6 | ||
|
|
010ae27471 | ||
|
|
24e189e4d8 | ||
|
|
61a15672bb | ||
|
|
dbeebe72b9 | ||
|
|
014694b04f | ||
|
|
6a1588c78e | ||
|
|
6d7f5ccc8d | ||
|
|
4bb067642f | ||
|
|
c38de0728d | ||
|
|
b93c12564d | ||
|
|
95d760a173 | ||
|
|
123a680669 | ||
|
|
9e114bcaa4 | ||
|
|
5fdc05d18d | ||
|
|
1f11a4fe90 | ||
|
|
ab0473aa42 | ||
|
|
4b60f17bba | ||
|
|
6265dcfb11 | ||
|
|
7e40a9475a | ||
|
|
a6ba04cdf4 | ||
|
|
55c4c14352 | ||
|
|
569bbb0077 | ||
|
|
abfba20b99 | ||
|
|
09231c317d | ||
|
|
1e705438e4 | ||
|
|
d70a0415b9 | ||
|
|
3816e0edf4 | ||
|
|
e7149e0c56 | ||
|
|
3392d99487 | ||
|
|
263e0f3bb2 | ||
|
|
b29cff9b9c | ||
|
|
2479921c71 | ||
|
|
53471a76f1 | ||
|
|
8ac5e7023c | ||
|
|
dfcacb8247 | ||
|
|
cf95a80be6 | ||
|
|
be5db9489e | ||
|
|
f3456a27e7 | ||
|
|
375754f1e6 | ||
|
|
f9c5f4565a | ||
|
|
86da5c2589 | ||
|
|
23891ede86 | ||
|
|
b4dc6fc133 | ||
|
|
0533b5b78e | ||
|
|
976ca18103 | ||
|
|
7e874368f7 | ||
|
|
d3d2a36fbc | ||
|
|
564e16d5ce | ||
|
|
c4313f0b39 | ||
|
|
7a2d96efe1 | ||
|
|
acfe0ad645 | ||
|
|
d07fa5d9d0 | ||
|
|
c101f8049c | ||
|
|
bd0b6ec2fd | ||
|
|
1d02a8b595 | ||
|
|
07be749bf2 | ||
|
|
2952874cb8 | ||
|
|
1cfbdcc9ce | ||
|
|
d4d23c7eb5 | ||
|
|
adca52578d | ||
|
|
3810e943b1 | ||
|
|
ca2a0114a2 | ||
|
|
2c75c27ee8 | ||
|
|
1d0dbeb232 | ||
|
|
d9924962ff | ||
|
|
00e440ebdb | ||
|
|
17f0828c74 | ||
|
|
8298fd2b0a | ||
|
|
7dcb817e6a | ||
|
|
9cf692e897 | ||
|
|
4f4aa1d49f | ||
|
|
9e5a83d8f9 | ||
|
|
c45b8e6c38 | ||
|
|
64d72b7bfd | ||
|
|
b7ce19709d | ||
|
|
5dec8bbbe9 | ||
|
|
4a50efe542 | ||
|
|
bdb18ab19c | ||
|
|
167fb6337b | ||
|
|
c924975434 | ||
|
|
92398409a5 | ||
|
|
c647671607 | ||
|
|
2845d9bf64 | ||
|
|
3d626da232 | ||
|
|
f428a306a1 | ||
|
|
aec1d7592c | ||
|
|
21f2cab710 | ||
|
|
ea9335ff48 | ||
|
|
adc1aacb60 | ||
|
|
814bab6900 | ||
|
|
1f55aaf4a6 | ||
|
|
8be8111008 | ||
|
|
1bec8fe082 | ||
|
|
7d06d7fb5d | ||
|
|
e0ee9becb4 | ||
|
|
0afa3c70bc | ||
|
|
38137b033a | ||
|
|
1200dd871a | ||
|
|
f3170bf64e | ||
|
|
7c9dc11e33 | ||
|
|
848214e789 | ||
|
|
e5240301c7 | ||
|
|
2bd0f7b8c4 | ||
|
|
fbc9a5edcb | ||
|
|
110b54c7c6 | ||
|
|
dbd132dca8 | ||
|
|
0930d9886b | ||
|
|
dd18811600 | ||
|
|
24146a96cf | ||
|
|
7dd3a5bf22 | ||
|
|
9ba672366e | ||
|
|
a1fe5809a4 | ||
|
|
5a3c1ffe7d | ||
|
|
144e1ff4e6 | ||
|
|
3f36196dfd | ||
|
|
f7c9b01800 | ||
|
|
6045158ce6 | ||
|
|
694a173adb | ||
|
|
8bc6da2ffa | ||
|
|
78003a016a | ||
|
|
9e5d0b1a40 | ||
|
|
219dd65bef | ||
|
|
ba423fe3d0 | ||
|
|
e2a54d9ac6 | ||
|
|
44ab0ccf01 | ||
|
|
192e46c32f | ||
|
|
e5c5d1064e | ||
|
|
2fb6da8d85 | ||
|
|
fd680a1cf0 | ||
|
|
313c772f4a | ||
|
|
0781b7d441 | ||
|
|
e6ce7958f2 | ||
|
|
d268ea7d6a | ||
|
|
0eaafe93ac | ||
|
|
8a75823eea | ||
|
|
e841b13166 | ||
|
|
7cb2194c8e | ||
|
|
eac141b69a | ||
|
|
d084ff59f2 | ||
|
|
dcc6f679bc | ||
|
|
3f5e8eb92b | ||
|
|
16879e20ec | ||
|
|
b700cd9101 | ||
|
|
a6d7377213 | ||
|
|
d48feb45fc | ||
|
|
b5c8558934 | ||
|
|
521b9bef33 | ||
|
|
ed3aec55fd | ||
|
|
ef560f19a3 | ||
|
|
6b9d244449 | ||
|
|
16dc670030 | ||
|
|
acd2187a43 | ||
|
|
b8445ebec0 | ||
|
|
4b75a2784c | ||
|
|
2b3947e8a8 | ||
|
|
1c43ca006d | ||
|
|
bc145d8dc8 | ||
|
|
76ee6b8441 | ||
|
|
3adfd18602 | ||
|
|
9e42842bb5 | ||
|
|
a8591daa68 | ||
|
|
265de2ed0d | ||
|
|
36007b6a76 | ||
|
|
34661c5aea | ||
|
|
d53edb5ea7 | ||
|
|
16fbba79ec | ||
|
|
fb4ad9c507 | ||
|
|
9eaaf55f7a | ||
|
|
dc069254c3 | ||
|
|
b97f88bf7e | ||
|
|
2c03b73dff | ||
|
|
6cc148e226 | ||
|
|
f9d76c0be9 | ||
|
|
bcf7032b8b | ||
|
|
0ace960ea5 | ||
|
|
b420c330b2 | ||
|
|
7fd2ae9786 | ||
|
|
3d2f2b4048 | ||
|
|
9fc6e4f4bd | ||
|
|
07fa11a94c | ||
|
|
36c6e4abb9 | ||
|
|
15949d43d1 | ||
|
|
696cd710df | ||
|
|
2d416a8017 | ||
|
|
b565431251 | ||
|
|
480021bc33 | ||
|
|
af448b94a1 | ||
|
|
4bd7195ea6 | ||
|
|
331d3e523d | ||
|
|
b5aee428ba | ||
|
|
3386c7765a | ||
|
|
97a3327f99 | ||
|
|
173ccf70d4 | ||
|
|
7860407cb5 | ||
|
|
4d6bd49719 | ||
|
|
9aa9170110 | ||
|
|
4b3aabebd2 | ||
|
|
1093244d43 | ||
|
|
0577ed8e6e | ||
|
|
4f87b9abd1 | ||
|
|
abe8e93c21 | ||
|
|
f222743e19 | ||
|
|
190b4b7c9e | ||
|
|
d55af7fe7e | ||
|
|
817681fb98 | ||
|
|
f0721df1d9 | ||
|
|
76d29b8df1 | ||
|
|
2f9aae7671 | ||
|
|
0108506433 | ||
|
|
b883da435b | ||
|
|
6a4572a56f | ||
|
|
fba75d93c4 | ||
|
|
c2b399b363 | ||
|
|
786ec27a05 | ||
|
|
2a505f73c4 | ||
|
|
e318641bfa | ||
|
|
6566009e89 | ||
|
|
a350bdc1c4 | ||
|
|
23eeec8769 | ||
|
|
f31d963a64 | ||
|
|
5e0948c142 | ||
|
|
73ada6ce7f | ||
|
|
48311061c1 | ||
|
|
39ad332cee | ||
|
|
90a4692c48 | ||
|
|
fe720be147 | ||
|
|
8d7b0c9c05 | ||
|
|
33b5757921 | ||
|
|
355b88c15d | ||
|
|
74c1b3637e | ||
|
|
9ffd9e6619 | ||
|
|
1460d23294 | ||
|
|
75cf4f0906 | ||
|
|
85c327861a | ||
|
|
c5c3ca370e | ||
|
|
72de930d08 | ||
|
|
8a662fa4b1 | ||
|
|
7546f19b51 | ||
|
|
55fb4d0b67 | ||
|
|
61e353d652 | ||
|
|
5ff45287ea | ||
|
|
6b27c32ee8 | ||
|
|
44869986ca | ||
|
|
2f75846baf | ||
|
|
ec2b3b3b3f | ||
|
|
b9b72f1951 | ||
|
|
ebeb57d7d3 | ||
|
|
e6aae96217 | ||
|
|
511d342a94 | ||
|
|
a1ec600b42 | ||
|
|
06185ea2d1 | ||
|
|
fc42b3ec84 | ||
|
|
5432a70c79 | ||
|
|
d02b01dc85 | ||
|
|
cc3e813786 | ||
|
|
d280fdef70 | ||
|
|
40fd335947 | ||
|
|
6a52f1a9df | ||
|
|
197b0505cb | ||
|
|
f8d899c4f1 | ||
|
|
d5ecae07ad | ||
|
|
8f9f70f922 | ||
|
|
69dcece31a | ||
|
|
34c8a555fa | ||
|
|
fe33ebe83c | ||
|
|
237bb54678 | ||
|
|
95bc884365 | ||
|
|
e45e87cfb7 | ||
|
|
2dc3ca544d | ||
|
|
4fb43c8af0 | ||
|
|
a5d33c992d | ||
|
|
dbd4b4945b | ||
|
|
17704c6e2f | ||
|
|
a35e8df118 | ||
|
|
d9c1214282 | ||
|
|
0674edc2ca | ||
|
|
f335cb0e0b | ||
|
|
c447f6e6bc | ||
|
|
884c8429fc | ||
|
|
5cf0326dcb | ||
|
|
59835a580e | ||
|
|
08f7bfbb5f | ||
|
|
f61cda9b7d | ||
|
|
76016d509b | ||
|
|
4458ef921c | ||
|
|
c9ac67cd05 | ||
|
|
cff5df73d9 | ||
|
|
e398154212 | ||
|
|
0ea26e7ba6 | ||
|
|
8f3bd54c3d | ||
|
|
18a9bcb882 | ||
|
|
7ee36c3a4c | ||
|
|
7f8f47566f | ||
|
|
d6a523e091 | ||
|
|
ac634b1639 | ||
|
|
a0513798bb | ||
|
|
8f4d6bbeba | ||
|
|
cd98a4f740 | ||
|
|
e25e7e767e | ||
|
|
de75303c38 | ||
|
|
32ba9920db | ||
|
|
7ae6a670fa | ||
|
|
cf4f8be5f0 | ||
|
|
ec1b970a32 | ||
|
|
ee6d0cfba9 | ||
|
|
789f6f8e7a | ||
|
|
3d2a52cd82 | ||
|
|
384068ce8c | ||
|
|
7e518596e0 | ||
|
|
f9eb8f93c2 | ||
|
|
d54925f777 | ||
|
|
eae26f958e | ||
|
|
ee7c2c28f1 | ||
|
|
8a2e6ecd8b | ||
|
|
1b0a585256 | ||
|
|
29b6a4307a | ||
|
|
ad4857df94 | ||
|
|
a73e37301a | ||
|
|
255e296113 | ||
|
|
e4696a445d | ||
|
|
81f688433d | ||
|
|
0130af0ff4 | ||
|
|
2cbcbb25b0 | ||
|
|
5197135a0a | ||
|
|
4c67811f65 | ||
|
|
8e8afafae6 | ||
|
|
370cfc43a2 | ||
|
|
d101633cfa | ||
|
|
128bcc4f62 | ||
|
|
050737bea0 | ||
|
|
63e17a19eb | ||
|
|
61e85ded8b | ||
|
|
1cc9fa6815 | ||
|
|
7bdb0331a6 | ||
|
|
623f1d96cf | ||
|
|
1de9535b8c | ||
|
|
68ebc572fc | ||
|
|
5f44ec7d01 | ||
|
|
10aee43cbc | ||
|
|
7e2e09e2a9 | ||
|
|
86ce4d4c18 | ||
|
|
361edd25b7 | ||
|
|
85691a02a6 | ||
|
|
1f96f0e92a | ||
|
|
34a6c13a2d | ||
|
|
542f06007c | ||
|
|
fdbca0fc9d | ||
|
|
632902d7e3 | ||
|
|
9310f1b4a9 | ||
|
|
ed0a46eff5 | ||
|
|
8323900f73 | ||
|
|
c83ae7397d | ||
|
|
3b1bee0eec | ||
|
|
ba1cf545df | ||
|
|
bfb2f9f58b | ||
|
|
13b8ecfe44 | ||
|
|
9e9e188ebf | ||
|
|
5034581e69 | ||
|
|
85ec5eccf7 | ||
|
|
9c8fcc3616 | ||
|
|
7976b61c89 | ||
|
|
43a6b92345 | ||
|
|
f25acae0bc | ||
|
|
9225f53d62 | ||
|
|
eb1b017ec7 | ||
|
|
0ddef9b2db | ||
|
|
1bdb07cefe | ||
|
|
0a879e2207 | ||
|
|
f3c3eab744 | ||
|
|
08209f1d23 | ||
|
|
3ec116ae08 | ||
|
|
3b600a986c | ||
|
|
0d4a38f3a5 | ||
|
|
2410db2ae7 | ||
|
|
e1278bc691 | ||
|
|
899439a906 | ||
|
|
02e3a4ec77 | ||
|
|
7250ce0668 | ||
|
|
2ebe5f2c92 | ||
|
|
3c730a804b | ||
|
|
313975debf | ||
|
|
0abe8e1997 | ||
|
|
bc5c5115cb | ||
|
|
61ac18531a | ||
|
|
0ee21bdbfe | ||
|
|
d116ca5d10 | ||
|
|
26a630dad2 | ||
|
|
2c2730280e | ||
|
|
2e2ba14c53 | ||
|
|
9fa68ca811 | ||
|
|
d38080aa00 | ||
|
|
aa6c1d28ad | ||
|
|
ba4fd784f5 | ||
|
|
3d67d80d49 | ||
|
|
25e97927f9 |
13
AUTHORS
Normal file
13
AUTHORS
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Authors of OpenJPEG
|
||||||
|
See also the files THANKS and CHANGES
|
||||||
|
|
||||||
|
David Janssens designed and implemented the first version of OpenJPEG.
|
||||||
|
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
||||||
|
Jerome Fimes implemented the alpha version of OpenJPEG v2.
|
||||||
|
Giuseppe Baruffa added the JPWL functionalities.
|
||||||
|
Yannick Verschueren,
|
||||||
|
Herve Drolon,
|
||||||
|
Francois-Olivier Devaux,
|
||||||
|
Antonin Descampe
|
||||||
|
improved the libraries and utilities.
|
||||||
|
|
||||||
198
CHANGES
Normal file
198
CHANGES
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
2012-10-01 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2028] CMakeLists.txt: [1.5] Start opj 1.5.2
|
||||||
|
* [r2029] libopenjpeg/jp2.c: [1.5] jp2_read_boxhdr() can trigger
|
||||||
|
random pointer memory access
|
||||||
|
|
||||||
|
Fixes issue 155
|
||||||
|
|
||||||
|
2012-10-02 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2031] libopenjpeg/Makefile.am, libopenjpeg/jpwl/Makefile.am:
|
||||||
|
[1.5] int main() in t1_generate_luts.c breaks mplayer
|
||||||
|
|
||||||
|
Fixes issue 152
|
||||||
|
* [r2032] libopenjpeg/j2k.c: [1.5] division by zero in j2k_read_siz
|
||||||
|
|
||||||
|
Fixes issue 169
|
||||||
|
* [r2033] libopenjpeg/j2k.c: [1.5] missing range check in
|
||||||
|
j2k_read_coc et al.
|
||||||
|
|
||||||
|
Fixes issue 166
|
||||||
|
* [r2035] libopenjpeg/CMakeLists.txt: [1.5] Build small internal
|
||||||
|
tools to generate t1_luts.h
|
||||||
|
|
||||||
|
2012-10-22 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2107] CMakeLists.txt, applications/JavaOpenJPEG/CMakeLists.txt:
|
||||||
|
[1.5] Fix Java binding issues.
|
||||||
|
|
||||||
|
Properly link to math lib on UNIX
|
||||||
|
Make JNI install location a user configuration
|
||||||
|
Remove SONAME property from the java module
|
||||||
|
|
||||||
|
2012-12-07 Rex Dieter
|
||||||
|
|
||||||
|
* [r2260] doc/Doxyfile.dox, doc/Doxyfile.dox.cmake.in: backport
|
||||||
|
r2259
|
||||||
|
|
||||||
|
Doxyfile: HTML_TIMESTAMP = NO
|
||||||
|
|
||||||
|
helps when comparing the output of multiple runs,
|
||||||
|
and distros will appreciate avoiding multilib conflicts.
|
||||||
|
|
||||||
|
2012-12-18 Mickaël Savinaud
|
||||||
|
|
||||||
|
* [r2265] applications/codec/convert.c: [1.5] improve the bmp read
|
||||||
|
function for RGB8 case (thanks Winfried). Update issue 203
|
||||||
|
|
||||||
|
2013-02-27 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2299] libopenjpeg/opj_includes.h: [1.5] Rework #ifdef checks.
|
||||||
|
We should check for _M_IX86 instead of not(_M_X64). Thanks to
|
||||||
|
Misha Ulyutin for report on ML
|
||||||
|
|
||||||
|
2013-03-14 Mickaël Savinaud
|
||||||
|
|
||||||
|
* [r2305] configure.ac: [b1.5.x] update the micro version into the
|
||||||
|
configure file (thanks to winfried)
|
||||||
|
|
||||||
|
2013-07-11 Antonin Descampe
|
||||||
|
|
||||||
|
* [r2345] tests/conformance/CMakeLists.txt: tests : reactivated
|
||||||
|
conformance tests in openjpeg 1.5 branch to enable comparison
|
||||||
|
with trunk
|
||||||
|
|
||||||
|
2013-09-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2346] libopenjpeg/image.c: [1.5] Import patch suggested in bug
|
||||||
|
#241
|
||||||
|
|
||||||
|
2014-02-24 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2390] libopenjpeg/bio.c: [1.5] Remove some simple warnings
|
||||||
|
* [r2391] CMake/CTestCustom.cmake.in: [1.5] Do not report warning
|
||||||
|
on third party lib
|
||||||
|
|
||||||
|
2014-02-25 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2420] tests/nonregression/CMakeLists.txt,
|
||||||
|
tests/nonregression/checkmd5refs.cmake,
|
||||||
|
tests/nonregression/md5refs.txt,
|
||||||
|
tests/nonregression/test_suite.ctest.in: [1.5] Import md5 checker
|
||||||
|
from trunk back onto 1.5 branch
|
||||||
|
* [r2423] libopenjpeg/j2k.c: [1.5] Remove addition from r1702 this
|
||||||
|
introduced a regression as seen in issue 205
|
||||||
|
|
||||||
|
Fixes issue 205
|
||||||
|
|
||||||
|
2014-02-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2437] tests/CMakeLists.txt, tests/conformance/CMakeLists.txt,
|
||||||
|
tests/nonregression/CMakeLists.txt, tests/unit/CMakeLists.txt:
|
||||||
|
[1.5] Use new add_test signature to handle cross compilation and
|
||||||
|
execution using wine
|
||||||
|
* [r2438] applications/codec/convert.c,
|
||||||
|
applications/codec/image_to_j2k.c, applications/codec/j2k_dump.c,
|
||||||
|
applications/codec/j2k_to_image.c, libopenjpeg/jp2.c,
|
||||||
|
libopenjpeg/tcd.c: [1.5] Import first patch (fixes.patch) from
|
||||||
|
issue 249 to fix leaks on error condition.
|
||||||
|
|
||||||
|
Update issue 249
|
||||||
|
* [r2439] applications/codec/image_to_j2k.c,
|
||||||
|
applications/codec/j2k_to_image.c: [1.5] Declare functions static
|
||||||
|
to track unused ones.
|
||||||
|
|
||||||
|
2014-03-04 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2564] CMakeLists.txt: [1.5] Use improved find_path syntax to
|
||||||
|
help cross-compilation setup find openjpeg data root
|
||||||
|
|
||||||
|
2014-03-12 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2696] applications/codec/convert.c, tests/unit/testempty2.c:
|
||||||
|
[1.5] Fix remainings warnings on 1.5 branch
|
||||||
|
* [r2697] applications/jpip/libopenjpip/msgqueue_manager.c: [1.5]
|
||||||
|
Prevent buffer overflow in openjpip code
|
||||||
|
|
||||||
|
2014-03-17 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2750] applications/common/opj_getopt.c: [1.5] Update BSD-4
|
||||||
|
copyright into a BSD-3 copyright
|
||||||
|
Update issue 300
|
||||||
|
* [r2752] libopenjpeg/jp2.c, libopenjpeg/t1_generate_luts.c: [1.5]
|
||||||
|
Remove simple warning about C++ style comments
|
||||||
|
* [r2753] applications/codec/convert.c,
|
||||||
|
applications/common/color.c, libopenjpeg/j2k.c,
|
||||||
|
libopenjpeg/jp2.c, libopenjpeg/t1_generate_luts.c,
|
||||||
|
libopenjpeg/tcd.c: [1.5] Remove another set of simple warnings
|
||||||
|
|
||||||
|
2014-03-18 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2757] libopenjpeg/cio.c, libopenjpeg/j2k.c, libopenjpeg/jp2.c,
|
||||||
|
libopenjpeg/t2.c, libopenjpeg/tcd.c,
|
||||||
|
tests/nonregression/test_suite.ctest.in: [1.5] Import portion of
|
||||||
|
patch from issue 297
|
||||||
|
Run test suite on new datasets
|
||||||
|
Update issue 297
|
||||||
|
* [r2758] libopenjpeg/jp2.c, libopenjpeg/tcd.c: [1.5] Import patch
|
||||||
|
from trunk to make test passes. Affects:
|
||||||
|
NR-DEC-2977.pdf.asan.67.2198.jp2-52-decode &
|
||||||
|
NR-DEC-4149.pdf.SIGSEGV.cf7.3501.jp2-50-decode
|
||||||
|
* [r2759] libopenjpeg/j2k.c: [1.5] Check the number of tiles
|
||||||
|
* [r2760] libopenjpeg/tcd.c: [1.5] Rework r2758 the conditions were
|
||||||
|
not quite right. Update checks.
|
||||||
|
* [r2762] applications/codec/convert.c: [1.5] Fix issues with big
|
||||||
|
endian handling
|
||||||
|
Fixes issue 302
|
||||||
|
* [r2765] applications/jpip/util/CMakeLists.txt: [1.5] Add a way
|
||||||
|
for user to override source/target java version
|
||||||
|
Update issue 303
|
||||||
|
* [r2768] CMakeLists.txt, applications/codec/CMakeLists.txt,
|
||||||
|
applications/common/opj_getopt.c,
|
||||||
|
applications/common/opj_getopt.h, opj_config.h.cmake.in,
|
||||||
|
tests/CMakeLists.txt: [1.5] Create a new cmake option to choose
|
||||||
|
between convienient copy of getopt and system installed one
|
||||||
|
Udapte issue 301
|
||||||
|
* [r2769] applications/codec/image_to_j2k.c,
|
||||||
|
applications/codec/j2k_dump.c, applications/codec/j2k_to_image.c,
|
||||||
|
applications/common/opj_getopt.h: [1.5] Rework r2768 in fact
|
||||||
|
getopt_long is slightly different on GNU. Adapt signature to
|
||||||
|
handle BSD signature and GNU one.
|
||||||
|
Update issue 301
|
||||||
|
|
||||||
|
2014-03-24 Rex Dieter
|
||||||
|
|
||||||
|
* [r2780] configure.ac: Calling AC_CANONICAL_SYSTEM implies
|
||||||
|
AC_CANONICAL_TARGET, which
|
||||||
|
gives incorrect results when cross compiling. Calling only
|
||||||
|
AC_CANONICAL_HOST is enough.
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
* [r2781] doc/Makefile.am: Install jpwl man pages only if jpwl is
|
||||||
|
enabled
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
* [r2782] m4/opj_check_lib.m4: Improve check for standard libs
|
||||||
|
|
||||||
|
Previously, with <lib>_LIBS and <lib>_CFLAGS undefined,
|
||||||
|
the most basic compile command "$CC conftest.c -l<lib>" was not
|
||||||
|
tested.
|
||||||
|
|
||||||
|
issue: 129
|
||||||
|
|
||||||
|
2014-03-25 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2800] applications/codec/Makefile.am,
|
||||||
|
applications/jpip/libopenjpip/CMakeLists.txt: [1.5] Import patch
|
||||||
|
from bug tracker
|
||||||
|
Thanks to winfried
|
||||||
|
Fixes issue 304
|
||||||
|
|
||||||
|
2014-03-26 Mathieu Malaterre
|
||||||
|
|
||||||
|
* [r2807] configure.ac: [1.5] Fix big endian checking with
|
||||||
|
autotools
|
||||||
|
Thanks to winfried for patch
|
||||||
|
Fixes issue 302
|
||||||
|
|
||||||
34
CMake/CTestCustom.cmake.in
Normal file
34
CMake/CTestCustom.cmake.in
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# For further details regarding this file,
|
||||||
|
# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
|
||||||
|
#
|
||||||
|
# and
|
||||||
|
# http://www.kitware.com/blog/home/post/27
|
||||||
|
#
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||||
|
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
|
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
|
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||||
|
|
||||||
|
# Exclude files from the Testing directories
|
||||||
|
".*/tests/.*"
|
||||||
|
|
||||||
|
# Exclude files from the ThirdParty Utilities directories
|
||||||
|
".*/thirdparty/.*"
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
|
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||||
|
|
||||||
|
# Suppress warning caused by intentional messages about deprecation
|
||||||
|
".*warning,.* is deprecated"
|
||||||
|
# supress warnings caused by 3rd party libs:
|
||||||
|
".*thirdparty.*"
|
||||||
|
"libtiff.*has no symbols"
|
||||||
|
"libpng.*has no symbols"
|
||||||
|
)
|
||||||
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(FCGI_FOUND)
|
||||||
|
SET(FCGI_LIBRARIES)
|
||||||
|
SET(FCGI_INCLUDE_DIRS)
|
||||||
|
ENDIF(FCGI_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||||
19
CMake/FindKAKADU.cmake
Normal file
19
CMake/FindKAKADU.cmake
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#
|
||||||
|
# this module looks for KAKADu
|
||||||
|
# http://www.kakadusoftware.com/
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
FIND_PROGRAM(KDU_EXPAND_EXECUTABLE
|
||||||
|
kdu_expand
|
||||||
|
)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
KDU_EXPAND_EXECUTABLE
|
||||||
|
)
|
||||||
31
CMake/FindLCMS.cmake
Normal file
31
CMake/FindLCMS.cmake
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# - Find LCMS library
|
||||||
|
# Find the native LCMS includes and library
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LCMS_INCLUDE_DIR - Where to find lcms.h, etc.
|
||||||
|
# LCMS_LIBRARIES - Libraries to link against to use LCMS.
|
||||||
|
# LCMS_FOUND - If false, do not try to use LCMS.
|
||||||
|
#
|
||||||
|
# also defined, but not for general use are
|
||||||
|
# LCMS_LIBRARY, where to find the LCMS library.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
FIND_PATH(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||||
|
|
||||||
|
SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||||
|
|
||||||
|
FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(LCMS_FOUND)
|
||||||
|
SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||||
|
SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||||
|
ENDIF(LCMS_FOUND)
|
||||||
31
CMake/FindLCMS2.cmake
Normal file
31
CMake/FindLCMS2.cmake
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# - Find LCMS2 library
|
||||||
|
# Find the native LCMS2 includes and library
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LCMS2_INCLUDE_DIR - Where to find lcms2.h, etc.
|
||||||
|
# LCMS2_LIBRARIES - Libraries to link against to use LCMS2.
|
||||||
|
# LCMS2_FOUND - If false, do not try to use LCMS2.
|
||||||
|
#
|
||||||
|
# also defined, but not for general use are
|
||||||
|
# LCMS2_LIBRARY - Where to find the LCMS2 library.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||||
|
|
||||||
|
SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||||
|
|
||||||
|
FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(LCMS2_FOUND)
|
||||||
|
SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||||
|
SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||||
|
ENDIF(LCMS2_FOUND)
|
||||||
9
CMake/JPIPTestDriver.cmake
Normal file
9
CMake/JPIPTestDriver.cmake
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# JPIP test driver
|
||||||
|
#message(STATUS "${D_URL}")
|
||||||
|
file(DOWNLOAD
|
||||||
|
"${D_URL}"
|
||||||
|
"${D_FILE}"
|
||||||
|
LOG log
|
||||||
|
EXPECTED_MD5 "${EXPECTED_MD5}"
|
||||||
|
)
|
||||||
|
message(STATUS "LOG: ${log}")
|
||||||
70
CMake/OpenJPEGCPack.cmake
Normal file
70
CMake/OpenJPEGCPack.cmake
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# package bundler
|
||||||
|
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||||
|
if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||||
|
set(CMAKE_INSTALL_MFC_LIBRARIES 0)
|
||||||
|
set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
|
||||||
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||||
|
endif()
|
||||||
|
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
||||||
|
endif(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||||
|
|
||||||
|
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
||||||
|
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
|
||||||
|
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
|
||||||
|
)
|
||||||
|
# For PackageMaker on MacOSX it is important to have a file extension:
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH "${OPENJPEG_VERSION_BUILD}")
|
||||||
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
|
|
||||||
|
# Make this explicit here, rather than accepting the CPack default value,
|
||||||
|
# so we can refer to it:
|
||||||
|
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||||
|
|
||||||
|
IF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
|
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||||
|
# cygwin is good for the system name
|
||||||
|
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
SET(CPACK_SYSTEM_NAME Cygwin)
|
||||||
|
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||||
|
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||||
|
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
IF(CMAKE_CL_64)
|
||||||
|
SET(CPACK_SYSTEM_NAME win64-x64)
|
||||||
|
ELSE(CMAKE_CL_64)
|
||||||
|
SET(CPACK_SYSTEM_NAME win32-x86)
|
||||||
|
ENDIF(CMAKE_CL_64)
|
||||||
|
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
|
||||||
|
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||||
|
# default to source package - system, on cygwin system is not
|
||||||
|
# needed
|
||||||
|
IF(CYGWIN)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||||
|
ELSE(CYGWIN)
|
||||||
|
SET(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||||
|
ENDIF(CYGWIN)
|
||||||
|
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
|
||||||
|
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
|
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
SET(CPACK_BUNDLE_PLIST
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
#include(BundleUtilities)
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||||
54
CMake/OpenJPEGConfig.cmake.in
Normal file
54
CMake/OpenJPEGConfig.cmake.in
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# OPENJPEGConfig.cmake - CMake configuration file for external projects.
|
||||||
|
#
|
||||||
|
# This file is configured by OPENJPEG and used by the UseOPENJPEG.cmake
|
||||||
|
# module to load OPENJPEG's settings for an external project.
|
||||||
|
@OPENJPEG_CONFIG_INSTALL_ONLY@
|
||||||
|
# The OPENJPEG version number.
|
||||||
|
SET(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
||||||
|
SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||||
|
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||||
|
|
||||||
|
# The libraries.
|
||||||
|
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||||
|
|
||||||
|
# The CMake macros dir.
|
||||||
|
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||||
|
|
||||||
|
# The configuration options.
|
||||||
|
SET(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||||
|
|
||||||
|
# The "use" file.
|
||||||
|
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||||
|
|
||||||
|
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
# The following is inspired from:
|
||||||
|
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||||||
|
# However the following is difficult to handle:
|
||||||
|
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
|
||||||
|
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
|
||||||
|
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
# This is an install tree
|
||||||
|
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||||
|
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||||
|
|
||||||
|
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
# This is a build tree
|
||||||
|
SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||||
|
|
||||||
|
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
|
||||||
|
else(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
message(FATAL_ERROR "ooops")
|
||||||
|
endif(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
endif(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
|
||||||
|
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||||
|
|
||||||
|
# Backward compatible part:
|
||||||
|
SET(OPENJPEG_FOUND TRUE)
|
||||||
|
|
||||||
306
CMakeLists.txt
Normal file
306
CMakeLists.txt
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
|
||||||
|
# Written by Mathieu Malaterre
|
||||||
|
|
||||||
|
# This CMake project will by default create a library called openjpeg
|
||||||
|
# But if you want to use this project within your own (CMake) project
|
||||||
|
# you will eventually like to prefix the library to avoid linking confusion
|
||||||
|
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||||
|
# e.g.:
|
||||||
|
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
|
|
||||||
|
IF(COMMAND CMAKE_POLICY)
|
||||||
|
CMAKE_POLICY(SET CMP0003 NEW)
|
||||||
|
ENDIF(COMMAND CMAKE_POLICY)
|
||||||
|
|
||||||
|
IF(NOT OPENJPEG_NAMESPACE)
|
||||||
|
SET(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||||
|
SET(OPENJPEG_STANDALONE 1)
|
||||||
|
ENDIF(NOT OPENJPEG_NAMESPACE)
|
||||||
|
# In all cases:
|
||||||
|
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||||
|
|
||||||
|
PROJECT(${OPENJPEG_NAMESPACE} C)
|
||||||
|
|
||||||
|
# Do full dependency headers.
|
||||||
|
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 2)
|
||||||
|
SET(OPENJPEG_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
SET(PACKAGE_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
|
||||||
|
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||||
|
# two numerorations, 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
|
||||||
|
# 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 5)
|
||||||
|
endif(NOT OPENJPEG_SOVERSION)
|
||||||
|
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
|
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Path to additional CMake modules
|
||||||
|
SET(CMAKE_MODULE_PATH
|
||||||
|
${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(
|
||||||
|
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||||
|
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||||
|
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||||
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
|
||||||
|
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
|
||||||
|
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
|
||||||
|
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||||
|
-D_SCL_SECURE_NO_DEPRECATE
|
||||||
|
)
|
||||||
|
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
|
ENDIF(NOT MINGW)
|
||||||
|
ENDIF(NOT CYGWIN)
|
||||||
|
ENDIF(NOT BORLAND)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Install directories
|
||||||
|
|
||||||
|
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_LIB_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
|
||||||
|
# The following will compute the amount of parent dir to go
|
||||||
|
# from include to lib. it works nicely with
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=/lib
|
||||||
|
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
|
||||||
|
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
set(relative_parent "..")
|
||||||
|
foreach( elem ${relative_to_lib})
|
||||||
|
set( relative_parent "${relative_parent}/.." )
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
|
|
||||||
|
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_INCLUDE_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
|
|
||||||
|
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||||
|
if(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(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Big endian test:
|
||||||
|
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
|
||||||
|
${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)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# configure name mangling to allow multiple libraries to coexist
|
||||||
|
# peacefully
|
||||||
|
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
|
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||||
|
@ONLY)
|
||||||
|
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# pkgconfig support
|
||||||
|
IF(UNIX)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||||
|
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
\"libopenjpeg1.pc\"
|
||||||
|
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Compiler specific flags:
|
||||||
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
# For all builds, make sure openjpeg is std99 compliant:
|
||||||
|
# SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||||
|
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||||
|
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
|
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (1/2)
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Build Library
|
||||||
|
INCLUDE_DIRECTORIES(BEFORE ${OPENJPEG_BINARY_DIR})
|
||||||
|
ADD_SUBDIRECTORY(libopenjpeg)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# 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)
|
||||||
|
OPTION(USE_SYSTEM_GETOPT "Prefer system installed getopt()" OFF)
|
||||||
|
MARK_AS_ADVANCED(USE_SYSTEM_GETOPT)
|
||||||
|
MARK_AS_ADVANCED(BUILD_VIEWER)
|
||||||
|
MARK_AS_ADVANCED(BUILD_JAVA)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (2/2)
|
||||||
|
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
|
||||||
|
"${OPENJPEG_BINARY_DIR}/opj_config.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)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Buld Testing
|
||||||
|
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||||
|
IF(BUILD_TESTING)
|
||||||
|
IF(BUILD_CODEC)
|
||||||
|
ENABLE_TESTING()
|
||||||
|
INCLUDE(CTest)
|
||||||
|
|
||||||
|
# Search openjpeg data needed for the tests
|
||||||
|
# They could be found via 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
|
||||||
|
${CMAKE_SOURCE_DIR}/../../data
|
||||||
|
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add repository where to find tests
|
||||||
|
ADD_SUBDIRECTORY(tests)
|
||||||
|
|
||||||
|
ELSE(BUILD_CODEC)
|
||||||
|
message(FATAL_ERROR "You need build codec to run the tests")
|
||||||
|
ENDIF(BUILD_CODEC)
|
||||||
|
ENDIF(BUILD_TESTING)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install all targets referenced as OPENJPEGTargets
|
||||||
|
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
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install CHANGES and LICENSE
|
||||||
|
IF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
|
INSTALL(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
ENDIF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
|
INSTALL(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
|
||||||
|
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||||
7
CTestConfig.cmake
Normal file
7
CTestConfig.cmake
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
set(CTEST_PROJECT_NAME "OPENJPEG")
|
||||||
|
set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
|
||||||
|
|
||||||
|
set(CTEST_DROP_METHOD "http")
|
||||||
|
set(CTEST_DROP_SITE "my.cdash.org")
|
||||||
|
set(CTEST_DROP_LOCATION "/submit.php?project=OPENJPEG")
|
||||||
|
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||||
114
INSTALL
Normal file
114
INSTALL
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
How to build and install openjpeg binaries
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
UNIX/LINUX similar 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)
|
||||||
|
|
||||||
|
Type:
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
|
||||||
|
If you are root:
|
||||||
|
make install
|
||||||
|
|
||||||
|
else if you have sudo power:
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Binaries are located in the 'bin' directory.
|
||||||
|
|
||||||
|
Main available cmake flags:
|
||||||
|
* 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 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 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).
|
||||||
|
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).
|
||||||
|
|
||||||
|
MACOSX
|
||||||
|
------
|
||||||
|
|
||||||
|
The same building procedures as above (autotools and cmake) 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 :
|
||||||
|
'-DCMAKE_OSX_ARCHITECTURES:STRING=i386'
|
||||||
|
|
||||||
|
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).
|
||||||
|
Type 'cmake --help' for available generators on your platform.
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
* 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
|
||||||
|
* 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
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -23,11 +29,3 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __FIX_H
|
|
||||||
#define __FIX_H
|
|
||||||
|
|
||||||
int fix_mul(int a, int b);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
75
Makefile.am
Normal file
75
Makefile.am
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpip-server=yes --enable-jpwl=yes --enable-mj2=yes
|
||||||
|
|
||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpeg applications doc
|
||||||
|
|
||||||
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
|
pkgconfig_DATA = libopenjpeg1.pc
|
||||||
|
|
||||||
|
if WANT_JPWL
|
||||||
|
pkgconfig_DATA += libopenjpeg-jpwl.pc
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
MAINTAINERCLEANFILES = \
|
||||||
|
Makefile.in \
|
||||||
|
aclocal.m4 \
|
||||||
|
config.guess \
|
||||||
|
opj_config.h.in \
|
||||||
|
opj_config.h.in~ \
|
||||||
|
config.sub \
|
||||||
|
configure \
|
||||||
|
depcomp \
|
||||||
|
install-sh \
|
||||||
|
ltmain.sh \
|
||||||
|
missing
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMake/CTestCustom.cmake.in \
|
||||||
|
CMake/FindFCGI.cmake \
|
||||||
|
CMake/FindLCMS2.cmake \
|
||||||
|
CMake/FindLCMS.cmake \
|
||||||
|
CMake/OpenJPEGConfig.cmake.in \
|
||||||
|
CMakeLists.txt \
|
||||||
|
CTestConfig.cmake \
|
||||||
|
AUTHORS \
|
||||||
|
CHANGES \
|
||||||
|
INSTALL \
|
||||||
|
LICENSE \
|
||||||
|
NEWS \
|
||||||
|
README \
|
||||||
|
THANKS \
|
||||||
|
bootstrap.sh \
|
||||||
|
libopenjpeg1.pc.cmake \
|
||||||
|
libopenjpeg1.pc.in \
|
||||||
|
libopenjpeg-jpwl.pc.in \
|
||||||
|
opj_config.h.cmake.in \
|
||||||
|
m4/opj_check_lib.m4 \
|
||||||
|
m4/opj_doxygen.m4 \
|
||||||
|
m4/pkg.m4
|
||||||
|
|
||||||
|
.PHONY: doc
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
doc:
|
||||||
|
@echo "entering doc/"
|
||||||
|
@cd doc && make doc
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
if HAVE_WIN32
|
||||||
|
$(LN_S) -f libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
|
else
|
||||||
|
$(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
|
endif
|
||||||
|
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.pc" >> $(top_builddir)/report.txt
|
||||||
|
if WANT_JPWL
|
||||||
|
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg-jpwl.pc" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
@cat $(top_builddir)/report.txt
|
||||||
|
@rm $(top_builddir)/report.txt
|
||||||
|
|
||||||
|
uninstall-hook:
|
||||||
|
rm -f $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
25
NEWS
Normal file
25
NEWS
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
OpenJPEG NEWS - user visible changes
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Changes from OpenJPEG 1.5.2 to OpenJPEG 1.5.1
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
Security:
|
||||||
|
|
||||||
|
* Fixes: CVE-2013-4289 CVE-2013-4290
|
||||||
|
* Fixes: CVE-2013-1447 CVE-2013-6045 CVE-2013-6052 CVE-2013-6054 CVE-2013-6053 CVE-2013-6887
|
||||||
|
|
||||||
|
New Features:
|
||||||
|
|
||||||
|
* Compile Java with source/target specific java version
|
||||||
|
* Do not set SONAME for Java module, fix linking (missing math lib)
|
||||||
|
* Support some BMP/RGB8 files
|
||||||
|
* Fix compilation on ARM
|
||||||
|
|
||||||
|
Misc:
|
||||||
|
|
||||||
|
* Remove BSD-4 license from getopt copy, since upstream switched to BSD-3
|
||||||
|
* Support compilation against system installed getopt
|
||||||
|
* Fix Big Endian checking (autotools)
|
||||||
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
25
README
Normal file
25
README
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
OPENJPEG LIBRARY and APPLICATIONS
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Details on folders hierarchy:
|
||||||
|
|
||||||
|
* libopenjpeg: contains the sources of the openjpeg library
|
||||||
|
* jpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||||
|
* applications: contains all applications that use the openjpeg library
|
||||||
|
* common: common files to all applications
|
||||||
|
* codec: a basic codec
|
||||||
|
* mj2: motion jpeg 2000 executables
|
||||||
|
* JavaOpenJPEG: java jni to use openjpeg in a java program
|
||||||
|
* jpip: complete client-server architecture for remote browsing of jpeg 2000 images. See corresponding README for more details.
|
||||||
|
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||||
|
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||||
|
* doc: doxygen documentation setup file and man pages
|
||||||
|
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||||
|
* CMake: cmake related files
|
||||||
|
* m4: autotools related files
|
||||||
|
|
||||||
|
see LICENSE for license and copyright information.
|
||||||
|
see INSTALL for installation procedures.
|
||||||
|
see NEWS for user visible changes in successive releases.
|
||||||
|
see CHANGES for per-revision changes.
|
||||||
33
THANKS
Normal file
33
THANKS
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
OpenJPEG THANKS file
|
||||||
|
|
||||||
|
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
||||||
|
or submitting actual code. Here is a list of these people. Help me keep
|
||||||
|
it complete and exempt of errors.
|
||||||
|
|
||||||
|
Mathieu Malaterre
|
||||||
|
Winfried Szukalski
|
||||||
|
Vincent Torri
|
||||||
|
Bob Friesenhahn
|
||||||
|
Callum Lerwick
|
||||||
|
Dzonatas Sol
|
||||||
|
Mickaël Savinaud
|
||||||
|
Julien Malik
|
||||||
|
Jerôme Fimes
|
||||||
|
Herve Drolon
|
||||||
|
Yannick Verschueren
|
||||||
|
Sebastien Lugan
|
||||||
|
Kaori Hagihara
|
||||||
|
Peter Wimmer
|
||||||
|
Francois-Olivier Devaux
|
||||||
|
Antonin Descampe
|
||||||
|
David Janssens
|
||||||
|
Pr. Benoit Macq
|
||||||
|
Luis Ibanez
|
||||||
|
Ben Boeckel
|
||||||
|
Vincent Nicolas
|
||||||
|
Glenn Pearson
|
||||||
|
Giuseppe Baruffa
|
||||||
|
Arnaud Maye
|
||||||
|
Rex Dieter
|
||||||
|
David Burken
|
||||||
|
Parvatha Elangovan
|
||||||
22
applications/CMakeLists.txt
Normal file
22
applications/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Build the each application if it needed
|
||||||
|
|
||||||
|
IF(BUILD_CODEC)
|
||||||
|
ADD_SUBDIRECTORY(codec)
|
||||||
|
ENDIF(BUILD_CODEC)
|
||||||
|
|
||||||
|
IF(BUILD_MJ2)
|
||||||
|
ADD_SUBDIRECTORY(mj2)
|
||||||
|
ENDIF(BUILD_MJ2)
|
||||||
|
|
||||||
|
# Client & Server:
|
||||||
|
IF(BUILD_JPIP)
|
||||||
|
ADD_SUBDIRECTORY(jpip)
|
||||||
|
ENDIF(BUILD_JPIP)
|
||||||
|
|
||||||
|
IF(BUILD_VIEWER)
|
||||||
|
ADD_SUBDIRECTORY(OPJViewer)
|
||||||
|
ENDIF(BUILD_VIEWER)
|
||||||
|
|
||||||
|
IF(BUILD_JAVA)
|
||||||
|
ADD_SUBDIRECTORY(JavaOpenJPEG)
|
||||||
|
ENDIF(BUILD_JAVA)
|
||||||
68
applications/JavaOpenJPEG/CMakeLists.txt
Normal file
68
applications/JavaOpenJPEG/CMakeLists.txt
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#JavaOpenJPEG/CMakeLists.txt
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
SET(openjpegjni_SRCS
|
||||||
|
JavaOpenJPEGDecoder.c
|
||||||
|
JavaOpenJPEG.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/codec/index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
|
||||||
|
#${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# JNI binding:
|
||||||
|
find_package(JNI REQUIRED)
|
||||||
|
include_directories(${JNI_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# required header file:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/codec
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(openjpegjni MODULE
|
||||||
|
${openjpegjni_SRCS}
|
||||||
|
)
|
||||||
|
# Java module should not have a SONAME:
|
||||||
|
set_property(TARGET openjpegjni PROPERTY NO_SONAME 1)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(openjpegjni ${OPENJPEG_LIBRARY_NAME})
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(openjpegjni m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
INSTALL(TARGETS openjpegjni
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
||||||
|
)
|
||||||
|
|
||||||
|
# build jar:
|
||||||
|
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||||
|
|
||||||
|
# build dep list:
|
||||||
|
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
||||||
|
|
||||||
|
# make sure target javac dir exists:
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
|
||||||
|
# Build java
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
|
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
||||||
|
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||||
|
COMMAND ${Java_JAR_EXECUTABLE} cvf ${LIBRARY_OUTPUT_PATH}/openjpeg.jar org
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||||
|
DEPENDS ${java_srcs}
|
||||||
|
COMMENT "javac *.java; jar cvf -> openjpeg.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
# name the target
|
||||||
|
ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
|
||||||
|
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
|
COMMENT "building openjpeg.jar"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||||
|
)
|
||||||
2016
applications/JavaOpenJPEG/JavaOpenJPEG.c
Normal file
2016
applications/JavaOpenJPEG/JavaOpenJPEG.c
Normal file
File diff suppressed because it is too large
Load Diff
905
applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c
Normal file
905
applications/JavaOpenJPEG/JavaOpenJPEGDecoder.c
Normal file
@@ -0,0 +1,905 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
|
||||||
|
* 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 <jni.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "dirent.h"
|
||||||
|
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "format_defs.h"
|
||||||
|
|
||||||
|
typedef struct callback_variables {
|
||||||
|
JNIEnv *env;
|
||||||
|
/** 'jclass' object used to call a Java method from the C */
|
||||||
|
jobject *jobj;
|
||||||
|
/** 'jclass' object used to call a Java method from the C */
|
||||||
|
jmethodID message_mid;
|
||||||
|
jmethodID error_mid;
|
||||||
|
} callback_variables_t;
|
||||||
|
|
||||||
|
typedef struct dircnt{
|
||||||
|
/** Buffer for holding images read from Directory*/
|
||||||
|
char *filename_buf;
|
||||||
|
/** Pointer to the buffer*/
|
||||||
|
char **filename;
|
||||||
|
}dircnt_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct img_folder{
|
||||||
|
/** The directory path of the folder containing input images*/
|
||||||
|
char *imgdirpath;
|
||||||
|
/** Output format*/
|
||||||
|
char *out_format;
|
||||||
|
/** Enable option*/
|
||||||
|
char set_imgdir;
|
||||||
|
/** Enable Cod Format for output*/
|
||||||
|
char set_out_format;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
|
||||||
|
void decode_help_display() {
|
||||||
|
fprintf(stdout,"HELP\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, BMP format\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-files, PPM-files, PNM-files, PGX-files and\n");
|
||||||
|
fprintf(stdout," BMP-files. 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");
|
||||||
|
/* 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", "j2k", "jp2", "jpt", "j2c" };
|
||||||
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int parse_cmdline_decoder(int argc, char * const argv[], opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen;
|
||||||
|
opj_option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
const char optlist[] = "i:o:r:l:hx:"
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"W:"
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
;
|
||||||
|
/*for (i=0; i<argc; i++) {
|
||||||
|
printf("[%s]",argv[i]);
|
||||||
|
}
|
||||||
|
printf("\n");*/
|
||||||
|
|
||||||
|
/* <<UniPG */
|
||||||
|
totlen=sizeof(long_option);
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
reset_options_reading();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int 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:
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(img_fol->imgdirpath == NULL) return 1;
|
||||||
|
|
||||||
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
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 = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}/* parse_cmdline_decoder() */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
error callback returning the message to Java andexpecting a callback_variables_t client object
|
||||||
|
*/
|
||||||
|
void error_callback(const char *msg, void *client_data) {
|
||||||
|
callback_variables_t* vars = (callback_variables_t*) client_data;
|
||||||
|
JNIEnv *env = vars->env;
|
||||||
|
jstring jbuffer;
|
||||||
|
|
||||||
|
jbuffer = (*env)->NewStringUTF(env, msg);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
(*env)->CallVoidMethod(env, *(vars->jobj), vars->error_mid, jbuffer);
|
||||||
|
|
||||||
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
|
fprintf(stderr,"C: Exception during call back method\n");
|
||||||
|
(*env)->ExceptionDescribe(env);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
}
|
||||||
|
(*env)->DeleteLocalRef(env, jbuffer);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
warning callback returning the message to Java andexpecting a callback_variables_t client object
|
||||||
|
*/
|
||||||
|
void warning_callback(const char *msg, void *client_data) {
|
||||||
|
callback_variables_t* vars = (callback_variables_t*) client_data;
|
||||||
|
JNIEnv *env = vars->env;
|
||||||
|
jstring jbuffer;
|
||||||
|
|
||||||
|
jbuffer = (*env)->NewStringUTF(env, msg);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
(*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
|
||||||
|
|
||||||
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
|
fprintf(stderr,"C: Exception during call back method\n");
|
||||||
|
(*env)->ExceptionDescribe(env);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
}
|
||||||
|
(*env)->DeleteLocalRef(env, jbuffer);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
information callback returning the message to Java andexpecting a callback_variables_t client object
|
||||||
|
*/
|
||||||
|
void info_callback(const char *msg, void *client_data) {
|
||||||
|
callback_variables_t* vars = (callback_variables_t*) client_data;
|
||||||
|
JNIEnv *env = vars->env;
|
||||||
|
jstring jbuffer;
|
||||||
|
|
||||||
|
jbuffer = (*env)->NewStringUTF(env, msg);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
(*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
|
||||||
|
|
||||||
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
|
fprintf(stderr,"C: Exception during call back method\n");
|
||||||
|
(*env)->ExceptionDescribe(env);
|
||||||
|
(*env)->ExceptionClear(env);
|
||||||
|
}
|
||||||
|
(*env)->DeleteLocalRef(env, jbuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FAILS -1
|
||||||
|
#define OK 0
|
||||||
|
/* --------------------------------------------------------------------------
|
||||||
|
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
|
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
|
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,j,imageno;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
int w,h;
|
||||||
|
long min_value, max_value;
|
||||||
|
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
||||||
|
/* ==> Access variables to the Java member variables */
|
||||||
|
jsize arraySize;
|
||||||
|
jclass cls;
|
||||||
|
jobject object;
|
||||||
|
jboolean isCopy;
|
||||||
|
jfieldID fid;
|
||||||
|
jbyteArray jba;
|
||||||
|
jshortArray jsa;
|
||||||
|
jintArray jia;
|
||||||
|
jbyte *jbBody, *ptrBBody;
|
||||||
|
jshort *jsBody, *ptrSBody;
|
||||||
|
jint *jiBody, *ptrIBody;
|
||||||
|
callback_variables_t msgErrorCallback_vars;
|
||||||
|
/* <=== access variable to Java member variables */
|
||||||
|
int *ptr, *ptr1, *ptr2;/* <== To transfer the decoded image to Java */
|
||||||
|
jint retval = FAILS;
|
||||||
|
|
||||||
|
/* configure the event callbacks */
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* JNI reference to the calling class */
|
||||||
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
|
/* Pointers to be able to call a Java method
|
||||||
|
* for all the info and error messages
|
||||||
|
*/
|
||||||
|
msgErrorCallback_vars.env = env;
|
||||||
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
|
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
|
/* Get the String[] containing the parameters */
|
||||||
|
|
||||||
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
|
argc = (int) arraySize +1;
|
||||||
|
argv = (const char **)malloc(argc*sizeof(char*));
|
||||||
|
|
||||||
|
if(argv == NULL) return FAILS;
|
||||||
|
|
||||||
|
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||||
|
j=0;
|
||||||
|
for (i=1; i<argc; i++) {
|
||||||
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
|
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*printf("C: decoder params = ");
|
||||||
|
for (i=0; i<argc; i++) {
|
||||||
|
printf("[%s]",argv[i]);
|
||||||
|
}
|
||||||
|
printf("\n");*/
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
parameters.decod_format = J2K_CFMT;
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
j = parse_cmdline_decoder(argc, (char * const*)argv, ¶meters,&img_fol);
|
||||||
|
|
||||||
|
/* Release the Java arguments array */
|
||||||
|
for (i=1; i<argc; i++)
|
||||||
|
(*env)->ReleaseStringUTFChars(env,
|
||||||
|
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
|
if(j == 1) goto fin; /* failure */
|
||||||
|
|
||||||
|
num_images=1;
|
||||||
|
|
||||||
|
/* Get additional information from the Java object variables */
|
||||||
|
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
||||||
|
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
||||||
|
|
||||||
|
/*Decoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++)
|
||||||
|
{
|
||||||
|
image = NULL;
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
|
/* read the input file and put it in memory into the 'src' object, if the -i option is given in JavaParameters.
|
||||||
|
Implemented for debug purpose. */
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
|
/* printf("C: opening [%s]\n", parameters.infile); */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
file_length = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
|
||||||
|
if(src == NULL) goto fin;
|
||||||
|
|
||||||
|
fread(src, 1, file_length, fsrc);
|
||||||
|
fclose(fsrc);
|
||||||
|
/* printf("C: %d bytes read from file\n",file_length); */
|
||||||
|
} else {
|
||||||
|
/* Preparing the transfer of the codestream from Java to C */
|
||||||
|
/* printf("C: before transfering codestream\n"); */
|
||||||
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
|
file_length = (*env)->GetArrayLength(env, jba);
|
||||||
|
jbBody = (*env)->GetByteArrayElements(env, jba, &isCopy);
|
||||||
|
src = (unsigned char*)jbBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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, &msgErrorCallback_vars);
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
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);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
}
|
||||||
|
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, &msgErrorCallback_vars);
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
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);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
}
|
||||||
|
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, &msgErrorCallback_vars);
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
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);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
|
free(src);
|
||||||
|
} else {
|
||||||
|
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
||||||
|
}
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
/* create output image.
|
||||||
|
If the -o parameter is given in the JavaParameters, write the decoded version into a file.
|
||||||
|
Implemented for debug purpose. */
|
||||||
|
/* ---------------------------------- */
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========= Return the image to the Java structure =============== */
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
printf("C: checking thresholds\n");
|
||||||
|
#endif
|
||||||
|
/* First compute the real with and height,
|
||||||
|
* in function of the resolutions decoded.
|
||||||
|
*/
|
||||||
|
/*---
|
||||||
|
wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
|
---*/
|
||||||
|
w = image->comps[0].w;
|
||||||
|
h = image->comps[0].h;
|
||||||
|
|
||||||
|
if (image->numcomps==3) { /* 3 components color image */
|
||||||
|
ptr = image->comps[0].data;
|
||||||
|
ptr1 = image->comps[1].data;
|
||||||
|
ptr2 = image->comps[2].data;
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (image->comps[0].sgnd) {
|
||||||
|
min_value = -128;
|
||||||
|
max_value = 127;
|
||||||
|
} else {
|
||||||
|
min_value = 0;
|
||||||
|
max_value = 255;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* Get the pointer to the Java structure where the data must be copied */
|
||||||
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
||||||
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
|
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
||||||
|
ptrIBody = jiBody;
|
||||||
|
printf("C: transfering image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
|
||||||
|
|
||||||
|
for (i=0; i<w*h; i++) {
|
||||||
|
tempUC = (unsigned char)(ptr[i]);
|
||||||
|
tempUC1 = (unsigned char)(ptr1[i]);
|
||||||
|
tempUC2 = (unsigned char)(ptr2[i]);
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (tempUC < min_value)
|
||||||
|
tempUC=min_value;
|
||||||
|
else if (tempUC > max_value)
|
||||||
|
tempUC=max_value;
|
||||||
|
if (tempUC1 < min_value)
|
||||||
|
tempUC1=min_value;
|
||||||
|
else if (tempUC1 > max_value)
|
||||||
|
tempUC1=max_value;
|
||||||
|
if (tempUC2 < min_value)
|
||||||
|
tempUC2=min_value;
|
||||||
|
else if (tempUC2 > max_value)
|
||||||
|
tempUC2=max_value;
|
||||||
|
#endif
|
||||||
|
*(ptrIBody++) = (int) ( (tempUC2<<16) + (tempUC1<<8) + tempUC );
|
||||||
|
}
|
||||||
|
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
||||||
|
|
||||||
|
} else { /* 1 component 8 or 16 bpp image */
|
||||||
|
ptr = image->comps[0].data;
|
||||||
|
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
||||||
|
if (image->comps[0].prec<=8) {
|
||||||
|
fid = (*env)->GetFieldID(env, cls,"image8", "[B");
|
||||||
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
|
jbBody = (*env)->GetByteArrayElements(env, jba, 0);
|
||||||
|
ptrBBody = jbBody;
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (image->comps[0].sgnd) {
|
||||||
|
min_value = -128;
|
||||||
|
max_value = 127;
|
||||||
|
} else {
|
||||||
|
min_value = 0;
|
||||||
|
max_value = 255;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody); */
|
||||||
|
for (i=0; i<w*h; i++) {
|
||||||
|
tempUC = (unsigned char) (ptr[i]);
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (tempUC<min_value)
|
||||||
|
tempUC = min_value;
|
||||||
|
else if (tempUC > max_value)
|
||||||
|
tempUC = max_value;
|
||||||
|
#endif
|
||||||
|
*(ptrBBody++) = tempUC;
|
||||||
|
}
|
||||||
|
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
||||||
|
printf("C: image8 transfered to Java\n");
|
||||||
|
} else {
|
||||||
|
fid = (*env)->GetFieldID(env, cls,"image16", "[S");
|
||||||
|
jsa = (*env)->GetObjectField(env, obj, fid);
|
||||||
|
jsBody = (*env)->GetShortArrayElements(env, jsa, 0);
|
||||||
|
ptrSBody = jsBody;
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (image->comps[0].sgnd) {
|
||||||
|
min_value = -32768;
|
||||||
|
max_value = 32767;
|
||||||
|
} else {
|
||||||
|
min_value = 0;
|
||||||
|
max_value = 65535;
|
||||||
|
}
|
||||||
|
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
|
||||||
|
#endif
|
||||||
|
printf("C: transfering %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
||||||
|
for (i=0; i<w*h; i++) {
|
||||||
|
tempS = (short) (ptr[i]);
|
||||||
|
#ifdef CHECK_THRESHOLDS
|
||||||
|
if (tempS<min_value) {
|
||||||
|
printf("C: value %d truncated to %d\n", tempS, min_value);
|
||||||
|
tempS = min_value;
|
||||||
|
} else if (tempS > max_value) {
|
||||||
|
printf("C: value %d truncated to %d\n", tempS, max_value);
|
||||||
|
tempS = max_value;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*(ptrSBody++) = tempS;
|
||||||
|
}
|
||||||
|
(*env)->ReleaseShortArrayElements(env, jsa, jsBody, 0);
|
||||||
|
printf("C: image16 completely filled\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
retval = OK;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
free(argv);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
/* end main MAIN */
|
||||||
|
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package org.openJpeg;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/** This class decodes one J2K codestream into an image (width + height + depth + pixels[],
|
||||||
|
* using the OpenJPEG.org library.
|
||||||
|
* To be able to log messages, the called must register a IJavaJ2KDecoderLogger object.
|
||||||
|
*/
|
||||||
|
public class OpenJPEGJavaDecoder {
|
||||||
|
|
||||||
|
public interface IJavaJ2KDecoderLogger {
|
||||||
|
public void logDecoderMessage(String message);
|
||||||
|
public void logDecoderError(String message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isInitialized = false;
|
||||||
|
|
||||||
|
// ===== decompression parameters =============>
|
||||||
|
// These value may be changed for each image
|
||||||
|
private String[] decoder_arguments = null;
|
||||||
|
/** number of resolutions decompositions */
|
||||||
|
private int nbResolutions = -1;
|
||||||
|
/** the quality layers */
|
||||||
|
private int[] layers = null;
|
||||||
|
|
||||||
|
/** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
|
||||||
|
* We store in Java the 8 or 16 bpp version of the image while the decoder uses a 32 bpp version, because <UL>
|
||||||
|
* <LI> the storage capacity required is smaller
|
||||||
|
* <LI> the transfer Java <-- C will be faster
|
||||||
|
* <LI> the conversion byte/short ==> int will be done faster by the C
|
||||||
|
* </UL>*/
|
||||||
|
private byte[] image8 = null;
|
||||||
|
/** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
|
||||||
|
private short[] image16 = null;
|
||||||
|
/** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
|
||||||
|
private int[] image24 = null;
|
||||||
|
/** Holds the J2K compressed bytecode to decode */
|
||||||
|
private byte compressedStream[] = null;
|
||||||
|
/** Holds the compressed version of the index file, to be used by the decoder */
|
||||||
|
private byte compressedIndex[] = null;
|
||||||
|
/** Width and Height of the image */
|
||||||
|
private int width = -1;
|
||||||
|
private int height = -1;
|
||||||
|
private int depth = -1;
|
||||||
|
/** This parameter is never used in Java but is read by the C library to know the number of resolutions to skip when decoding,
|
||||||
|
* i.e. if there are 5 resolutions and skipped=1 ==> decode until resolution 4. */
|
||||||
|
private int skippedResolutions = 0;
|
||||||
|
|
||||||
|
private Vector<IJavaJ2KDecoderLogger> loggers = new Vector();
|
||||||
|
|
||||||
|
|
||||||
|
public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName, IJavaJ2KDecoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
|
||||||
|
{
|
||||||
|
this(openJPEGlibraryFullPathAndName);
|
||||||
|
loggers.addElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
|
||||||
|
{
|
||||||
|
if (!isInitialized) {
|
||||||
|
try {
|
||||||
|
System.load(openJPEGlibraryFullPathAndName);
|
||||||
|
isInitialized = true;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new ExceptionInInitializerError("OpenJPEG Java Decoder: probably impossible to find the C library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
|
||||||
|
loggers.addElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
|
||||||
|
loggers.removeElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int decodeJ2KtoImage() {
|
||||||
|
if ((image16 == null || (image16 != null && image16.length != width*height)) && (depth==-1 || depth==16)) {
|
||||||
|
image16 = new short[width*height];
|
||||||
|
logMessage("OpenJPEGJavaDecoder.decompressImage: image16 length = " + image16.length + " (" + width + " x " + height + ") ");
|
||||||
|
}
|
||||||
|
if ((image8 == null || (image8 != null && image8.length != width*height)) && (depth==-1 || depth==8)) {
|
||||||
|
image8 = new byte[width*height];
|
||||||
|
logMessage("OpenJPEGJavaDecoder.decompressImage: image8 length = " + image8.length + " (" + width + " x " + height + ") ");
|
||||||
|
}
|
||||||
|
if ((image24 == null || (image24 != null && image24.length != width*height)) && (depth==-1 || depth==24)) {
|
||||||
|
image24 = new int[width*height];
|
||||||
|
logMessage("OpenJPEGJavaDecoder.decompressImage: image24 length = " + image24.length + " (" + width + " x " + height + ") ");
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] arguments = new String[0 + (decoder_arguments != null ? decoder_arguments.length : 0)];
|
||||||
|
int offset = 0;
|
||||||
|
if (decoder_arguments != null) {
|
||||||
|
for (int i=0; i<decoder_arguments.length; i++) {
|
||||||
|
arguments[i+offset] = decoder_arguments[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return internalDecodeJ2KtoImage(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the j2k stream given in the codestream byte[] and fills the image8, image16 or image24 array, according to the bit depth.
|
||||||
|
*/
|
||||||
|
private native int internalDecodeJ2KtoImage(String[] parameters);
|
||||||
|
|
||||||
|
/** Image depth in bpp */
|
||||||
|
public int getDepth() {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image depth in bpp */
|
||||||
|
public void setDepth(int depth) {
|
||||||
|
this.depth = depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image height in pixels */
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image height in pixels */
|
||||||
|
public void setHeight(int height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Number of resolutions contained in the image */
|
||||||
|
public int getNbResolutions() {
|
||||||
|
return nbResolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Number of resolutions contained in the image */
|
||||||
|
public void setNbResolutions(int nbResolutions) {
|
||||||
|
this.nbResolutions = nbResolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Width of the image in pixels */
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Width of the image in pixels */
|
||||||
|
public void setWidth(int width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contains the decompressed version of the image, if the depth in is [9,16] bpp.
|
||||||
|
* Returns NULL otherwise.
|
||||||
|
*/
|
||||||
|
public short[] getImage16() {
|
||||||
|
return image16;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contains the decompressed version of the image, if the depth in is [17,24] bpp and the image is in color.
|
||||||
|
* Returns NULL otherwise.
|
||||||
|
*/
|
||||||
|
public int[] getImage24() {
|
||||||
|
return image24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contains the decompressed version of the image, if the depth in is [1,8] bpp.
|
||||||
|
* Returns NULL otherwise.
|
||||||
|
*/
|
||||||
|
public byte[] getImage8() {
|
||||||
|
return image8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the compressed version of the index file for this image.
|
||||||
|
* This index file is used by the decompressor
|
||||||
|
*/
|
||||||
|
public void setCompressedIndex(byte[] compressedIndex) {
|
||||||
|
this.compressedIndex = compressedIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the codestream to be decoded */
|
||||||
|
public void setCompressedStream(byte[] compressedStream) {
|
||||||
|
this.compressedStream = compressedStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return the compressed code stream length, or -1 if not defined */
|
||||||
|
public long getCodestreamLength() {
|
||||||
|
if (compressedStream == null)
|
||||||
|
return -1;
|
||||||
|
else return compressedStream.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called either directly or by the C methods */
|
||||||
|
public void logMessage(String message) {
|
||||||
|
for (IJavaJ2KDecoderLogger logger:loggers)
|
||||||
|
logger.logDecoderMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method is called either directly or by the C methods */
|
||||||
|
public void logError(String error) {
|
||||||
|
for (IJavaJ2KDecoderLogger logger:loggers)
|
||||||
|
logger.logDecoderError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
nbResolutions = -1;
|
||||||
|
layers = null;
|
||||||
|
image8 = null;
|
||||||
|
image16 = null;
|
||||||
|
image24 = null;
|
||||||
|
compressedStream = null;
|
||||||
|
compressedIndex = null;
|
||||||
|
width = -1;
|
||||||
|
height = -1;
|
||||||
|
depth = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSkippedResolutions(int numberOfSkippedResolutions) {
|
||||||
|
skippedResolutions = numberOfSkippedResolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contains all the decoding arguments other than the input/output file */
|
||||||
|
public void setDecoderArguments(String[] argumentsForTheDecoder) {
|
||||||
|
decoder_arguments = argumentsForTheDecoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,338 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package org.openJpeg;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/** This class encodes one image into the J2K format,
|
||||||
|
* using the OpenJPEG.org library.
|
||||||
|
* To be able to log messages, the called must register a IJavaJ2KEncoderLogger object.
|
||||||
|
*/
|
||||||
|
public class OpenJPEGJavaEncoder {
|
||||||
|
|
||||||
|
public interface IJavaJ2KEncoderLogger {
|
||||||
|
public void logEncoderMessage(String message);
|
||||||
|
public void logEncoderError(String message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isInitialized = false;
|
||||||
|
|
||||||
|
// ===== Compression parameters =============>
|
||||||
|
// These value may be changed for each image
|
||||||
|
private String[] encoder_arguments = null;
|
||||||
|
/** number of resolutions decompositions */
|
||||||
|
private int nbResolutions = -1;
|
||||||
|
/** the quality layers, expressed as compression rate */
|
||||||
|
private float[] ratioLayers = null;
|
||||||
|
/** the quality layers, expressed as PSNR values. This variable, if defined, has priority over the ratioLayers variable */
|
||||||
|
private float[] psnrLayers = null;
|
||||||
|
|
||||||
|
/** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
|
||||||
|
* We store the 8 or 16 bpp version of the original image while the encoder uses a 32 bpp version, because <UL>
|
||||||
|
* <LI> the storage capacity required is smaller
|
||||||
|
* <LI> the transfer Java --> C will be faster
|
||||||
|
* <LI> the conversion byte/short ==> int will be done faster by the C
|
||||||
|
* </UL>*/
|
||||||
|
private byte[] image8 = null;
|
||||||
|
/** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
|
||||||
|
private short[] image16 = null;
|
||||||
|
/** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
|
||||||
|
private int[] image24 = null;
|
||||||
|
/** Holds the result of the compression, i.e. the J2K compressed bytecode */
|
||||||
|
private byte compressedStream[] = null;
|
||||||
|
/** Holds the compressed stream length, which may be smaller than compressedStream.length if this byte[] is pre-allocated */
|
||||||
|
private long compressedStreamLength = -1;
|
||||||
|
/** Holds the compressed version of the index file, returned by the encoder */
|
||||||
|
private byte compressedIndex[] = null;
|
||||||
|
/** Width and Height of the image */
|
||||||
|
private int width = -1;
|
||||||
|
private int height = -1;
|
||||||
|
private int depth = -1;
|
||||||
|
/** Tile size. We suppose the same size for the horizontal and vertical tiles.
|
||||||
|
* If size == -1 ==> no tiling */
|
||||||
|
private int tileSize = -1;
|
||||||
|
// <===== Compression parameters =============
|
||||||
|
|
||||||
|
private Vector<IJavaJ2KEncoderLogger> loggers = new Vector();
|
||||||
|
|
||||||
|
public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName, IJavaJ2KEncoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
|
||||||
|
{
|
||||||
|
this(openJPEGlibraryFullPathAndName);
|
||||||
|
loggers.addElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
|
||||||
|
{
|
||||||
|
if (!isInitialized) {
|
||||||
|
try {
|
||||||
|
String absolutePath = (new File(openJPEGlibraryFullPathAndName)).getCanonicalPath();
|
||||||
|
System.load(absolutePath);
|
||||||
|
isInitialized = true;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
throw new ExceptionInInitializerError("OpenJPEG Java Encoder: probably impossible to find the C library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
|
||||||
|
loggers.addElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
|
||||||
|
loggers.removeElement(messagesAndErrorsLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method compresses the given image.<P>
|
||||||
|
* It returns the compressed J2K codestream into the compressedStream byte[].<P>
|
||||||
|
* It also returns the compression index as a compressed form, into the compressedIndex byte[].<P>
|
||||||
|
* One of the image8, image16 or image24 arrays must be correctly initialized and filled.<P>
|
||||||
|
* The width, height and depth variables must be correctly filled.<P>
|
||||||
|
* The nbResolutions, nbLayers and if needed the float[] psnrLayers or ratioLayers must also be filled before calling this method.
|
||||||
|
*/
|
||||||
|
public void encodeImageToJ2K() {
|
||||||
|
// Need to allocate / reallocate the compressed stream buffer ? (size = max possible size = original image size)
|
||||||
|
if (compressedStream== null || (compressedStream.length != width*height*depth/8)) {
|
||||||
|
logMessage("OpenJPEGJavaEncoder.encodeImageToJ2K: (re-)allocating " + (width*height*depth/8) + " bytes for the compressedStream");
|
||||||
|
compressedStream = new byte[width*height*depth/8];
|
||||||
|
}
|
||||||
|
// Arguments =
|
||||||
|
// - number of resolutions "-n 5" : 2
|
||||||
|
// - size of tile "-t 512,512" : 2
|
||||||
|
//
|
||||||
|
// Image width, height, depth and pixels are directly fetched by C from the Java class
|
||||||
|
int nbArgs = 2 + (tileSize == -1 ? 0 : 2) + (encoder_arguments != null ? encoder_arguments.length : 0);
|
||||||
|
if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0] != 0)
|
||||||
|
// If psnrLayers is defined and doesn't just express "lossless"
|
||||||
|
nbArgs += 2;
|
||||||
|
else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0)
|
||||||
|
nbArgs += 2;
|
||||||
|
String[] arguments = new String[nbArgs];
|
||||||
|
int offset = 0;
|
||||||
|
arguments[offset] = "-n"; arguments[offset+1] = "" + nbResolutions; offset += 2;
|
||||||
|
if (tileSize!= -1) {
|
||||||
|
arguments[offset++] = "-t";
|
||||||
|
arguments[offset++] = "" + tileSize + "," + tileSize;
|
||||||
|
}
|
||||||
|
// If PSNR layers are defined, use them to encode the images
|
||||||
|
if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0]!=-1) {
|
||||||
|
arguments[offset++] = "-q";
|
||||||
|
String s = "";
|
||||||
|
for (int i=0; i<psnrLayers.length; i++)
|
||||||
|
s += psnrLayers[i] + ",";
|
||||||
|
arguments[offset++] = s.substring(0, s.length()-1);
|
||||||
|
} else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0) {
|
||||||
|
// Specify quality ratioLayers, as compression ratios
|
||||||
|
arguments[offset++] = "-r";
|
||||||
|
String s = "";
|
||||||
|
for (int i=0; i<ratioLayers.length; i++)
|
||||||
|
s += ratioLayers[i] + ",";
|
||||||
|
arguments[offset++] = s.substring(0, s.length()-1);
|
||||||
|
}
|
||||||
|
if (encoder_arguments != null) {
|
||||||
|
for (int i=0; i<encoder_arguments.length; i++) {
|
||||||
|
arguments[i+offset] = encoder_arguments[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logMessage("Encoder additional arguments = " + arrayToString(arguments));
|
||||||
|
long startTime = (new java.util.Date()).getTime();
|
||||||
|
compressedStreamLength = internalEncodeImageToJ2K(arguments);
|
||||||
|
logMessage("compression time = " + ((new java.util.Date()).getTime() - startTime) + " msec");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills the compressedStream byte[] and the compressedIndex byte[]
|
||||||
|
* @return the codestream length.
|
||||||
|
*/
|
||||||
|
private native long internalEncodeImageToJ2K(String[] parameters);
|
||||||
|
|
||||||
|
/** Image depth in bpp */
|
||||||
|
public int getDepth() {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image depth in bpp */
|
||||||
|
public void setDepth(int depth) {
|
||||||
|
this.depth = depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image height in pixels */
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image height in pixels */
|
||||||
|
public void setHeight(int height) {
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method must be called in depth in [9,16].
|
||||||
|
* @param an array of shorts, containing width*height values
|
||||||
|
*/
|
||||||
|
public void setImage16(short[] image16) {
|
||||||
|
this.image16 = image16;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method must be called in depth in [17,24] for RGB images.
|
||||||
|
* @param an array of int, containing width*height values
|
||||||
|
*/
|
||||||
|
public void setImage24(int[] image24) {
|
||||||
|
this.image24 = image24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method must be called in depth in [1,8].
|
||||||
|
* @param an array of bytes, containing width*height values
|
||||||
|
*/
|
||||||
|
public void setImage8(byte[] image8) {
|
||||||
|
this.image8 = image8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the ratioLayers, i.e. the compression ratio for each quality layer.
|
||||||
|
* If the last value is 0.0, last layer is lossless compressed.
|
||||||
|
*/
|
||||||
|
public float[] getRatioLayers() {
|
||||||
|
return ratioLayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the quality layers.
|
||||||
|
* At least one level.
|
||||||
|
* Each level is expressed as a compression ratio (float).
|
||||||
|
* If the last value is 0.0, the last layer will be losslessly compressed
|
||||||
|
*/
|
||||||
|
public void setRatioLayers(float[] layers) {
|
||||||
|
this.ratioLayers = layers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the PSNR Layers, i.e. the target PSNR for each quality layer.
|
||||||
|
* If the last value is -1, last layer is lossless compressed.
|
||||||
|
*/
|
||||||
|
public float[] getPsnrLayers() {
|
||||||
|
return psnrLayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the quality layers.
|
||||||
|
* At least one level.
|
||||||
|
* Each level is expressed as a target PSNR (float).
|
||||||
|
* If the last value is -1, the last layer will be losslessly compressed
|
||||||
|
*/
|
||||||
|
public void setPsnrLayers(float[] layers) {
|
||||||
|
this.psnrLayers = layers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the number of resolutions that must be created */
|
||||||
|
public void setNbResolutions(int nbResolutions) {
|
||||||
|
this.nbResolutions = nbResolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Width of the image, in pixels */
|
||||||
|
public void setWidth(int width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the compressed index file.
|
||||||
|
* Syntax: TODO PP:
|
||||||
|
*/
|
||||||
|
public byte[] getCompressedIndex() {
|
||||||
|
return compressedIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompressedIndex(byte[] index) {
|
||||||
|
compressedIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getCompressedStream() {
|
||||||
|
return compressedStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
nbResolutions = -1;
|
||||||
|
ratioLayers = null;
|
||||||
|
psnrLayers = null;
|
||||||
|
image8 = null;
|
||||||
|
image16 = null;
|
||||||
|
image24 = null;
|
||||||
|
compressedStream = null;
|
||||||
|
compressedIndex = null;
|
||||||
|
width = -1;
|
||||||
|
height = -1;
|
||||||
|
depth = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short[] getImage16() {
|
||||||
|
return image16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getImage24() {
|
||||||
|
return image24;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getImage8() {
|
||||||
|
return image8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the size of the tiles. We assume square tiles */
|
||||||
|
public void setTileSize(int tileSize) {
|
||||||
|
this.tileSize = tileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Contains all the encoding arguments other than the input/output file, compression ratio, tile size */
|
||||||
|
public void setEncoderArguments(String[] argumentsForTheEncoder) {
|
||||||
|
encoder_arguments = argumentsForTheEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logMessage(String message) {
|
||||||
|
for (IJavaJ2KEncoderLogger logger:loggers)
|
||||||
|
logger.logEncoderMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logError(String error) {
|
||||||
|
for (IJavaJ2KEncoderLogger logger:loggers)
|
||||||
|
logger.logEncoderError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCompressedStreamLength() {
|
||||||
|
return compressedStreamLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String arrayToString(String[] array) {
|
||||||
|
if (array == null)
|
||||||
|
return "NULL";
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int i=0; i<array.length; i++)
|
||||||
|
sb.append(array[i]).append(" ");
|
||||||
|
sb.delete(sb.length()-1, sb.length());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
21
applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaDecoder.h
Normal file
21
applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaDecoder.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class org_openJpeg_OpenJPEGJavaDecoder */
|
||||||
|
|
||||||
|
#ifndef _Included_org_openJpeg_OpenJPEGJavaDecoder
|
||||||
|
#define _Included_org_openJpeg_OpenJPEGJavaDecoder
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: org_openJpeg_OpenJPEGJavaDecoder
|
||||||
|
* Method: internalDecodeJ2KtoImage
|
||||||
|
* Signature: ([Ljava/lang/String;)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage
|
||||||
|
(JNIEnv *, jobject, jobjectArray);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
21
applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaEncoder.h
Normal file
21
applications/JavaOpenJPEG/org_openJpeg_OpenJPEGJavaEncoder.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class org_openJpeg_OpenJPEGJavaEncoder */
|
||||||
|
|
||||||
|
#ifndef _Included_org_openJpeg_OpenJPEGJavaEncoder
|
||||||
|
#define _Included_org_openJpeg_OpenJPEGJavaEncoder
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: org_openJpeg_OpenJPEGJavaEncoder
|
||||||
|
* Method: internalEncodeImageToJ2K
|
||||||
|
* Signature: ([Ljava/lang/String;)J
|
||||||
|
*/
|
||||||
|
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K
|
||||||
|
(JNIEnv *, jobject, jobjectArray);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
19
applications/Makefile.am
Normal file
19
applications/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = codec
|
||||||
|
|
||||||
|
if WANT_MJ2
|
||||||
|
SUBDIRS += mj2
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WANT_JPIP_CODE
|
||||||
|
SUBDIRS += jpip
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
common/color.c \
|
||||||
|
common/color.h \
|
||||||
|
common/format_defs.h \
|
||||||
|
common/opj_getopt.c \
|
||||||
|
common/opj_getopt.h
|
||||||
25
applications/OPJViewer/CMakeLists.txt
Normal file
25
applications/OPJViewer/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
PROJECT(viewer CXX)
|
||||||
|
|
||||||
|
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||||
|
INCLUDE(${wxWidgets_USE_FILE})
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||||
|
)
|
||||||
|
|
||||||
|
# original flags:
|
||||||
|
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
||||||
|
ADD_DEFINITIONS(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
||||||
|
SET(OPJV_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/wxjp2parser.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
|
||||||
|
)
|
||||||
|
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
||||||
48
applications/OPJViewer/OPJViewer.iss
Normal file
48
applications/OPJViewer/OPJViewer.iss
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
; Script generated by the Inno Setup Script Wizard.
|
||||||
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
AppName=OPJViewer
|
||||||
|
AppVerName=OPJViewer 0.4 beta
|
||||||
|
AppPublisher=OpenJPEG
|
||||||
|
AppPublisherURL=http://www.openjpeg.org
|
||||||
|
AppSupportURL=http://www.openjpeg.org
|
||||||
|
AppUpdatesURL=http://www.openjpeg.org
|
||||||
|
DefaultDirName={pf}\OPJViewer
|
||||||
|
DefaultGroupName=OPJViewer
|
||||||
|
OutputDir=setup
|
||||||
|
OutputBaseFilename=OPJViewer04beta_setup
|
||||||
|
Compression=lzma
|
||||||
|
SolidCompression=true
|
||||||
|
InfoBeforeFile=source\readmebefore.txt
|
||||||
|
InfoAfterFile=source\readmeafter.txt
|
||||||
|
LicenseFile=source\license.txt
|
||||||
|
VersionInfoVersion=0.4.0.0
|
||||||
|
VersionInfoCompany=OpenJPEG
|
||||||
|
VersionInfoDescription=JPEG 2000 viewer
|
||||||
|
ShowLanguageDialog=yes
|
||||||
|
SetupIconFile=source\OPJViewer.ico
|
||||||
|
|
||||||
|
[Languages]
|
||||||
|
Name: english; MessagesFile: compiler:Default.isl
|
||||||
|
|
||||||
|
[Tasks]
|
||||||
|
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
Source: Release\OPJViewer.exe; DestDir: {app}; Flags: ignoreversion
|
||||||
|
;Source: about\about.htm; DestDir: {app}/about; Flags: ignoreversion
|
||||||
|
;Source: about\opj_logo.png; DestDir: {app}/about; Flags: ignoreversion
|
||||||
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
Name: {group}\OPJViewer; Filename: {app}\OPJViewer.exe; WorkingDir: {app}; IconIndex: 0
|
||||||
|
Name: {group}\{cm:UninstallProgram,OPJViewer}; Filename: {uninstallexe}
|
||||||
|
Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
|
||||||
|
|
||||||
|
[Run]
|
||||||
|
Filename: {app}\OPJViewer.exe; Description: {cm:LaunchProgram,OPJViewer}; Flags: nowait postinstall skipifsilent; WorkingDir: {app}
|
||||||
|
|
||||||
|
[Registry]
|
||||||
|
Root: HKCU; Subkey: Software\OpenJPEG; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||||
|
Root: HKCU; Subkey: Software\OpenJPEG\OPJViewer; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||||
100
applications/OPJViewer/Readme.txt
Normal file
100
applications/OPJViewer/Readme.txt
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
===============================================================================
|
||||||
|
JPEG2000 Visualization Software - OPJViewer
|
||||||
|
|
||||||
|
Version 0.4 beta
|
||||||
|
===============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
1. Scope
|
||||||
|
=============
|
||||||
|
|
||||||
|
This document describes the installation and use of the OPJViewer in the framework of OpenJPEG library.
|
||||||
|
|
||||||
|
This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8 as GUI engine.
|
||||||
|
|
||||||
|
If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl@diei.unipg.it
|
||||||
|
|
||||||
|
2. Installing the viewer
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There are two options available, at the moment:
|
||||||
|
|
||||||
|
a) compile from source code
|
||||||
|
b) download a precompiled binary.
|
||||||
|
|
||||||
|
In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
|
||||||
|
|
||||||
|
2.1. Compiling the source code in Windows
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
The steps required to compile the viewer under windows are:
|
||||||
|
|
||||||
|
a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
|
||||||
|
b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
|
||||||
|
c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
|
||||||
|
d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
|
||||||
|
e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
|
||||||
|
f) Build!
|
||||||
|
g) Run!
|
||||||
|
h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
|
||||||
|
|
||||||
|
2.1.1 Additional libraries
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Since we are also working on the Digital Cinema JPEG 2000, we are integrating the viewer with the MXF library, which is used to prepare the DCPs for digital movies. You can enable its linking in the code by specifying the USE_MXF preprocessor directive but, remember, the integration is at a very early stage.
|
||||||
|
|
||||||
|
2.2. Compiling the source code in Unix-like systems
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
The porting is possible and under way.
|
||||||
|
|
||||||
|
|
||||||
|
3. General information on the viewer
|
||||||
|
====================================
|
||||||
|
|
||||||
|
This viewer is conceived to open and display information and image content of J2K, JP2, and MJ2 files.
|
||||||
|
The viewer application interface is divided into three main panels:
|
||||||
|
- a browsing pane;
|
||||||
|
- a viewing pane;
|
||||||
|
- a log/peek pane.
|
||||||
|
|
||||||
|
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||||
|
|
||||||
|
filename
|
||||||
|
|
|
||||||
|
|_ #000: Marker/Box short name (Hex code)
|
||||||
|
| |
|
||||||
|
| |_ *** Marker/Box long name ***
|
||||||
|
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||||
|
| |_ Additional info, depending on the marker/box type
|
||||||
|
| |_ ...
|
||||||
|
|
|
||||||
|
|_ #001: Marker/Box short name (Hex code)
|
||||||
|
| |
|
||||||
|
| |_ ...
|
||||||
|
|
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||||
|
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||||
|
|
||||||
|
|
||||||
|
The log/peek pane is shared among two different subpanels:
|
||||||
|
|
||||||
|
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||||
|
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||||
|
|
||||||
|
|
||||||
|
4. Known bugs and limitations
|
||||||
|
===============================
|
||||||
|
|
||||||
|
4.1. Bugs
|
||||||
|
-----------
|
||||||
|
|
||||||
|
*
|
||||||
|
|
||||||
|
4.2. Limitations
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* For mj2 files, rendering is only in B/W
|
||||||
36
applications/OPJViewer/about/about.htm
Normal file
36
applications/OPJViewer/about/about.htm
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<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="opj_logo.png"><br><br>
|
||||||
|
</td>
|
||||||
|
<td align=center>
|
||||||
|
<font size=+2 color="#000000"><b>OPJViewer v0.2 alpha</b></font><br>
|
||||||
|
<font size=+0 color="#000000"><b>A JPEG 2000 image viewer</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>
|
||||||
|
<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,
|
||||||
|
among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool
|
||||||
|
useful for the JPIP protocol, JPWL-tools for error-resilience, ...</font>
|
||||||
|
</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-2007 <a href="http://www.tele.ucl.ac.be/">TELE</a> - <a href="http://www.uclouvain.be/">Universit<EFBFBD> Catholique de Louvain</a></font><br>
|
||||||
|
<font size=-2 color="#444444">OPJViewer is also © 2005-2007 <a href="http://dsplab.diei.unipg.it/">DSPLab</a> - <a href="http://www.unipg.it/">Universit<EFBFBD> degli studi di Perugia</a></font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
applications/OPJViewer/about/opj_logo.png
Normal file
BIN
applications/OPJViewer/about/opj_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
87
applications/OPJViewer/source/OPJAbout.cpp
Normal file
87
applications/OPJViewer/source/OPJAbout.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||||
|
* 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 USE_MXF
|
||||||
|
#include "mxflib/mxflib.h"
|
||||||
|
#endif // USE_MXF
|
||||||
|
|
||||||
|
#include "OPJViewer.h"
|
||||||
|
|
||||||
|
// about window for the frame
|
||||||
|
void OPJFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
#ifdef OPJ_HTMLABOUT
|
||||||
|
#include "about_htm.h"
|
||||||
|
#include "opj_logo.xpm"
|
||||||
|
|
||||||
|
wxBoxSizer *topsizer;
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
wxDialog dlg(this, wxID_ANY, wxString(_("About")));
|
||||||
|
|
||||||
|
wxMemoryFSHandler::AddFile(wxT("opj_logo.xpm"), wxBitmap(opj_logo), wxBITMAP_TYPE_XPM);
|
||||||
|
|
||||||
|
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(320, 250), wxHW_SCROLLBAR_NEVER);
|
||||||
|
html->SetBorders(0);
|
||||||
|
//html->LoadPage(wxT("about/about.htm"));
|
||||||
|
//html->SetPage("<html><body>Hello, world!</body></html>");
|
||||||
|
html->SetPage(htmlaboutpage);
|
||||||
|
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
|
||||||
|
html->GetInternalRepresentation()->GetHeight());
|
||||||
|
|
||||||
|
topsizer->Add(html, 1, wxALL, 10);
|
||||||
|
|
||||||
|
topsizer->Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||||
|
|
||||||
|
wxButton *bu1 = new wxButton(&dlg, wxID_OK, wxT("OK"));
|
||||||
|
bu1->SetDefault();
|
||||||
|
|
||||||
|
topsizer->Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
|
||||||
|
|
||||||
|
dlg.SetSizer(topsizer);
|
||||||
|
topsizer->Fit(&dlg);
|
||||||
|
|
||||||
|
dlg.ShowModal();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxMessageBox(wxString::Format(OPJ_APPLICATION_TITLEBAR
|
||||||
|
wxT("\n\n")
|
||||||
|
wxT("Built with %s and OpenJPEG ")
|
||||||
|
wxT(OPENJPEG_VERSION)
|
||||||
|
wxT("\non ") wxT(__DATE__) wxT(", ") wxT(__TIME__)
|
||||||
|
wxT("\nRunning under %s\n\n")
|
||||||
|
OPJ_APPLICATION_COPYRIGHT,
|
||||||
|
wxVERSION_STRING,
|
||||||
|
wxGetOsDescription().c_str()),
|
||||||
|
wxT("About ") OPJ_APPLICATION_NAME,
|
||||||
|
wxOK | wxICON_INFORMATION,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
BIN
applications/OPJViewer/source/OPJChild.ico
Normal file
BIN
applications/OPJViewer/source/OPJChild.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
28
applications/OPJViewer/source/OPJChild16.xpm
Normal file
28
applications/OPJViewer/source/OPJChild16.xpm
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char *OPJChild16[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"16 16 6 1",
|
||||||
|
" c black",
|
||||||
|
". c #008000",
|
||||||
|
"X c red",
|
||||||
|
"o c #800080",
|
||||||
|
"O c gray100",
|
||||||
|
"+ c None",
|
||||||
|
/* pixels */
|
||||||
|
"++++++++++++++++",
|
||||||
|
"+OOOOOOOOOOOOOO+",
|
||||||
|
"+OooooooooooooO+",
|
||||||
|
"+OooooooooooooO+",
|
||||||
|
"+OooOOOOOOOOOoO+",
|
||||||
|
"+OooO.......OoO+",
|
||||||
|
"+OooO.......OoO+",
|
||||||
|
"+OooO..OOO..OoO+",
|
||||||
|
"+OooO..OXO..OoO+",
|
||||||
|
"+OooO..OOO..OoO+",
|
||||||
|
"+OooO.......OoO+",
|
||||||
|
"+OooO.......OoO+",
|
||||||
|
"+OooOOOOOOOOOoO+",
|
||||||
|
"+OooooooooooooO+",
|
||||||
|
"+OOOOOOOOOOOOOO+",
|
||||||
|
"++++++++++++++++"
|
||||||
|
};
|
||||||
1373
applications/OPJViewer/source/OPJDialogs.cpp
Normal file
1373
applications/OPJViewer/source/OPJDialogs.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1268
applications/OPJViewer/source/OPJThreads.cpp
Normal file
1268
applications/OPJViewer/source/OPJThreads.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1666
applications/OPJViewer/source/OPJViewer.cpp
Normal file
1666
applications/OPJViewer/source/OPJViewer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
812
applications/OPJViewer/source/OPJViewer.h
Normal file
812
applications/OPJViewer/source/OPJViewer.h
Normal file
@@ -0,0 +1,812 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: sashtest.h
|
||||||
|
// Purpose: Layout window/sash sample
|
||||||
|
// Author: Julian Smart
|
||||||
|
// Modified by:
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id: sashtest.h,v 1.5 2005/06/02 12:04:24 JS Exp $
|
||||||
|
// Copyright: (c) Julian Smart
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: treectrl.h
|
||||||
|
// Purpose: wxTreeCtrl sample
|
||||||
|
// Author: Julian Smart
|
||||||
|
// Modified by:
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id: treetest.h,v 1.50 2006/11/04 11:26:51 VZ Exp $
|
||||||
|
// Copyright: (c) Julian Smart
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: dialogs.h
|
||||||
|
// Purpose: Common dialogs demo
|
||||||
|
// Author: Julian Smart
|
||||||
|
// Modified by: ABX (2004) - adjustementd for conditional building
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id: dialogs.h,v 1.50 2006/10/08 14:12:59 VZ Exp $
|
||||||
|
// Copyright: (c) Julian Smart
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __OPJ_VIEWER_H__
|
||||||
|
#define __OPJ_VIEWER_H__
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#include "wx/mdi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/toolbar.h"
|
||||||
|
#include "wx/laywin.h"
|
||||||
|
#include "wx/treectrl.h"
|
||||||
|
|
||||||
|
#include "icon1.xpm"
|
||||||
|
#include "icon2.xpm"
|
||||||
|
#include "icon3.xpm"
|
||||||
|
#include "icon4.xpm"
|
||||||
|
#include "icon5.xpm"
|
||||||
|
|
||||||
|
#include "wx/filedlg.h"
|
||||||
|
#include "wx/toolbar.h"
|
||||||
|
#include <wx/filename.h>
|
||||||
|
#include <wx/busyinfo.h>
|
||||||
|
#include <wx/cmdline.h>
|
||||||
|
#include <wx/file.h>
|
||||||
|
#include "wx/notebook.h"
|
||||||
|
#include <wx/numdlg.h>
|
||||||
|
|
||||||
|
#include "wx/propdlg.h"
|
||||||
|
#include "wx/spinctrl.h"
|
||||||
|
|
||||||
|
#include <wx/dnd.h>
|
||||||
|
#include "wx/wxhtml.h"
|
||||||
|
#include "wx/statline.h"
|
||||||
|
#include <wx/fs_mem.h>
|
||||||
|
|
||||||
|
#include <wx/imaglist.h>
|
||||||
|
|
||||||
|
#include "wx/toolbar.h"
|
||||||
|
#include "wx/artprov.h"
|
||||||
|
|
||||||
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
|
//#include "imagj2k.h"
|
||||||
|
//#include "imagjp2.h"
|
||||||
|
//#include "imagmj2.h"
|
||||||
|
#include "imagjpeg2000.h"
|
||||||
|
#ifdef USE_MXF
|
||||||
|
#include "imagmxf.h"
|
||||||
|
#endif // USE_MXF
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
typedef unsigned __int64 int8byte;
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
typedef unsigned long long int8byte;
|
||||||
|
#endif // __WXGTK__
|
||||||
|
|
||||||
|
#define USE_GENERIC_TREECTRL 0
|
||||||
|
#define USE_PENCIL_ON_CANVAS 0
|
||||||
|
|
||||||
|
#if USE_GENERIC_TREECTRL
|
||||||
|
#include "wx/generic/treectlg.h"
|
||||||
|
#ifndef wxTreeCtrl
|
||||||
|
#define wxTreeCtrl wxGenericTreeCtrl
|
||||||
|
#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OPJ_APPLICATION wxT("OPJViewer")
|
||||||
|
#define OPJ_APPLICATION_NAME wxT("OpenJPEG Viewer")
|
||||||
|
#define OPJ_APPLICATION_VERSION wxT("0.4 beta")
|
||||||
|
#define OPJ_APPLICATION_TITLEBAR OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
|
||||||
|
#define OPJ_APPLICATION_COPYRIGHT wxT("(C) 2007-2008, Giuseppe Baruffa")
|
||||||
|
#define OPJ_APPLICATION_VENDOR wxT("OpenJPEG")
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
#define OPJ_APPLICATION_PLATFORM wxT("Windows")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
#define OPJ_APPLICATION_PLATFORM wxT("Linux")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OPJ_FRAME_WIDTH 800
|
||||||
|
#define OPJ_FRAME_HEIGHT 600
|
||||||
|
|
||||||
|
#define OPJ_BROWSER_WIDTH 300
|
||||||
|
#define OPJ_PEEKER_HEIGHT 130
|
||||||
|
|
||||||
|
#define OPJ_CANVAS_BORDER 10
|
||||||
|
#define OPJ_CANVAS_COLOUR *wxWHITE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
|
||||||
|
//#define MYJPWL_MAX_NO_TILESPECS JPWL_MAX_NO_TILESPECS
|
||||||
|
#define MYJPWL_MAX_NO_TILESPECS 4
|
||||||
|
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
|
||||||
|
class OPJDecoThread;
|
||||||
|
class OPJEncoThread;
|
||||||
|
class OPJParseThread;
|
||||||
|
WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread);
|
||||||
|
class OPJChildFrame;
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// this is our main application //
|
||||||
|
//////////////////////////////////
|
||||||
|
class OPJViewerApp: public wxApp
|
||||||
|
{
|
||||||
|
// public methods and variables
|
||||||
|
public:
|
||||||
|
|
||||||
|
// class constructor
|
||||||
|
OPJViewerApp() { m_showImages = true; m_showButtons = false; }
|
||||||
|
|
||||||
|
// other methods
|
||||||
|
bool OnInit(void);
|
||||||
|
int OnExit(void);
|
||||||
|
void SetShowImages(bool show) { m_showImages = show; }
|
||||||
|
bool ShowImages() const { return m_showImages; }
|
||||||
|
void ShowCmdLine(const wxCmdLineParser& parser);
|
||||||
|
|
||||||
|
// all the threads currently alive - as soon as the thread terminates, it's
|
||||||
|
// removed from the array
|
||||||
|
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
|
||||||
|
|
||||||
|
// crit section protects access to all of the arrays below
|
||||||
|
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
|
||||||
|
|
||||||
|
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
|
||||||
|
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
|
||||||
|
|
||||||
|
// the last exiting thread should post to m_semAllDone if this is true
|
||||||
|
// (protected by the same m_critsect)
|
||||||
|
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
|
||||||
|
|
||||||
|
// the list of all filenames written in the command line
|
||||||
|
wxArrayString m_filelist;
|
||||||
|
|
||||||
|
// displaying engine parameters
|
||||||
|
int m_resizemethod;
|
||||||
|
|
||||||
|
// decoding engine parameters
|
||||||
|
bool m_enabledeco, m_enableparse;
|
||||||
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
bool m_enablejpwl, m_enablejpwle;
|
||||||
|
int m_expcomps, m_maxtiles;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
int m_framewidth, m_frameheight;
|
||||||
|
|
||||||
|
// encoding engine parameters
|
||||||
|
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
||||||
|
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
|
||||||
|
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
|
||||||
|
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
|
||||||
|
bool m_enablesegmark, m_enablepoc;
|
||||||
|
bool m_enablequality;
|
||||||
|
int m_resolutions, m_progression;
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
|
||||||
|
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
// some layout settings
|
||||||
|
bool m_showtoolbar, m_showbrowser, m_showpeeker;
|
||||||
|
int m_browserwidth, m_peekerheight;
|
||||||
|
|
||||||
|
// application configuration
|
||||||
|
wxConfig *OPJconfig;
|
||||||
|
|
||||||
|
// private methods and variables
|
||||||
|
private:
|
||||||
|
bool m_showImages, m_showButtons;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_APP(OPJViewerApp)
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// this canvas is used to draw the image //
|
||||||
|
///////////////////////////////////////////
|
||||||
|
class OPJCanvas: public wxScrolledWindow
|
||||||
|
{
|
||||||
|
// public methods and variables
|
||||||
|
public:
|
||||||
|
|
||||||
|
// class constructor
|
||||||
|
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
|
virtual void OnDraw(wxDC& dc);
|
||||||
|
void OnEvent(wxMouseEvent& event);
|
||||||
|
void WriteText(const wxString& text) {
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif //__WXGTK__
|
||||||
|
wxLogMessage(text);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif //__WXGTK__
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnThreadSignal(wxCommandEvent& event);
|
||||||
|
|
||||||
|
OPJDecoThread *CreateDecoThread(void);
|
||||||
|
OPJEncoThread *CreateEncoThread(void);
|
||||||
|
|
||||||
|
|
||||||
|
OPJChildFrame *m_childframe;
|
||||||
|
|
||||||
|
wxBitmap m_image, m_image100;
|
||||||
|
wxFileName m_fname, m_savename;
|
||||||
|
long m_zooml;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////
|
||||||
|
// the data associated to each tree leaf or node //
|
||||||
|
///////////////////////////////////////////////////
|
||||||
|
class OPJMarkerData : public wxTreeItemData
|
||||||
|
{
|
||||||
|
// public methods and variables
|
||||||
|
public:
|
||||||
|
|
||||||
|
// class constructor
|
||||||
|
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
|
||||||
|
|
||||||
|
void ShowInfo(wxTreeCtrl *tree);
|
||||||
|
const wxChar *GetDesc1() const { return m_desc.c_str(); }
|
||||||
|
const wxChar *GetDesc2() const { return m_filestring.c_str(); }
|
||||||
|
wxFileOffset m_start, m_length;
|
||||||
|
wxString m_desc;
|
||||||
|
|
||||||
|
// private methods and variables
|
||||||
|
private:
|
||||||
|
wxString m_filestring;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OPJMarkerTree : public wxTreeCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TreeCtrlIcon_File,
|
||||||
|
TreeCtrlIcon_FileSelected,
|
||||||
|
TreeCtrlIcon_Folder,
|
||||||
|
TreeCtrlIcon_FolderSelected,
|
||||||
|
TreeCtrlIcon_FolderOpened
|
||||||
|
};
|
||||||
|
|
||||||
|
OPJMarkerTree() { };
|
||||||
|
OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
|
||||||
|
const wxPoint& pos, const wxSize& size,
|
||||||
|
long style);
|
||||||
|
virtual ~OPJMarkerTree(){};
|
||||||
|
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
||||||
|
void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
|
||||||
|
|
||||||
|
wxFileName m_fname;
|
||||||
|
wxTextCtrl *m_peektextCtrl;
|
||||||
|
OPJChildFrame *m_childframe;
|
||||||
|
|
||||||
|
/*void OnBeginDrag(wxTreeEvent& event);
|
||||||
|
void OnBeginRDrag(wxTreeEvent& event);
|
||||||
|
void OnEndDrag(wxTreeEvent& event);*/
|
||||||
|
/*void OnBeginLabelEdit(wxTreeEvent& event);
|
||||||
|
void OnEndLabelEdit(wxTreeEvent& event);*/
|
||||||
|
/*void OnDeleteItem(wxTreeEvent& event);*/
|
||||||
|
/*void OnContextMenu(wxContextMenuEvent& event);*/
|
||||||
|
void OnItemMenu(wxTreeEvent& event);
|
||||||
|
/*void OnGetInfo(wxTreeEvent& event);
|
||||||
|
void OnSetInfo(wxTreeEvent& event);*/
|
||||||
|
/*void OnItemExpanded(wxTreeEvent& event);*/
|
||||||
|
void OnItemExpanding(wxTreeEvent& event);
|
||||||
|
/*void OnItemCollapsed(wxTreeEvent& event);
|
||||||
|
void OnItemCollapsing(wxTreeEvent& event);*/
|
||||||
|
void OnSelChanged(wxTreeEvent& event);
|
||||||
|
/*void OnSelChanging(wxTreeEvent& event);*/
|
||||||
|
/*void OnTreeKeyDown(wxTreeEvent& event);*/
|
||||||
|
/*void OnItemActivated(wxTreeEvent& event);*/
|
||||||
|
/*void OnItemRClick(wxTreeEvent& event);*/
|
||||||
|
/*void OnRMouseDown(wxMouseEvent& event);
|
||||||
|
void OnRMouseUp(wxMouseEvent& event);
|
||||||
|
void OnRMouseDClick(wxMouseEvent& event);*/
|
||||||
|
/*void GetItemsRecursively(const wxTreeItemId& idParent,
|
||||||
|
wxTreeItemIdValue cookie = 0);*/
|
||||||
|
|
||||||
|
void CreateImageList(int size = 16);
|
||||||
|
void CreateButtonsImageList(int size = 11);
|
||||||
|
|
||||||
|
/*void AddTestItemsToTree(size_t numChildren, size_t depth);*/
|
||||||
|
/*void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
|
||||||
|
{ m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }*/
|
||||||
|
/*void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }*/
|
||||||
|
/*void DoToggleIcon(const wxTreeItemId& item);*/
|
||||||
|
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
|
||||||
|
|
||||||
|
int ImageSize(void) const { return m_imageSize; }
|
||||||
|
|
||||||
|
void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
|
||||||
|
|
||||||
|
// is this the test item which we use in several event handlers?
|
||||||
|
/*bool IsTestItem(const wxTreeItemId& item)
|
||||||
|
{
|
||||||
|
// the test item is the first child folder
|
||||||
|
return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*void AddItemsRecursively(const wxTreeItemId& idParent,
|
||||||
|
size_t nChildren,
|
||||||
|
size_t depth,
|
||||||
|
size_t folder);*/
|
||||||
|
|
||||||
|
void LogEvent(const wxChar *name, const wxTreeEvent& event);
|
||||||
|
|
||||||
|
int m_imageSize; // current size of images
|
||||||
|
bool m_reverseSort; // flag for OnCompareItems
|
||||||
|
wxTreeItemId m_lastItem, // for OnEnsureVisible()
|
||||||
|
m_draggedItem; // item being dragged right now
|
||||||
|
|
||||||
|
// NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
|
||||||
|
// if you want your overloaded OnCompareItems() to be called.
|
||||||
|
// OTOH, if you don't want it you may omit the next line - this will
|
||||||
|
// make default (alphabetical) sorting much faster under wxMSW.
|
||||||
|
DECLARE_DYNAMIC_CLASS(OPJMarkerTree)
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// this hash map stores all the trees of currently opened images, with an integer key
|
||||||
|
WX_DECLARE_HASH_MAP(int, OPJMarkerTree*, wxIntegerHash, wxIntegerEqual, OPJMarkerTreeHash);
|
||||||
|
|
||||||
|
// this hash map stores all the children of currently opened images, with an integer key
|
||||||
|
WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChildFrameHash);
|
||||||
|
|
||||||
|
// Define a new frame
|
||||||
|
class OPJFrame: public wxMDIParentFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
|
|
||||||
|
~OPJFrame(void);
|
||||||
|
void OnSize(wxSizeEvent& WXUNUSED(event));
|
||||||
|
void OnAbout(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnFileOpen(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnMemoryOpen(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnQuit(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnClose(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnZoom(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnFit(wxCommandEvent& event);
|
||||||
|
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
|
||||||
|
void OnReload(wxCommandEvent& event);
|
||||||
|
void OnPrevFrame(wxCommandEvent& event);
|
||||||
|
void OnHomeFrame(wxCommandEvent& event);
|
||||||
|
void OnNextFrame(wxCommandEvent& event);
|
||||||
|
void OnLessLayers(wxCommandEvent& event);
|
||||||
|
void OnAllLayers(wxCommandEvent& event);
|
||||||
|
void OnMoreLayers(wxCommandEvent& event);
|
||||||
|
void OnLessRes(wxCommandEvent& event);
|
||||||
|
void OnFullRes(wxCommandEvent& event);
|
||||||
|
void OnMoreRes(wxCommandEvent& event);
|
||||||
|
void OnPrevComp(wxCommandEvent& event);
|
||||||
|
void OnAllComps(wxCommandEvent& event);
|
||||||
|
void OnNextComp(wxCommandEvent& event);
|
||||||
|
void OnSetsEnco(wxCommandEvent& event);
|
||||||
|
void OnSetsDeco(wxCommandEvent& event);
|
||||||
|
void OnSashDrag(wxSashEvent& event);
|
||||||
|
void OpenFiles(wxArrayString paths, wxArrayString filenames);
|
||||||
|
void SaveFile(wxArrayString paths, wxArrayString filenames);
|
||||||
|
void OnNotebook(wxNotebookEvent& event);
|
||||||
|
void Rescale(int scale, OPJChildFrame *child);
|
||||||
|
void OnThreadLogmsg(wxCommandEvent& event);
|
||||||
|
|
||||||
|
OPJMarkerTreeHash m_treehash;
|
||||||
|
OPJChildFrameHash m_childhash;
|
||||||
|
wxSashLayoutWindow* markerTreeWindow;
|
||||||
|
wxSashLayoutWindow* loggingWindow;
|
||||||
|
wxToolBar* tool_bar;
|
||||||
|
void Resize(int number);
|
||||||
|
wxNotebook *m_bookCtrl;
|
||||||
|
wxNotebook *m_bookCtrlbottom;
|
||||||
|
wxTextCtrl *m_textCtrlbrowse;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void TogStyle(int id, long flag);
|
||||||
|
|
||||||
|
void DoSort(bool reverse = false);
|
||||||
|
|
||||||
|
wxPanel *m_panel;
|
||||||
|
wxTextCtrl *m_textCtrl;
|
||||||
|
|
||||||
|
void DoSetBold(bool bold = true);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxSashLayoutWindow* m_topWindow;
|
||||||
|
wxSashLayoutWindow* m_leftWindow2;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
class OPJChildFrame: public wxMDIChildFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OPJCanvas *m_canvas;
|
||||||
|
OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
|
~OPJChildFrame(void);
|
||||||
|
void OnActivate(wxActivateEvent& event);
|
||||||
|
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
||||||
|
void OnClose(wxCloseEvent& event);
|
||||||
|
void OnGotFocus(wxFocusEvent& event);
|
||||||
|
void OnLostFocus(wxFocusEvent& event);
|
||||||
|
OPJFrame *m_frame;
|
||||||
|
wxFileName m_fname;
|
||||||
|
int m_winnumber;
|
||||||
|
|
||||||
|
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// frame and main menu ids
|
||||||
|
enum {
|
||||||
|
OPJFRAME_FILEEXIT = wxID_EXIT,
|
||||||
|
OPJFRAME_HELPABOUT = wxID_ABOUT,
|
||||||
|
OPJFRAME_FILEOPEN,
|
||||||
|
OPJFRAME_MEMORYOPEN,
|
||||||
|
OPJFRAME_FILESAVEAS,
|
||||||
|
OPJFRAME_FILETOGGLEB,
|
||||||
|
OPJFRAME_FILETOGGLEP,
|
||||||
|
OPJFRAME_FILETOGGLET,
|
||||||
|
OPJFRAME_VIEWZOOM,
|
||||||
|
OPJFRAME_VIEWFIT,
|
||||||
|
OPJFRAME_VIEWRELOAD,
|
||||||
|
OPJFRAME_VIEWPREVFRAME,
|
||||||
|
OPJFRAME_VIEWHOMEFRAME,
|
||||||
|
OPJFRAME_VIEWNEXTFRAME,
|
||||||
|
OPJFRAME_VIEWLESSLAYERS,
|
||||||
|
OPJFRAME_VIEWALLLAYERS,
|
||||||
|
OPJFRAME_VIEWMORELAYERS,
|
||||||
|
OPJFRAME_VIEWLESSRES,
|
||||||
|
OPJFRAME_VIEWFULLRES,
|
||||||
|
OPJFRAME_VIEWMORERES,
|
||||||
|
OPJFRAME_VIEWPREVCOMP,
|
||||||
|
OPJFRAME_VIEWALLCOMPS,
|
||||||
|
OPJFRAME_VIEWNEXTCOMP,
|
||||||
|
OPJFRAME_FILECLOSE,
|
||||||
|
OPJFRAME_SETSENCO,
|
||||||
|
OPJFRAME_SETSDECO,
|
||||||
|
|
||||||
|
OPJFRAME_BROWSEWIN = 10000,
|
||||||
|
OPJFRAME_LOGWIN,
|
||||||
|
OPJFRAME_TOOLBAR,
|
||||||
|
|
||||||
|
OPJFRAME_THREADLOGMSG,
|
||||||
|
OPJCANVAS_THREADSIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// menu and control ids
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TreeTest_Quit = wxID_EXIT,
|
||||||
|
TreeTest_About = wxID_ABOUT,
|
||||||
|
TreeTest_TogButtons = wxID_HIGHEST,
|
||||||
|
TreeTest_TogTwist,
|
||||||
|
TreeTest_TogLines,
|
||||||
|
TreeTest_TogEdit,
|
||||||
|
TreeTest_TogHideRoot,
|
||||||
|
TreeTest_TogRootLines,
|
||||||
|
TreeTest_TogBorder,
|
||||||
|
TreeTest_TogFullHighlight,
|
||||||
|
TreeTest_SetFgColour,
|
||||||
|
TreeTest_SetBgColour,
|
||||||
|
TreeTest_ResetStyle,
|
||||||
|
TreeTest_Highlight,
|
||||||
|
TreeTest_Dump,
|
||||||
|
TreeTest_DumpSelected,
|
||||||
|
TreeTest_Count,
|
||||||
|
TreeTest_CountRec,
|
||||||
|
TreeTest_Sort,
|
||||||
|
TreeTest_SortRev,
|
||||||
|
TreeTest_SetBold,
|
||||||
|
TreeTest_ClearBold,
|
||||||
|
TreeTest_Rename,
|
||||||
|
TreeTest_Delete,
|
||||||
|
TreeTest_DeleteChildren,
|
||||||
|
TreeTest_DeleteAll,
|
||||||
|
TreeTest_Recreate,
|
||||||
|
TreeTest_ToggleImages,
|
||||||
|
TreeTest_ToggleButtons,
|
||||||
|
TreeTest_SetImageSize,
|
||||||
|
TreeTest_ToggleSel,
|
||||||
|
TreeTest_CollapseAndReset,
|
||||||
|
TreeTest_EnsureVisible,
|
||||||
|
TreeTest_AddItem,
|
||||||
|
TreeTest_InsertItem,
|
||||||
|
TreeTest_IncIndent,
|
||||||
|
TreeTest_DecIndent,
|
||||||
|
TreeTest_IncSpacing,
|
||||||
|
TreeTest_DecSpacing,
|
||||||
|
TreeTest_ToggleIcon,
|
||||||
|
TreeTest_Select,
|
||||||
|
TreeTest_Unselect,
|
||||||
|
TreeTest_SelectRoot,
|
||||||
|
TreeTest_Ctrl = 1000,
|
||||||
|
BOTTOM_NOTEBOOK_ID,
|
||||||
|
LEFT_NOTEBOOK_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
class OPJEncoThread : public wxThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OPJEncoThread(OPJCanvas *canvas);
|
||||||
|
|
||||||
|
// thread execution starts here
|
||||||
|
virtual void *Entry();
|
||||||
|
|
||||||
|
// called when the thread exits - whether it terminates normally or is
|
||||||
|
// stopped with Delete() (but not when it is Kill()ed!)
|
||||||
|
virtual void OnExit();
|
||||||
|
|
||||||
|
// write something to the text control
|
||||||
|
void WriteText(const wxString& text);
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned m_count;
|
||||||
|
OPJCanvas *m_canvas;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OPJDecoThread : public wxThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OPJDecoThread(OPJCanvas *canvas);
|
||||||
|
|
||||||
|
// thread execution starts here
|
||||||
|
virtual void *Entry();
|
||||||
|
|
||||||
|
// called when the thread exits - whether it terminates normally or is
|
||||||
|
// stopped with Delete() (but not when it is Kill()ed!)
|
||||||
|
virtual void OnExit();
|
||||||
|
|
||||||
|
// write something to the text control
|
||||||
|
void WriteText(const wxString& text);
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned m_count;
|
||||||
|
OPJCanvas *m_canvas;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OPJParseThread : public wxThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid = 0x00);
|
||||||
|
|
||||||
|
// thread execution starts here
|
||||||
|
virtual void *Entry();
|
||||||
|
|
||||||
|
// called when the thread exits - whether it terminates normally or is
|
||||||
|
// stopped with Delete() (but not when it is Kill()ed!)
|
||||||
|
virtual void OnExit();
|
||||||
|
|
||||||
|
// write something to the text control
|
||||||
|
void WriteText(const wxString& text);
|
||||||
|
void LoadFile(wxFileName fname);
|
||||||
|
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
||||||
|
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
||||||
|
|
||||||
|
unsigned m_count;
|
||||||
|
OPJMarkerTree *m_tree;
|
||||||
|
wxTreeItemId m_parentid;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||||
|
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||||
|
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||||
|
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Drag and drop files target
|
||||||
|
class OPJDnDFile: public wxFileDropTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
|
||||||
|
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
||||||
|
|
||||||
|
private:
|
||||||
|
OPJFrame *m_pOwner;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Property sheet dialog: encoder
|
||||||
|
class OPJEncoderDialog: public wxPropertySheetDialog
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(OPJEncoderDialog)
|
||||||
|
public:
|
||||||
|
OPJEncoderDialog(wxWindow* parent, int dialogType);
|
||||||
|
~OPJEncoderDialog();
|
||||||
|
|
||||||
|
wxBookCtrlBase* m_settingsNotebook;
|
||||||
|
|
||||||
|
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||||
|
wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
|
||||||
|
wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
|
||||||
|
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
|
||||||
|
void OnEnableComm(wxCommandEvent& event);
|
||||||
|
void OnEnableIdx(wxCommandEvent& event);
|
||||||
|
void OnEnablePoc(wxCommandEvent& event);
|
||||||
|
void OnRadioQualityRate(wxCommandEvent& event);
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
void OnEnableJPWL(wxCommandEvent& event);
|
||||||
|
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||||
|
/*wxCheckBox *m_enablejpwlCheck;*/
|
||||||
|
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
|
||||||
|
void OnHprotSelect(wxCommandEvent& event);
|
||||||
|
void OnPprotSelect(wxCommandEvent& event);
|
||||||
|
void OnSensiSelect(wxCommandEvent& event);
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
|
||||||
|
wxRadioButton *m_rateRadio, *m_qualityRadio;
|
||||||
|
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
|
||||||
|
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
|
||||||
|
wxRadioBox *progressionBox;
|
||||||
|
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
|
||||||
|
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
|
||||||
|
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
|
||||||
|
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
|
||||||
|
wxSpinCtrl *m_resolutionsCtrl;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum {
|
||||||
|
OPJENCO_ENABLEJPWL = 100,
|
||||||
|
OPJENCO_RATEFACTOR,
|
||||||
|
OPJENCO_RATERADIO,
|
||||||
|
OPJENCO_QUALITYFACTOR,
|
||||||
|
OPJENCO_QUALITYRADIO,
|
||||||
|
OPJENCO_RESNUMBER,
|
||||||
|
OPJENCO_CODEBLOCKSIZE,
|
||||||
|
OPJENCO_PRECINCTSIZE,
|
||||||
|
OPJENCO_TILESIZE,
|
||||||
|
OPJENCO_PROGRESSION,
|
||||||
|
OPJENCO_SUBSAMPLING,
|
||||||
|
OPJENCO_ENABLESOP,
|
||||||
|
OPJENCO_ENABLEEPH,
|
||||||
|
OPJENCO_ENABLEBYPASS,
|
||||||
|
OPJENCO_ENABLERESET,
|
||||||
|
OPJENCO_ENABLERESTART,
|
||||||
|
OPJENCO_ENABLEVSC,
|
||||||
|
OPJENCO_ENABLEERTERM,
|
||||||
|
OPJENCO_ENABLESEGMARK,
|
||||||
|
OPJENCO_ENABLEPOC,
|
||||||
|
OPJENCO_ROICOMP,
|
||||||
|
OPJENCO_ROISHIFT,
|
||||||
|
OPJENCO_IMORIG,
|
||||||
|
OPJENCO_TILORIG,
|
||||||
|
OPJENCO_ENABLEMCT,
|
||||||
|
OPJENCO_ENABLEIRREV,
|
||||||
|
OPJENCO_ENABLEINDEX,
|
||||||
|
OPJENCO_INDEXNAME,
|
||||||
|
OPJENCO_POCSPEC,
|
||||||
|
OPJENCO_ENABLECOMM,
|
||||||
|
OPJENCO_COMMENTTEXT,
|
||||||
|
OPJENCO_HPROT,
|
||||||
|
OPJENCO_HTILE,
|
||||||
|
OPJENCO_PPROT,
|
||||||
|
OPJENCO_PTILE,
|
||||||
|
OPJENCO_PPACK,
|
||||||
|
OPJENCO_SENSI,
|
||||||
|
OPJENCO_STILE
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Property sheet dialog: decoder
|
||||||
|
class OPJDecoderDialog: public wxPropertySheetDialog
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(OPJDecoderDialog)
|
||||||
|
public:
|
||||||
|
OPJDecoderDialog(wxWindow* parent, int dialogType);
|
||||||
|
~OPJDecoderDialog();
|
||||||
|
|
||||||
|
wxBookCtrlBase* m_settingsNotebook;
|
||||||
|
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
||||||
|
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
||||||
|
wxRadioBox* m_resizeBox;
|
||||||
|
|
||||||
|
void OnEnableDeco(wxCommandEvent& event);
|
||||||
|
|
||||||
|
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||||
|
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
|
||||||
|
wxPanel* CreatePart3SettingsPage(wxWindow* parent);
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
void OnEnableJPWL(wxCommandEvent& event);
|
||||||
|
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||||
|
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
||||||
|
wxCheckBox *m_enablejpwlCheck;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
wxSpinCtrl *m_framenumCtrl;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum {
|
||||||
|
OPJDECO_RESMETHOD = 100,
|
||||||
|
OPJDECO_REDUCEFACTOR,
|
||||||
|
OPJDECO_QUALITYLAYERS,
|
||||||
|
OPJDECO_NUMCOMPS,
|
||||||
|
OPJDECO_ENABLEDECO,
|
||||||
|
OPJDECO_ENABLEPARSE,
|
||||||
|
OPJDECO_ENABLEJPWL,
|
||||||
|
OPJDECO_EXPCOMPS,
|
||||||
|
OPJDECO_MAXTILES,
|
||||||
|
OPJDECO_FRAMENUM
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //__OPJ_VIEWER_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BIN
applications/OPJViewer/source/OPJViewer.ico
Normal file
BIN
applications/OPJViewer/source/OPJViewer.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
3
applications/OPJViewer/source/OPJViewer.rc
Normal file
3
applications/OPJViewer/source/OPJViewer.rc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
OPJChild16 ICON OPJChild.ico
|
||||||
|
OPJViewer16 ICON OPJViewer.ico
|
||||||
|
#include "wx/msw/wx.rc"
|
||||||
26
applications/OPJViewer/source/OPJViewer16.xpm
Normal file
26
applications/OPJViewer/source/OPJViewer16.xpm
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char *OPJViewer16[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"16 16 4 1",
|
||||||
|
" c black",
|
||||||
|
". c #800000",
|
||||||
|
"X c red",
|
||||||
|
"o c None",
|
||||||
|
/* pixels */
|
||||||
|
"oooooooooooooooo",
|
||||||
|
"ooo.XXXXoooooooo",
|
||||||
|
"ooXXoo .Xooooooo",
|
||||||
|
"o..oooo .ooooooo",
|
||||||
|
"oX.oooo ooooooo",
|
||||||
|
"oX.oooo .ooooooo",
|
||||||
|
"oXXoooo .ooooooo",
|
||||||
|
"o.XXoo .oooooooo",
|
||||||
|
"oo.XXXXooooooooo",
|
||||||
|
"ooooooooo.Xo .oo",
|
||||||
|
"ooooooooo X. ooo",
|
||||||
|
"oooooooooo...ooo",
|
||||||
|
"oooooooooo XXooo",
|
||||||
|
"oooooooooo .Xooo",
|
||||||
|
"oooooooooooooooo",
|
||||||
|
"oooooooooooooooo"
|
||||||
|
};
|
||||||
54
applications/OPJViewer/source/about_htm.h
Normal file
54
applications/OPJViewer/source/about_htm.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
wxString htmlaboutpage = wxT(
|
||||||
|
"<html>"
|
||||||
|
"<body bgcolor=#FFFFFF>"
|
||||||
|
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||||
|
"<tr>"
|
||||||
|
"<td rowspan=3 valign=top align=center width=70>"
|
||||||
|
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||||
|
"</td>"
|
||||||
|
"<td align=center>"
|
||||||
|
"<font size=+0 color=#000000><b>"
|
||||||
|
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||||
|
"</b></font><br>"
|
||||||
|
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||||
|
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr height=3 valign=center>"
|
||||||
|
"<td valign=center bgcolor=#cc3300></td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td align=justify>"
|
||||||
|
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||||
|
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||||
|
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||||
|
"<font size=-2 color=red>* Build: ")
|
||||||
|
#include "build.h"
|
||||||
|
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||||
|
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||||
|
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||||
|
#endif // USE_JPWL
|
||||||
|
#ifdef USE_JPSEC
|
||||||
|
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||||
|
#endif // USE_JPSEC
|
||||||
|
wxT(")</font><br>")
|
||||||
|
#ifdef USE_MXF
|
||||||
|
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||||
|
#endif // USE_MXF
|
||||||
|
wxT("</td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||||
|
"</tr>"
|
||||||
|
"<tr>"
|
||||||
|
"<td colspan=2>"
|
||||||
|
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||||
|
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>"
|
||||||
|
"</table>"
|
||||||
|
"</body>"
|
||||||
|
"</html>"
|
||||||
|
);
|
||||||
1
applications/OPJViewer/source/build.h
Normal file
1
applications/OPJViewer/source/build.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
wxT("491")
|
||||||
79
applications/OPJViewer/source/icon1.xpm
Normal file
79
applications/OPJViewer/source/icon1.xpm
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* XPM */
|
||||||
|
static const char *icon1_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 41 1",
|
||||||
|
"> c #97C4E7",
|
||||||
|
"# c #4381AA",
|
||||||
|
"d c #FFFFFF",
|
||||||
|
"< c #71B2DE",
|
||||||
|
"+ c #538BB1",
|
||||||
|
"& c #D1E5F5",
|
||||||
|
"q c #63B3DE",
|
||||||
|
"6 c #F1F4F7",
|
||||||
|
"* c #CAE1F3",
|
||||||
|
"y c #7AC4E5",
|
||||||
|
"= c #C3DDF1",
|
||||||
|
"X c #74A1BD",
|
||||||
|
"- c #BCD9EF",
|
||||||
|
"5 c #619BC4",
|
||||||
|
"3 c #E6EAF1",
|
||||||
|
"2 c #4B8EBF",
|
||||||
|
"o c #6B97B6",
|
||||||
|
". c #4B82A8",
|
||||||
|
" c None",
|
||||||
|
"w c #54A6D8",
|
||||||
|
"1 c #71A8D1",
|
||||||
|
", c #85BBE2",
|
||||||
|
"t c #EFF6FC",
|
||||||
|
"7 c #DEEDF8",
|
||||||
|
"@ c #4388B4",
|
||||||
|
"a c #F7FBFD",
|
||||||
|
"$ c #D7E0E9",
|
||||||
|
"r c #FAFCFE",
|
||||||
|
"4 c #DAEAF7",
|
||||||
|
"e c #E9F3FA",
|
||||||
|
"0 c #76BAE2",
|
||||||
|
"% c #7FA6C0",
|
||||||
|
"s c #FDFDFE",
|
||||||
|
"O c #5896BE",
|
||||||
|
"p c #B6D5EE",
|
||||||
|
"8 c #87ABC3",
|
||||||
|
": c #A5CCEA",
|
||||||
|
"9 c #E5F0F9",
|
||||||
|
"; c #AFD1EC",
|
||||||
|
"i c #F4F9FD",
|
||||||
|
"u c #8FB0C3",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" .XXXooOO++@#$ ",
|
||||||
|
" %&*=-;:>>,<123 ",
|
||||||
|
" %4&*=-;:>>,1>56 ",
|
||||||
|
" %74&*=-;:>>1*>56 ",
|
||||||
|
" 89700qqqqwq1e*>X ",
|
||||||
|
" 8e974&*=-;:1re*>8 ",
|
||||||
|
" 8te974&*=-;11111# ",
|
||||||
|
" 8tty000qqqqqww>,+ ",
|
||||||
|
" uitte974&*=-p:>>+ ",
|
||||||
|
" uaitte974&*=-p:>O ",
|
||||||
|
" uaayyyy000qqqqp:O ",
|
||||||
|
" uraaitte974&*=-po ",
|
||||||
|
" urraaitte974&*=-o ",
|
||||||
|
" usryyyyyyy000q*=X ",
|
||||||
|
" ussrraaitte974&*X ",
|
||||||
|
" udssrraaitte974&X ",
|
||||||
|
" uddyyyyyyyyyy074% ",
|
||||||
|
" udddssrraaitte97% ",
|
||||||
|
" uddddssrraaitte9% ",
|
||||||
|
" udddddssrraaitte8 ",
|
||||||
|
" uddddddssrraaitt8 ",
|
||||||
|
" uuuuuuuuuuuuuu88u ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" "
|
||||||
|
};
|
||||||
53
applications/OPJViewer/source/icon2.xpm
Normal file
53
applications/OPJViewer/source/icon2.xpm
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* XPM */
|
||||||
|
static const char *icon2_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 15 1",
|
||||||
|
". c Black",
|
||||||
|
"O c #97C4E7",
|
||||||
|
"$ c #63B3DE",
|
||||||
|
"@ c #CAE1F3",
|
||||||
|
"; c #7AC4E5",
|
||||||
|
"* c #74A1BD",
|
||||||
|
"+ c #619BC4",
|
||||||
|
"o c #4B8EBF",
|
||||||
|
" c None",
|
||||||
|
"% c #54A6D8",
|
||||||
|
"= c #FAFCFE",
|
||||||
|
"& c #E9F3FA",
|
||||||
|
"# c #76BAE2",
|
||||||
|
"X c #C00000",
|
||||||
|
"- c #87ABC3",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ............. ",
|
||||||
|
" .XXXXXXXXXX.o. ",
|
||||||
|
" .XXXXXXXXXX.O+. ",
|
||||||
|
" .XXXXXXXXXX.@O+. ",
|
||||||
|
" .XX##$$$$%$.&@O* ",
|
||||||
|
" .XXXXXXXXXX.=&@O- ",
|
||||||
|
" .XXXXXXXXXX...... ",
|
||||||
|
" .XX;###$$$$$%%XX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XX;;;;###$$$$XX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XX;;;;;;;###$XX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XX;;;;;;;;;;#XX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" .XXXXXXXXXXXXXXX. ",
|
||||||
|
" ................. ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" "
|
||||||
|
};
|
||||||
79
applications/OPJViewer/source/icon3.xpm
Normal file
79
applications/OPJViewer/source/icon3.xpm
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* XPM */
|
||||||
|
static const char *icon3_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 41 1",
|
||||||
|
"6 c #EDF2FB",
|
||||||
|
"- c #AAC1E8",
|
||||||
|
": c #B9CDED",
|
||||||
|
"X c #295193",
|
||||||
|
", c #C6D6F0",
|
||||||
|
"a c #4A7CCE",
|
||||||
|
"u c #779DDB",
|
||||||
|
"y c #7FA2DD",
|
||||||
|
"$ c #3263B4",
|
||||||
|
"5 c #EAF0FA",
|
||||||
|
". c #2D59A3",
|
||||||
|
"o c #6E96D8",
|
||||||
|
"* c #356AC1",
|
||||||
|
"r c #F7F9FD",
|
||||||
|
"> c #BED0EE",
|
||||||
|
"3 c #E1E9F7",
|
||||||
|
"7 c #F0F5FC",
|
||||||
|
"< c #CBD9F1",
|
||||||
|
"2 c #DAE5F6",
|
||||||
|
"# c #3161B1",
|
||||||
|
" c None",
|
||||||
|
"0 c #FDFEFF",
|
||||||
|
"= c #9FB9E5",
|
||||||
|
"e c #AEC5EA",
|
||||||
|
"t c #89A9DF",
|
||||||
|
"q c #98B5E4",
|
||||||
|
"p c #5584D1",
|
||||||
|
"d c #3A70CA",
|
||||||
|
"@ c #305FAC",
|
||||||
|
"i c #5D89D3",
|
||||||
|
"1 c #D2DFF4",
|
||||||
|
"% c #3366B9",
|
||||||
|
"9 c #FAFCFE",
|
||||||
|
"8 c #F5F8FD",
|
||||||
|
"s c #4075CC",
|
||||||
|
"O c #638ED5",
|
||||||
|
"w c #90AFE2",
|
||||||
|
"& c #3467BC",
|
||||||
|
"+ c #2F5DA9",
|
||||||
|
"; c #B3C8EB",
|
||||||
|
"4 c #E5EDF9",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ......X ",
|
||||||
|
" .oooooO+ ",
|
||||||
|
" .ooooooo. ",
|
||||||
|
" .+@@@##$%%&&&&&****. ",
|
||||||
|
" .=-;:>,<12345678900. ",
|
||||||
|
" .q=-;:>,<1234567890. ",
|
||||||
|
" .wq=-e:>,<12345678r. ",
|
||||||
|
" .twq=-e:>,<12345678. ",
|
||||||
|
" .ytwq=-e:>,<1234567. ",
|
||||||
|
" .uytwq=-e:>,<123456. ",
|
||||||
|
" .ouytwq=-e:>,<12345. ",
|
||||||
|
" .Oouytwq=-e;>,<1234. ",
|
||||||
|
" .iOouytwq=-e;>,<123. ",
|
||||||
|
" .piOouytwq=-e;>,<12. ",
|
||||||
|
" .apiOouytwq=-e;>,<1. ",
|
||||||
|
" .sapiOouytwq=-e;>,<. ",
|
||||||
|
" .dsapiOouytwq=-e;>,. ",
|
||||||
|
" ...................# ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" "
|
||||||
|
};
|
||||||
43
applications/OPJViewer/source/icon4.xpm
Normal file
43
applications/OPJViewer/source/icon4.xpm
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* XPM */
|
||||||
|
static const char *icon4_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 5 1",
|
||||||
|
". c Black",
|
||||||
|
"o c #8399B4",
|
||||||
|
"X c #8DA0B9",
|
||||||
|
" c None",
|
||||||
|
"O c #800000",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ....... ",
|
||||||
|
" .XXXXXo. ",
|
||||||
|
" .XXXXXXX. ",
|
||||||
|
" .................... ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .OOOOOOOOOOOOOOOOOO. ",
|
||||||
|
" .................... ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" "
|
||||||
|
};
|
||||||
79
applications/OPJViewer/source/icon5.xpm
Normal file
79
applications/OPJViewer/source/icon5.xpm
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* XPM */
|
||||||
|
static const char *icon5_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 41 1",
|
||||||
|
"0 c #AAC1E8",
|
||||||
|
"q c #B9CDED",
|
||||||
|
"X c #295193",
|
||||||
|
"e c #C6D6F0",
|
||||||
|
"a c #4A7CCE",
|
||||||
|
"& c #779DDB",
|
||||||
|
"* c #7FA2DD",
|
||||||
|
"2 c #EAF0FA",
|
||||||
|
"@ c #2D59A3",
|
||||||
|
"o c #6E96D8",
|
||||||
|
"y c #356AC1",
|
||||||
|
"d c #214279",
|
||||||
|
"w c #BED0EE",
|
||||||
|
"= c #85A7DF",
|
||||||
|
"< c #E1E9F7",
|
||||||
|
"3 c #F0F5FC",
|
||||||
|
"s c #CBD9F1",
|
||||||
|
", c #DAE5F6",
|
||||||
|
"7 c #3161B1",
|
||||||
|
" c None",
|
||||||
|
". c #274D8B",
|
||||||
|
"6 c #FDFEFF",
|
||||||
|
"i c #E7EEF9",
|
||||||
|
"9 c #9FB9E5",
|
||||||
|
"- c #89A9DF",
|
||||||
|
"8 c #98B5E4",
|
||||||
|
"$ c #5584D1",
|
||||||
|
"+ c #3569BF",
|
||||||
|
"% c #305FAC",
|
||||||
|
"O c #5D89D3",
|
||||||
|
"> c #D2DFF4",
|
||||||
|
"p c #3366B9",
|
||||||
|
"5 c #FAFCFE",
|
||||||
|
"4 c #F5F8FD",
|
||||||
|
"t c #4075CC",
|
||||||
|
"u c #638ED5",
|
||||||
|
"r c #CEDCF2",
|
||||||
|
"; c #90AFE2",
|
||||||
|
"# c #2F5DA9",
|
||||||
|
": c #B3C8EB",
|
||||||
|
"1 c #E5EDF9",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ......X ",
|
||||||
|
" XoooooO. ",
|
||||||
|
" Xoooooo+. ",
|
||||||
|
" Xooooooo@XXXXXXXXXX# ",
|
||||||
|
" Xoooooooooooooooooo# ",
|
||||||
|
" Xoooooooooooooooooo# ",
|
||||||
|
" Xoo$################### ",
|
||||||
|
" Xoo%O&*=-;:>,<123445667 ",
|
||||||
|
" XooX890:qwer>,<123445q# ",
|
||||||
|
" Xoty;890:qwer>,<12344# ",
|
||||||
|
" Xo%u-;890:qwer>,<i234# ",
|
||||||
|
" XoX&*-;890:qwer>,<i2r# ",
|
||||||
|
" Xtpo&*-;890:qwer>,<i# ",
|
||||||
|
" X%auo&*-;890:qwer>,<# ",
|
||||||
|
" XX$Ouo&*-;890:qwer>s# ",
|
||||||
|
" d%a$Ouo&*-;890:qwer# ",
|
||||||
|
" d+ta$Ouo&*-;890:qwe# ",
|
||||||
|
" d..................# ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" "
|
||||||
|
};
|
||||||
1464
applications/OPJViewer/source/imagjpeg2000.cpp
Normal file
1464
applications/OPJViewer/source/imagjpeg2000.cpp
Normal file
File diff suppressed because it is too large
Load Diff
177
applications/OPJViewer/source/imagjpeg2000.h
Normal file
177
applications/OPJViewer/source/imagjpeg2000.h
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: imagalljpeg2000.h
|
||||||
|
// Purpose: wxImage JPEG 2000 family file format handler
|
||||||
|
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||||
|
// RCS-ID: $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
|
||||||
|
// Copyright: (c) Giuseppe Baruffa
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_IMAGJPEG2000_H_
|
||||||
|
#define _WX_IMAGJPEG2000_H_
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxJPEG2000Handler
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#include "wx/image.h"
|
||||||
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
#include "codec/index.h"
|
||||||
|
|
||||||
|
#define wxBITMAP_TYPE_JPEG2000 50
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline wxJPEG2000Handler()
|
||||||
|
{
|
||||||
|
m_name = wxT("JPEG 2000 family file format");
|
||||||
|
m_extension = wxT("mj2");
|
||||||
|
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||||
|
m_mime = wxT("image/mj2");
|
||||||
|
|
||||||
|
/* decoding */
|
||||||
|
m_reducefactor = 0;
|
||||||
|
m_qualitylayers = 0;
|
||||||
|
m_components = 0;
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
m_enablejpwl = true;
|
||||||
|
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||||
|
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
/* encoding */
|
||||||
|
m_subsampling = wxT("1,1");
|
||||||
|
m_origin = wxT("0,0");
|
||||||
|
m_rates = wxT("20,10,5");
|
||||||
|
m_quality = wxT("30,35,40");
|
||||||
|
m_enablequality = false;
|
||||||
|
m_multicomp = false;
|
||||||
|
m_irreversible = false;
|
||||||
|
m_resolutions = 6;
|
||||||
|
m_progression = 0;
|
||||||
|
m_cbsize = wxT("32,32");
|
||||||
|
m_prsize = wxT("[128,128],[128,128]");
|
||||||
|
m_tsize = wxT("");
|
||||||
|
m_torigin = wxT("0,0");
|
||||||
|
/*m_progression
|
||||||
|
m_resilience*/
|
||||||
|
m_enablesop = false;
|
||||||
|
m_enableeph = false;
|
||||||
|
m_enablereset = false;
|
||||||
|
m_enablesegmark = false;
|
||||||
|
m_enablevsc = false;
|
||||||
|
m_enablerestart = false;
|
||||||
|
m_enableerterm = false;
|
||||||
|
m_enablebypass = false;
|
||||||
|
/*m_roicompo
|
||||||
|
m_roiup
|
||||||
|
m_indexfname*/
|
||||||
|
m_enableidx = false;
|
||||||
|
m_index = wxT("index.txt");
|
||||||
|
m_enablepoc = false;
|
||||||
|
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||||
|
m_enablecomm = true;
|
||||||
|
|
||||||
|
#if defined __WXMSW__
|
||||||
|
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||||
|
#elif defined __WXGTK__
|
||||||
|
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||||
|
#else
|
||||||
|
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||||
|
#else
|
||||||
|
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// decoding engine parameters
|
||||||
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
bool m_enablejpwl;
|
||||||
|
int m_expcomps, m_maxtiles;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
// encoding engine parameters
|
||||||
|
wxString m_subsampling;
|
||||||
|
wxString m_origin;
|
||||||
|
wxString m_rates;
|
||||||
|
wxString m_quality;
|
||||||
|
bool m_enablequality;
|
||||||
|
bool m_multicomp;
|
||||||
|
bool m_irreversible;
|
||||||
|
int m_resolutions;
|
||||||
|
int m_progression;
|
||||||
|
wxString m_cbsize;
|
||||||
|
wxString m_prsize;
|
||||||
|
wxString m_tsize;
|
||||||
|
wxString m_torigin;
|
||||||
|
/*m_progression
|
||||||
|
m_resilience*/
|
||||||
|
bool m_enablesop;
|
||||||
|
bool m_enableeph;
|
||||||
|
bool m_enablebypass;
|
||||||
|
bool m_enableerterm;
|
||||||
|
bool m_enablerestart;
|
||||||
|
bool m_enablereset;
|
||||||
|
bool m_enablesegmark;
|
||||||
|
bool m_enablevsc;
|
||||||
|
/*m_roicompo
|
||||||
|
m_roiup
|
||||||
|
m_indexfname*/
|
||||||
|
bool m_enableidx;
|
||||||
|
wxString m_index;
|
||||||
|
bool m_enablecomm;
|
||||||
|
wxString m_comment;
|
||||||
|
bool m_enablepoc;
|
||||||
|
wxString m_poc;
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
|
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||||
|
virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true);
|
||||||
|
protected:
|
||||||
|
virtual bool DoCanRead(wxInputStream& stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#endif // _WX_IMAGJPEG2000_H_
|
||||||
|
|
||||||
502
applications/OPJViewer/source/imagmxf.cpp
Normal file
502
applications/OPJViewer/source/imagmxf.cpp
Normal file
@@ -0,0 +1,502 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: imagmxf.cpp
|
||||||
|
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
|
||||||
|
// Author: Giuseppe Baruffa - based on imagjpeg.cpp, Vaclav Slavik
|
||||||
|
// RCS-ID: $Id: imagmxf.cpp,v 0.00 2007/11/19 17:00:00 MW Exp $
|
||||||
|
// Copyright: (c) Giuseppe Baruffa
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef USE_MXF
|
||||||
|
|
||||||
|
#include "mxflib/mxflib.h"
|
||||||
|
using namespace mxflib;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
//! Structure holding information about the essence in each body stream
|
||||||
|
struct EssenceInfo
|
||||||
|
{
|
||||||
|
UMIDPtr PackageID;
|
||||||
|
PackagePtr Package;
|
||||||
|
MDObjectPtr Descriptor;
|
||||||
|
};
|
||||||
|
//! Map of EssenceInfo structures indexed by BodySID
|
||||||
|
typedef std::map<UInt32, EssenceInfo> EssenceInfoMap;
|
||||||
|
|
||||||
|
//! The map of essence info for this file
|
||||||
|
EssenceInfoMap EssenceLookup;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Build an EssenceInfoMap for the essence in a given file
|
||||||
|
/*! \return True if al OK, else false
|
||||||
|
*/
|
||||||
|
bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup);
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE && wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#include "imagmxf.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
#include "wx/module.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "wx/filefn.h"
|
||||||
|
#include "wx/wfstream.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// types
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxMXFHandler
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxMXFHandler,wxImageHandler)
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#define MAX_MESSAGE_LEN 200
|
||||||
|
|
||||||
|
//------------- MXF Manager
|
||||||
|
|
||||||
|
// Debug and error messages
|
||||||
|
|
||||||
|
//! Display a warning message
|
||||||
|
void mxflib::warning(const char *Fmt, ...)
|
||||||
|
{
|
||||||
|
char msg[MAX_MESSAGE_LEN];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, Fmt);
|
||||||
|
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[WARNING_MXF] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Display an error message
|
||||||
|
void mxflib::error(const char *Fmt, ...)
|
||||||
|
{
|
||||||
|
char msg[MAX_MESSAGE_LEN];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, Fmt);
|
||||||
|
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[ERROR_MXF] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Display an error message
|
||||||
|
void mxflib::debug(const char *Fmt, ...)
|
||||||
|
{
|
||||||
|
char msg[MAX_MESSAGE_LEN];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, Fmt);
|
||||||
|
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[DEBUG_MXF] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//------------- JPEG 2000 Data Source Manager
|
||||||
|
|
||||||
|
#define J2K_CFMT 0
|
||||||
|
#define JP2_CFMT 1
|
||||||
|
#define JPT_CFMT 2
|
||||||
|
#define MJ2_CFMT 3
|
||||||
|
#define PXM_DFMT 0
|
||||||
|
#define PGX_DFMT 1
|
||||||
|
#define BMP_DFMT 2
|
||||||
|
#define YUV_DFMT 3
|
||||||
|
|
||||||
|
/* sample error callback expecting a FILE* client object */
|
||||||
|
void mxf_error_callback(const char *msg, void *client_data) {
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sample warning callback expecting a FILE* client object */
|
||||||
|
void mxf_warning_callback(const char *msg, void *client_data) {
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sample debug callback expecting no client object */
|
||||||
|
void mxf_info_callback(const char *msg, void *client_data) {
|
||||||
|
int message_len = strlen(msg) - 1;
|
||||||
|
if (msg[message_len] != '\n')
|
||||||
|
message_len = MAX_MESSAGE_LEN;
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
|
||||||
|
#ifndef __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
#endif /* __WXGTK__ */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// load the mxf file format
|
||||||
|
bool wxMXFHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index)
|
||||||
|
{
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *opjimage = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
unsigned char *ptr;
|
||||||
|
int file_length, j2k_point, j2k_len;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
|
||||||
|
// simply display the version of the library
|
||||||
|
wxLogMessage(wxT("Version of MXF: %s "), wxString::FromAscii(LibraryVersion().c_str()));
|
||||||
|
//wxLogMessage(wxT("MXF file name: %s"), m_filename.GetFullPath());
|
||||||
|
|
||||||
|
// open MXF file
|
||||||
|
MXFFilePtr TestFile = new MXFFile;
|
||||||
|
if (! TestFile->Open(m_filename.GetFullPath().c_str(), true))
|
||||||
|
{
|
||||||
|
wxLogError(wxT("Could not find %s"), m_filename.GetFullPath().c_str());
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
wxLogMessage(wxT("Found %s"), m_filename.GetFullPath().c_str());
|
||||||
|
|
||||||
|
// Get the size
|
||||||
|
TestFile->SeekEnd();
|
||||||
|
wxLogMessage(wxT("Size is %d bytes"), TestFile->Tell());
|
||||||
|
TestFile->Seek(0);
|
||||||
|
|
||||||
|
// essence information
|
||||||
|
//BuildEssenceInfo(TestFile, EssenceLookup);
|
||||||
|
|
||||||
|
// close MXF file
|
||||||
|
TestFile->Close();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// destroy the image
|
||||||
|
image->Destroy();
|
||||||
|
|
||||||
|
/* handle to a decompressor */
|
||||||
|
opj_dinfo_t* dinfo = NULL;
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
|
||||||
|
/* configure the event callbacks (not required) */
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = mxf_error_callback;
|
||||||
|
event_mgr.warning_handler = mxf_warning_callback;
|
||||||
|
event_mgr.info_handler = mxf_info_callback;
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* prepare parameters */
|
||||||
|
strncpy(parameters.infile, "", sizeof(parameters.infile)-1);
|
||||||
|
strncpy(parameters.outfile, "", sizeof(parameters.outfile)-1);
|
||||||
|
parameters.decod_format = J2K_CFMT;
|
||||||
|
parameters.cod_format = BMP_DFMT;
|
||||||
|
if (m_reducefactor)
|
||||||
|
parameters.cp_reduce = m_reducefactor;
|
||||||
|
if (m_qualitylayers)
|
||||||
|
parameters.cp_layer = m_qualitylayers;
|
||||||
|
/*if (n_components)
|
||||||
|
parameters. = n_components;*/
|
||||||
|
|
||||||
|
/* JPWL only */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
parameters.jpwl_exp_comps = m_expcomps;
|
||||||
|
parameters.jpwl_max_tiles = m_maxtiles;
|
||||||
|
parameters.jpwl_correct = m_enablejpwl;
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_J2K);
|
||||||
|
|
||||||
|
/* find length of the stream */
|
||||||
|
stream.SeekI(0, wxFromEnd);
|
||||||
|
file_length = (int) stream.TellI();
|
||||||
|
|
||||||
|
/* search for the m_framenum codestream position and length */
|
||||||
|
//jp2c_point = searchjp2c(stream, file_length, m_framenum);
|
||||||
|
//jp2c_len = searchjp2c(stream, file_length, m_framenum);
|
||||||
|
j2k_point = 0;
|
||||||
|
j2k_len = 10;
|
||||||
|
|
||||||
|
// malloc memory source
|
||||||
|
src = (unsigned char *) malloc(j2k_len);
|
||||||
|
|
||||||
|
// copy the jp2c
|
||||||
|
stream.SeekI(j2k_point, wxFromStart);
|
||||||
|
stream.Read(src, j2k_len);
|
||||||
|
|
||||||
|
/* 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, j2k_len);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
if (!opjimage) {
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
wxLogError(wxT("MXF: failed to decode image!"));
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* common rendering method */
|
||||||
|
#include "imagjpeg2000.cpp"
|
||||||
|
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
wxLogMessage(wxT("MXF: image loaded."));
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
|
||||||
|
/* close openjpeg structs */
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_image_destroy(opjimage);
|
||||||
|
free(src);
|
||||||
|
|
||||||
|
if (!image->Ok())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// save the mxf file format
|
||||||
|
bool wxMXFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
|
||||||
|
{
|
||||||
|
wxLogError(wxT("MXF: Couldn't save movie -> not implemented."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __VISUALC__
|
||||||
|
#pragma warning(default:4611)
|
||||||
|
#endif /* VC++ */
|
||||||
|
|
||||||
|
// recognize the MXF JPEG 2000 starting box
|
||||||
|
bool wxMXFHandler::DoCanRead( wxInputStream& stream )
|
||||||
|
{
|
||||||
|
unsigned char hdr[4];
|
||||||
|
|
||||||
|
if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (hdr[0] == 0x06 &&
|
||||||
|
hdr[1] == 0x0E &&
|
||||||
|
hdr[2] == 0x2B &&
|
||||||
|
hdr[3] == 0x34);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Build an EssenceInfoMap for the essence in a given file
|
||||||
|
/*! \return True if al OK, else false
|
||||||
|
*/
|
||||||
|
bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup)
|
||||||
|
{
|
||||||
|
// Empty any old data
|
||||||
|
EssenceLookup.clear();
|
||||||
|
|
||||||
|
// Get the master metadata set (or the header if we must)
|
||||||
|
PartitionPtr MasterPartition = File->ReadMasterPartition();
|
||||||
|
if(!MasterPartition)
|
||||||
|
{
|
||||||
|
File->Seek(0);
|
||||||
|
MasterPartition = File->ReadPartition();
|
||||||
|
warning("File %s does not contain a cloased copy of header metadata - using the open copy in the file header\n", File->Name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!MasterPartition)
|
||||||
|
{
|
||||||
|
error("Could not read header metadata from file %s\n", File->Name.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read and parse the metadata
|
||||||
|
MasterPartition->ReadMetadata();
|
||||||
|
MetadataPtr HMeta = MasterPartition->ParseMetadata();
|
||||||
|
|
||||||
|
if(!HMeta)
|
||||||
|
{
|
||||||
|
error("Could not read header metadata from file %s\n", File->Name.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scan the Essence container data sets to get PackageID to BodySID mapping */
|
||||||
|
MDObjectPtr ECDSet = HMeta[ContentStorage_UL];
|
||||||
|
if(ECDSet) ECDSet = ECDSet->GetLink();
|
||||||
|
if(ECDSet) ECDSet = ECDSet[EssenceContainerDataBatch_UL];
|
||||||
|
if(!ECDSet)
|
||||||
|
{
|
||||||
|
error("Header metadata in file %s does not contain an EssenceContainerData set\n", File->Name.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDObject::iterator it = ECDSet->begin();
|
||||||
|
while(it != ECDSet->end())
|
||||||
|
{
|
||||||
|
MDObjectPtr ThisECDSet = (*it).second->GetLink();
|
||||||
|
MDObjectPtr PackageID;
|
||||||
|
if(ThisECDSet) PackageID = ThisECDSet->Child(LinkedPackageUID_UL);
|
||||||
|
if(PackageID)
|
||||||
|
{
|
||||||
|
EssenceInfo NewEI;
|
||||||
|
NewEI.PackageID = new UMID(PackageID->PutData()->Data);
|
||||||
|
|
||||||
|
// Inset the basic essence info - but not if this is external essence (BodySID == 0)
|
||||||
|
UInt32 BodySID = ThisECDSet->GetUInt(BodySID_UL);
|
||||||
|
if(BodySID) EssenceLookup[BodySID] = NewEI;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now find the other items for the essence lookup map */
|
||||||
|
if(EssenceLookup.size())
|
||||||
|
{
|
||||||
|
PackageList::iterator it = HMeta->Packages.begin();
|
||||||
|
while(it != HMeta->Packages.end())
|
||||||
|
{
|
||||||
|
// Only Source Packages are of interest
|
||||||
|
if((*it)->IsA(SourcePackage_UL))
|
||||||
|
{
|
||||||
|
MDObjectPtr Descriptor = (*it)->Child(Descriptor_UL);
|
||||||
|
if(Descriptor) Descriptor = Descriptor->GetLink();
|
||||||
|
|
||||||
|
if(Descriptor)
|
||||||
|
{
|
||||||
|
MDObjectPtr PackageID = (*it)->Child(PackageUID_UL);
|
||||||
|
if(PackageID)
|
||||||
|
{
|
||||||
|
UMIDPtr TheID = new UMID(PackageID->PutData()->Data);
|
||||||
|
|
||||||
|
/* Now do a lookup in the essence lookup map (it will need to be done the long way here */
|
||||||
|
EssenceInfoMap::iterator EL_it = EssenceLookup.begin();
|
||||||
|
while(EL_it != EssenceLookup.end())
|
||||||
|
{
|
||||||
|
if((*((*EL_it).second.PackageID)) == (*TheID))
|
||||||
|
{
|
||||||
|
// If found, set the missing items and stop searching
|
||||||
|
(*EL_it).second.Package = (*it);
|
||||||
|
(*EL_it).second.Descriptor = Descriptor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EL_it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
|
#endif // wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#endif // USE_MXF
|
||||||
|
|
||||||
99
applications/OPJViewer/source/imagmxf.h
Normal file
99
applications/OPJViewer/source/imagmxf.h
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: imagmxf.h
|
||||||
|
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
|
||||||
|
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||||
|
// RCS-ID: $Id: imagmj2.h,v 0.0 2007/11/19 17:00:00 VZ Exp $
|
||||||
|
// Copyright: (c) Giuseppe Baruffa
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_IMAGMXF_H_
|
||||||
|
#define _WX_IMAGMXF_H_
|
||||||
|
|
||||||
|
#ifdef USE_MXF
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxMXFHandler
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#include "wx/image.h"
|
||||||
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
|
#define wxBITMAP_TYPE_MXF 51
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxMXFHandler: public wxImageHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline wxMXFHandler()
|
||||||
|
{
|
||||||
|
m_name = wxT("MXF JPEG 2000 file format");
|
||||||
|
m_extension = wxT("mxf");
|
||||||
|
m_type = wxBITMAP_TYPE_MXF;
|
||||||
|
m_mime = wxT("image/mxf");
|
||||||
|
|
||||||
|
m_reducefactor = 0;
|
||||||
|
m_qualitylayers = 0;
|
||||||
|
m_components = 0;
|
||||||
|
m_filename = wxT("");
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
m_enablejpwl = true;
|
||||||
|
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||||
|
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
}
|
||||||
|
|
||||||
|
// decoding engine parameters
|
||||||
|
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||||
|
wxFileName m_filename;
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
bool m_enablejpwl;
|
||||||
|
int m_expcomps, m_maxtiles;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
|
||||||
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
|
||||||
|
protected:
|
||||||
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMXFHandler)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
|
#endif // USE_MXF
|
||||||
|
|
||||||
|
#endif // _WX_IMAGMXF_H_
|
||||||
|
|
||||||
14
applications/OPJViewer/source/license.txt
Normal file
14
applications/OPJViewer/source/license.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare 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.
|
||||||
285
applications/OPJViewer/source/opj_logo.xpm
Normal file
285
applications/OPJViewer/source/opj_logo.xpm
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char *opj_logo[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"90 61 218 2",
|
||||||
|
" c #BE3D12",
|
||||||
|
". c #BF461D",
|
||||||
|
"X c #AD5435",
|
||||||
|
"o c #B64925",
|
||||||
|
"O c #B54E2B",
|
||||||
|
"+ c #BC4620",
|
||||||
|
"@ c #BB4B25",
|
||||||
|
"# c #BC4E29",
|
||||||
|
"$ c #B5502F",
|
||||||
|
"% c #BD512C",
|
||||||
|
"& c #B45334",
|
||||||
|
"* c #B35638",
|
||||||
|
"= c #B45B3D",
|
||||||
|
"- c #BB5533",
|
||||||
|
"; c #BE5937",
|
||||||
|
": c #BC5C3D",
|
||||||
|
"> c #9C766A",
|
||||||
|
", c #AD5D42",
|
||||||
|
"< c #B55F41",
|
||||||
|
"1 c #BA5E40",
|
||||||
|
"2 c #A7634D",
|
||||||
|
"3 c #A76C57",
|
||||||
|
"4 c #AA6750",
|
||||||
|
"5 c #AC6B56",
|
||||||
|
"6 c #AA6E5A",
|
||||||
|
"7 c #A4705E",
|
||||||
|
"8 c #B46045",
|
||||||
|
"9 c #B1644B",
|
||||||
|
"0 c #BD6244",
|
||||||
|
"q c #B96448",
|
||||||
|
"w c #BC694D",
|
||||||
|
"e c #B36B53",
|
||||||
|
"r c #B26E58",
|
||||||
|
"t c #BB6C52",
|
||||||
|
"y c #B2725D",
|
||||||
|
"u c #BD7056",
|
||||||
|
"i c #BB745C",
|
||||||
|
"p c #A67566",
|
||||||
|
"a c #A57B6D",
|
||||||
|
"s c #AE7562",
|
||||||
|
"d c #AB7867",
|
||||||
|
"f c #AA7C6C",
|
||||||
|
"g c #A07E73",
|
||||||
|
"h c #AA7F71",
|
||||||
|
"j c #B37661",
|
||||||
|
"k c #B47863",
|
||||||
|
"l c #B27D6B",
|
||||||
|
"z c #BB7863",
|
||||||
|
"x c #BA7E69",
|
||||||
|
"c c #C73605",
|
||||||
|
"v c #C63A0B",
|
||||||
|
"b c #CB3300",
|
||||||
|
"n c #CA3807",
|
||||||
|
"m c #C93A0A",
|
||||||
|
"M c #C43E11",
|
||||||
|
"N c #C93E10",
|
||||||
|
"B c #C44115",
|
||||||
|
"V c #C3441A",
|
||||||
|
"C c #C4481E",
|
||||||
|
"Z c #CA4113",
|
||||||
|
"A c #C94519",
|
||||||
|
"S c #CB481C",
|
||||||
|
"D c #C24A23",
|
||||||
|
"F c #C24F28",
|
||||||
|
"G c #CD4D23",
|
||||||
|
"H c #C4522D",
|
||||||
|
"J c #CB532B",
|
||||||
|
"K c #C25632",
|
||||||
|
"L c #C35936",
|
||||||
|
"P c #C25C3B",
|
||||||
|
"I c #C85630",
|
||||||
|
"U c #CB5933",
|
||||||
|
"Y c #CB5E3A",
|
||||||
|
"T c #D05026",
|
||||||
|
"R c #CC613D",
|
||||||
|
"E c #C26343",
|
||||||
|
"W c #C46748",
|
||||||
|
"Q c #C1694C",
|
||||||
|
"! c #CD6744",
|
||||||
|
"~ c #CA6C4D",
|
||||||
|
"^ c #C37155",
|
||||||
|
"/ c #C4755B",
|
||||||
|
"( c #CB7356",
|
||||||
|
") c #C8765B",
|
||||||
|
"_ c #D06D4C",
|
||||||
|
"` c #D07253",
|
||||||
|
"' c #D47B5E",
|
||||||
|
"] c #C37B63",
|
||||||
|
"[ c #C27E68",
|
||||||
|
"{ c #C97F68",
|
||||||
|
"} c #A68175",
|
||||||
|
"| c #A48479",
|
||||||
|
" . c #AD8172",
|
||||||
|
".. c #AD8578",
|
||||||
|
"X. c #AB897D",
|
||||||
|
"o. c #B1806F",
|
||||||
|
"O. c #BA816F",
|
||||||
|
"+. c #B38373",
|
||||||
|
"@. c #B58778",
|
||||||
|
"#. c #B3897B",
|
||||||
|
"$. c #BA8472",
|
||||||
|
"%. c #BB8C7C",
|
||||||
|
"&. c #C2816B",
|
||||||
|
"*. c #CD846C",
|
||||||
|
"=. c #C38470",
|
||||||
|
"-. c #C38976",
|
||||||
|
";. c #C38D7B",
|
||||||
|
":. c #CC8973",
|
||||||
|
">. c #CF8F7A",
|
||||||
|
",. c #CB907D",
|
||||||
|
"<. c #D1937F",
|
||||||
|
"1. c #948E8C",
|
||||||
|
"2. c #9D8C86",
|
||||||
|
"3. c #9D8F89",
|
||||||
|
"4. c #96908E",
|
||||||
|
"5. c #9C918D",
|
||||||
|
"6. c #949392",
|
||||||
|
"7. c #9B9492",
|
||||||
|
"8. c #9D9997",
|
||||||
|
"9. c #9D9C9C",
|
||||||
|
"0. c #A38B83",
|
||||||
|
"q. c #AA8D83",
|
||||||
|
"w. c #A4918B",
|
||||||
|
"e. c #AC9087",
|
||||||
|
"r. c #AB938C",
|
||||||
|
"t. c #A49590",
|
||||||
|
"y. c #A29996",
|
||||||
|
"u. c #A19D9C",
|
||||||
|
"i. c #AA9790",
|
||||||
|
"p. c #AC9994",
|
||||||
|
"a. c #AC9E99",
|
||||||
|
"s. c #B18D81",
|
||||||
|
"d. c #B59084",
|
||||||
|
"f. c #B49389",
|
||||||
|
"g. c #BA9184",
|
||||||
|
"h. c #B89589",
|
||||||
|
"j. c #BA988D",
|
||||||
|
"k. c #B29B93",
|
||||||
|
"l. c #BC9C92",
|
||||||
|
"z. c #ACA19D",
|
||||||
|
"x. c #B1A19D",
|
||||||
|
"c. c #BCA39B",
|
||||||
|
"v. c #A3A3A3",
|
||||||
|
"b. c #ABA5A3",
|
||||||
|
"n. c #AEA9A7",
|
||||||
|
"m. c #ABABAA",
|
||||||
|
"M. c #B3A5A1",
|
||||||
|
"N. c #B3A9A6",
|
||||||
|
"B. c #B3ADAA",
|
||||||
|
"V. c #B9A6A0",
|
||||||
|
"C. c #B9AAA5",
|
||||||
|
"Z. c #BAADA9",
|
||||||
|
"A. c #B4B0AF",
|
||||||
|
"S. c #BAB0AD",
|
||||||
|
"D. c #B4B3B3",
|
||||||
|
"F. c #BAB5B3",
|
||||||
|
"G. c #BDB8B6",
|
||||||
|
"H. c #BBBBBB",
|
||||||
|
"J. c #C39384",
|
||||||
|
"K. c #C0978A",
|
||||||
|
"L. c #C2998B",
|
||||||
|
"P. c #CA9483",
|
||||||
|
"I. c #CD9A8A",
|
||||||
|
"U. c #C19D92",
|
||||||
|
"Y. c #D69B89",
|
||||||
|
"T. c #DB9680",
|
||||||
|
"R. c #C2A095",
|
||||||
|
"E. c #C4A69C",
|
||||||
|
"W. c #CCA193",
|
||||||
|
"Q. c #C8A599",
|
||||||
|
"!. c #CBA99D",
|
||||||
|
"~. c #C6AEA6",
|
||||||
|
"^. c #CCACA2",
|
||||||
|
"/. c #CBB2AB",
|
||||||
|
"(. c #C3B8B5",
|
||||||
|
"). c #C2BDBC",
|
||||||
|
"_. c #C9B9B3",
|
||||||
|
"`. c #D3ADA0",
|
||||||
|
"'. c #D3B4A9",
|
||||||
|
"]. c #DCB2A4",
|
||||||
|
"[. c #DEB6A8",
|
||||||
|
"{. c #D1BFB9",
|
||||||
|
"}. c #D9BEB5",
|
||||||
|
"|. c #C5C0BE",
|
||||||
|
" X c #CDC0BC",
|
||||||
|
".X c #D2C1BB",
|
||||||
|
"XX c #DDC3BB",
|
||||||
|
"oX c #E0C5BC",
|
||||||
|
"OX c #E0C8BF",
|
||||||
|
"+X c #C2C2C2",
|
||||||
|
"@X c #CBC4C2",
|
||||||
|
"#X c #CDC8C6",
|
||||||
|
"$X c #CCCBCB",
|
||||||
|
"%X c #D2C6C2",
|
||||||
|
"&X c #D1CECD",
|
||||||
|
"*X c #DDC8C1",
|
||||||
|
"=X c #DECFCA",
|
||||||
|
"-X c #D9D1CE",
|
||||||
|
";X c #D3D3D3",
|
||||||
|
":X c #D9D5D4",
|
||||||
|
">X c #DED9D7",
|
||||||
|
",X c #DBDBDB",
|
||||||
|
"<X c #E1CAC3",
|
||||||
|
"1X c #E2CFC8",
|
||||||
|
"2X c #E1D3CE",
|
||||||
|
"3X c #E2D5D0",
|
||||||
|
"4X c #E5D8D3",
|
||||||
|
"5X c #E4DDDB",
|
||||||
|
"6X c #E8DBD6",
|
||||||
|
"7X c #EADEDA",
|
||||||
|
"8X c #E6E0DE",
|
||||||
|
"9X c #EBE0DC",
|
||||||
|
"0X c #E4E4E4",
|
||||||
|
"qX c #E8E2E0",
|
||||||
|
"wX c #EBEBEB",
|
||||||
|
"eX c #F0EAE8",
|
||||||
|
"rX c #F3F3F3",
|
||||||
|
"tX c #FEFEFE",
|
||||||
|
/* pixels */
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXrXrXtXrXrXrXrXrXrXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXrXtXrXrXrXwXwXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXrXrXrXwXwX0X0XqX0X0X0X0XwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXrXtXrXwXwX2X[.[.].].].].].1XwXrXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXrXrXrXwX0X0XL.J b b b b b b b J '.0X0XwXwXrXrXrXrXrXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXrXrXwX0XXXt m b m B V N b b v >.;X0XwXwXwXwXrXwXwXrXrXrXrXtXrXtXrXrXrXwXrXrXrXrXrXrXrXrXrXrXrXwXrXrXwXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXrXrXrX0X,X'.S b b P l.z.M.k.w n b b g.;X,X,X,X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0XwX0X0XwXwXwXwX0X0X0X0X0X0XwXwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXrXrXwX0X:XT.m b A ] G.D.D.m.$.m b b $.$X&X.X}.XX>XOX}.oXXX<X0X0XwXwXwX0X2XXXoXXXoXOX5X0XwX0X1XoXXX5X*X}.}.oX<XqXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXrXwX0X,XL.b b D M.H.D.D.D.D.m.L b b W H.Z.# b Y / m b b b Z P.:X:X:X$X:.Z b b b b n :.;X;X;XR b A &.Z b b b b *.wXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXrXwX0X:X$.b b E B.H.H.D.D.D.D.P b b E H.V.. b U L v v n b b ( #X;X$X~.Y b m N m b b ! {.&X#XI b C R v v n b b ! 0XwXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXwX0X:X!.A b Z F.H.H.H.H.H.D.m.L b b e b.+.b b V k i.r.t n b b s.H.x v b L q.b.p.D b b t F.$.n b M l a.M.y b b A :X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXwX0X:XL.m b D H.).H.+XH.H.H.D.H b b 6 v.j b b - a.A.m.@.m b b h D.< b b w z.b.b.P b b q B.z b b @ B.D.m...v b G :X,XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwX0X,X&X/ b b , D.H.+X+X+X+XH.f.B b b 5.8.M b M w.v.v.v.r.D b b h l v b b M V v b b q u.X b n @.v.m.v.j b b Q &X,X0XwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwX0X,X$X^ b b , H.H.+X+XH.H.H.s.N b n 7.7.v b B 8.v.v.v.w.M b b g r b b b n n n b b b b e y.O b n X.m.v.n.e b b u &X,X0XrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrX0X,X$X/ b b + F.H.H.H.+XH.d.b b M | 8.> c b @ 9.v.9.u., b b - 3.& b b 7 1.1.4.4.4.6.7.9.w.m b + t.v.m.p.D b b K.;X,X0XwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwX0X,X$X-.b b b i D.H.G.H.J.N b b = 9.9.5 c b B 7.9.v.y.b b m f 4.O b b 3 6.6.6.g 9 4 h u.h b b - b.m.m.s.b b N ~.;X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwX0X,X;XE.G b b I z ] ] ] W n b H l 9.8.9 b b m e 6 r e b b # 0.y.< b b O 6 p 6 < # ; q.v.t b b 0 n.A.A.+.b b H _.;X,XwXwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwXwX,X;X#Xf.b b b b b b b b b - a.v.v.w.@ b b v b b b b b @ b.m.v.w.M b b b b b b v ..m.n.A b n g.H.H.H.4 b b [ &X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXwXwX0X:X$XZ.Q H v n b m B H E x n.m.m.q.B b v < . v N + E z m.m.m.b.e - M m v M - t k.D.m.; # - V.H.+XH.s # # K.:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXwXwX,X,X$X+XG.Z.Z.B.C.S.F.H.H.H.D.D.j b b q v.b.a.n.B.H.H.+X+X+XH.H.D.Z.C.Z.Z.F.H.H.+X+XH.).H.$X&X&X;X$X#X#X:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXrXwX0X,X;X#X+X+X+XH.H.+X+X+XH.H.H.D.e b n i n.m.D.H.H.+X#X$X$X+X+X+X+XH.H.H.H.+X+X+X$X&X&X&X$X;X;X;X:X;X:X,X,X0XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXrXrXwXwX,X,X;X;X$X$X$X;X;X&X;X$X#X+XF b v s.H.H.+X$X&X;X;X,X,X,X;X:X;X;X;X;X;X;X:X,X,X,X0X,X0X,X0X0X0X0X0X0X0XwXwXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXrXtXrXwXwX0X,X:X;X;X;X;X;X:X;X;X;X$X+XC b B k.+X+X$X$X;X,X,X0X0X0X0X0X;X,X,X,X,X,X,X,X,X0X0X0X0X0X0XwX0X0X0XwXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXrXrXrXrXwXwXwX0X0X0X0X0X0X0X,X,X:X^.^.!.$X$X;X,X,X0XwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXwXrXrXwXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXrXrXrXrXwXwXwXwX0XwXwXwX0X0X,X:X;X$X&X&X;X,X,X0XwXwXwXrXrXrXrXrXwXwXwXwXwXwXwXrXrXrXwXrXrXrXrXrXrXrXrXrXrXtXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXwXwXwXwX0X,X0X0X0XwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXwXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXtXtXtXrXrXtXtXtXtXrXrXtXrXrXtXrXtXrXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXrXtXtXrXtXrXrXrXrXrXrXwXwXwX0XwX0XwXwXwXrXrXrXtXtXrXrXrXrXrXrXrXrXwXrXwXrXwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXrXrXtXtXrXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwXrXrXrXrXrXrXtXrXtXrXrXrXrXrXwXwXwXwXwX0X0XwX0XwXwXwXwXwXwXwXrXwXwXwX0X0X0X0XwX0XwXwXrXrXrXwXrXwXwXwX0XwX0XwXwXwXrXrXrXrXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXtXtXrXrXtXrXrXeX7X7X9XwXwXwX5X3X3X3X2X2X2X5X0XwXwXwXwXwX8X3X3X2X2X2X2X2X3X6X6X7XwXwXwXwXwXwX7X1XXXOXOX1X8XwXwXrXrXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXrXrXwXT.T T :.,X,X-X` G G G G G G U _ J.-X,X,X,X[ G G G G G G G G G G _ >XwX0X,X&XI.R N b b b m ! `.5XwXrXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXtXrXrXrXwX0X' b b ] >X,X%XJ b b b b b b b b Q {.:X;X:Xq b b b b b b b b b b Y >X0X,X-X'.^ n b b b b b m *.1XwXwXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrX0X0X%XL b b L.@X+X-.b b M L L L D b b b M V.+X(.N b b D H H H H H U U W.;X&X^.H b b n W -.-.W n b b J &XwXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0X XF b b U.+X+X[ b b D z z j P v b b N U.H.S.m b m E Q t ^ ) / ) ) /.$X$X;.m b n A %.H.H.J.N b b N .XwXwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X!.m b L N.D.m.* b b y v.v.v.v.p.n b M f.m.w b b D u.v.m.m.D.G.H.H.+X).g.b b B j.F.D.D.D.D.l.; F I /.0XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X:XU.n b E B.A.n.$ b b s v.9.v.v.r.n n M r.b.1 b b D u.v.m.m.D.D.H.H.).H.k b b # M.G.D.D.D.D.Z.t w u _.0XwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX,X;X$XJ b m h b.v.i.m b M a 5.5.2.p M b c < 8.2.+ b b M o o o o # % j G.H.g.m b A M.D.D.D.B.M.M.M.M.Z.(.:X0XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXwX,X,X&X(.n b M 0.v.v.s b b b b b n b b c b M u.v.g M b b b b b b b b b i G.D.0 b b 8 D.D.H.G.P n b b n b U :X,XwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwX0X,X;X$XV.n b M w.v.9.< b b b b b b b b c H r 9.v.a n b * < < w w Q Q g.D.B.: b b r D.D.D.m.C b b b b b ) ;X0XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrX6XP.=.K.;X#X+Xx n b D v.u.7.. b b M D . D & 2 q.b.b.v.v.< b b X 6.9.9.b.m.D.D.D.D.n.# b b f D.D.D.b.= 1 * N b n !.;X,XwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXwX<X~ P x $X+XH.z b b - v.v.3.M b b < r r r k 0.a.m.m.m.v.# b b , 6.9.v.m.D.D.D.H.D.z.O b b s D.D.D.N.f l 9 v b M ~.;X,XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwX0XY.n b e H.H.V.F b b p b.v.h v b v v.m.A.D.H.+X+X+XH.D.p.b b m p 9.v.m.D.D.H.H.H.D.N.- b b - m.A.D.A.m.a.B b b - (.:X0XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0XY.n b ; Z.C.$.A b v 0.m.m.l n b M m.D.D.H.+X#X+X+XH.H.r.b b m < d l l l $.;.J.V.H.B.w b b C @.s.a.k.#.j n b b : ).:X,XwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X'.N b b A B n b n z m.D.B.0 b b 9 H.H.+X$X;X:X;X$X$X+Xl b b b b b b b b b b b s.H.H.B.H b b b n Z Z b b V n b ] $X:X0XwXrXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwX0X,X.XR b b b b b A P d.D.D.C.H b b j H.$X$X;X:X,X,X;X;X+X/ b b b b b b b b b b b a.H.H.D.u G b b b b b B H : v m ;.$X,XwXwXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X Xg.j 5 y s.C.H.H.+X+X|.E.Q.Q. X;X;X,X0XwXwX0X0X,X;X/.U.j.h.g.f.h.j.U.U.U.!.$X$X+X+XH.Z.g.y 4 6 l x.D.A.l.~.#X,X0XwXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwX0X:X$XG.k.e.f.B.H.H.+X$X$X$X#X$X$X;X;X,X0XwXwXwXwX0X0X;X$X+XH.D.D.D.F.H.+X+X#X&X$X;X$X$X+X+XA.r.X.e.a.H.H.H.+X+X;X,X0XwXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X,X$X&X$X$X$X$X;X;X,X,X,X,X,X,X0XwXwXwXrXtXrXrXwXwX0X,X;X$X$X+X$X$X$X;X;X:X,X,X,X,X,X;X$X&X#X#X$X$X$X$X$X;X,X,X0XwXrXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X,X:X;X;X$X;X;X:X,X,X0X0X,X0X0X0XwXwXwXrXrXtXrXrXwXwX0X;X;X$X&X$X$X&X:X,X,X,X,X0X,X,X:X;X;X$X$X$X$X$X;X:X,X,X0XwXwXrXrXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwXwXwX0X0X0X0X0X0XwXwXwXwXwXwXwXwXrXwXrXtXtXrXtXtXrXrXrXwX0X0X0X0X,X,X0X0X0X0XwXwXwXwXwXwX0X0X0X,X,X,X,X0X0XwXwXwXrXtXrXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwXwX0X0X0X0X0XwXwXwXrXwXrXrXrXrXrXtXrXtXtXtXtXrXrXrXwXwXwX0X0X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXrXrXrXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXrXtXtXtXtXtXtXtXrXtXrXtXrXrXrXrXwXwXrXrXrXrXrXrXrXtXrXrXrXrXrXrXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXtXtXrXtXrXtXrXrXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXrXrXtXrXrXrXrXrXrXrXrXtXrXrXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||||
|
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX"
|
||||||
|
};
|
||||||
34
applications/OPJViewer/source/readmeafter.txt
Normal file
34
applications/OPJViewer/source/readmeafter.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
This viewer is conceived to open and display information and image content of J2K, JP2,
|
||||||
|
and MJ2 files.
|
||||||
|
The viewer application interface is divided into three main panels:
|
||||||
|
- a browsing pane;
|
||||||
|
- a viewing pane;
|
||||||
|
- a log/peek pane.
|
||||||
|
|
||||||
|
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||||
|
|
||||||
|
filename
|
||||||
|
|
|
||||||
|
|_ #000: Marker/Box short name (Hex code)
|
||||||
|
| |
|
||||||
|
| |_ *** Marker/Box long name ***
|
||||||
|
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||||
|
| |_ Additional info, depending on the marker/box type
|
||||||
|
| |_ ...
|
||||||
|
|
|
||||||
|
|_ #001: Marker/Box short name (Hex code)
|
||||||
|
| |
|
||||||
|
| |_ ...
|
||||||
|
|
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||||
|
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||||
|
|
||||||
|
|
||||||
|
The log/peek pane is shared among two different subpanels:
|
||||||
|
|
||||||
|
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||||
|
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||||
|
|
||||||
11
applications/OPJViewer/source/readmebefore.txt
Normal file
11
applications/OPJViewer/source/readmebefore.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
What is OpenJPEG ?
|
||||||
|
==================
|
||||||
|
The OpenJPEG library is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, the new still-image compression standard from the Joint Photographic Experts Group (JPEG). In addition to the basic codec, various other features are under development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, a Java-viewer for j2k-images, ...
|
||||||
|
|
||||||
|
Who can use the library ?
|
||||||
|
=========================
|
||||||
|
Anybody. As the OpenJPEG library is released under the BSD license, anybody can use or modify the library, even for commercial applications. The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||||
|
|
||||||
|
Who is developing the library ?
|
||||||
|
===============================
|
||||||
|
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit<69> Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||||
1465
applications/OPJViewer/source/wxj2kparser.cpp
Normal file
1465
applications/OPJViewer/source/wxj2kparser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1116
applications/OPJViewer/source/wxjp2parser.cpp
Normal file
1116
applications/OPJViewer/source/wxjp2parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
117
applications/codec/CMakeLists.txt
Normal file
117
applications/codec/CMakeLists.txt
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
SET(common_SRCS
|
||||||
|
convert.c
|
||||||
|
index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
)
|
||||||
|
if(NOT USE_SYSTEM_GETOPT)
|
||||||
|
list(APPEND common_SRCS
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||||
|
ELSE(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||||
|
ENDIF(BUILD_SHARED_LIBS)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
|
||||||
|
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
|
||||||
|
)
|
||||||
|
# To support universal exe:
|
||||||
|
IF(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} z)
|
||||||
|
ELSe(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} ${Z_LIBNAME})
|
||||||
|
ENDIF(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
# Install exe
|
||||||
|
INSTALL(TARGETS ${exe}
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDFOREACH(exe)
|
||||||
|
|
||||||
|
# Install man pages
|
||||||
|
INSTALL(
|
||||||
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/image_to_j2k.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_dump.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_to_image.1
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||||
|
#
|
||||||
|
|
||||||
|
IF(BUILD_JPWL)
|
||||||
|
ADD_EXECUTABLE(JPWL_j2k_to_image
|
||||||
|
j2k_to_image.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_j2k_to_image
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
# To support universal exe:
|
||||||
|
IF(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image z)
|
||||||
|
ELSe(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${Z_LIBNAME})
|
||||||
|
ENDIF(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(JPWL_image_to_j2k
|
||||||
|
image_to_j2k.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_image_to_j2k
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
# To support universal exe:
|
||||||
|
IF(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k z)
|
||||||
|
ELSe(ZLIB_FOUND AND APPLE)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${Z_LIBNAME})
|
||||||
|
ENDIF(ZLIB_FOUND AND APPLE)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDIF(BUILD_JPWL)
|
||||||
118
applications/codec/Makefile.am
Normal file
118
applications/codec/Makefile.am
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump
|
||||||
|
|
||||||
|
if WANT_JPWL
|
||||||
|
bin_PROGRAMS += JPWL_j2k_to_image JPWL_image_to_j2k
|
||||||
|
endif
|
||||||
|
|
||||||
|
j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
j2k_to_image_CFLAGS =
|
||||||
|
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
j2k_to_image.c \
|
||||||
|
../common/color.h
|
||||||
|
|
||||||
|
image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@
|
||||||
|
image_to_j2k_CFLAGS =
|
||||||
|
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
image_to_j2k_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
image_to_j2k.c \
|
||||||
|
convert.h \
|
||||||
|
../common/format_defs.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
j2k_dump_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg
|
||||||
|
j2k_dump_CFLAGS =
|
||||||
|
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
|
j2k_dump_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
j2k_dump.c \
|
||||||
|
../common/opj_getopt.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
JPWL_j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
JPWL_j2k_to_image_CFLAGS =
|
||||||
|
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
JPWL_j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
j2k_to_image.c
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@
|
||||||
|
JPWL_image_to_j2k_CFLAGS =
|
||||||
|
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_SOURCES = \
|
||||||
|
../common/opj_getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
image_to_j2k.c
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
windirent.h
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_dump$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
if WANT_JPWL
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
8
applications/codec/README
Normal file
8
applications/codec/README
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Simple codec compilation
|
||||||
|
------------------------
|
||||||
|
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
|
||||||
|
|
||||||
|
gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
|
You should add '-L..' to those lines if you did not use the 'install' target when building the library.
|
||||||
3607
applications/codec/convert.c
Normal file
3607
applications/codec/convert.c
Normal file
File diff suppressed because it is too large
Load Diff
82
applications/codec/convert.h
Normal file
82
applications/codec/convert.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __J2K_CONVERT_H
|
||||||
|
#define __J2K_CONVERT_H
|
||||||
|
|
||||||
|
/**@name RAW image encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_cparameters {
|
||||||
|
/** width of the raw image */
|
||||||
|
int rawWidth;
|
||||||
|
/** height of the raw image */
|
||||||
|
int rawHeight;
|
||||||
|
/** components of the raw image */
|
||||||
|
int rawComp;
|
||||||
|
/** bit depth of the raw image */
|
||||||
|
int rawBitDepth;
|
||||||
|
/** signed/unsigned raw image */
|
||||||
|
opj_bool rawSigned;
|
||||||
|
/*@}*/
|
||||||
|
} raw_cparameters_t;
|
||||||
|
|
||||||
|
/* TGA conversion */
|
||||||
|
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotga(opj_image_t * image, const char *outfile);
|
||||||
|
|
||||||
|
/* BMP conversion */
|
||||||
|
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
/* TIFF conversion*/
|
||||||
|
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotif(opj_image_t *image, const char *outfile);
|
||||||
|
/**
|
||||||
|
Load a single image component encoded in PGX file format
|
||||||
|
@param filename Name of the PGX file to load
|
||||||
|
@param parameters *List ?*
|
||||||
|
@return Returns a greyscale image if successful, returns NULL otherwise
|
||||||
|
*/
|
||||||
|
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopgx(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetopnm(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
|
/* RAW conversion */
|
||||||
|
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||||
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
|
||||||
|
|
||||||
|
/* PNG conversion*/
|
||||||
|
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
||||||
|
extern opj_image_t* pngtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
|
||||||
|
#endif /* __J2K_CONVERT_H */
|
||||||
|
|
||||||
1819
applications/codec/image_to_j2k.c
Normal file
1819
applications/codec/image_to_j2k.c
Normal file
File diff suppressed because it is too large
Load Diff
391
applications/codec/index.c
Normal file
391
applications/codec/index.c
Normal file
@@ -0,0 +1,391 @@
|
|||||||
|
/*
|
||||||
|
* 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 <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a structured index to a file
|
||||||
|
@param cstr_info Codestream information
|
||||||
|
@param index Index filename
|
||||||
|
@return Returns 0 if successful, returns 1 otherwise
|
||||||
|
*/
|
||||||
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
|
FILE *stream = NULL;
|
||||||
|
double total_disto = 0;
|
||||||
|
/* UniPG>> */
|
||||||
|
int tilepartno;
|
||||||
|
char disto_on, numpix_on;
|
||||||
|
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||||
|
return 0;
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
|
if (!cstr_info)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
stream = fopen(index, "w");
|
||||||
|
if (!stream) {
|
||||||
|
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].distotile)
|
||||||
|
disto_on = 1;
|
||||||
|
else
|
||||||
|
disto_on = 0;
|
||||||
|
|
||||||
|
if (cstr_info->tile[0].numpix)
|
||||||
|
numpix_on = 1;
|
||||||
|
else
|
||||||
|
numpix_on = 0;
|
||||||
|
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->prog);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||||
|
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||||
|
|
||||||
|
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||||
|
fprintf(stream, "[%d,%d] ",
|
||||||
|
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||||
|
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||||
|
|
||||||
|
fprintf(stream, "\nINFO ON TILES\n");
|
||||||
|
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream," disto");
|
||||||
|
if (numpix_on)
|
||||||
|
fprintf(stream," nbpix");
|
||||||
|
if (disto_on && numpix_on)
|
||||||
|
fprintf(stream," disto/nbpix");
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||||
|
cstr_info->tile[tileno].tileno,
|
||||||
|
cstr_info->tile[tileno].start_pos,
|
||||||
|
cstr_info->tile[tileno].end_header,
|
||||||
|
cstr_info->tile[tileno].end_pos,
|
||||||
|
cstr_info->tile[tileno].num_tps);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||||
|
if (numpix_on)
|
||||||
|
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||||
|
if (disto_on && numpix_on)
|
||||||
|
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
|
int start_pos, end_ph_pos, end_pos;
|
||||||
|
double disto = 0;
|
||||||
|
int max_numdecompos = 0;
|
||||||
|
pack_nb = 0;
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||||
|
max_numdecompos = cstr_info->numdecompos[compno];
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||||
|
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||||
|
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||||
|
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||||
|
tilepartno, tileno,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||||
|
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||||
|
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
fprintf(stream,"\n");
|
||||||
|
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno])
|
||||||
|
break;
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||||
|
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* LRCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||||
|
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
fprintf(stream,"\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int prec_max;
|
||||||
|
if (resno > cstr_info->numdecompos[compno])
|
||||||
|
break;
|
||||||
|
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* RLCP */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||||
|
|
||||||
|
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
fprintf(stream,"\n");
|
||||||
|
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < numprec; precno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||||
|
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||||
|
if (resno > cstr_info->numdecompos[compno])
|
||||||
|
break;
|
||||||
|
for(y = y0; y < y1; y++) {
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x*pcx == x ) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* resno */
|
||||||
|
} /* RPCL */
|
||||||
|
|
||||||
|
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec)
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
fprintf(stream,"\n");
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||||
|
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||||
|
if (precno >= numprec)
|
||||||
|
continue;
|
||||||
|
for(y = y0; y < y1; y++) {
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x*pcx == x ) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* compno */
|
||||||
|
} /* precno */
|
||||||
|
} /* PCRL */
|
||||||
|
|
||||||
|
else { /* CPRL */
|
||||||
|
/* Count the maximum number of precincts */
|
||||||
|
int max_numprec = 0;
|
||||||
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
if (numprec > max_numprec)
|
||||||
|
max_numprec = numprec;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " disto");
|
||||||
|
fprintf(stream,"\n");
|
||||||
|
|
||||||
|
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
|
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||||
|
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||||
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
|
for (precno = 0; precno < max_numprec; precno++) {
|
||||||
|
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||||
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
|
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||||
|
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||||
|
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||||
|
if (precno >= numprec)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for(y = y0; y < y1; y++) {
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
|
for (x = x0; x < x1; x++) {
|
||||||
|
if (precno_x*pcx == x ) {
|
||||||
|
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||||
|
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||||
|
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||||
|
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||||
|
if (disto_on)
|
||||||
|
fprintf(stream, " %8e", disto);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
total_disto += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* x = x0..x1 */
|
||||||
|
}
|
||||||
|
} /* y = y0..y1 */
|
||||||
|
} /* resno */
|
||||||
|
} /* precno */
|
||||||
|
} /* compno */
|
||||||
|
} /* CPRL */
|
||||||
|
} /* tileno */
|
||||||
|
|
||||||
|
if (disto_on) {
|
||||||
|
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||||
|
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||||
|
}
|
||||||
|
/* UniPG>> */
|
||||||
|
/* print the markers' list */
|
||||||
|
if (cstr_info->marknum) {
|
||||||
|
fprintf(stream, "\nMARKER LIST\n");
|
||||||
|
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||||
|
fprintf(stream, "type\tstart_pos length\n");
|
||||||
|
for (x = 0; x < cstr_info->marknum; x++)
|
||||||
|
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||||
|
}
|
||||||
|
/* <<UniPG */
|
||||||
|
fclose(stream);
|
||||||
|
|
||||||
|
fprintf(stderr,"Generated index file %s\n", index);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
* 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.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -24,31 +26,24 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fix.h"
|
#ifndef __J2K_INDEX_H
|
||||||
#include <math.h> //Add Antonin : multbug1
|
#define __J2K_INDEX_H
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef __cplusplus
|
||||||
#define int64 __int64
|
extern "C" {
|
||||||
#else
|
|
||||||
#define int64 long long
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Multiply two fixed-precision rational numbers.
|
Write a structured index to a file
|
||||||
*/
|
@param cstr_info Codestream information
|
||||||
|
@param index Index filename
|
||||||
|
@return Returns 0 if successful, returns 1 otherwise
|
||||||
|
*/
|
||||||
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
|
||||||
|
|
||||||
//int fix_mul(int a, int b)
|
#ifdef __cplusplus
|
||||||
//{
|
|
||||||
// return (int) ((int64) a * (int64) b >> 13);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//Mod Antonin : multbug1
|
|
||||||
int fix_mul(int a, int b)
|
|
||||||
{
|
|
||||||
double tmp= (double) ((int64) a * (int64) b);
|
|
||||||
int64 v = (int64) ((fabs(tmp/8192.0)>=floor(fabs(tmp/8192.0))+0.5)?fabs(tmp/8192.0)+1.0:fabs(tmp/8192.0));
|
|
||||||
v = (tmp<0)?-v:v;
|
|
||||||
return (int) v;
|
|
||||||
}
|
}
|
||||||
//doM
|
#endif
|
||||||
|
|
||||||
|
#endif /* __J2K_INDEX_H */
|
||||||
|
|
||||||
684
applications/codec/j2k_dump.c
Normal file
684
applications/codec/j2k_dump.c
Normal file
@@ -0,0 +1,684 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "windirent.h"
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <strings.h>
|
||||||
|
#define _stricmp strcasecmp
|
||||||
|
#define _strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "j2k.h"
|
||||||
|
#include "jp2.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#include "format_defs.h"
|
||||||
|
|
||||||
|
typedef struct dircnt{
|
||||||
|
/** Buffer for holding images read from Directory*/
|
||||||
|
char *filename_buf;
|
||||||
|
/** Pointer to the buffer*/
|
||||||
|
char **filename;
|
||||||
|
}dircnt_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct img_folder{
|
||||||
|
/** The directory path of the folder containing input images*/
|
||||||
|
char *imgdirpath;
|
||||||
|
/** Output format*/
|
||||||
|
const char *out_format;
|
||||||
|
/** Enable option*/
|
||||||
|
char set_imgdir;
|
||||||
|
/** Enable Cod Format for output*/
|
||||||
|
char set_out_format;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
void decode_help_display(void) {
|
||||||
|
fprintf(stdout,"HELP for j2k_dump\n----\n\n");
|
||||||
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"+ JPWL "
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
"decoder:\n");
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -ImgDir \n");
|
||||||
|
fprintf(stdout," Image file Directory path \n");
|
||||||
|
fprintf(stdout," -i <compressed file>\n");
|
||||||
|
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||||
|
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||||
|
fprintf(stdout," is identified based on its suffix.\n");
|
||||||
|
fprintf(stdout," -o <output file>\n");
|
||||||
|
fprintf(stdout," OPTIONAL\n");
|
||||||
|
fprintf(stdout," Output file where file info will be dump.\n");
|
||||||
|
fprintf(stdout," By default it will be in the stdout.\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||||
|
|
||||||
|
int get_num_images(char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int num_images = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
num_images++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return num_images;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
fprintf(stderr,"Folder opened successfully\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strcpy(dirptr->filename[i],content->d_name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_file_format(char *filename) {
|
||||||
|
unsigned int i;
|
||||||
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||||
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||||
|
char * ext = strrchr(filename, '.');
|
||||||
|
if (ext == NULL)
|
||||||
|
return -1;
|
||||||
|
ext++;
|
||||||
|
if(ext) {
|
||||||
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
|
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||||
|
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||||
|
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||||
|
|
||||||
|
strcpy(image_filename,dirptr->filename[imageno]);
|
||||||
|
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||||
|
parameters->decod_format = get_file_format(image_filename);
|
||||||
|
if (parameters->decod_format == -1)
|
||||||
|
return 1;
|
||||||
|
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||||
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
|
/*Set output file*/
|
||||||
|
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||||
|
while((temp_p = strtok(NULL,".")) != NULL){
|
||||||
|
strcat(temp_ofname,temp1);
|
||||||
|
sprintf(temp1,".%s",temp_p);
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format==1){
|
||||||
|
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||||
|
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen, c;
|
||||||
|
opj_option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
{0,0,0,0} /* GNU getopt_long requirement */
|
||||||
|
};
|
||||||
|
const char optlist[] = "i:o:h";
|
||||||
|
|
||||||
|
OPJ_ARG_NOT_USED(indexfilename);
|
||||||
|
|
||||||
|
totlen=sizeof(long_option)-1;
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
do {
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||||
|
#else
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
|
#endif
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
switch (c) {
|
||||||
|
case 'i': /* input file */
|
||||||
|
{
|
||||||
|
char *infile = opj_optarg;
|
||||||
|
parameters->decod_format = get_file_format(infile);
|
||||||
|
switch(parameters->decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
case JP2_CFMT:
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'o': /* output file */
|
||||||
|
{
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': /* display an help description */
|
||||||
|
decode_help_display();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'y': /* Image Directory path */
|
||||||
|
{
|
||||||
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}while(c != -1);
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
if(img_fol->set_imgdir==1){
|
||||||
|
if(!(parameters->infile[0]==0)){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format == 0){
|
||||||
|
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||||
|
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(!(parameters->outfile[0] == 0)){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if( parameters->infile[0] == 0 ) {
|
||||||
|
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||||
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void error_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void warning_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
void info_callback(const char *msg, void *client_data) {
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
img_fol_t img_fol;
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
FILE *fsrc = NULL, *fout = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int num_images;
|
||||||
|
int i,imageno;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
|
/* configure the event callbacks (not required) */
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = error_callback;
|
||||||
|
event_mgr.warning_handler = warning_callback;
|
||||||
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* Initialize indexfilename and img_fol */
|
||||||
|
*indexfilename = 0;
|
||||||
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if(dirptr){
|
||||||
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||||
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
|
if(!dirptr->filename_buf){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<num_images;i++){
|
||||||
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (num_images==0){
|
||||||
|
fprintf(stdout,"Folder is empty\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
num_images=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
if (parameters.outfile[0] != 0)
|
||||||
|
{
|
||||||
|
fout = fopen(parameters.outfile,"w");
|
||||||
|
if (!fout)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fout = stdout;
|
||||||
|
|
||||||
|
/*Encoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++)
|
||||||
|
{
|
||||||
|
image = NULL;
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||||
|
fprintf(stderr,"skipping file...\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the input file and put it in memory */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
file_length = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||||
|
{
|
||||||
|
free(src);
|
||||||
|
fclose(fsrc);
|
||||||
|
fclose(fout);
|
||||||
|
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
switch(parameters.decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG-2000 codestream */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_J2K);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
j2k_dump_image(fout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JP2_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000 compressed image data */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JP2);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
if(image->icc_profile_buf)
|
||||||
|
{
|
||||||
|
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||||
|
}
|
||||||
|
j2k_dump_image(fout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(fout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JPT_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000, JPIP */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JPT);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
fclose(fout);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free codestream information structure */
|
||||||
|
if (*indexfilename)
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fout);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||||
|
int compno;
|
||||||
|
fprintf(fd, "image {\n");
|
||||||
|
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||||
|
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_image_comp_t *comp = &img->comps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||||
|
fprintf(fd, " prec=%d\n", comp->prec);
|
||||||
|
/*fprintf(fd, " bpp=%d\n", comp->bpp);*/
|
||||||
|
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||||
|
int tileno, compno, layno, bandno, resno, numbands;
|
||||||
|
fprintf(fd, "coding parameters {\n");
|
||||||
|
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||||
|
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||||
|
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||||
|
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||||
|
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||||
|
fprintf(fd, " tile %d {\n", tileno);
|
||||||
|
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||||
|
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||||
|
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||||
|
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||||
|
fprintf(fd, " rates=");
|
||||||
|
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||||
|
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||||
|
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||||
|
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||||
|
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||||
|
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||||
|
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||||
|
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||||
|
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||||
|
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||||
|
fprintf(fd, " stepsizes=");
|
||||||
|
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||||
|
for (bandno = 0; bandno < numbands; bandno++) {
|
||||||
|
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||||
|
tccp->stepsizes[bandno].expn);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
|
||||||
|
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||||
|
fprintf(fd, " prcw=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
fprintf(fd, " prch=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
861
applications/codec/j2k_to_image.c
Normal file
861
applications/codec/j2k_to_image.c
Normal file
@@ -0,0 +1,861 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "windirent.h"
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <strings.h>
|
||||||
|
#define _stricmp strcasecmp
|
||||||
|
#define _strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
#include <lcms2.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
#include <lcms.h>
|
||||||
|
#endif
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
#include "format_defs.h"
|
||||||
|
|
||||||
|
typedef struct dircnt{
|
||||||
|
/** Buffer for holding images read from Directory*/
|
||||||
|
char *filename_buf;
|
||||||
|
/** Pointer to the buffer*/
|
||||||
|
char **filename;
|
||||||
|
}dircnt_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct img_folder{
|
||||||
|
/** The directory path of the folder containing input images*/
|
||||||
|
char *imgdirpath;
|
||||||
|
/** Output format*/
|
||||||
|
const char *out_format;
|
||||||
|
/** Enable option*/
|
||||||
|
char set_imgdir;
|
||||||
|
/** Enable Cod Format for output*/
|
||||||
|
char set_out_format;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
static void decode_help_display(void) {
|
||||||
|
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
||||||
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"+ JPWL "
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
"decoder:\n");
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -ImgDir \n");
|
||||||
|
fprintf(stdout," Image file Directory path \n");
|
||||||
|
fprintf(stdout," -OutFor \n");
|
||||||
|
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
|
||||||
|
fprintf(stdout," Need to specify only format without filename <BMP> \n");
|
||||||
|
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
|
||||||
|
fprintf(stdout," -i <compressed file>\n");
|
||||||
|
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||||
|
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||||
|
fprintf(stdout," is identified based on its suffix.\n");
|
||||||
|
fprintf(stdout," -o <decompressed file>\n");
|
||||||
|
fprintf(stdout," REQUIRED\n");
|
||||||
|
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, PNG, BMP, TIF, RAW and TGA files\n");
|
||||||
|
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
|
||||||
|
fprintf(stdout," filename is given, there will be as many output files as there are\n");
|
||||||
|
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
|
||||||
|
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
|
||||||
|
fprintf(stdout," is given and there are more than one component, only the first component\n");
|
||||||
|
fprintf(stdout," will be written to the file.\n");
|
||||||
|
fprintf(stdout," -r <reduce factor>\n");
|
||||||
|
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
|
||||||
|
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
|
||||||
|
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
|
||||||
|
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
|
||||||
|
fprintf(stdout," -l <number of quality layers to decode>\n");
|
||||||
|
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
|
||||||
|
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
|
||||||
|
fprintf(stdout," are decoded.\n");
|
||||||
|
fprintf(stdout," -x \n");
|
||||||
|
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
fprintf(stdout," -W <options>\n");
|
||||||
|
fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
|
||||||
|
fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
|
||||||
|
fprintf(stdout," c, c=numcomps\n");
|
||||||
|
fprintf(stdout," numcomps is the number of expected components in the codestream\n");
|
||||||
|
fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static int get_num_images(char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int num_images = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
num_images++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return num_images;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
fprintf(stderr,"Folder opened successfully\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strcpy(dirptr->filename[i],content->d_name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_file_format(char *filename) {
|
||||||
|
unsigned int i;
|
||||||
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||||
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||||
|
char * ext = strrchr(filename, '.');
|
||||||
|
if (ext == NULL)
|
||||||
|
return -1;
|
||||||
|
ext++;
|
||||||
|
if(ext) {
|
||||||
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
|
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||||
|
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||||
|
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||||
|
|
||||||
|
strcpy(image_filename,dirptr->filename[imageno]);
|
||||||
|
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||||
|
parameters->decod_format = get_file_format(image_filename);
|
||||||
|
if (parameters->decod_format == -1)
|
||||||
|
return 1;
|
||||||
|
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||||
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
|
/*Set output file*/
|
||||||
|
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||||
|
while((temp_p = strtok(NULL,".")) != NULL){
|
||||||
|
strcat(temp_ofname,temp1);
|
||||||
|
sprintf(temp1,".%s",temp_p);
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format==1){
|
||||||
|
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||||
|
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen, c;
|
||||||
|
opj_option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
|
{0,0,0,0} /* GNU getopt_long requirement */
|
||||||
|
};
|
||||||
|
|
||||||
|
const char optlist[] = "i:o:r:l:x:"
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"W:"
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
"h" ;
|
||||||
|
totlen=sizeof(long_option) - 1;
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
do {
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||||
|
#else
|
||||||
|
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
|
#endif
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
switch (c) {
|
||||||
|
case 'i': /* input file */
|
||||||
|
{
|
||||||
|
char *infile = opj_optarg;
|
||||||
|
parameters->decod_format = get_file_format(infile);
|
||||||
|
switch(parameters->decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
case JP2_CFMT:
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'o': /* output file */
|
||||||
|
{
|
||||||
|
char *outfile = opj_optarg;
|
||||||
|
parameters->cod_format = get_file_format(outfile);
|
||||||
|
switch(parameters->cod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
case PXM_DFMT:
|
||||||
|
case BMP_DFMT:
|
||||||
|
case TIF_DFMT:
|
||||||
|
case RAW_DFMT:
|
||||||
|
case TGA_DFMT:
|
||||||
|
case PNG_DFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'O': /* output format */
|
||||||
|
{
|
||||||
|
char outformat[50];
|
||||||
|
char *of = opj_optarg;
|
||||||
|
sprintf(outformat,".%s",of);
|
||||||
|
img_fol->set_out_format = 1;
|
||||||
|
parameters->cod_format = get_file_format(outformat);
|
||||||
|
switch(parameters->cod_format) {
|
||||||
|
case PGX_DFMT:
|
||||||
|
img_fol->out_format = "pgx";
|
||||||
|
break;
|
||||||
|
case PXM_DFMT:
|
||||||
|
img_fol->out_format = "ppm";
|
||||||
|
break;
|
||||||
|
case BMP_DFMT:
|
||||||
|
img_fol->out_format = "bmp";
|
||||||
|
break;
|
||||||
|
case TIF_DFMT:
|
||||||
|
img_fol->out_format = "tif";
|
||||||
|
break;
|
||||||
|
case RAW_DFMT:
|
||||||
|
img_fol->out_format = "raw";
|
||||||
|
break;
|
||||||
|
case TGA_DFMT:
|
||||||
|
img_fol->out_format = "raw";
|
||||||
|
break;
|
||||||
|
case PNG_DFMT:
|
||||||
|
img_fol->out_format = "png";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
case 'r': /* reduce option */
|
||||||
|
{
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
case 'l': /* layering option */
|
||||||
|
{
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': /* display an help description */
|
||||||
|
decode_help_display();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'y': /* Image Directory path */
|
||||||
|
{
|
||||||
|
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||||
|
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'x': /* Creation of index file */
|
||||||
|
{
|
||||||
|
char *index = opj_optarg;
|
||||||
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
/* UniPG>> */
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
|
||||||
|
case 'W': /* activate JPWL correction */
|
||||||
|
{
|
||||||
|
char *token = NULL;
|
||||||
|
|
||||||
|
token = strtok(opj_optarg, ",");
|
||||||
|
while(token != NULL) {
|
||||||
|
|
||||||
|
/* search expected number of components */
|
||||||
|
if (*token == 'c') {
|
||||||
|
|
||||||
|
static int compno;
|
||||||
|
|
||||||
|
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
|
||||||
|
|
||||||
|
if(sscanf(token, "c=%d", &compno) == 1) {
|
||||||
|
/* Specified */
|
||||||
|
if ((compno < 1) || (compno > 256)) {
|
||||||
|
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->jpwl_exp_comps = compno;
|
||||||
|
|
||||||
|
} else if (!strcmp(token, "c")) {
|
||||||
|
/* default */
|
||||||
|
parameters->jpwl_exp_comps = compno; /* auto for default size */
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search maximum number of tiles */
|
||||||
|
if (*token == 't') {
|
||||||
|
|
||||||
|
static int tileno;
|
||||||
|
|
||||||
|
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
|
||||||
|
|
||||||
|
if(sscanf(token, "t=%d", &tileno) == 1) {
|
||||||
|
/* Specified */
|
||||||
|
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
|
||||||
|
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters->jpwl_max_tiles = tileno;
|
||||||
|
|
||||||
|
} else if (!strcmp(token, "t")) {
|
||||||
|
/* default */
|
||||||
|
parameters->jpwl_max_tiles = tileno; /* auto for default size */
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* next token or bust */
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
};
|
||||||
|
parameters->jpwl_correct = OPJ_TRUE;
|
||||||
|
fprintf(stdout, "JPWL correction capability activated\n");
|
||||||
|
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}while(c != -1);
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
if(img_fol->set_imgdir==1){
|
||||||
|
if(!(parameters->infile[0]==0)){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format == 0){
|
||||||
|
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||||
|
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(!((parameters->outfile[0] == 0))){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||||
|
fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
|
||||||
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
static void error_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
static void warning_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
static void info_callback(const char *msg, void *client_data) {
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
img_fol_t img_fol;
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
FILE *fsrc = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int num_images;
|
||||||
|
int i,imageno;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
|
/* configure the event callbacks (not required) */
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = error_callback;
|
||||||
|
event_mgr.warning_handler = warning_callback;
|
||||||
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* Initialize indexfilename and img_fol */
|
||||||
|
*indexfilename = 0;
|
||||||
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if(dirptr){
|
||||||
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||||
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
|
if(!dirptr->filename_buf){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<num_images;i++){
|
||||||
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (num_images==0){
|
||||||
|
fprintf(stdout,"Folder is empty\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
num_images=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Encoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++) {
|
||||||
|
image = NULL;
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||||
|
fprintf(stderr,"skipping file...\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the input file and put it in memory */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
file_length = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||||
|
{
|
||||||
|
free(src);
|
||||||
|
fclose(fsrc);
|
||||||
|
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
switch(parameters.decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG-2000 codestream */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_J2K);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JP2_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000 compressed image data */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JP2);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JPT_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000, JPIP */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JPT);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) /* If need to extract codestream information*/
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
free(src);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
opj_bool bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
if(image->color_space == CLRSPC_SYCC)
|
||||||
|
{
|
||||||
|
color_sycc_to_rgb(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image->icc_profile_buf)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||||
|
color_apply_icc_profile(image);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free(image->icc_profile_buf);
|
||||||
|
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create output image */
|
||||||
|
/* ------------------- */
|
||||||
|
switch (parameters.cod_format) {
|
||||||
|
case PXM_DFMT: /* PNM PGM PPM */
|
||||||
|
if (imagetopnm(image, parameters.outfile)) {
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PGX_DFMT: /* PGX */
|
||||||
|
if(imagetopgx(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BMP_DFMT: /* BMP */
|
||||||
|
if(imagetobmp(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_LIBTIFF
|
||||||
|
case TIF_DFMT: /* TIFF */
|
||||||
|
if(imagetotif(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* HAVE_LIBTIFF */
|
||||||
|
case RAW_DFMT: /* RAW */
|
||||||
|
if(imagetoraw(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TGA_DFMT: /* TGA */
|
||||||
|
if(imagetotga(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_LIBPNG
|
||||||
|
case PNG_DFMT: /* PNG */
|
||||||
|
if(imagetopng(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* HAVE_LIBPNG */
|
||||||
|
/* Can happen if output file is TIFF or PNG
|
||||||
|
* and HAVE_LIBTIF or HAVE_LIBPNG is undefined
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free codestream information structure */
|
||||||
|
if (*indexfilename)
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*end main*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
679
applications/codec/windirent.h
Normal file
679
applications/codec/windirent.h
Normal file
@@ -0,0 +1,679 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* uce-dirent.h - operating system independent dirent implementation
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998-2002 Toni Ronkko
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* ``Software''), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* May 28 1998, Toni Ronkko <tronkko@messi.uku.fi>
|
||||||
|
*
|
||||||
|
* $Id: uce-dirent.h,v 1.7 2002/05/13 10:48:35 tr Exp $
|
||||||
|
*
|
||||||
|
* $Log: uce-dirent.h,v $
|
||||||
|
* Revision 1.7 2002/05/13 10:48:35 tr
|
||||||
|
* embedded some source code directly to the header so that no source
|
||||||
|
* modules need to be included in the MS Visual C project using the
|
||||||
|
* interface, removed all the dependencies to other headers of the `uce'
|
||||||
|
* library so that the header can be made public
|
||||||
|
*
|
||||||
|
* Revision 1.6 2002/04/12 16:22:04 tr
|
||||||
|
* Unified Compiling Environment (UCE) replaced `std' library
|
||||||
|
*
|
||||||
|
* Revision 1.5 2001/07/20 16:33:40 tr
|
||||||
|
* moved to `std' library and re-named defines accordingly
|
||||||
|
*
|
||||||
|
* Revision 1.4 2001/07/10 16:47:18 tronkko
|
||||||
|
* revised comments
|
||||||
|
*
|
||||||
|
* Revision 1.3 2001/01/11 13:16:43 tr
|
||||||
|
* using ``uce-machine.h'' for finding out defines such as `FREEBSD'
|
||||||
|
*
|
||||||
|
* Revision 1.2 2000/10/08 16:00:41 tr
|
||||||
|
* copy of FreeBSD man page
|
||||||
|
*
|
||||||
|
* Revision 1.1 2000/07/10 05:53:16 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
* Revision 1.2 1998/07/19 18:29:14 tr
|
||||||
|
* Added error reporting capabilities and some asserts.
|
||||||
|
*
|
||||||
|
* Revision 1.1 1998/07/04 16:27:51 tr
|
||||||
|
* Initial revision
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MSVC 1.0 scans automatic dependencies incorrectly when your project
|
||||||
|
* contains this very header. The problem is that MSVC cannot handle
|
||||||
|
* include directives inside #if..#endif block those are never entered.
|
||||||
|
* Since this header ought to compile in many different operating systems,
|
||||||
|
* there had to be several conditional blocks that are compiled only in
|
||||||
|
* operating systems for what they were designed for. MSVC 1.0 cannot
|
||||||
|
* handle inclusion of sys/dir.h in a part that is compiled only in Apollo
|
||||||
|
* operating system. To fix the problem you need to insert DIR.H into
|
||||||
|
* SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
|
||||||
|
* Consult manuals for more informaton about the problem.
|
||||||
|
*
|
||||||
|
* Since many UNIX systems have dirent.h we assume to have one also.
|
||||||
|
* However, if your UNIX system does not have dirent.h you can download one
|
||||||
|
* for example at: http://ftp.uni-mannheim.de/ftp/GNU/dirent/dirent.tar.gz.
|
||||||
|
* You can also see if you have one of dirent.h, direct.h, dir.h, ndir.h,
|
||||||
|
* sys/dir.h and sys/ndir.h somewhere. Try defining HAVE_DIRENT_H,
|
||||||
|
* HAVE_DIRECT_H, HAVE_DIR_H, HAVE_NDIR_H, HAVE_SYS_DIR_H and
|
||||||
|
* HAVE_SYS_NDIR_H according to the files found.
|
||||||
|
*/
|
||||||
|
#ifndef DIRENT_H
|
||||||
|
#define DIRENT_H
|
||||||
|
#define DIRENT_H_INCLUDED
|
||||||
|
|
||||||
|
/* find out platform */
|
||||||
|
#if defined(MSDOS) /* MS-DOS */
|
||||||
|
#elif defined(__MSDOS__) /* Turbo C/Borland */
|
||||||
|
# define MSDOS
|
||||||
|
#elif defined(__DOS__) /* Watcom */
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) /* MS-Windows */
|
||||||
|
#elif defined(__NT__) /* Watcom */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(_WIN32) /* Microsoft */
|
||||||
|
# define WIN32
|
||||||
|
#elif defined(__WIN32__) /* Borland */
|
||||||
|
# define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See what kind of dirent interface we have unless autoconf has already
|
||||||
|
* determinated that.
|
||||||
|
*/
|
||||||
|
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
|
||||||
|
# if defined(_MSC_VER) /* Microsoft C/C++ */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__MINGW32__) /* MinGW */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__BORLANDC__) /* Borland C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# define VOID_CLOSEDIR
|
||||||
|
# elif defined(__TURBOC__) /* Borland Turbo C */
|
||||||
|
/* no dirent.h */
|
||||||
|
# elif defined(__WATCOMC__) /* Watcom C/C++ */
|
||||||
|
# define HAVE_DIRECT_H
|
||||||
|
# elif defined(__apollo) /* Apollo */
|
||||||
|
# define HAVE_SYS_DIR_H
|
||||||
|
# elif defined(__hpux) /* HP-UX */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif (defined(__alpha) || defined(__alpha__)) && !defined(__linux__) /* Alpha OSF1 */
|
||||||
|
# error "not implemented"
|
||||||
|
# elif defined(__sgi) /* Silicon Graphics */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(sun) || defined(__sun) /* Sun Solaris */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__FreeBSD__) /* FreeBSD */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__linux__) /* Linux */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# elif defined(__GNUC__) /* GNU C/C++ */
|
||||||
|
# define HAVE_DIRENT_H
|
||||||
|
# else
|
||||||
|
# error "not implemented"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* include proper interface headers */
|
||||||
|
#if defined(HAVE_DIRENT_H)
|
||||||
|
# include <dirent.h>
|
||||||
|
# ifdef FREEBSD
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
# else
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(HAVE_NDIR_H)
|
||||||
|
# include <ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_NDIR_H)
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIRECT_H)
|
||||||
|
# include <direct.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_DIR_H)
|
||||||
|
# include <dir.h>
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYS_DIR_H)
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# ifndef dirent
|
||||||
|
# define dirent direct
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)((dp)->d_namlen))
|
||||||
|
|
||||||
|
#elif defined(MSDOS) || defined(WIN32)
|
||||||
|
|
||||||
|
/* figure out type of underlaying directory interface to be used */
|
||||||
|
# if defined(WIN32)
|
||||||
|
# define DIRENT_WIN32_INTERFACE
|
||||||
|
# elif defined(MSDOS)
|
||||||
|
# define DIRENT_MSDOS_INTERFACE
|
||||||
|
# else
|
||||||
|
# error "missing native dirent interface"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** WIN32 specifics ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
# include <windows.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (MAX_PATH)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*** MS-DOS specifics ***/
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# include <dos.h>
|
||||||
|
|
||||||
|
/* Borland defines file length macros in dir.h */
|
||||||
|
# if defined(__BORLANDC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# if !defined(_find_t)
|
||||||
|
# define _find_t find_t
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Turbo C defines ffblk structure in dir.h */
|
||||||
|
# elif defined(__TURBOC__)
|
||||||
|
# include <dir.h>
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN ((MAXFILE)+(MAXEXT))
|
||||||
|
# endif
|
||||||
|
# define DIRENT_USE_FFBLK
|
||||||
|
|
||||||
|
/* MSVC */
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Watcom */
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# if !defined(DIRENT_MAXNAMLEN)
|
||||||
|
# if defined(__OS2__) || defined(__NT__)
|
||||||
|
# define DIRENT_MAXNAMLEN (255)
|
||||||
|
# else
|
||||||
|
# define DIRENT_MAXNAMLEN (12)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*** generic MS-DOS and MS-Windows stuff ***/
|
||||||
|
# if !defined(NAME_MAX) && defined(DIRENT_MAXNAMLEN)
|
||||||
|
# define NAME_MAX DIRENT_MAXNAMLEN
|
||||||
|
# endif
|
||||||
|
# if NAME_MAX < DIRENT_MAXNAMLEN
|
||||||
|
# error "assertion failed: NAME_MAX >= DIRENT_MAXNAMLEN"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Substitute for real dirent structure. Note that `d_name' field is a
|
||||||
|
* true character array although we have it copied in the implementation
|
||||||
|
* dependent data. We could save some memory if we had declared `d_name'
|
||||||
|
* as a pointer refering the name within implementation dependent data.
|
||||||
|
* We have not done that since some code may rely on sizeof(d_name) to be
|
||||||
|
* something other than four. Besides, directory entries are typically so
|
||||||
|
* small that it takes virtually no time to copy them from place to place.
|
||||||
|
*/
|
||||||
|
typedef struct dirent {
|
||||||
|
char d_name[NAME_MAX + 1];
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE) /*WIN32*/
|
||||||
|
WIN32_FIND_DATA data;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE) /*MSDOS*/
|
||||||
|
# if defined(DIRENT_USE_FFBLK)
|
||||||
|
struct ffblk data;
|
||||||
|
# else
|
||||||
|
struct _find_t data;
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
} dirent;
|
||||||
|
|
||||||
|
/* DIR substitute structure containing directory name. The name is
|
||||||
|
* essential for the operation of ``rewinndir'' function. */
|
||||||
|
typedef struct DIR {
|
||||||
|
char *dirname; /* directory being scanned */
|
||||||
|
dirent current; /* current entry */
|
||||||
|
int dirent_filled; /* is current un-processed? */
|
||||||
|
|
||||||
|
/*** Operating system specific part ***/
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
HANDLE search_handle;
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
# endif
|
||||||
|
} DIR;
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* supply prototypes for dirent functions */
|
||||||
|
static DIR *opendir (const char *dirname);
|
||||||
|
static struct dirent *readdir (DIR *dirp);
|
||||||
|
static int closedir (DIR *dirp);
|
||||||
|
static void rewinddir (DIR *dirp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implement dirent interface as static functions so that the user does not
|
||||||
|
* need to change his project in any way to use dirent function. With this
|
||||||
|
* it is sufficient to include this very header from source modules using
|
||||||
|
* dirent functions and the functions will be pulled in automatically.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* use ffblk instead of _find_t if requested */
|
||||||
|
#if defined(DIRENT_USE_FFBLK)
|
||||||
|
# define _A_ARCH (FA_ARCH)
|
||||||
|
# define _A_HIDDEN (FA_HIDDEN)
|
||||||
|
# define _A_NORMAL (0)
|
||||||
|
# define _A_RDONLY (FA_RDONLY)
|
||||||
|
# define _A_SUBDIR (FA_DIREC)
|
||||||
|
# define _A_SYSTEM (FA_SYSTEM)
|
||||||
|
# define _A_VOLID (FA_LABEL)
|
||||||
|
# define _dos_findnext(dest) findnext(dest)
|
||||||
|
# define _dos_findfirst(name,flags,dest) findfirst(name,dest,flags)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int _initdir (DIR *p);
|
||||||
|
static const char *_getdirname (const struct dirent *dp);
|
||||||
|
static void _setdirname (struct DIR *dirp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="opendir">
|
||||||
|
* <intro>open directory stream for reading
|
||||||
|
* <syntax>DIR *opendir (const char *dirname);
|
||||||
|
*
|
||||||
|
* <desc>Open named directory stream for read and return pointer to the
|
||||||
|
* internal working area that is used for retrieving individual directory
|
||||||
|
* entries. The internal working area has no fields of your interest.
|
||||||
|
*
|
||||||
|
* <ret>Returns a pointer to the internal working area or NULL in case the
|
||||||
|
* directory stream could not be opened. Global `errno' variable will set
|
||||||
|
* in case of error as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EACESS |Permission denied.
|
||||||
|
* [EMFILE |Too many open files used by the process.
|
||||||
|
* [ENFILE |Too many open files in system.
|
||||||
|
* [ENOENT |Directory does not exist.
|
||||||
|
* [ENOMEM |Insufficient memory.
|
||||||
|
* [ENOTDIR |dirname does not refer to directory. This value is not
|
||||||
|
* reliable on MS-DOS and MS-Windows platforms. Many
|
||||||
|
* implementations return ENOENT even when the name refers to a
|
||||||
|
* file.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static DIR *opendir(const char *dirname)
|
||||||
|
{
|
||||||
|
DIR *dirp;
|
||||||
|
assert (dirname != NULL);
|
||||||
|
|
||||||
|
dirp = (DIR*)malloc (sizeof (struct DIR));
|
||||||
|
if (dirp != NULL) {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
/* allocate room for directory name */
|
||||||
|
dirp->dirname = (char*) malloc (strlen (dirname) + 1 + strlen ("\\*.*"));
|
||||||
|
if (dirp->dirname == NULL) {
|
||||||
|
/* failed to duplicate directory name. errno set by malloc() */
|
||||||
|
free (dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Copy directory name while appending directory separator and "*.*".
|
||||||
|
* Directory separator is not appended if the name already ends with
|
||||||
|
* drive or directory separator. Directory separator is assumed to be
|
||||||
|
* '/' or '\' and drive separator is assumed to be ':'. */
|
||||||
|
strcpy (dirp->dirname, dirname);
|
||||||
|
p = strchr (dirp->dirname, '\0');
|
||||||
|
if (dirp->dirname < p &&
|
||||||
|
*(p - 1) != '\\' && *(p - 1) != '/' && *(p - 1) != ':')
|
||||||
|
{
|
||||||
|
strcpy (p++, "\\");
|
||||||
|
}
|
||||||
|
# ifdef DIRENT_WIN32_INTERFACE
|
||||||
|
strcpy (p, "*"); /*scan files with and without extension in win32*/
|
||||||
|
# else
|
||||||
|
strcpy (p, "*.*"); /*scan files with and without extension in DOS*/
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* open stream */
|
||||||
|
if (_initdir (dirp) == 0) {
|
||||||
|
/* initialization failed */
|
||||||
|
free (dirp->dirname);
|
||||||
|
free (dirp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="readdir">
|
||||||
|
* <intro>read a directory entry
|
||||||
|
* <syntax>struct dirent *readdir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Read individual directory entry and return pointer to a structure
|
||||||
|
* containing the name of the entry. Individual directory entries returned
|
||||||
|
* include normal files, sub-directories, pseudo-directories "." and ".."
|
||||||
|
* and also volume labels, hidden files and system files in MS-DOS and
|
||||||
|
* MS-Windows. You might want to use stat(2) function to determinate which
|
||||||
|
* one are you dealing with. Many dirent implementations already contain
|
||||||
|
* equivalent information in dirent structure but you cannot depend on
|
||||||
|
* this.
|
||||||
|
*
|
||||||
|
* The dirent structure contains several system dependent fields that
|
||||||
|
* generally have no interest to you. The only interesting one is char
|
||||||
|
* d_name[] that is also portable across different systems. The d_name
|
||||||
|
* field contains the name of the directory entry without leading path.
|
||||||
|
* While d_name is portable across different systems the actual storage
|
||||||
|
* capacity of d_name varies from system to system and there is no portable
|
||||||
|
* way to find out it at compile time as different systems define the
|
||||||
|
* capacity of d_name with different macros and some systems do not define
|
||||||
|
* capacity at all (besides actual declaration of the field). If you really
|
||||||
|
* need to find out storage capacity of d_name then you might want to try
|
||||||
|
* NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought
|
||||||
|
* there are many MS-DOS and MS-Windows implementations those do not define
|
||||||
|
* it. There are also systems that declare d_name as "char d_name[1]" and
|
||||||
|
* then allocate suitable amount of memory at run-time. Thanks to Alain
|
||||||
|
* Decamps (Alain.Decamps@advalvas.be) for pointing it out to me.
|
||||||
|
*
|
||||||
|
* This all leads to the fact that it is difficult to allocate space
|
||||||
|
* for the directory names when the very same program is being compiled on
|
||||||
|
* number of operating systems. Therefore I suggest that you always
|
||||||
|
* allocate space for directory names dynamically.
|
||||||
|
*
|
||||||
|
* <ret>
|
||||||
|
* Returns a pointer to a structure containing name of the directory entry
|
||||||
|
* in `d_name' field or NULL if there was an error. In case of an error the
|
||||||
|
* global `errno' variable will set as follows:
|
||||||
|
*
|
||||||
|
* <table>
|
||||||
|
* [EBADF |dir parameter refers to an invalid directory stream. This value
|
||||||
|
* is not set reliably on all implementations.]
|
||||||
|
* </table>
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static struct dirent *
|
||||||
|
readdir (DIR *dirp)
|
||||||
|
{
|
||||||
|
assert(dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dirp->dirent_filled != 0) {
|
||||||
|
/*
|
||||||
|
* Directory entry has already been retrieved and there is no need to
|
||||||
|
* retrieve a new one. Directory entry will be retrieved in advance
|
||||||
|
* when the user calls readdir function for the first time. This is so
|
||||||
|
* because real dirent has separate functions for opening and reading
|
||||||
|
* the stream whereas Win32 and DOS dirents open the stream
|
||||||
|
* automatically when we retrieve the first file. Therefore, we have to
|
||||||
|
* save the first file when opening the stream and later we have to
|
||||||
|
* return the saved entry when the user tries to read the first entry.
|
||||||
|
*/
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
} else {
|
||||||
|
/* fill in entry and return that */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||||
|
/* Last file has been processed or an error occured */
|
||||||
|
FindClose (dirp->search_handle);
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
errno = ENOENT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findnext (&dirp->current.data) != 0) {
|
||||||
|
/* _dos_findnext and findnext will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
_setdirname (dirp);
|
||||||
|
assert (dirp->dirent_filled == 0);
|
||||||
|
}
|
||||||
|
return &dirp->current;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="closedir">
|
||||||
|
* <intro>close directory stream.
|
||||||
|
* <syntax>int closedir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Close directory stream opened by the `opendir' function. Close of
|
||||||
|
* directory stream invalidates the DIR structure as well as previously read
|
||||||
|
* dirent entry.
|
||||||
|
*
|
||||||
|
* <ret>The function typically returns 0 on success and -1 on failure but
|
||||||
|
* the function may be declared to return void on same systems. At least
|
||||||
|
* Borland C/C++ and some UNIX implementations use void as a return type.
|
||||||
|
* The dirent wrapper tries to define VOID_CLOSEDIR whenever closedir is
|
||||||
|
* known to return nothing. The very same definition is made by the GNU
|
||||||
|
* autoconf if you happen to use it.
|
||||||
|
*
|
||||||
|
* The global `errno' variable will set to EBADF in case of error.
|
||||||
|
* </function>
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
closedir (DIR *dirp)
|
||||||
|
{
|
||||||
|
int retcode = 0;
|
||||||
|
|
||||||
|
/* make sure that dirp points to legal structure */
|
||||||
|
assert (dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free directory name and search handles */
|
||||||
|
if (dirp->dirname != NULL) free (dirp->dirname);
|
||||||
|
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose (dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
retcode = -1;
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* clear dirp structure to make sure that it cannot be used anymore*/
|
||||||
|
memset (dirp, 0, sizeof (*dirp));
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
free (dirp);
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <function name="rewinddir">
|
||||||
|
* <intro>rewind directory stream to the beginning
|
||||||
|
* <syntax>void rewinddir (DIR *dirp);
|
||||||
|
*
|
||||||
|
* <desc>Rewind directory stream to the beginning so that the next call of
|
||||||
|
* readdir() returns the very first directory entry again. However, note
|
||||||
|
* that next call of readdir() may not return the same directory entry as it
|
||||||
|
* did in first time. The directory stream may have been affected by newly
|
||||||
|
* created files.
|
||||||
|
*
|
||||||
|
* Almost every dirent implementation ensure that rewinddir will update
|
||||||
|
* the directory stream to reflect any changes made to the directory entries
|
||||||
|
* since the previous ``opendir'' or ``rewinddir'' call. Keep an eye on
|
||||||
|
* this if your program depends on the feature. I know at least one dirent
|
||||||
|
* implementation where you are required to close and re-open the stream to
|
||||||
|
* see the changes.
|
||||||
|
*
|
||||||
|
* <ret>Returns nothing. If something went wrong while rewinding, you will
|
||||||
|
* notice it later when you try to retrieve the first directory entry.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
rewinddir (DIR *dirp)
|
||||||
|
{
|
||||||
|
/* make sure that dirp is legal */
|
||||||
|
assert (dirp != NULL);
|
||||||
|
if (dirp == NULL) {
|
||||||
|
errno = EBADF;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assert (dirp->dirname != NULL);
|
||||||
|
|
||||||
|
/* close previous stream */
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||||
|
if (FindClose (dirp->search_handle) == FALSE) {
|
||||||
|
/* Unknown error */
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* re-open previous stream */
|
||||||
|
if (_initdir (dirp) == 0) {
|
||||||
|
/* initialization failed but we cannot deal with error. User will notice
|
||||||
|
* error later when she tries to retrieve first directory enty. */
|
||||||
|
/*EMPTY*/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open native directory stream object and retrieve first file.
|
||||||
|
* Be sure to close previous stream before opening new one.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
_initdir (DIR *dirp)
|
||||||
|
{
|
||||||
|
assert (dirp != NULL);
|
||||||
|
assert (dirp->dirname != NULL);
|
||||||
|
dirp->dirent_filled = 0;
|
||||||
|
|
||||||
|
# if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
/* Open stream and retrieve first file */
|
||||||
|
dirp->search_handle = FindFirstFile (dirp->dirname, &dirp->current.data);
|
||||||
|
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||||
|
/* something went wrong but we don't know what. GetLastError() could
|
||||||
|
* give us more information about the error, but then we should map
|
||||||
|
* the error code into errno. */
|
||||||
|
errno = ENOENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# elif defined(DIRENT_MSDOS_INTERFACE)
|
||||||
|
if (_dos_findfirst (dirp->dirname,
|
||||||
|
_A_SUBDIR | _A_RDONLY | _A_ARCH | _A_SYSTEM | _A_HIDDEN,
|
||||||
|
&dirp->current.data) != 0)
|
||||||
|
{
|
||||||
|
/* _dos_findfirst and findfirst will set errno to ENOENT when no
|
||||||
|
* more entries could be retrieved. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* initialize DIR and it's first entry */
|
||||||
|
_setdirname (dirp);
|
||||||
|
dirp->dirent_filled = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return implementation dependent name of the current directory entry.
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
_getdirname (const struct dirent *dp)
|
||||||
|
{
|
||||||
|
#if defined(DIRENT_WIN32_INTERFACE)
|
||||||
|
return dp->data.cFileName;
|
||||||
|
|
||||||
|
#elif defined(DIRENT_USE_FFBLK)
|
||||||
|
return dp->data.ff_name;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return dp->data.name;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy name of implementation dependent directory entry to the d_name field.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_setdirname (struct DIR *dirp) {
|
||||||
|
/* make sure that d_name is long enough */
|
||||||
|
assert (strlen (_getdirname (&dirp->current)) <= NAME_MAX);
|
||||||
|
|
||||||
|
strncpy (dirp->current.d_name,
|
||||||
|
_getdirname (&dirp->current),
|
||||||
|
NAME_MAX);
|
||||||
|
dirp->current.d_name[NAME_MAX] = '\0'; /*char d_name[NAME_MAX+1]*/
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# define NAMLEN(dp) ((int)(strlen((dp)->d_name)))
|
||||||
|
|
||||||
|
#else
|
||||||
|
# error "missing dirent interface"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*DIRENT_H*/
|
||||||
468
applications/common/color.c
Normal file
468
applications/common/color.c
Normal file
@@ -0,0 +1,468 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
#include <lcms2.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
#include <lcms.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*--------------------------------------------------------
|
||||||
|
Matrix f<>r sYCC, Amendment 1 to IEC 61966-2-1
|
||||||
|
|
||||||
|
Y : 0.299 0.587 0.114 :R
|
||||||
|
Cb: -0.1687 -0.3312 0.5 :G
|
||||||
|
Cr: 0.5 -0.4187 -0.0812 :B
|
||||||
|
|
||||||
|
Inverse:
|
||||||
|
|
||||||
|
R: 1 -3.68213e-05 1.40199 :Y
|
||||||
|
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||||
|
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||||
|
|
||||||
|
-----------------------------------------------------------*/
|
||||||
|
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||||
|
int *out_r, int *out_g, int *out_b)
|
||||||
|
{
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
cb -= offset; cr -= offset;
|
||||||
|
r = y + (int)(1.402 * (float)cr);
|
||||||
|
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
|
||||||
|
|
||||||
|
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
|
||||||
|
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
|
||||||
|
|
||||||
|
b = y + (int)(1.772 * (float)cb);
|
||||||
|
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sycc444_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b;
|
||||||
|
const int *y, *cb, *cr;
|
||||||
|
int maxw, maxh, max, i, offset, upb;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
}/* sycc444_to_rgb() */
|
||||||
|
|
||||||
|
static void sycc422_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b;
|
||||||
|
const int *y, *cb, *cr;
|
||||||
|
int maxw, maxh, max, offset, upb;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i=0; i < maxh; ++i)
|
||||||
|
{
|
||||||
|
for(j=0; j < maxw; j += 2)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||||
|
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||||
|
img->comps[1].dx = img->comps[0].dx;
|
||||||
|
img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[0].dy;
|
||||||
|
img->comps[2].dy = img->comps[0].dy;
|
||||||
|
|
||||||
|
}/* sycc422_to_rgb() */
|
||||||
|
|
||||||
|
static void sycc420_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||||
|
const int *y, *cb, *cr, *ny;
|
||||||
|
int maxw, maxh, max, offset, upb;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
i = img->comps[0].prec;
|
||||||
|
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||||
|
|
||||||
|
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||||
|
max = maxw * maxh;
|
||||||
|
|
||||||
|
y = img->comps[0].data;
|
||||||
|
cb = img->comps[1].data;
|
||||||
|
cr = img->comps[2].data;
|
||||||
|
|
||||||
|
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||||
|
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||||
|
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||||
|
|
||||||
|
for(i=0; i < maxh; i += 2)
|
||||||
|
{
|
||||||
|
ny = y + maxw;
|
||||||
|
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||||
|
|
||||||
|
for(j=0; j < maxw; j += 2)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||||
|
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||||
|
|
||||||
|
++ny; ++nr; ++ng; ++nb;
|
||||||
|
|
||||||
|
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||||
|
|
||||||
|
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||||
|
}
|
||||||
|
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||||
|
}
|
||||||
|
free(img->comps[0].data); img->comps[0].data = d0;
|
||||||
|
free(img->comps[1].data); img->comps[1].data = d1;
|
||||||
|
free(img->comps[2].data); img->comps[2].data = d2;
|
||||||
|
|
||||||
|
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||||
|
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||||
|
img->comps[1].dx = img->comps[0].dx;
|
||||||
|
img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[0].dy;
|
||||||
|
img->comps[2].dy = img->comps[0].dy;
|
||||||
|
|
||||||
|
}/* sycc420_to_rgb() */
|
||||||
|
|
||||||
|
void color_sycc_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
if(img->numcomps < 3)
|
||||||
|
{
|
||||||
|
img->color_space = CLRSPC_GRAY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 2)
|
||||||
|
&& (img->comps[2].dx == 2)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 2)
|
||||||
|
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||||
|
{
|
||||||
|
sycc420_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 2)
|
||||||
|
&& (img->comps[2].dx == 2)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 1)
|
||||||
|
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||||
|
{
|
||||||
|
sycc422_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if((img->comps[0].dx == 1)
|
||||||
|
&& (img->comps[1].dx == 1)
|
||||||
|
&& (img->comps[2].dx == 1)
|
||||||
|
&& (img->comps[0].dy == 1)
|
||||||
|
&& (img->comps[1].dy == 1)
|
||||||
|
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||||
|
{
|
||||||
|
sycc444_to_rgb(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n",
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
img->color_space = CLRSPC_SRGB;
|
||||||
|
|
||||||
|
}/* color_sycc_to_rgb() */
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
/* Bob Friesenhahn proposed:*/
|
||||||
|
#define cmsSigXYZData icSigXYZData
|
||||||
|
#define cmsSigLabData icSigLabData
|
||||||
|
#define cmsSigCmykData icSigCmykData
|
||||||
|
#define cmsSigYCbCrData icSigYCbCrData
|
||||||
|
#define cmsSigLuvData icSigLuvData
|
||||||
|
#define cmsSigGrayData icSigGrayData
|
||||||
|
#define cmsSigRgbData icSigRgbData
|
||||||
|
#define cmsUInt32Number DWORD
|
||||||
|
|
||||||
|
#define cmsColorSpaceSignature icColorSpaceSignature
|
||||||
|
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
|
void color_apply_icc_profile(opj_image_t *image)
|
||||||
|
{
|
||||||
|
cmsHPROFILE in_prof, out_prof;
|
||||||
|
cmsHTRANSFORM transform;
|
||||||
|
cmsColorSpaceSignature in_space, out_space;
|
||||||
|
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||||
|
int *r, *g, *b;
|
||||||
|
int prec, i, max, max_w, max_h;
|
||||||
|
OPJ_COLOR_SPACE oldspace;
|
||||||
|
|
||||||
|
in_prof =
|
||||||
|
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||||
|
|
||||||
|
if(in_prof == NULL) return;
|
||||||
|
|
||||||
|
in_space = cmsGetPCS(in_prof);
|
||||||
|
(void)in_space;
|
||||||
|
out_space = cmsGetColorSpace(in_prof);
|
||||||
|
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||||
|
|
||||||
|
|
||||||
|
max_w = image->comps[0].w; max_h = image->comps[0].h;
|
||||||
|
prec = image->comps[0].prec;
|
||||||
|
(void)prec;
|
||||||
|
oldspace = image->color_space;
|
||||||
|
|
||||||
|
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_RGB_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_GRAY_8;
|
||||||
|
out_type = TYPE_RGB_8;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_YCbCr_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
image->color_space = CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||||
|
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||||
|
__FILE__,__LINE__,out_space,
|
||||||
|
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||||
|
(out_space>>8) & 0xff, out_space & 0xff);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||||
|
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||||
|
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||||
|
|
||||||
|
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||||
|
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||||
|
" type: in(%u) out:(%u)\n",
|
||||||
|
intent,
|
||||||
|
in_space,
|
||||||
|
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||||
|
(in_space>>8) & 0xff, in_space & 0xff,
|
||||||
|
|
||||||
|
out_space,
|
||||||
|
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||||
|
(out_space>>8) & 0xff, out_space & 0xff,
|
||||||
|
|
||||||
|
in_type,out_type
|
||||||
|
);
|
||||||
|
#endif /* DEBUG_PROFILE */
|
||||||
|
|
||||||
|
transform = cmsCreateTransform(in_prof, in_type,
|
||||||
|
out_prof, out_type, intent, 0);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS2
|
||||||
|
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(transform == NULL)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||||
|
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||||
|
#endif
|
||||||
|
image->color_space = oldspace;
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image->numcomps > 2)/* RGB, RGBA */
|
||||||
|
{
|
||||||
|
unsigned short *inbuf, *outbuf, *in, *out;
|
||||||
|
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned short);
|
||||||
|
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned short)*r++;
|
||||||
|
*in++ = (unsigned short)*g++;
|
||||||
|
*in++ = (unsigned short)*b++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++;
|
||||||
|
*g++ = (int)*out++;
|
||||||
|
*b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
free(inbuf); free(outbuf);
|
||||||
|
}
|
||||||
|
else /* GRAY, GRAYA */
|
||||||
|
{
|
||||||
|
unsigned char *in, *inbuf, *out, *outbuf;
|
||||||
|
|
||||||
|
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned char);
|
||||||
|
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
|
||||||
|
image->comps = (opj_image_comp_t*)
|
||||||
|
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||||
|
|
||||||
|
if(image->numcomps == 2)
|
||||||
|
image->comps[3] = image->comps[1];
|
||||||
|
|
||||||
|
image->comps[1] = image->comps[0];
|
||||||
|
image->comps[2] = image->comps[0];
|
||||||
|
|
||||||
|
image->comps[1].data = (int*)calloc(max, sizeof(int));
|
||||||
|
image->comps[2].data = (int*)calloc(max, sizeof(int));
|
||||||
|
|
||||||
|
image->numcomps += 2;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned char)*r++;
|
||||||
|
}
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
free(inbuf); free(outbuf);
|
||||||
|
|
||||||
|
}/* if(image->numcomps */
|
||||||
|
|
||||||
|
cmsDeleteTransform(transform);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
}/* color_apply_icc_profile() */
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBLCMS2 || HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
|
* 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) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,14 +29,10 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "j2k.h"
|
#ifndef _OPJ_COLOR_H_
|
||||||
|
#define _OPJ_COLOR_H_
|
||||||
|
|
||||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||||
int subsampling_dy, int Dim[2]);
|
extern void color_apply_icc_profile(opj_image_t *image);
|
||||||
|
|
||||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
#endif /* _OPJ_COLOR_H_ */
|
||||||
int subsampling_dx, int subsampling_dy, int Dim[2],
|
|
||||||
j2k_cp_t cp);
|
|
||||||
|
|
||||||
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
|
||||||
int subsampling_dy, int Dim[2]);
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
|
* 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) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,14 +29,20 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "j2k.h"
|
#ifndef _OPJ_FORMAT_DEFS_H_
|
||||||
|
#define _OPJ_FORMAT_DEFS_H_
|
||||||
|
|
||||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
#define J2K_CFMT 0
|
||||||
int subsampling_dy, int Dim[2]);
|
#define JP2_CFMT 1
|
||||||
|
#define JPT_CFMT 2
|
||||||
|
|
||||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
#define PXM_DFMT 10
|
||||||
int subsampling_dx, int subsampling_dy, int Dim[2],
|
#define PGX_DFMT 11
|
||||||
j2k_cp_t cp);
|
#define BMP_DFMT 12
|
||||||
|
#define YUV_DFMT 13
|
||||||
|
#define TIF_DFMT 14
|
||||||
|
#define RAW_DFMT 15
|
||||||
|
#define TGA_DFMT 16
|
||||||
|
#define PNG_DFMT 17
|
||||||
|
|
||||||
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||||
int subsampling_dy, int Dim[2]);
|
|
||||||
254
applications/common/opj_getopt.c
Normal file
254
applications/common/opj_getopt.c
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "opj_getopt.h"
|
||||||
|
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int opj_opterr = 1, /* if error message should be printed */
|
||||||
|
opj_optind = 1, /* index into parent argv vector */
|
||||||
|
opj_optopt, /* character checked for validity */
|
||||||
|
opj_optreset; /* reset getopt */
|
||||||
|
char *opj_optarg; /* argument associated with option */
|
||||||
|
|
||||||
|
#define BADCH (int)'?'
|
||||||
|
#define BADARG (int)':'
|
||||||
|
static char EMSG[]={""};
|
||||||
|
|
||||||
|
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||||
|
void reset_options_reading(void) {
|
||||||
|
opj_opterr = 1;
|
||||||
|
opj_optind = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||||
|
# define __progname nargv[0]
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
char *oli = NULL; /* option letter list index */
|
||||||
|
|
||||||
|
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||||
|
opj_optreset = 0;
|
||||||
|
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
|
++opj_optind;
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
} /* option letter okay? */
|
||||||
|
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
||||||
|
!(oli = strchr(ostr, opj_optopt))) {
|
||||||
|
/*
|
||||||
|
* if the user didn't specify '-' as an option,
|
||||||
|
* assume it means -1.
|
||||||
|
*/
|
||||||
|
if (opj_optopt == (int) '-')
|
||||||
|
return (-1);
|
||||||
|
if (!*place)
|
||||||
|
++opj_optind;
|
||||||
|
if (opj_opterr && *ostr != ':') {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*++oli != ':') { /* don't need argument */
|
||||||
|
opj_optarg = NULL;
|
||||||
|
if (!*place)
|
||||||
|
++opj_optind;
|
||||||
|
} else { /* need an argument */
|
||||||
|
if (*place) /* no white space */
|
||||||
|
opj_optarg = place;
|
||||||
|
else if (nargc <= ++opj_optind) { /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (*ostr == ':')
|
||||||
|
return (BADARG);
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: option requires an argument -- %c\n",
|
||||||
|
__progname, opj_optopt);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
} else /* white space */
|
||||||
|
opj_optarg = nargv[opj_optind];
|
||||||
|
place = EMSG;
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
return (opj_optopt); /* dump back option letter */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen) {
|
||||||
|
static int lastidx,lastofs;
|
||||||
|
char *tmp;
|
||||||
|
int i,len;
|
||||||
|
char param = 1;
|
||||||
|
|
||||||
|
again:
|
||||||
|
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
||||||
|
if(opj_optind >= (argc - 1)){ /* no more input parameters */
|
||||||
|
param = 0;
|
||||||
|
}
|
||||||
|
else{ /* more input parameters */
|
||||||
|
if(argv[opj_optind + 1][0] == '-'){
|
||||||
|
param = 0; /* Missing parameter after '-' */
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
param = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param == 0) {
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv[opj_optind][0]=='-') { /* long option */
|
||||||
|
char* arg=argv[opj_optind]+1;
|
||||||
|
const opj_option_t* o;
|
||||||
|
o=longopts;
|
||||||
|
len=sizeof(longopts[0]);
|
||||||
|
|
||||||
|
if (param > 1){
|
||||||
|
arg = argv[opj_optind+1];
|
||||||
|
opj_optind++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
arg = argv[opj_optind]+1;
|
||||||
|
|
||||||
|
if(strlen(arg)>1){
|
||||||
|
for (i=0;i<totlen;i=i+len,o++) {
|
||||||
|
if (!strcmp(o->name,arg)) { /* match */
|
||||||
|
if (o->has_arg == 0) {
|
||||||
|
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))){
|
||||||
|
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
opj_optarg=argv[opj_optind+1];
|
||||||
|
if(opj_optarg){
|
||||||
|
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
if (o->flag)
|
||||||
|
*(o->flag)=o->val;
|
||||||
|
else
|
||||||
|
return o->val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}/*(end for)String not found in the list*/
|
||||||
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}else{ /*Single character input parameter*/
|
||||||
|
if (*optstring==':') return ':';
|
||||||
|
if (lastidx!=opj_optind) {
|
||||||
|
lastidx=opj_optind; lastofs=0;
|
||||||
|
}
|
||||||
|
opj_optopt=argv[opj_optind][lastofs+1];
|
||||||
|
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
||||||
|
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||||
|
++opj_optind;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
if (tmp[1]==':') { /* argument expected */
|
||||||
|
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
||||||
|
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
opj_optarg=argv[opj_optind+1];
|
||||||
|
if(opj_optarg){
|
||||||
|
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!opj_optarg) { /* missing argument */
|
||||||
|
if (opj_opterr) {
|
||||||
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++opj_optind;
|
||||||
|
}else {/*Argument not expected*/
|
||||||
|
++lastofs;
|
||||||
|
return opj_optopt;
|
||||||
|
}
|
||||||
|
found:
|
||||||
|
++opj_optind;
|
||||||
|
return opj_optopt;
|
||||||
|
} else { /* not found */
|
||||||
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);
|
||||||
|
}/*end of not found*/
|
||||||
|
|
||||||
|
}/* end of single character*/
|
||||||
|
}/*end '-'*/
|
||||||
|
fprintf(stderr,"Invalid option\n");
|
||||||
|
++opj_optind;
|
||||||
|
return (BADCH);;
|
||||||
|
}/*end function*/
|
||||||
51
applications/common/opj_getopt.h
Normal file
51
applications/common/opj_getopt.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
|
||||||
|
#ifdef USE_SYSTEM_GETOPT
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#define opj_opterr opterr
|
||||||
|
#define opj_optind optind
|
||||||
|
#define opj_optopt optopt
|
||||||
|
#define opj_optreset optreset
|
||||||
|
#define opj_optarg optarg
|
||||||
|
|
||||||
|
typedef struct option opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG no_argument
|
||||||
|
#define REQ_ARG required_argument
|
||||||
|
#define OPT_ARG optional_argument
|
||||||
|
|
||||||
|
#define opj_getopt getopt
|
||||||
|
#define opj_getopt_long getopt_long
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
typedef struct opj_option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
} opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG 0
|
||||||
|
#define REQ_ARG 1
|
||||||
|
#define OPT_ARG 2
|
||||||
|
|
||||||
|
extern int opj_opterr;
|
||||||
|
extern int opj_optind;
|
||||||
|
extern int opj_optopt;
|
||||||
|
extern int opj_optreset;
|
||||||
|
extern char *opj_optarg;
|
||||||
|
|
||||||
|
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen);
|
||||||
|
extern void reset_options_reading(void);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
||||||
|
#endif /* USE_SYSTEM_GETOPT */
|
||||||
127
applications/jpip/CHANGES
Normal file
127
applications/jpip/CHANGES
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
What's New for OpenJPIP
|
||||||
|
|
||||||
|
* : fixed
|
||||||
|
- : removed
|
||||||
|
! : changed
|
||||||
|
+ : added
|
||||||
|
|
||||||
|
Feburary 28, 2012
|
||||||
|
+ [kaori] enabled the opj_server to reply the first query consisting with len request from kakadu client
|
||||||
|
|
||||||
|
February 9, 2012
|
||||||
|
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||||
|
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||||
|
|
||||||
|
January 26, 2012
|
||||||
|
! [kaori] unapplied auxtrans_manager to the local mode
|
||||||
|
|
||||||
|
December 24, 2011
|
||||||
|
* [kaori] additional modification for the warning
|
||||||
|
|
||||||
|
December 22, 2011
|
||||||
|
* [kaori] fixed auxtrans_manager to enable MAC
|
||||||
|
* [kaori] warnings due to disregarding return value are removed
|
||||||
|
|
||||||
|
November 30, 2011
|
||||||
|
+ [kaori] TCP return (http-tcp) implemented
|
||||||
|
|
||||||
|
November 16, 2011
|
||||||
|
* [kaori] fixed Region of Interest option, and memory leak of opj_dec_server
|
||||||
|
+ [kaori] new feature to target JP2 files from www (libcurl required)
|
||||||
|
* [kaori] fixed opj_server execusion error (instant terminating) with autotool, cmake still need to be fixed
|
||||||
|
|
||||||
|
November 8, 2011
|
||||||
|
! [kaori] updated main page of doxygen
|
||||||
|
|
||||||
|
November 3, 2011
|
||||||
|
* [kaori] solved memory leak of opj_server
|
||||||
|
! [kaori] removed redundant defines
|
||||||
|
|
||||||
|
November 2, 2011
|
||||||
|
* [antonin] additional patches for autotools and cmake
|
||||||
|
|
||||||
|
October 26, 2011
|
||||||
|
* [kaori] additional patches for autotool are applied
|
||||||
|
|
||||||
|
October 25, 2011
|
||||||
|
* [kaori] patches for cmake and autotool are applied
|
||||||
|
* [kaori] fixed client viewer to be compatible with server response header both Content-type and Content-Type
|
||||||
|
|
||||||
|
October 20, 2011
|
||||||
|
+ [added] API style in openJPIP library
|
||||||
|
! [kaori] rearranged directories, applications are all under util/ directory, currently only 'make -f Makefile.nix' works
|
||||||
|
|
||||||
|
October 18, 2011
|
||||||
|
! [kaori] rearranged opj_server, opj_dec_server directory
|
||||||
|
|
||||||
|
October 14, 2011
|
||||||
|
+ [kaori] enable all progression orders
|
||||||
|
|
||||||
|
October 12, 2011
|
||||||
|
+ [kaori] enable layers requests; restricting the number of codesream quality layers
|
||||||
|
|
||||||
|
October 11, 2011
|
||||||
|
+ [antonin] enable JPT-stream request from client viewer option (credit to kaori)
|
||||||
|
|
||||||
|
October 10, 2011
|
||||||
|
- [antonin] removed obsolete indexer utility (credit to kaori)
|
||||||
|
+ [antonin] enabled JPP-stream (credit to kaori)
|
||||||
|
|
||||||
|
September 16, 2011
|
||||||
|
+ [kaori] enabled stateless requests from the opj_viewers
|
||||||
|
|
||||||
|
Septempber 1, 2011
|
||||||
|
* [kaori] changed terminating status of opj_server in debug/non-server mode
|
||||||
|
|
||||||
|
August 27, 2011
|
||||||
|
* [antonin] fixed missing include directory in opj_client/opj_dec_server/CMakeLists.txt
|
||||||
|
|
||||||
|
August 26, 2011
|
||||||
|
* [antonin] fixed cmake and autotools files to reflect recent indexer changes in JPIP
|
||||||
|
! [kaori] indexer using the latest openjpeg library
|
||||||
|
* [antonin] fixed cmake and autotools files to reflect recent changes in JPIP
|
||||||
|
! [kaori] fixed Makefile.nix to load openjpeg library from this archive
|
||||||
|
|
||||||
|
August 25, 2011
|
||||||
|
+ [kaori] added tid request support to JPIP client
|
||||||
|
+ [kaori] added quit JPIP server request
|
||||||
|
|
||||||
|
August 24, 2011
|
||||||
|
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||||
|
+ [kaori] added tid request support to JPIP server
|
||||||
|
|
||||||
|
August 16, 2011
|
||||||
|
* [antonin] fixed cmake support for openjpip
|
||||||
|
|
||||||
|
August 12, 2011
|
||||||
|
+ [antonin] added cmake support to openjpip
|
||||||
|
|
||||||
|
July 6, 2011
|
||||||
|
* [antonin] JPIP : fixed autotools to work with recent name changes
|
||||||
|
|
||||||
|
July 5, 2011
|
||||||
|
! [kaori] changed parameter, file names, message names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||||
|
|
||||||
|
May 26, 2011
|
||||||
|
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||||
|
|
||||||
|
May 23, 2011
|
||||||
|
+ [antonin] added autotools for the 'tools' directory
|
||||||
|
+ [antonin] added autotools as a build method for jpip (credit to Vincent Torri)
|
||||||
|
|
||||||
|
May 10, 2011
|
||||||
|
! [kaori] opj_viewer removed the xml functions (for users without Xersus2)
|
||||||
|
+ [kaori] renamed opj_viewer to opj_viewer_xerces ( needs Xersus2)
|
||||||
|
! [kaori] Modification of opj_dec_server to be portable to windows
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [antonin] OpenJPIP: small bug fixes to compile on win platform
|
||||||
|
|
||||||
|
May 8, 2011
|
||||||
|
* [antonin] OpenJPIP: fixed several bugs in opj_server (removal of strsep function, duplication of query string) + some changes to compile opj_server under windows (replacement of strcasecmp(), bzero()).
|
||||||
|
|
||||||
|
April 14, 2011
|
||||||
|
+ [antonin] initial commit of OpenJPIP 1.0, a JPIP client-server architecture based on OpenJPEG (see README file in jpip directory for more details)
|
||||||
16
applications/jpip/CMakeLists.txt
Normal file
16
applications/jpip/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# required dep for server:
|
||||||
|
IF(BUILD_JPIP_SERVER)
|
||||||
|
FIND_PACKAGE(CURL REQUIRED)
|
||||||
|
FIND_PACKAGE(FCGI REQUIRED)
|
||||||
|
FIND_PACKAGE(Threads REQUIRED)
|
||||||
|
IF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
MESSAGE(FATAL_ERROR "Only pthread are supported")
|
||||||
|
ENDIF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
ENDIF(BUILD_JPIP_SERVER)
|
||||||
|
|
||||||
|
# JPIP library:
|
||||||
|
ADD_SUBDIRECTORY(libopenjpip)
|
||||||
|
|
||||||
|
# JPIP binaries:
|
||||||
|
ADD_SUBDIRECTORY(util)
|
||||||
|
|
||||||
3
applications/jpip/Makefile.am
Normal file
3
applications/jpip/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpip util
|
||||||
149
applications/jpip/README
Normal file
149
applications/jpip/README
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
========================================================================
|
||||||
|
OpenJPIP software 2.1 ReadMe
|
||||||
|
|
||||||
|
OpenJPEG:
|
||||||
|
http://www.openjpeg.org
|
||||||
|
|
||||||
|
Written by:
|
||||||
|
Kaori Hagihara
|
||||||
|
UCL/SST/ICTM/ELEN
|
||||||
|
February 18 2011
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
1. Introduction
|
||||||
|
2. License
|
||||||
|
3. System requirements
|
||||||
|
4. Implementing instructions
|
||||||
|
5. JP2 encoding instructions
|
||||||
|
|
||||||
|
|
||||||
|
----------
|
||||||
|
1. Introduction
|
||||||
|
----------
|
||||||
|
|
||||||
|
OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).
|
||||||
|
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
|
||||||
|
The current implementation uses some results from the 2KAN project (http://www.2kan.org).
|
||||||
|
|
||||||
|
Version 2.1 covers:
|
||||||
|
- JPT-stream (Tile) and JPP-stream (Precinct) media types
|
||||||
|
- Session, channels, cache model managements
|
||||||
|
- JPIP over HTTP, HTTP requests and TCP return
|
||||||
|
- Indexing JPEG 2000 files
|
||||||
|
- Embedding XML formatted metadata
|
||||||
|
- Region Of Interest (ROI) requests
|
||||||
|
- Access to JP2 files with their URL
|
||||||
|
|
||||||
|
----------
|
||||||
|
2. License
|
||||||
|
----------
|
||||||
|
|
||||||
|
This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.
|
||||||
|
The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||||
|
Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
|
||||||
|
----------
|
||||||
|
3. System requirements
|
||||||
|
----------
|
||||||
|
|
||||||
|
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||||
|
- libcURL library
|
||||||
|
- Java application launcher at client
|
||||||
|
<Optional>
|
||||||
|
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
|
||||||
|
|
||||||
|
We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||||
|
|
||||||
|
----------
|
||||||
|
4. Building instructions
|
||||||
|
----------
|
||||||
|
|
||||||
|
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
|
||||||
|
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
|
||||||
|
|
||||||
|
The documentation can be build this way (requires doxygen utility):
|
||||||
|
cd doc
|
||||||
|
doxygen Doxyfile
|
||||||
|
|
||||||
|
----------
|
||||||
|
5. Usage
|
||||||
|
----------
|
||||||
|
|
||||||
|
Preliminary notes :
|
||||||
|
* HTML documentation is available at http://www.openjpeg.org/jpip/doc/html
|
||||||
|
* Example image is available at http://www.openjpeg.org/jpip/data/copenhague1.zip (20 Mb !)
|
||||||
|
|
||||||
|
Webserver:
|
||||||
|
You need a webserver running with the fastcgi module enabled and correctly configured.
|
||||||
|
For Apache, add the following line to your /etc/apache2/mods-available/fastcgi.conf configuration file:
|
||||||
|
|
||||||
|
FastCGIExternalServer /var/www/myFCGI -host localhost:3000
|
||||||
|
|
||||||
|
where /var/www is your DocumentRoot.
|
||||||
|
Please refer to 'http://www.openjpeg.org/jpip/doc/ApacheFastCGITutorial.pdf' for more details.
|
||||||
|
|
||||||
|
Server:
|
||||||
|
1. Store JP2 files in the same directory as opj_server
|
||||||
|
|
||||||
|
2. Launch opj_server from the server terminal:
|
||||||
|
% spawn-fcgi -f ./opj_server -p 3000 -n
|
||||||
|
|
||||||
|
For shutting down JPIP server:
|
||||||
|
%GET http://hostname/myFCGI?quitJPIP
|
||||||
|
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
|
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
|
||||||
|
|
||||||
|
Client:
|
||||||
|
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||||
|
% ./opj_dec_server [portnumber (50000 by default)]
|
||||||
|
|
||||||
|
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||||
|
% mkdir cache
|
||||||
|
% cd cache
|
||||||
|
% ../opj_dec_server
|
||||||
|
|
||||||
|
2. Open image viewers (as many as needed)
|
||||||
|
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||||
|
( The arguments
|
||||||
|
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
|
- path/filename.jp2 is the server local path or URL of a JP2 file
|
||||||
|
- host name of opj_dec_server, localhost by default
|
||||||
|
- portnumber of opj_dec_server, 50000 by default
|
||||||
|
- request type stateless for no caching, session (default) for caching
|
||||||
|
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
||||||
|
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
||||||
|
Image viewer GUI instructions:
|
||||||
|
Scale up request: Enlarge the window
|
||||||
|
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
|
||||||
|
<If Xerces2 is installed>
|
||||||
|
% java -jar opj_viewer_xerces.jar http://hostname/myFCGI JP2_filename.jp2
|
||||||
|
Annotate image with ROI information in XML metadata: Click button "Region Of Interest"
|
||||||
|
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
|
||||||
|
|
||||||
|
3. Quit the image decoding server through the telnet, be sure all image viewers are closed
|
||||||
|
% telnet localhost 50000
|
||||||
|
quit
|
||||||
|
|
||||||
|
----------
|
||||||
|
5. JP2 encoding instructions
|
||||||
|
----------
|
||||||
|
|
||||||
|
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
|
||||||
|
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
||||||
|
|
||||||
|
options
|
||||||
|
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
||||||
|
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
||||||
|
|
||||||
|
<Option>
|
||||||
|
3. Embed metadata into JP2 file
|
||||||
|
% ./addXMLinJP2 copenhague1.jp2 copenhague1.xml
|
||||||
|
Input metadata file "copenhague1.xml" looks like:
|
||||||
|
<xmlbox>
|
||||||
|
<roi name="island" x="1890" y="1950" w="770" h="310"/>
|
||||||
|
<roi name="ship" x="750" y="330" w="100" h="60"/>
|
||||||
|
<roi name="airport" x="650" y="1800" w="650" h="800"/>
|
||||||
|
<roi name="harbor" x="4200" y="1650" w="130" h="130"/>
|
||||||
|
<irt refimg="name1.jp2" m1="0.50" m2="-0.50" m3="0" m4="0.80" m5="-0.80" m6="0" m7="500" m8="1000" m9="0"/>
|
||||||
|
</xmlbox>
|
||||||
1514
applications/jpip/doc/Doxyfile
Normal file
1514
applications/jpip/doc/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
BIN
applications/jpip/doc/jpip_architect.png
Normal file
BIN
applications/jpip/doc/jpip_architect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
applications/jpip/doc/jpip_protocol.png
Normal file
BIN
applications/jpip/doc/jpip_protocol.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
72
applications/jpip/libopenjpip/CMakeLists.txt
Normal file
72
applications/jpip/libopenjpip/CMakeLists.txt
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${FCGI_INCLUDE_DIRS}
|
||||||
|
${CURL_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Defines the source code for the library
|
||||||
|
SET(OPENJPIP_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/boxheader_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/codestream_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/imgreg_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/marker_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/msgqueue_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/box_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/faixbox_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/index_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/metadata_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/placeholder_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/byte_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ihdrbox_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/manfbox_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mhixbox_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/target_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cachemodel_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/j2kheader_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_encoder.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/openjpip.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/query_parser.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/channel_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(SERVER_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/auxtrans_manager.c
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(LOCAL_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/dec_clientmsg_handler.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build the library
|
||||||
|
ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME})
|
||||||
|
IF(WIN32)
|
||||||
|
# add Winsock on windows+mingw
|
||||||
|
TARGET_LINK_LIBRARIES(openjpip_local ws2_32)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
# Install library
|
||||||
|
INSTALL(TARGETS openjpip_local
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(BUILD_JPIP_SERVER)
|
||||||
|
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
SET_TARGET_PROPERTIES(openjpip_server
|
||||||
|
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
||||||
|
INSTALL(TARGETS openjpip_server
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||||
|
)
|
||||||
|
ENDIF(BUILD_JPIP_SERVER)
|
||||||
151
applications/jpip/libopenjpip/Makefile.am
Normal file
151
applications/jpip/libopenjpip/Makefile.am
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
|
||||||
|
includes_HEADERS =
|
||||||
|
|
||||||
|
lib_LTLIBRARIES =
|
||||||
|
|
||||||
|
if WANT_JPIP
|
||||||
|
lib_LTLIBRARIES += libopenjpip_local.la
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WANT_JPIP_SERVER
|
||||||
|
lib_LTLIBRARIES += libopenjpip_server.la
|
||||||
|
endif
|
||||||
|
|
||||||
|
JPIP_SRC = \
|
||||||
|
openjpip.c \
|
||||||
|
query_parser.c \
|
||||||
|
channel_manager.c \
|
||||||
|
session_manager.c \
|
||||||
|
jpip_parser.c \
|
||||||
|
boxheader_manager.c \
|
||||||
|
codestream_manager.c \
|
||||||
|
imgreg_manager.c \
|
||||||
|
marker_manager.c \
|
||||||
|
msgqueue_manager.c \
|
||||||
|
box_manager.c \
|
||||||
|
faixbox_manager.c \
|
||||||
|
index_manager.c \
|
||||||
|
metadata_manager.c \
|
||||||
|
placeholder_manager.c \
|
||||||
|
byte_manager.c \
|
||||||
|
ihdrbox_manager.c \
|
||||||
|
manfbox_manager.c \
|
||||||
|
mhixbox_manager.c \
|
||||||
|
target_manager.c \
|
||||||
|
cachemodel_manager.c \
|
||||||
|
j2kheader_manager.c \
|
||||||
|
jp2k_encoder.c \
|
||||||
|
sock_manager.c \
|
||||||
|
openjpip.h \
|
||||||
|
bool.h \
|
||||||
|
boxheader_manager.h \
|
||||||
|
box_manager.h \
|
||||||
|
byte_manager.h \
|
||||||
|
codestream_manager.h \
|
||||||
|
faixbox_manager.h \
|
||||||
|
ihdrbox_manager.h \
|
||||||
|
imgreg_manager.h \
|
||||||
|
index_manager.h \
|
||||||
|
manfbox_manager.h \
|
||||||
|
marker_manager.h \
|
||||||
|
metadata_manager.h \
|
||||||
|
mhixbox_manager.h \
|
||||||
|
msgqueue_manager.h \
|
||||||
|
placeholder_manager.h \
|
||||||
|
target_manager.h \
|
||||||
|
cachemodel_manager.h \
|
||||||
|
j2kheader_manager.h \
|
||||||
|
jp2k_encoder.h \
|
||||||
|
query_parser.h \
|
||||||
|
channel_manager.h \
|
||||||
|
session_manager.h \
|
||||||
|
jpip_parser.h \
|
||||||
|
jp2k_decoder.h \
|
||||||
|
sock_manager.h
|
||||||
|
|
||||||
|
SERVER_SRC = auxtrans_manager.c \
|
||||||
|
auxtrans_manager.h
|
||||||
|
|
||||||
|
LOCAL_SRC = jp2k_decoder.c \
|
||||||
|
imgsock_manager.c \
|
||||||
|
jpipstream_manager.c \
|
||||||
|
cache_manager.c \
|
||||||
|
dec_clientmsg_handler.c \
|
||||||
|
imgsock_manager.h \
|
||||||
|
jpipstream_manager.h \
|
||||||
|
cache_manager.h \
|
||||||
|
dec_clientmsg_handler.h
|
||||||
|
|
||||||
|
libopenjpip_server_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||||
|
@FCGI_CFLAGS@ \
|
||||||
|
@LIBCURL_CFLAGS@ \
|
||||||
|
-DSERVER
|
||||||
|
libopenjpip_server_la_CFLAGS = @THREAD_CFLAGS@
|
||||||
|
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ @LIBCURL_LIBS@ @THREAD_LIBS@ -lm
|
||||||
|
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_server_la_SOURCES = $(JPIP_SRC) $(SERVER_SRC)
|
||||||
|
|
||||||
|
libopenjpip_local_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||||
|
@LIBCURL_CFLAGS@
|
||||||
|
libopenjpip_local_la_CFLAGS =
|
||||||
|
libopenjpip_local_la_LIBADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
|
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
if WANT_JPIP_SERVER
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
|
||||||
|
if BUILD_SHARED
|
||||||
|
@( $(call solist_s) ) >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
if BUILD_STATIC
|
||||||
|
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if WANT_JPIP
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
|
||||||
|
if BUILD_SHARED
|
||||||
|
@( $(call solist_c) ) >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
if BUILD_STATIC
|
||||||
|
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
solist_s = $(foreach f, $(dll_s) $(so_s), echo -e ' $(SO_PREFIX)\t$(base_s)/$(f)' ;)
|
||||||
|
get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)
|
||||||
|
base_s = $(call get_tok_s,libdir)
|
||||||
|
so_s = $(call get_tok_s,library_names)
|
||||||
|
a_s = $(call get_tok_s,old_library)
|
||||||
|
|
||||||
|
solist_c = $(foreach f, $(dll_c) $(so_c), echo -e ' $(SO_PREFIX)\t$(base_c)/$(f)' ;)
|
||||||
|
get_tok_c = $(shell grep -E "^$(1)=" libopenjpip_local.la | cut -d "'" -f 2)
|
||||||
|
base_c = $(call get_tok_c,libdir)
|
||||||
|
so_c = $(call get_tok_c,library_names)
|
||||||
|
a_c = $(call get_tok_c,old_library)
|
||||||
|
|
||||||
|
if HAVE_WIN32
|
||||||
|
SO_PREFIX = (DLL)
|
||||||
|
dll_s = $(call get_tok_s,dlname)
|
||||||
|
dll_c = $(call get_tok_c,dlname)
|
||||||
|
else
|
||||||
|
if HAVE_DARWIN
|
||||||
|
SO_PREFIX = (DY)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
else
|
||||||
|
SO_PREFIX = (SO)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
endif
|
||||||
|
endif
|
||||||
267
applications/jpip/libopenjpip/auxtrans_manager.c
Normal file
267
applications/jpip/libopenjpip/auxtrans_manager.c
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "auxtrans_manager.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <process.h>
|
||||||
|
#else
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||||
|
{
|
||||||
|
auxtrans_param_t auxtrans;
|
||||||
|
|
||||||
|
auxtrans.tcpauxport = tcp_auxport;
|
||||||
|
auxtrans.udpauxport = udp_auxport;
|
||||||
|
|
||||||
|
if( 49152 <= tcp_auxport && tcp_auxport <= 65535)
|
||||||
|
auxtrans.tcplistensock = open_listeningsocket( tcp_auxport);
|
||||||
|
else
|
||||||
|
auxtrans.tcplistensock = -1;
|
||||||
|
|
||||||
|
auxtrans.udplistensock = -1;
|
||||||
|
/* open listening socket for udp later */
|
||||||
|
|
||||||
|
return auxtrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
void close_aux_transport( auxtrans_param_t auxtrans)
|
||||||
|
{
|
||||||
|
if( auxtrans.tcplistensock != -1)
|
||||||
|
if( close_socket( auxtrans.tcplistensock) != 0)
|
||||||
|
perror("close");
|
||||||
|
|
||||||
|
if( auxtrans.udplistensock != -1)
|
||||||
|
if( close_socket( auxtrans.udplistensock) != 0)
|
||||||
|
perror("close");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!< auxiliary response parameters */
|
||||||
|
typedef struct aux_response_param{
|
||||||
|
char *cid; /*!< channel ID */
|
||||||
|
unsigned char *data; /*!< sending data */
|
||||||
|
int datalen; /*!< length of data */
|
||||||
|
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||||
|
SOCKET listensock; /*!< listeing socket */
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE hTh; /*!< thread handle */
|
||||||
|
#endif
|
||||||
|
} aux_response_param_t;
|
||||||
|
|
||||||
|
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame);
|
||||||
|
|
||||||
|
void delete_auxresponse( aux_response_param_t **auxresponse);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned __stdcall aux_streaming( void *arg);
|
||||||
|
#else
|
||||||
|
void * aux_streaming( void *arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||||
|
{
|
||||||
|
aux_response_param_t *auxresponse;
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned int threadId;
|
||||||
|
#else
|
||||||
|
pthread_t thread;
|
||||||
|
int status;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( istcp){
|
||||||
|
if( auxtrans.tcplistensock == -1){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), tcp listening socket no open\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId);
|
||||||
|
if( auxresponse->hTh == 0)
|
||||||
|
fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh));
|
||||||
|
#else
|
||||||
|
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
|
||||||
|
if( status != 0)
|
||||||
|
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||||
|
{
|
||||||
|
aux_response_param_t *auxresponse;
|
||||||
|
|
||||||
|
auxresponse = (aux_response_param_t *)malloc( sizeof(aux_response_param_t));
|
||||||
|
|
||||||
|
auxresponse->cid = strdup( cid);
|
||||||
|
auxresponse->data = data;
|
||||||
|
auxresponse->datalen = datalen;
|
||||||
|
auxresponse->maxlenPerFrame = maxlenPerFrame;
|
||||||
|
auxresponse->listensock = istcp ? auxtrans.tcplistensock : auxtrans.udplistensock;
|
||||||
|
|
||||||
|
return auxresponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_auxresponse( aux_response_param_t **auxresponse)
|
||||||
|
{
|
||||||
|
free( (*auxresponse)->cid);
|
||||||
|
free( (*auxresponse)->data);
|
||||||
|
free( *auxresponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify cid sent from client
|
||||||
|
*
|
||||||
|
* @param [in] connected_socket file descriptor of the connected socket
|
||||||
|
* @param [in] refcid refenrece channel ID
|
||||||
|
* @param [in] fp file pointer for log of aux stream
|
||||||
|
* @return true if identified, false otherwise
|
||||||
|
*/
|
||||||
|
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp);
|
||||||
|
|
||||||
|
bool recv_ack( SOCKET connected_socket, void *data);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
unsigned __stdcall aux_streaming( void *arg)
|
||||||
|
#else
|
||||||
|
void * aux_streaming( void *arg)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
SOCKET connected_socket;
|
||||||
|
unsigned char *chunk, *ptr;
|
||||||
|
int maxLenOfBody, remlen, chunklen;
|
||||||
|
const int headlen = 8;
|
||||||
|
|
||||||
|
aux_response_param_t *auxresponse = (aux_response_param_t *)arg;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
CloseHandle( auxresponse->hTh);
|
||||||
|
#else
|
||||||
|
pthread_detach( pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame);
|
||||||
|
maxLenOfBody = auxresponse->maxlenPerFrame - headlen;
|
||||||
|
remlen = auxresponse->datalen;
|
||||||
|
|
||||||
|
while((connected_socket = accept_socket( auxresponse->listensock)) != -1){
|
||||||
|
if( identify_cid( connected_socket, auxresponse->cid, FCGI_stderr)){
|
||||||
|
ptr = auxresponse->data;
|
||||||
|
while( 0 < remlen){
|
||||||
|
memset( chunk, 0, auxresponse->maxlenPerFrame);
|
||||||
|
|
||||||
|
chunklen = remlen<maxLenOfBody?remlen:maxLenOfBody;
|
||||||
|
chunklen += headlen;
|
||||||
|
|
||||||
|
chunk[0] = (chunklen >> 8) & 0xff;
|
||||||
|
chunk[1] = chunklen & 0xff;
|
||||||
|
|
||||||
|
memcpy( chunk+headlen, ptr, chunklen-headlen);
|
||||||
|
|
||||||
|
do{
|
||||||
|
send_stream( connected_socket, chunk, chunklen);
|
||||||
|
}while( !recv_ack( connected_socket, chunk));
|
||||||
|
|
||||||
|
remlen -= maxLenOfBody;
|
||||||
|
ptr += maxLenOfBody;
|
||||||
|
}
|
||||||
|
if( close_socket( connected_socket) != 0)
|
||||||
|
perror("close");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free( chunk);
|
||||||
|
|
||||||
|
delete_auxresponse( &auxresponse);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
_endthreadex(0);
|
||||||
|
#else
|
||||||
|
pthread_exit(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp)
|
||||||
|
{
|
||||||
|
char *cid;
|
||||||
|
bool succeed;
|
||||||
|
|
||||||
|
if(!(cid = receive_string( connected_socket))){
|
||||||
|
fprintf( fp, "Error: error in identify_cid(), while receiving cid from client\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
succeed = false;
|
||||||
|
if( strncmp( refcid, cid, strlen( refcid)) == 0)
|
||||||
|
succeed = true;
|
||||||
|
|
||||||
|
free( cid);
|
||||||
|
|
||||||
|
return succeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool recv_ack( SOCKET connected_socket, void *data)
|
||||||
|
{
|
||||||
|
char *header;
|
||||||
|
bool succeed;
|
||||||
|
|
||||||
|
header = receive_stream( connected_socket, 8);
|
||||||
|
|
||||||
|
if( memcmp( header, data, 8) != 0)
|
||||||
|
succeed = false;
|
||||||
|
else
|
||||||
|
succeed = true;
|
||||||
|
|
||||||
|
free( header);
|
||||||
|
|
||||||
|
return succeed;
|
||||||
|
}
|
||||||
72
applications/jpip/libopenjpip/auxtrans_manager.h
Normal file
72
applications/jpip/libopenjpip/auxtrans_manager.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AUXTRANS_MANAGER_H_
|
||||||
|
# define AUXTRANS_MANAGER_H_
|
||||||
|
|
||||||
|
#include "sock_manager.h"
|
||||||
|
|
||||||
|
/** auxiliary transport setting parameters*/
|
||||||
|
typedef struct auxtrans_param{
|
||||||
|
int tcpauxport; /**< tcp port*/
|
||||||
|
int udpauxport; /**< udp port*/
|
||||||
|
SOCKET tcplistensock; /**< listenning socket for aux tcp (-1 if not open)*/
|
||||||
|
SOCKET udplistensock; /**< listenning socket for aux udp (-1 if not open)*/
|
||||||
|
} auxtrans_param_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize auxiliary transport server of JPIP server
|
||||||
|
*
|
||||||
|
* @param[in] tcp_auxport opening tcp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||||
|
* @param[in] udp_auxport opening udp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||||
|
* @return intialized transport parameters
|
||||||
|
*/
|
||||||
|
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close auxiliary transport server of JPIP server
|
||||||
|
*
|
||||||
|
* @param[in] auxtrans closing transport server
|
||||||
|
*/
|
||||||
|
void close_aux_transport( auxtrans_param_t auxtrans);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send response data on aux transport
|
||||||
|
*
|
||||||
|
* @param[in] istcp true if tcp, false if udp
|
||||||
|
* @param[in] auxtrans available transport parameters
|
||||||
|
* @param[in] cid channel ID
|
||||||
|
* @param[in] data sending data
|
||||||
|
* @param[in] length length of data
|
||||||
|
* @param[in] maxlenPerFrame maximum data length to send per frame
|
||||||
|
*/
|
||||||
|
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int length, int maxlenPerFrame);
|
||||||
|
|
||||||
|
#endif /* !AUXTRANS_MANAGER_H_ */
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
* $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.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -24,10 +28,25 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef BOOL_H_
|
||||||
|
# define BOOL_H_
|
||||||
|
|
||||||
#ifndef __FIX_H
|
#ifndef false
|
||||||
#define __FIX_H
|
#define false 0
|
||||||
|
|
||||||
int fix_mul(int a, int b);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef true
|
||||||
|
#define true (!false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (!FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef char bool;
|
||||||
|
|
||||||
|
#endif /* !BOOL_H_ */
|
||||||
415
applications/jpip/libopenjpip/box_manager.c
Normal file
415
applications/jpip/libopenjpip/box_manager.c
Normal file
@@ -0,0 +1,415 @@
|
|||||||
|
/*
|
||||||
|
* $Id: box_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include "box_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
boxlist_param_t * gene_boxlist()
|
||||||
|
{
|
||||||
|
boxlist_param_t *boxlist;
|
||||||
|
|
||||||
|
boxlist = (boxlist_param_t *)malloc( sizeof(boxlist_param_t));
|
||||||
|
|
||||||
|
boxlist->first = NULL;
|
||||||
|
boxlist->last = NULL;
|
||||||
|
|
||||||
|
return boxlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
|
||||||
|
{
|
||||||
|
boxlist_param_t *boxlist;
|
||||||
|
box_param_t *box;
|
||||||
|
int pos;
|
||||||
|
|
||||||
|
boxlist = NULL;
|
||||||
|
pos = offset;
|
||||||
|
do{
|
||||||
|
if(!(box = gene_boxbyOffset( fd, pos)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
pos += box->length;
|
||||||
|
|
||||||
|
if( !boxlist)
|
||||||
|
boxlist = gene_boxlist();
|
||||||
|
insert_box_into_list( box, boxlist);
|
||||||
|
}while( pos < (int)(offset+length));
|
||||||
|
|
||||||
|
return boxlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
/* box type constraint*/
|
||||||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
|
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||||
|
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||||
|
free( data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
Byte_t *data2;
|
||||||
|
headlen = 16;
|
||||||
|
/* read XLBox*/
|
||||||
|
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
||||||
|
boxlen = big8(data2);
|
||||||
|
free(data2);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
|
free( data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
box->fd = fd;
|
||||||
|
box->offset = offset;
|
||||||
|
box->headlen = headlen;
|
||||||
|
box->length = boxlen;
|
||||||
|
strncpy( box->type, boxtype, 4);
|
||||||
|
box->next = NULL;
|
||||||
|
free( data);
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||||
|
{
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4( stream);
|
||||||
|
boxtype = (char *)( stream+4);
|
||||||
|
|
||||||
|
/* box type constraint*/
|
||||||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
|
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||||
|
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
headlen = 16;
|
||||||
|
boxlen = big8( stream+8); /* read XLBox*/
|
||||||
|
}
|
||||||
|
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
box->fd = -1;
|
||||||
|
box->offset = offset;
|
||||||
|
box->headlen = headlen;
|
||||||
|
box->length = boxlen;
|
||||||
|
strncpy( box->type, boxtype, 4);
|
||||||
|
box->next = NULL;
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
|
{
|
||||||
|
Byte8_t pos;
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|
||||||
|
if( length==0){ /* set the max length*/
|
||||||
|
if( (length = get_filesize( fd) - offset) <= 0)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = offset;
|
||||||
|
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
if((data = fetch_bytes( fd, pos, 8))){
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
Byte_t *data2;
|
||||||
|
headlen = 16;
|
||||||
|
/* read XLBox*/
|
||||||
|
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
||||||
|
boxlen = big8(data2);
|
||||||
|
free(data2);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||||
|
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
foundbox->fd = fd;
|
||||||
|
foundbox->offset = pos;
|
||||||
|
foundbox->headlen = headlen;
|
||||||
|
foundbox->length = boxlen;
|
||||||
|
strncpy( foundbox->type, TBox, 4);
|
||||||
|
foundbox->next = NULL;
|
||||||
|
free( data);
|
||||||
|
return foundbox;
|
||||||
|
}
|
||||||
|
free( data);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pos+= boxlen;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||||
|
{
|
||||||
|
Byte8_t pos;
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t boxlen, headlen;
|
||||||
|
char *boxtype;
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|
||||||
|
if( length<=0){ /* set the max length*/
|
||||||
|
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = offset;
|
||||||
|
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||||
|
|
||||||
|
/* read LBox and TBox*/
|
||||||
|
data = stream + pos;
|
||||||
|
headlen = 8;
|
||||||
|
boxlen = (Byte8_t)big4(data);
|
||||||
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
|
if( boxlen == 1){
|
||||||
|
/* read XLBox*/
|
||||||
|
headlen = 16;
|
||||||
|
boxlen = big8( data+8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||||
|
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
|
foundbox->fd = -1;
|
||||||
|
foundbox->offset = pos;
|
||||||
|
foundbox->headlen = headlen;
|
||||||
|
foundbox->length = boxlen;
|
||||||
|
strncpy( foundbox->type, TBox, 4);
|
||||||
|
foundbox->next = NULL;
|
||||||
|
return foundbox;
|
||||||
|
}
|
||||||
|
pos+= boxlen;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||||
|
{
|
||||||
|
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[])
|
||||||
|
{
|
||||||
|
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_DBoxoff( box_param_t *box)
|
||||||
|
{
|
||||||
|
return box->offset+box->headlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_DBoxlen( box_param_t *box)
|
||||||
|
{
|
||||||
|
return box->length-box->headlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t * fetch_headbytes( box_param_t *box)
|
||||||
|
{
|
||||||
|
return fetch_bytes( box->fd, box->offset, box->headlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size)
|
||||||
|
{
|
||||||
|
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
||||||
|
{
|
||||||
|
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
box_param_t * search_box( const char type[], boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
foundbox = boxlist->first;
|
||||||
|
|
||||||
|
while( foundbox != NULL){
|
||||||
|
|
||||||
|
if( strncmp( type, foundbox->type, 4) == 0)
|
||||||
|
return foundbox;
|
||||||
|
|
||||||
|
foundbox = foundbox->next;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", type);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_box( box_param_t *box)
|
||||||
|
{
|
||||||
|
fprintf( logstream, "box info:\n"
|
||||||
|
"\t type: %.4s\n"
|
||||||
|
"\t offset: %lld %#llx\n"
|
||||||
|
"\t header length: %d\n"
|
||||||
|
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allbox( boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *ptr;
|
||||||
|
|
||||||
|
if( !boxlist)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ptr = boxlist->first;
|
||||||
|
if( !ptr)
|
||||||
|
fprintf( logstream, "no box\n");
|
||||||
|
|
||||||
|
fprintf( logstream, "all box info: \n");
|
||||||
|
while( ptr != NULL){
|
||||||
|
print_box( ptr);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *ptr;
|
||||||
|
|
||||||
|
if( *box == boxlist->first)
|
||||||
|
boxlist->first = (*box)->next;
|
||||||
|
else{
|
||||||
|
ptr = boxlist->first;
|
||||||
|
while( ptr->next != *box){
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
ptr->next = (*box)->next;
|
||||||
|
|
||||||
|
if( *box == boxlist->last)
|
||||||
|
boxlist->last = ptr;
|
||||||
|
}
|
||||||
|
free( *box);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *box;
|
||||||
|
|
||||||
|
box = search_box( type, boxlist);
|
||||||
|
delete_box_in_list( &box, boxlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_boxlist( boxlist_param_t **boxlist)
|
||||||
|
{
|
||||||
|
box_param_t *boxPtr, *boxNext;
|
||||||
|
|
||||||
|
if(!(*boxlist))
|
||||||
|
return;
|
||||||
|
|
||||||
|
boxPtr = (*boxlist)->first;
|
||||||
|
while( boxPtr != NULL){
|
||||||
|
boxNext=boxPtr->next;
|
||||||
|
free( boxPtr);
|
||||||
|
boxPtr=boxNext;
|
||||||
|
}
|
||||||
|
free( *boxlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist)
|
||||||
|
{
|
||||||
|
if( boxlist->first)
|
||||||
|
boxlist->last->next = box;
|
||||||
|
else
|
||||||
|
boxlist->first = box;
|
||||||
|
boxlist->last = box;
|
||||||
|
}
|
||||||
264
applications/jpip/libopenjpip/box_manager.h
Normal file
264
applications/jpip/libopenjpip/box_manager.h
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
/*
|
||||||
|
* $Id: box_manager.h 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BOX_MANAGER_H_
|
||||||
|
# define BOX_MANAGER_H_
|
||||||
|
|
||||||
|
#include "byte_manager.h"
|
||||||
|
|
||||||
|
/** box parameters*/
|
||||||
|
typedef struct box_param{
|
||||||
|
int fd; /**< file descriptor*/
|
||||||
|
Byte8_t offset; /**< byte position of the whole Box (LBox) in the file*/
|
||||||
|
Byte_t headlen; /**< header length 8 or 16*/
|
||||||
|
Byte8_t length; /**< length of the whole Box*/
|
||||||
|
char type[4]; /**< type of information in the DBox*/
|
||||||
|
struct box_param *next; /**< pointer to the next box*/
|
||||||
|
} box_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/** Box list parameters*/
|
||||||
|
typedef struct boxlist_param{
|
||||||
|
box_param_t *first; /**< first box pointer of the list*/
|
||||||
|
box_param_t *last; /**< last box pointer of the list*/
|
||||||
|
} boxlist_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a box list
|
||||||
|
*
|
||||||
|
* @return pointer to the generated box list
|
||||||
|
*/
|
||||||
|
boxlist_param_t * gene_boxlist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get box structure of JP2 file
|
||||||
|
*
|
||||||
|
* @param[in] fd file descriptor
|
||||||
|
* @param[in] offset offset of the decomposing region
|
||||||
|
* @param[in] length length of the decomposing region
|
||||||
|
* @return pointer to the generated boxlist
|
||||||
|
*/
|
||||||
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate box from JP2 file at the given offset
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor of the JP2 file
|
||||||
|
* @param[in] offset Box offset
|
||||||
|
* @return pointer to the structure of generate box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate box from code stream (JPP or JPT stream) at the given offset
|
||||||
|
*
|
||||||
|
* @param[in] stream code stream of a box
|
||||||
|
* @param[in] offset Box offset of the whole stream
|
||||||
|
* @return pointer to the structure of generate box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate(search) box from JP2 file
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor of the JP2 file
|
||||||
|
* @param[in] offset start Byte position of the search
|
||||||
|
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||||
|
* @param[in] TBox Box Type
|
||||||
|
* @return pointer to the structure of generate/found box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate(search) box from code stream
|
||||||
|
*
|
||||||
|
* @param[in] stream code stream ( from the first byte)
|
||||||
|
* @param[in] offset start Byte position of the search
|
||||||
|
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||||
|
* @param[in] TBox Box Type
|
||||||
|
* @return pointer to the structure of generate/found box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate child box from JP2 file at the given offset
|
||||||
|
*
|
||||||
|
* @param[in] superbox super box pointer
|
||||||
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
|
* @return pointer to the structure of generate box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate(search) box from JP2 file
|
||||||
|
*
|
||||||
|
* @param[in] superbox super box pointer
|
||||||
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
|
* @param[in] TBox Box Type
|
||||||
|
* @return pointer to the structure of generate/found box parameters
|
||||||
|
*/
|
||||||
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get DBox offset
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @return DBox offset (byte position) in the file
|
||||||
|
*/
|
||||||
|
Byte8_t get_DBoxoff( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get DBox length
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @return DBox length ( content length)
|
||||||
|
*/
|
||||||
|
Byte8_t get_DBoxlen( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch header bytes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @return pointer to the fetched bytes
|
||||||
|
*/
|
||||||
|
Byte_t * fetch_headbytes( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch DBox (Box Contents) bytes of data in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] offset start Byte position in DBox
|
||||||
|
* @param[in] size Byte length
|
||||||
|
* @return pointer to the fetched data
|
||||||
|
*/
|
||||||
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] offset start Byte position in DBox
|
||||||
|
* @return fetched code
|
||||||
|
*/
|
||||||
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] offset start Byte position in DBox
|
||||||
|
* @return fetched code
|
||||||
|
*/
|
||||||
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] offset start Byte position in DBox
|
||||||
|
* @return fetched code
|
||||||
|
*/
|
||||||
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] offset start Byte position in DBox
|
||||||
|
* @return fetched code
|
||||||
|
*/
|
||||||
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a box by box type
|
||||||
|
*
|
||||||
|
* @param[in] type box type
|
||||||
|
* @param[in] boxlist box list pointer
|
||||||
|
* @return found box pointer
|
||||||
|
*/
|
||||||
|
box_param_t * search_box( const char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print box parameters
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
*/
|
||||||
|
void print_box( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print all box parameters
|
||||||
|
*
|
||||||
|
* @param[in] boxlist box list pointer
|
||||||
|
*/
|
||||||
|
void print_allbox( boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a box in list
|
||||||
|
*
|
||||||
|
* @param[in,out] box address of the deleting box pointer
|
||||||
|
* @param[in] boxlist box list pointer
|
||||||
|
*/
|
||||||
|
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a box in list by Type
|
||||||
|
*
|
||||||
|
* @param[in,out] type box type
|
||||||
|
* @param[in] boxlist box list pointer
|
||||||
|
*/
|
||||||
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete box list
|
||||||
|
*
|
||||||
|
* @param[in,out] boxlist address of the box list pointer
|
||||||
|
*/
|
||||||
|
void delete_boxlist( boxlist_param_t **boxlist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* insert a box into list
|
||||||
|
*
|
||||||
|
* @param[in] box box pointer
|
||||||
|
* @param[in] boxlist box list pointer
|
||||||
|
*/
|
||||||
|
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
#endif /* !BOX_MANAGER_H_ */
|
||||||
83
applications/jpip/libopenjpip/boxheader_manager.c
Normal file
83
applications/jpip/libopenjpip/boxheader_manager.c
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* $Id: boxheader_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 <string.h>
|
||||||
|
#include <stdlib.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*/
|
||||||
|
|
||||||
|
|
||||||
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||||
|
{
|
||||||
|
Byte8_t boxlen;
|
||||||
|
Byte_t headlen;
|
||||||
|
char *boxtype;
|
||||||
|
boxheader_param_t *boxheader;
|
||||||
|
|
||||||
|
boxlen = fetch_4bytebigendian( fd, offset);
|
||||||
|
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||||
|
headlen = 8;
|
||||||
|
|
||||||
|
if( boxlen == 1){ /* read XLBox */
|
||||||
|
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||||
|
headlen = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
||||||
|
boxheader->headlen = headlen;
|
||||||
|
boxheader->length = boxlen;
|
||||||
|
strncpy( boxheader->type, boxtype, 4);
|
||||||
|
boxheader->next = NULL;
|
||||||
|
|
||||||
|
free( boxtype);
|
||||||
|
return boxheader;
|
||||||
|
}
|
||||||
|
|
||||||
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset)
|
||||||
|
{
|
||||||
|
return gene_boxheader( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_boxheader( boxheader_param_t *boxheader)
|
||||||
|
{
|
||||||
|
fprintf( logstream, "boxheader info:\n"
|
||||||
|
"\t type: %.4s\n"
|
||||||
|
"\t length:%lld %#llx\n", boxheader->type, boxheader->length, boxheader->length);
|
||||||
|
}
|
||||||
71
applications/jpip/libopenjpip/boxheader_manager.h
Normal file
71
applications/jpip/libopenjpip/boxheader_manager.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* $Id: boxheader_manager.h 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BOXHEADER_MANAGER_H_
|
||||||
|
# define BOXHEADER_MANAGER_H_
|
||||||
|
|
||||||
|
#include "byte_manager.h"
|
||||||
|
#include "box_manager.h"
|
||||||
|
|
||||||
|
/** box header parameters*/
|
||||||
|
typedef struct boxheader_param{
|
||||||
|
Byte_t headlen; /**< header length 8 or 16*/
|
||||||
|
Byte8_t length; /**< length of the reference Box*/
|
||||||
|
char type[4]; /**< type of information in the DBox*/
|
||||||
|
struct boxheader_param *next; /**< pointer to the next header box*/
|
||||||
|
} boxheader_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a box header at the given offset
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor of the JP2 file
|
||||||
|
* @param[in] offset Box offset
|
||||||
|
* @return pointer to the structure of generate box header parameters
|
||||||
|
*/
|
||||||
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a child box header at the given offset
|
||||||
|
*
|
||||||
|
* @param[in] superbox super box pointer
|
||||||
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
|
* @return pointer to the structure of generate box header parameters
|
||||||
|
*/
|
||||||
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print box header parameters
|
||||||
|
*
|
||||||
|
* @param[in] boxheader boxheader pointer
|
||||||
|
*/
|
||||||
|
void print_boxheader( boxheader_param_t *boxheader);
|
||||||
|
|
||||||
|
#endif /* !BOXHEADER_MANAGER_H_ */
|
||||||
172
applications/jpip/libopenjpip/byte_manager.c
Normal file
172
applications/jpip/libopenjpip/byte_manager.c
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* $Id: byte_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "byte_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
|
Byte_t * fetch_bytes( int fd, long offset, int size)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
|
||||||
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (Byte_t *)malloc( size);
|
||||||
|
|
||||||
|
if( read( fd, data, size) != size){
|
||||||
|
free( data);
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t fetch_1byte( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t code;
|
||||||
|
|
||||||
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( read( fd, &code, 1) != 1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte2_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big2(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte4_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big4(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||||
|
{
|
||||||
|
Byte_t *data;
|
||||||
|
Byte8_t code;
|
||||||
|
|
||||||
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
|
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
code = big8(data);
|
||||||
|
free( data);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Byte2_t big2( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t big4( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((((((Byte4_t) buf[0]) << 8) + ((Byte4_t) buf[1])) << 8)
|
||||||
|
+ ((Byte4_t) buf[2])) << 8) + ((Byte4_t) buf[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t big8( Byte_t *buf)
|
||||||
|
{
|
||||||
|
return (((Byte8_t) big4 (buf)) << 32)
|
||||||
|
+ ((Byte8_t) big4 (buf + 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void modify_4Bytecode( Byte4_t code, Byte_t *stream)
|
||||||
|
{
|
||||||
|
*stream = (Byte_t) ((Byte4_t)(code & 0xff000000) >> 24);
|
||||||
|
*(stream+1) = (Byte_t) ((Byte4_t)(code & 0x00ff0000) >> 16);
|
||||||
|
*(stream+2) = (Byte_t) ((Byte4_t)(code & 0x0000ff00) >> 8);
|
||||||
|
*(stream+3) = (Byte_t) (code & 0x000000ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte8_t get_filesize( int fd)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if( fstat( fd, &sb) == -1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
||||||
|
fprintf( FCGI_stderr, "Error: error in get_filesize( %d)\n", fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (Byte8_t)sb.st_size;
|
||||||
|
}
|
||||||
145
applications/jpip/libopenjpip/byte_manager.h
Normal file
145
applications/jpip/libopenjpip/byte_manager.h
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* $Id: byte_manager.h 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BYTE_MANAGER_H_
|
||||||
|
#define BYTE_MANAGER_H_
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef uint8_t Byte_t;
|
||||||
|
typedef uint16_t Byte2_t;
|
||||||
|
typedef uint32_t Byte4_t;
|
||||||
|
typedef uint64_t Byte8_t;
|
||||||
|
#else
|
||||||
|
#if defined(_WIN32)
|
||||||
|
/** 1Byte parameter type*/
|
||||||
|
typedef unsigned __int8 Byte_t;
|
||||||
|
/** 2Byte parameter type*/
|
||||||
|
typedef unsigned __int16 Byte2_t;
|
||||||
|
/** 4Byte parameter type*/
|
||||||
|
typedef unsigned __int32 Byte4_t;
|
||||||
|
/** 8Byte parameter type*/
|
||||||
|
typedef unsigned __int64 Byte8_t;
|
||||||
|
#else
|
||||||
|
#error unsupported platform
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch bytes of data in file stream
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @param[in] offset start Byte position
|
||||||
|
* @param[in] size Byte length
|
||||||
|
* @return pointer to the fetched data
|
||||||
|
*/
|
||||||
|
Byte_t * fetch_bytes( int fd, long offset, int size);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch a 1-byte Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @param[in] offset start Byte position
|
||||||
|
* @return fetched codes
|
||||||
|
*/
|
||||||
|
Byte_t fetch_1byte( int fd, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch a 2-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @param[in] offset start Byte position
|
||||||
|
* @return fetched codes
|
||||||
|
*/
|
||||||
|
Byte2_t fetch_2bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch a 4-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @param[in] offset start Byte position
|
||||||
|
* @return fetched codes
|
||||||
|
*/
|
||||||
|
Byte4_t fetch_4bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch a 8-byte big endian Byte codes in file stream
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @param[in] offset start Byte position
|
||||||
|
* @return fetched codes
|
||||||
|
*/
|
||||||
|
Byte8_t fetch_8bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert 2-byte big endian Byte codes to number
|
||||||
|
*
|
||||||
|
* @param[in] buf Byte codes
|
||||||
|
* @return resolved number
|
||||||
|
*/
|
||||||
|
Byte2_t big2( Byte_t *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert 4-byte big endian Byte codes to number
|
||||||
|
*
|
||||||
|
* @param[in] buf Byte codes
|
||||||
|
* @return resolved number
|
||||||
|
*/
|
||||||
|
Byte4_t big4( Byte_t *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert 8-byte big endian Byte codes to number
|
||||||
|
*
|
||||||
|
* @param[in] buf Byte codes
|
||||||
|
* @return resolved number
|
||||||
|
*/
|
||||||
|
Byte8_t big8( Byte_t *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* modify 4Byte code in a codestream
|
||||||
|
*
|
||||||
|
* @param[in] code code value
|
||||||
|
* @param[out] stream modifying codestream
|
||||||
|
*/
|
||||||
|
void modify_4Bytecode( Byte4_t code, Byte_t *stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file size
|
||||||
|
*
|
||||||
|
* @param[in] fd file discriptor
|
||||||
|
* @return file size
|
||||||
|
*/
|
||||||
|
Byte8_t get_filesize( int fd);
|
||||||
|
|
||||||
|
#endif /* !BYTE_MANAGER_H_ */
|
||||||
275
applications/jpip/libopenjpip/cache_manager.c
Normal file
275
applications/jpip/libopenjpip/cache_manager.c
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
* $Id: cache_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "cache_manager.h"
|
||||||
|
|
||||||
|
cachelist_param_t * gene_cachelist()
|
||||||
|
{
|
||||||
|
cachelist_param_t *cachelist;
|
||||||
|
|
||||||
|
cachelist = (cachelist_param_t *)malloc( sizeof(cachelist_param_t));
|
||||||
|
|
||||||
|
cachelist->first = NULL;
|
||||||
|
cachelist->last = NULL;
|
||||||
|
|
||||||
|
return cachelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachelist(cachelist_param_t **cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *cachePtr, *cacheNext;
|
||||||
|
|
||||||
|
cachePtr = (*cachelist)->first;
|
||||||
|
while( cachePtr != NULL){
|
||||||
|
cacheNext=cachePtr->next;
|
||||||
|
delete_cache( &cachePtr);
|
||||||
|
cachePtr=cacheNext;
|
||||||
|
}
|
||||||
|
free( *cachelist);
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
|
||||||
|
{
|
||||||
|
cache_param_t *cache;
|
||||||
|
|
||||||
|
cache = (cache_param_t *)malloc( sizeof(cache_param_t));
|
||||||
|
cache->filename = strdup( targetname);
|
||||||
|
cache->tid = strdup( tid);
|
||||||
|
cache->csn = csn;
|
||||||
|
cache->cid = (char **)malloc( sizeof(char *));
|
||||||
|
*cache->cid = strdup( cid);
|
||||||
|
cache->numOfcid = 1;
|
||||||
|
#if 1
|
||||||
|
cache->metadatalist = NULL;
|
||||||
|
#else
|
||||||
|
cache->metadatalist = gene_metadatalist();
|
||||||
|
#endif
|
||||||
|
cache->ihdrbox = NULL;
|
||||||
|
cache->next = NULL;
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cache( cache_param_t **cache)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
free( (*cache)->filename);
|
||||||
|
free( (*cache)->tid);
|
||||||
|
|
||||||
|
delete_metadatalist( &(*cache)->metadatalist);
|
||||||
|
|
||||||
|
if((*cache)->ihdrbox)
|
||||||
|
free((*cache)->ihdrbox);
|
||||||
|
for( i=0; i<(*cache)->numOfcid; i++)
|
||||||
|
free( (*cache)->cid[i]);
|
||||||
|
free( (*cache)->cid);
|
||||||
|
free( *cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
if( cachelist->first)
|
||||||
|
cachelist->last->next = cache;
|
||||||
|
else
|
||||||
|
cachelist->first = cache;
|
||||||
|
cachelist->last = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
if( !targetname)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
|
||||||
|
if( strcmp( targetname, foundcache->filename) == 0)
|
||||||
|
return foundcache;
|
||||||
|
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
|
||||||
|
if( csn == foundcache->csn)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if( !cid)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
for( i=0; i<foundcache->numOfcid; i++)
|
||||||
|
if( strcmp( cid, foundcache->cid[i]) == 0)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *foundcache;
|
||||||
|
|
||||||
|
if( !tid)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
foundcache = cachelist->first;
|
||||||
|
|
||||||
|
while( foundcache != NULL){
|
||||||
|
if( strcmp( tid, foundcache->tid) == 0)
|
||||||
|
return foundcache;
|
||||||
|
foundcache = foundcache->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_cachecid( char *cid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
if( !cid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( (cache->cid = realloc( cache->cid, (cache->numOfcid+1)*sizeof(char *))) == NULL){
|
||||||
|
fprintf( stderr, "failed to add new cid to cache table in add_cachecid()\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache->cid[ cache->numOfcid] = strdup( cid);
|
||||||
|
|
||||||
|
cache->numOfcid ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_cachetid( char *tid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
if( !tid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( tid[0] != '0' && strcmp( tid, cache->tid) !=0){
|
||||||
|
fprintf( stderr, "tid is updated to %s for %s\n", tid, cache->filename);
|
||||||
|
free( cache->tid);
|
||||||
|
cache->tid = strdup( tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_cidInCache( char *cid, cache_param_t *cache);
|
||||||
|
|
||||||
|
void remove_cachecid( char *cid, cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *cache;
|
||||||
|
|
||||||
|
cache = search_cacheBycid( cid, cachelist);
|
||||||
|
remove_cidInCache( cid, cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_cidInCache( char *cid, cache_param_t *cache)
|
||||||
|
{
|
||||||
|
int idx = -1;
|
||||||
|
char **tmp;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for( i=0; i<cache->numOfcid; i++)
|
||||||
|
if( strcmp( cid, cache->cid[i]) == 0){
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( idx == -1){
|
||||||
|
fprintf( stderr, "cid: %s not found\n", cid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = cache->cid;
|
||||||
|
|
||||||
|
cache->cid = (char **)malloc( (cache->numOfcid-1)*sizeof(char *));
|
||||||
|
|
||||||
|
for( i=0, j=0; i<cache->numOfcid; i++){
|
||||||
|
if( i != idx){
|
||||||
|
cache->cid[j] = strdup( tmp[i]);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
free( tmp[i]);
|
||||||
|
}
|
||||||
|
free( tmp);
|
||||||
|
|
||||||
|
cache->numOfcid --;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_cache( cache_param_t *cache)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
fprintf( stdout,"cache\n");
|
||||||
|
fprintf( stdout,"\t filename: %s\n", cache->filename);
|
||||||
|
fprintf( stdout,"\t tid: %s\n", cache->tid);
|
||||||
|
fprintf( stdout,"\t csn: %d\n", cache->csn);
|
||||||
|
fprintf( stdout,"\t cid:");
|
||||||
|
|
||||||
|
for( i=0; i<cache->numOfcid; i++)
|
||||||
|
fprintf( stdout," %s", cache->cid[i]);
|
||||||
|
fprintf( stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allcache( cachelist_param_t *cachelist)
|
||||||
|
{
|
||||||
|
cache_param_t *ptr;
|
||||||
|
|
||||||
|
fprintf( stdout,"cache list\n");
|
||||||
|
|
||||||
|
ptr = cachelist->first;
|
||||||
|
while( ptr != NULL){
|
||||||
|
print_cache( ptr);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
177
applications/jpip/libopenjpip/cache_manager.h
Normal file
177
applications/jpip/libopenjpip/cache_manager.h
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* $Id: cache_manager.h 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CACHE_MANAGER_H_
|
||||||
|
# define CACHE_MANAGER_H_
|
||||||
|
|
||||||
|
#include "metadata_manager.h"
|
||||||
|
#include "ihdrbox_manager.h"
|
||||||
|
|
||||||
|
/** cache parameters*/
|
||||||
|
typedef struct cache_param{
|
||||||
|
char *filename; /**< file name*/
|
||||||
|
char *tid; /**< taregt identifier*/
|
||||||
|
int csn; /**< codestream number*/
|
||||||
|
char **cid; /**< dynamic array of channel identifiers*/
|
||||||
|
int numOfcid; /**< number of cids*/
|
||||||
|
metadatalist_param_t *metadatalist; /**< metadata-bin list*/
|
||||||
|
ihdrbox_param_t *ihdrbox; /**< ihdrbox*/
|
||||||
|
struct cache_param *next; /**< pointer to the next cache*/
|
||||||
|
} cache_param_t;
|
||||||
|
|
||||||
|
/**< cache list parameters*/
|
||||||
|
typedef struct cachelist_param{
|
||||||
|
cache_param_t *first; /**< first cache pointer of the list*/
|
||||||
|
cache_param_t *last; /**< last cache pointer of the list*/
|
||||||
|
} cachelist_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a cache list
|
||||||
|
*
|
||||||
|
* @return pointer to the generated cache list
|
||||||
|
*/
|
||||||
|
cachelist_param_t * gene_cachelist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete cache list
|
||||||
|
*
|
||||||
|
* @param[in,out] cachelist address of the cache list pointer
|
||||||
|
*/
|
||||||
|
void delete_cachelist(cachelist_param_t **cachelist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a cache
|
||||||
|
*
|
||||||
|
* @param[in] targetname target file name
|
||||||
|
* @param[in] csn codestream number
|
||||||
|
* @param[in] tid target identifier
|
||||||
|
* @param[in] cid channel identifier
|
||||||
|
* @return pointer to the generated cache
|
||||||
|
*/
|
||||||
|
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a cache
|
||||||
|
*
|
||||||
|
* @param[in] cache address of the cache pointer
|
||||||
|
*/
|
||||||
|
void delete_cache( cache_param_t **cache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* insert a cache into list
|
||||||
|
*
|
||||||
|
* @param[in] cache cache pointer
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
*/
|
||||||
|
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache by target name
|
||||||
|
*
|
||||||
|
* @param[in] targetname target filename
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
* @return found cache pointer
|
||||||
|
*/
|
||||||
|
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache by csn
|
||||||
|
*
|
||||||
|
* @param[in] csn codestream number
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
* @return found cache pointer
|
||||||
|
*/
|
||||||
|
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache by cid
|
||||||
|
*
|
||||||
|
* @param[in] cid channel identifer
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
* @return found cache pointer
|
||||||
|
*/
|
||||||
|
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache by tid
|
||||||
|
*
|
||||||
|
* @param[in] tid target identifer
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
* @return found cache pointer
|
||||||
|
*/
|
||||||
|
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add cid into a cache
|
||||||
|
*
|
||||||
|
* @param[in] cid channel identifier
|
||||||
|
* @param[in] cache cache pointer
|
||||||
|
*/
|
||||||
|
void add_cachecid( char *cid, cache_param_t *cache);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update tid of a cache
|
||||||
|
*
|
||||||
|
* @param[in] tid target identifier
|
||||||
|
* @param[in] cache cache pointer
|
||||||
|
*/
|
||||||
|
void update_cachetid( char *tid, cache_param_t *cache);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove cid in cache
|
||||||
|
*
|
||||||
|
* @param[in] cid channel identifier
|
||||||
|
* @param[in] cachelist cachelist pointer
|
||||||
|
*/
|
||||||
|
void remove_cachecid( char *cid, cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print cache parameters
|
||||||
|
*
|
||||||
|
* @param[in] cache cache pointer
|
||||||
|
*/
|
||||||
|
void print_cache( cache_param_t *cache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print all cache parameters
|
||||||
|
*
|
||||||
|
* @param[in] cachelist cache list pointer
|
||||||
|
*/
|
||||||
|
void print_allcache( cachelist_param_t *cachelist);
|
||||||
|
|
||||||
|
#endif /* !CACHE_MANAGER_H_ */
|
||||||
235
applications/jpip/libopenjpip/cachemodel_manager.c
Normal file
235
applications/jpip/libopenjpip/cachemodel_manager.c
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "cachemodel_manager.h"
|
||||||
|
#include "faixbox_manager.h"
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER*/
|
||||||
|
|
||||||
|
|
||||||
|
cachemodellist_param_t * gene_cachemodellist(void)
|
||||||
|
{
|
||||||
|
cachemodellist_param_t *cachemodellist;
|
||||||
|
|
||||||
|
cachemodellist = (cachemodellist_param_t *)malloc( sizeof(cachemodellist_param_t));
|
||||||
|
|
||||||
|
cachemodellist->first = NULL;
|
||||||
|
cachemodellist->last = NULL;
|
||||||
|
|
||||||
|
return cachemodellist;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodel;
|
||||||
|
faixbox_param_t *tilepart;
|
||||||
|
faixbox_param_t *precpacket;
|
||||||
|
size_t numOfelem;
|
||||||
|
Byte8_t numOftiles;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
|
||||||
|
|
||||||
|
refer_target( target, &cachemodel->target);
|
||||||
|
|
||||||
|
if( reqJPP){
|
||||||
|
if( target->jppstream)
|
||||||
|
cachemodel->jppstream = true;
|
||||||
|
else
|
||||||
|
cachemodel->jppstream = false;
|
||||||
|
} else{ /* reqJPT */
|
||||||
|
if( target->jptstream)
|
||||||
|
cachemodel->jppstream = false;
|
||||||
|
else
|
||||||
|
cachemodel->jppstream = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel->mhead_model = false;
|
||||||
|
|
||||||
|
tilepart = target->codeidx->tilepart;
|
||||||
|
numOftiles = get_m( tilepart);
|
||||||
|
numOfelem = get_nmax( tilepart)*numOftiles;
|
||||||
|
cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
|
||||||
|
cachemodel->th_model = (bool *)calloc( 1, numOftiles*sizeof(bool));
|
||||||
|
cachemodel->pp_model = (bool **)malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
|
||||||
|
for( i=0; i<target->codeidx->SIZ.Csiz; i++){
|
||||||
|
precpacket = target->codeidx->precpacket[i];
|
||||||
|
cachemodel->pp_model[i] = (bool *)calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
|
||||||
|
}
|
||||||
|
cachemodel->next = NULL;
|
||||||
|
|
||||||
|
if( cachemodellist){
|
||||||
|
if( cachemodellist->first) /* there are one or more entries */
|
||||||
|
cachemodellist->last->next = cachemodel;
|
||||||
|
else /* first entry */
|
||||||
|
cachemodellist->first = cachemodel;
|
||||||
|
cachemodellist->last = cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel generated\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return cachemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||||
|
{
|
||||||
|
target_param_t *target;
|
||||||
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: Is this large enough ? */
|
||||||
|
|
||||||
|
target = cachemodel.target;
|
||||||
|
|
||||||
|
fprintf( logstream, "target: %s\n", target->targetname);
|
||||||
|
fprintf( logstream, "\t main header model: %d\n", cachemodel.mhead_model);
|
||||||
|
|
||||||
|
fprintf( logstream, "\t tile part model:\n");
|
||||||
|
TPnum = get_nmax( target->codeidx->tilepart);
|
||||||
|
|
||||||
|
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++){
|
||||||
|
for( j=0; j<target->codeidx->SIZ.XTnum; j++){
|
||||||
|
for( k=0; k<TPnum; k++)
|
||||||
|
fprintf( logstream, "%d", cachemodel.tp_model[n++]);
|
||||||
|
fprintf( logstream, " ");
|
||||||
|
}
|
||||||
|
fprintf( logstream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||||
|
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||||
|
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
|
||||||
|
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||||
|
fprintf( logstream, "\t compo.%llud: ", j);
|
||||||
|
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||||
|
for( k=0; k<Pmax; k++)
|
||||||
|
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||||
|
fprintf( logstream, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = cachemodellist->first;
|
||||||
|
|
||||||
|
while( foundcachemodel != NULL){
|
||||||
|
|
||||||
|
if( foundcachemodel->target == target)
|
||||||
|
return foundcachemodel;
|
||||||
|
|
||||||
|
foundcachemodel = foundcachemodel->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodellist( cachemodellist_param_t **cachemodellist)
|
||||||
|
{
|
||||||
|
cachemodel_param_t *cachemodelPtr, *cachemodelNext;
|
||||||
|
|
||||||
|
cachemodelPtr = (*cachemodellist)->first;
|
||||||
|
while( cachemodelPtr != NULL){
|
||||||
|
cachemodelNext=cachemodelPtr->next;
|
||||||
|
delete_cachemodel( &cachemodelPtr);
|
||||||
|
cachemodelPtr=cachemodelNext;
|
||||||
|
}
|
||||||
|
free(*cachemodellist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
unrefer_target( (*cachemodel)->target);
|
||||||
|
|
||||||
|
free( (*cachemodel)->tp_model);
|
||||||
|
free( (*cachemodel)->th_model);
|
||||||
|
|
||||||
|
for( i=0; i<(*cachemodel)->target->codeidx->SIZ.Csiz; i++)
|
||||||
|
free( (*cachemodel)->pp_model[i]);
|
||||||
|
free( (*cachemodel)->pp_model);
|
||||||
|
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: cachemodel deleted\n");
|
||||||
|
#endif
|
||||||
|
free( *cachemodel);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_allsent( cachemodel_param_t cachemodel)
|
||||||
|
{
|
||||||
|
target_param_t *target;
|
||||||
|
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||||
|
Byte8_t Pmax; /* max num of packets per tile */
|
||||||
|
Byte8_t i, j, k;
|
||||||
|
int n; /* FIXME: is this large enough ? */
|
||||||
|
|
||||||
|
target = cachemodel.target;
|
||||||
|
|
||||||
|
if( !cachemodel.mhead_model)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TPnum = get_nmax( target->codeidx->tilepart);
|
||||||
|
|
||||||
|
if( cachemodel.jppstream){
|
||||||
|
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||||
|
if( !cachemodel.th_model[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||||
|
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||||
|
for( k=0; k<Pmax; k++)
|
||||||
|
if( !cachemodel.pp_model[j][i*Pmax+k])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
|
||||||
|
for( j=0; j<target->codeidx->SIZ.XTnum; j++)
|
||||||
|
for( k=0; k<TPnum; k++)
|
||||||
|
if( !cachemodel.tp_model[n++])
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
115
applications/jpip/libopenjpip/cachemodel_manager.h
Normal file
115
applications/jpip/libopenjpip/cachemodel_manager.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CACHEMODEL_MANAGER_H_
|
||||||
|
# define CACHEMODEL_MANAGER_H_
|
||||||
|
|
||||||
|
#include "bool.h"
|
||||||
|
#include "target_manager.h"
|
||||||
|
|
||||||
|
/** Cache model parameters*/
|
||||||
|
typedef struct cachemodel_param{
|
||||||
|
target_param_t *target; /**< reference pointer to the target*/
|
||||||
|
bool jppstream; /**< return type, true: JPP-stream, false: JPT-stream*/
|
||||||
|
bool mhead_model; /**< main header model, if sent, 1, else 0*/
|
||||||
|
bool *tp_model; /**< dynamic array pointer of tile part model, if sent, 1, else 0*/
|
||||||
|
bool *th_model; /**< dynamic array pointer of tile header model*/
|
||||||
|
bool **pp_model; /**< dynamic array pointer of precint packet model*/
|
||||||
|
struct cachemodel_param *next; /**< pointer to the next cache model*/
|
||||||
|
} cachemodel_param_t;
|
||||||
|
|
||||||
|
/** Cache model list parameters*/
|
||||||
|
typedef struct cachemodellist_param{
|
||||||
|
cachemodel_param_t *first; /**< first cache model pointer of the list*/
|
||||||
|
cachemodel_param_t *last; /**< last cache model pointer of the list*/
|
||||||
|
} cachemodellist_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a cache model list
|
||||||
|
*
|
||||||
|
* @return pointer to the generated cache model list
|
||||||
|
*/
|
||||||
|
cachemodellist_param_t * gene_cachemodellist(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a cache model under a list
|
||||||
|
*
|
||||||
|
* @param[in] cachemodellist cachemodel list to insert the generated cache model, NULL for stateless
|
||||||
|
* @param[in] target pointer the reference target
|
||||||
|
* @param[in] reqJPP if JPP-stream is desired true, JPT-stream false
|
||||||
|
* @return pointer to the generated cache model
|
||||||
|
*/
|
||||||
|
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print cache model
|
||||||
|
*
|
||||||
|
* @param[in] cachemodel cache model
|
||||||
|
*/
|
||||||
|
void print_cachemodel( cachemodel_param_t cachemodel);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a cache model of a target
|
||||||
|
*
|
||||||
|
* @param[in] target refering target
|
||||||
|
* @param[in] cachemodellist cache model list
|
||||||
|
* @return found cache model pointer
|
||||||
|
*/
|
||||||
|
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if all data has been sent
|
||||||
|
*
|
||||||
|
* @param[in] cachemodel cache model
|
||||||
|
* @return true if sent all, false otherwise
|
||||||
|
*/
|
||||||
|
bool is_allsent( cachemodel_param_t cachemodel);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a cache model
|
||||||
|
*
|
||||||
|
* @param[in] cachemodel address of the cachemodel pointer
|
||||||
|
*/
|
||||||
|
void delete_cachemodel( cachemodel_param_t **cachemodel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete cachemodel list
|
||||||
|
*
|
||||||
|
* @param[in,out] cachemodellist address of the cachemodel list pointer
|
||||||
|
*/
|
||||||
|
void delete_cachemodellist( cachemodellist_param_t **cachemodellist);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !CACHEMODEL_MANAGER_H_ */
|
||||||
180
applications/jpip/libopenjpip/channel_manager.c
Normal file
180
applications/jpip/libopenjpip/channel_manager.c
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* $Id: channel_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "channel_manager.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define snprintf _snprintf /* Visual Studio */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERVER
|
||||||
|
#include "fcgi_stdio.h"
|
||||||
|
#define logstream FCGI_stdout
|
||||||
|
#else
|
||||||
|
#define FCGI_stdout stdout
|
||||||
|
#define FCGI_stderr stderr
|
||||||
|
#define logstream stderr
|
||||||
|
#endif /*SERVER */
|
||||||
|
|
||||||
|
channellist_param_t * gene_channellist(void)
|
||||||
|
{
|
||||||
|
channellist_param_t *channellist;
|
||||||
|
|
||||||
|
channellist = (channellist_param_t *)malloc( sizeof(channellist_param_t));
|
||||||
|
|
||||||
|
channellist->first = NULL;
|
||||||
|
channellist->last = NULL;
|
||||||
|
|
||||||
|
return channellist;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *channel;
|
||||||
|
char transport[4][10] = { "non", "http", "http-tcp", "http-udp"};
|
||||||
|
|
||||||
|
if( !cachemodel){
|
||||||
|
fprintf( FCGI_stdout, "Status: 404\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||||
|
channel->cachemodel = cachemodel;
|
||||||
|
|
||||||
|
/* set channel ID and get present time */
|
||||||
|
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||||
|
|
||||||
|
channel->aux = query_param.cnew;
|
||||||
|
|
||||||
|
/* only tcp implemented for now */
|
||||||
|
if( channel->aux == udp)
|
||||||
|
channel->aux = tcp;
|
||||||
|
|
||||||
|
channel->next=NULL;
|
||||||
|
|
||||||
|
set_channel_variable_param( query_param, channel);
|
||||||
|
|
||||||
|
if( channellist->first != NULL)
|
||||||
|
channellist->last->next = channel;
|
||||||
|
else
|
||||||
|
channellist->first = channel;
|
||||||
|
channellist->last = channel;
|
||||||
|
|
||||||
|
fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid);
|
||||||
|
fprintf( FCGI_stdout, ",transport=%s", transport[channel->aux]);
|
||||||
|
|
||||||
|
if( channel->aux == tcp || channel->aux == udp)
|
||||||
|
fprintf( FCGI_stdout, ",auxport=%d", channel->aux==tcp ? auxtrans.tcpauxport : auxtrans.udpauxport);
|
||||||
|
|
||||||
|
fprintf( FCGI_stdout, "\r\n");
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||||
|
{
|
||||||
|
/* set roi information */
|
||||||
|
(void)query_param;
|
||||||
|
(void)channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void delete_channel( channel_param_t **channel, channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *ptr;
|
||||||
|
|
||||||
|
if( *channel == channellist->first)
|
||||||
|
channellist->first = (*channel)->next;
|
||||||
|
else{
|
||||||
|
ptr = channellist->first;
|
||||||
|
while( ptr->next != *channel){
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->next = (*channel)->next;
|
||||||
|
|
||||||
|
if( *channel == channellist->last)
|
||||||
|
channellist->last = ptr;
|
||||||
|
}
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: channel: %s deleted\n", (*channel)->cid);
|
||||||
|
#endif
|
||||||
|
free(*channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete_channellist( channellist_param_t **channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *channelPtr, *channelNext;
|
||||||
|
|
||||||
|
channelPtr = (*channellist)->first;
|
||||||
|
while( channelPtr != NULL){
|
||||||
|
channelNext=channelPtr->next;
|
||||||
|
#ifndef SERVER
|
||||||
|
fprintf( logstream, "local log: channel %s deleted!\n", channelPtr->cid);
|
||||||
|
#endif
|
||||||
|
free(channelPtr);
|
||||||
|
channelPtr=channelNext;
|
||||||
|
}
|
||||||
|
free( *channellist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_allchannel( channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *ptr;
|
||||||
|
|
||||||
|
ptr = channellist->first;
|
||||||
|
while( ptr != NULL){
|
||||||
|
fprintf( logstream,"channel-ID=%s \t target=%s\n", ptr->cid, ptr->cachemodel->target->targetname);
|
||||||
|
ptr=ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_param_t * search_channel( char cid[], channellist_param_t *channellist)
|
||||||
|
{
|
||||||
|
channel_param_t *foundchannel;
|
||||||
|
|
||||||
|
foundchannel = channellist->first;
|
||||||
|
|
||||||
|
while( foundchannel != NULL){
|
||||||
|
|
||||||
|
if( strcmp( cid, foundchannel->cid) == 0)
|
||||||
|
return foundchannel;
|
||||||
|
|
||||||
|
foundchannel = foundchannel->next;
|
||||||
|
}
|
||||||
|
fprintf( FCGI_stdout, "Status: 503\r\n");
|
||||||
|
fprintf( FCGI_stdout, "Reason: Channel %s not found in this session\r\n", cid);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
120
applications/jpip/libopenjpip/channel_manager.h
Normal file
120
applications/jpip/libopenjpip/channel_manager.h
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* $Id: channel_manager.h 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHANNEL_MANAGER_H_
|
||||||
|
# define CHANNEL_MANAGER_H_
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include "query_parser.h"
|
||||||
|
#include "cachemodel_manager.h"
|
||||||
|
#include "auxtrans_manager.h"
|
||||||
|
|
||||||
|
/** maximum length of channel identifier*/
|
||||||
|
#define MAX_LENOFCID 30
|
||||||
|
|
||||||
|
/** Channel parameters*/
|
||||||
|
typedef struct channel_param{
|
||||||
|
cachemodel_param_t *cachemodel; /**< reference pointer to the cache model*/
|
||||||
|
char cid[MAX_LENOFCID]; /**< channel identifier*/
|
||||||
|
cnew_transport_t aux; /**< auxiliary transport*/
|
||||||
|
/* - a record of the client's capabilities and preferences to the extent that the server queues requests*/
|
||||||
|
time_t start_tm; /**< starting time*/
|
||||||
|
struct channel_param *next; /**< pointer to the next channel*/
|
||||||
|
} channel_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/** Channel list parameters*/
|
||||||
|
typedef struct channellist_param{
|
||||||
|
channel_param_t *first; /**< first channel pointer of the list*/
|
||||||
|
channel_param_t *last; /**< last channel pointer of the list*/
|
||||||
|
} channellist_param_t;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a channel list
|
||||||
|
*
|
||||||
|
* @return pointer to the generated channel list
|
||||||
|
*/
|
||||||
|
channellist_param_t * gene_channellist(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a channel under the channel list
|
||||||
|
*
|
||||||
|
* @param[in] query_param query parameters
|
||||||
|
* @param[in] auxtrans auxiliary transport
|
||||||
|
* @param[in] cachemodel reference cachemodel
|
||||||
|
* @param[in] channellist channel list pointer
|
||||||
|
* @return pointer to the generated channel
|
||||||
|
*/
|
||||||
|
channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set channel variable parameters
|
||||||
|
*
|
||||||
|
* @param[in] query_param query parameters
|
||||||
|
* @param[in,out] channel pointer to the modifying channel
|
||||||
|
*/
|
||||||
|
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete a channel
|
||||||
|
*
|
||||||
|
* @param[in] channel address of the deleting channel pointer
|
||||||
|
* @param[in,out] channellist channel list pointer
|
||||||
|
*/
|
||||||
|
void delete_channel( channel_param_t **channel, channellist_param_t *channellist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete channel list
|
||||||
|
*
|
||||||
|
* @param[in,out] channellist address of the channel list pointer
|
||||||
|
*/
|
||||||
|
void delete_channellist( channellist_param_t **channellist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print all channel parameters
|
||||||
|
*
|
||||||
|
* @param[in] channellist channel list pointer
|
||||||
|
*/
|
||||||
|
void print_allchannel( channellist_param_t *channellist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search a channel by channel ID
|
||||||
|
*
|
||||||
|
* @param[in] cid channel identifier
|
||||||
|
* @param[in] channellist channel list pointer
|
||||||
|
* @return found channel pointer
|
||||||
|
*/
|
||||||
|
channel_param_t * search_channel( char cid[], channellist_param_t *channellist);
|
||||||
|
#endif /* !CHANNEL_MANAGER_H_ */
|
||||||
80
applications/jpip/libopenjpip/codestream_manager.c
Normal file
80
applications/jpip/libopenjpip/codestream_manager.c
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* $Id: codestream_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 "codestream_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 */
|
||||||
|
|
||||||
|
codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
|
||||||
|
{
|
||||||
|
codestream_param_t cs;
|
||||||
|
|
||||||
|
cs.fd = fd;
|
||||||
|
cs.offset = offset;
|
||||||
|
cs.length = length;
|
||||||
|
|
||||||
|
return cs;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t * fetch_codestreambytes( codestream_param_t *cs, long offset, int size)
|
||||||
|
{
|
||||||
|
return fetch_bytes( cs->fd, cs->offset+offset, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte_t fetch_codestream1byte( codestream_param_t *cs, long offset)
|
||||||
|
{
|
||||||
|
return fetch_1byte( cs->fd, cs->offset+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte2_t fetch_codestream2bytebigendian( codestream_param_t *cs, long offset)
|
||||||
|
{
|
||||||
|
return fetch_2bytebigendian( cs->fd, cs->offset+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte4_t fetch_codestream4bytebigendian( codestream_param_t *cs, long offset)
|
||||||
|
{
|
||||||
|
return fetch_4bytebigendian( cs->fd, cs->offset+offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_codestream( codestream_param_t cs)
|
||||||
|
{
|
||||||
|
fprintf( logstream, "codestream info:\n"
|
||||||
|
"\t fd: %d\n"
|
||||||
|
"\t offset: %#llx\n"
|
||||||
|
"\t length: %#llx\n", cs.fd, cs.offset, cs.length);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user