Compare commits
2086 Commits
opj0-97
...
fix-bypass
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdb4bfaf05 | ||
|
|
51a51bdd03 | ||
|
|
44a499f2ac | ||
|
|
94cfb1b008 | ||
|
|
17a0a8a195 | ||
|
|
ba0cf122f6 | ||
|
|
da56086e01 | ||
|
|
04b8cbd27a | ||
|
|
e1e018a8dc | ||
|
|
b51d088267 | ||
|
|
4f11e89c80 | ||
|
|
9a20f8e8d1 | ||
|
|
72deb588cb | ||
|
|
cd77b6003b | ||
|
|
f40a2ff2ad | ||
|
|
be42e72d22 | ||
|
|
15f081c896 | ||
|
|
ad593c9e06 | ||
|
|
319fc971fe | ||
|
|
e166e4a209 | ||
|
|
29313eb5f1 | ||
|
|
e982d03966 | ||
|
|
66fd497765 | ||
|
|
20789fed4e | ||
|
|
5947e10ff7 | ||
|
|
e6881e7527 | ||
|
|
2296dc9e68 | ||
|
|
6f2ac3ee36 | ||
|
|
c559c62853 | ||
|
|
a9feb9addd | ||
|
|
74e814358c | ||
|
|
54393d9e38 | ||
|
|
06e8dc9edd | ||
|
|
f5446fdcfb | ||
|
|
8611d127db | ||
|
|
889bf16791 | ||
|
|
6ea2ff0b06 | ||
|
|
3436c4e9ba | ||
|
|
e1a93d9e59 | ||
|
|
a1c0ee9a86 | ||
|
|
40b5a53d2f | ||
|
|
e7797b97a1 | ||
|
|
5e5f6999a8 | ||
|
|
0069a2bd2f | ||
|
|
e3100f714c | ||
|
|
5c5ae1d51a | ||
|
|
3767af52de | ||
|
|
1b86fb6f48 | ||
|
|
a42d03df79 | ||
|
|
cb33ff43bb | ||
|
|
6a1974d40d | ||
|
|
87c0d7dc1e | ||
|
|
0dd44e7dba | ||
|
|
9cad6bc1f6 | ||
|
|
79b1c4cc85 | ||
|
|
c00ee8bff7 | ||
|
|
a205f70328 | ||
|
|
9c5b30005e | ||
|
|
83e5e2703e | ||
|
|
3a0253f4e2 | ||
|
|
99c4f621bd | ||
|
|
2e4fadf330 | ||
|
|
8f9905936c | ||
|
|
a834ab305f | ||
|
|
51efe91971 | ||
|
|
4ddc2627dd | ||
|
|
5d56fb3115 | ||
|
|
51cbcd5748 | ||
|
|
f51d52f85a | ||
|
|
c414d9c238 | ||
|
|
e5ca873ab1 | ||
|
|
601aa38c30 | ||
|
|
fb4be3894e | ||
|
|
c37d69b25e | ||
|
|
a77717583e | ||
|
|
968085190c | ||
|
|
93a61459cd | ||
|
|
38ffbbe42e | ||
|
|
ce26e523dd | ||
|
|
7dfcbf9d7b | ||
|
|
4ac509182a | ||
|
|
0ae66e891a | ||
|
|
9f78c68953 | ||
|
|
f080ab8ce0 | ||
|
|
e975ca2832 | ||
|
|
b06bed7b7b | ||
|
|
b7a162348d | ||
|
|
540aa58f6c | ||
|
|
d48be27f5a | ||
|
|
eaf55b677c | ||
|
|
0967d64854 | ||
|
|
5799672237 | ||
|
|
a1fc83cc25 | ||
|
|
ad7eb5630e | ||
|
|
4831badeb4 | ||
|
|
80be580d50 | ||
|
|
05b3afd28f | ||
|
|
e1122a8f50 | ||
|
|
f9d47e28b9 | ||
|
|
8034ffde8b | ||
|
|
b3a15954f6 | ||
|
|
83249c318f | ||
|
|
b1a8e1adcb | ||
|
|
ee04854e1a | ||
|
|
b3c581760f | ||
|
|
bd3959dc77 | ||
|
|
fd424cfb66 | ||
|
|
e734f0522a | ||
|
|
9729405a8f | ||
|
|
65f78eaa73 | ||
|
|
08238dbed6 | ||
|
|
c8d03fea9b | ||
|
|
6721f8a53f | ||
|
|
54a5860ee2 | ||
|
|
372fead0d7 | ||
|
|
98324bbd6b | ||
|
|
522d13af2a | ||
|
|
26dcb7c125 | ||
|
|
51a67a9cbf | ||
|
|
dd81b5892d | ||
|
|
0cd240e2e3 | ||
|
|
dac03fd168 | ||
|
|
d02bf257a6 | ||
|
|
0f1b1c63b4 | ||
|
|
11a27e6d20 | ||
|
|
ab8929262a | ||
|
|
813121e688 | ||
|
|
7a7901cd6d | ||
|
|
c5a8732b0e | ||
|
|
101a0034e2 | ||
|
|
2c8ba10cc9 | ||
|
|
30a0180d84 | ||
|
|
99c4376aed | ||
|
|
c3493063b9 | ||
|
|
4042210416 | ||
|
|
dc869c2985 | ||
|
|
caeb91121a | ||
|
|
891e7c298a | ||
|
|
d60937922f | ||
|
|
229d9cdb9c | ||
|
|
f0a980ec16 | ||
|
|
cc9bf1d557 | ||
|
|
a01f7cdee0 | ||
|
|
d753441028 | ||
|
|
53d7f70c15 | ||
|
|
70a16d80d9 | ||
|
|
4560d270e0 | ||
|
|
f33f50126c | ||
|
|
8d2019ae73 | ||
|
|
cf6db1641a | ||
|
|
9df5546838 | ||
|
|
b816ac185b | ||
|
|
d92c2b2117 | ||
|
|
d035952c52 | ||
|
|
1ed6ede703 | ||
|
|
d03c4770cb | ||
|
|
50b561e911 | ||
|
|
2d410fc74b | ||
|
|
d5c460fc5f | ||
|
|
62006e2b26 | ||
|
|
d05b19072d | ||
|
|
32ac092dec | ||
|
|
27102f0b06 | ||
|
|
87d44603a0 | ||
|
|
74f71ec923 | ||
|
|
5c3632b00e | ||
|
|
a4eade843f | ||
|
|
cba89a62a1 | ||
|
|
4123c0ba86 | ||
|
|
1a9cb9aef7 | ||
|
|
0dc4914b4e | ||
|
|
e224dee4b8 | ||
|
|
d2ddf006a6 | ||
|
|
a7ae153a46 | ||
|
|
de0a9ed103 | ||
|
|
553714a87a | ||
|
|
1b2ebfc69a | ||
|
|
3259fe2ff8 | ||
|
|
bbef2a9da3 | ||
|
|
5b6ff103bd | ||
|
|
c86827952f | ||
|
|
9b437b0c6a | ||
|
|
c8ae3c5225 | ||
|
|
07f65540b5 | ||
|
|
8414870ca7 | ||
|
|
2dab5fed59 | ||
|
|
26b2728c49 | ||
|
|
e526d435cc | ||
|
|
f8c8222660 | ||
|
|
d6b51b7041 | ||
|
|
987f96004f | ||
|
|
0b6a592372 | ||
|
|
83c9e0b1f2 | ||
|
|
db23831d57 | ||
|
|
0cfe2ca4a9 | ||
|
|
cf352af089 | ||
|
|
c59f464a3f | ||
|
|
05235963d9 | ||
|
|
99fc1ab306 | ||
|
|
f7dbcf1512 | ||
|
|
838dfb8058 | ||
|
|
4da7e9617f | ||
|
|
b9ca882749 | ||
|
|
f9df8ba19a | ||
|
|
09c35dcb84 | ||
|
|
f82d7f3a63 | ||
|
|
faf63fddad | ||
|
|
281537851b | ||
|
|
55dbf8acff | ||
|
|
c16c91797f | ||
|
|
a4e93c3b0a | ||
|
|
4bb5e24d23 | ||
|
|
6cb56b36f6 | ||
|
|
9c911c0e1e | ||
|
|
3ea4486bed | ||
|
|
6e11b55441 | ||
|
|
c6b2fdf572 | ||
|
|
700f8cb4f8 | ||
|
|
7d32f11a6f | ||
|
|
b4e8a425ae | ||
|
|
c8a3117659 | ||
|
|
49cbc11a19 | ||
|
|
3d295431e6 | ||
|
|
c08bd89739 | ||
|
|
1621df453d | ||
|
|
0b611c5250 | ||
|
|
b8ba5a8357 | ||
|
|
9add0fe298 | ||
|
|
ecb00ea4e4 | ||
|
|
cde7423958 | ||
|
|
6c157b60f2 | ||
|
|
fc131a1339 | ||
|
|
4f157f3cf0 | ||
|
|
41730e8cc6 | ||
|
|
82c238f504 | ||
|
|
52c36b4955 | ||
|
|
b7069ce2b2 | ||
|
|
cc2ae75450 | ||
|
|
b97aadcf3e | ||
|
|
1e2dcaf7b3 | ||
|
|
175eceb020 | ||
|
|
7981908754 | ||
|
|
9258f8f6a7 | ||
|
|
41a96aee5a | ||
|
|
897d2c0b75 | ||
|
|
e3579b6c1d | ||
|
|
8d46ac19ff | ||
|
|
4b02d246a4 | ||
|
|
47b7b2787b | ||
|
|
c31a28fcd1 | ||
|
|
cd10f46572 | ||
|
|
29ce132df4 | ||
|
|
5d953558de | ||
|
|
bac2c9e0a3 | ||
|
|
ee0f313848 | ||
|
|
ccdce606f1 | ||
|
|
d7d9f84707 | ||
|
|
4cde646cd7 | ||
|
|
5f02757eef | ||
|
|
4f5ec07c31 | ||
|
|
0a27667878 | ||
|
|
66d890bf22 | ||
|
|
dd00120e96 | ||
|
|
e71247bb90 | ||
|
|
a024980007 | ||
|
|
dc46d267f0 | ||
|
|
c32809d464 | ||
|
|
5be56d582c | ||
|
|
bd291ae5a8 | ||
|
|
f1ba09f690 | ||
|
|
4eabbc8661 | ||
|
|
e4be47279d | ||
|
|
29c644ec49 | ||
|
|
940100c28a | ||
|
|
c31fb68ccc | ||
|
|
15d07f33d1 | ||
|
|
c5dd6035c9 | ||
|
|
2eb97a851d | ||
|
|
8a95efcd3f | ||
|
|
38770403d4 | ||
|
|
589cc547b9 | ||
|
|
a521472427 | ||
|
|
d4ac2f613d | ||
|
|
fa9142b7e4 | ||
|
|
f98df1c715 | ||
|
|
3109759fd7 | ||
|
|
0a4ac0852a | ||
|
|
dc34a6cc8c | ||
|
|
238f4419ab | ||
|
|
60301842c7 | ||
|
|
acbb297a0a | ||
|
|
4fc1073809 | ||
|
|
7c688c3453 | ||
|
|
372c887aad | ||
|
|
0df90afdf7 | ||
|
|
75a33de3bc | ||
|
|
f026c0541e | ||
|
|
e4735c703d | ||
|
|
ae7953849b | ||
|
|
1947323329 | ||
|
|
c3d9719cd4 | ||
|
|
2263b6bacc | ||
|
|
5b66156be4 | ||
|
|
b0035538af | ||
|
|
45ccf501f0 | ||
|
|
15e4168ee2 | ||
|
|
2452bb7c45 | ||
|
|
85904a3291 | ||
|
|
012f22958a | ||
|
|
f3dad25c77 | ||
|
|
e6cf1744d4 | ||
|
|
db9b3400e5 | ||
|
|
c423cc84e7 | ||
|
|
d87de3a88d | ||
|
|
6007ac5c56 | ||
|
|
335e972554 | ||
|
|
8c4afeff40 | ||
|
|
ffd9db9700 | ||
|
|
b190a91ab5 | ||
|
|
f6843d5511 | ||
|
|
a56819eaab | ||
|
|
d6f2d26430 | ||
|
|
9ac3a1572e | ||
|
|
0905cab40a | ||
|
|
2fc9d4956a | ||
|
|
28c6f54798 | ||
|
|
2c7dab7655 | ||
|
|
96ae1b8dfc | ||
|
|
1bbb607069 | ||
|
|
fd1f7cf297 | ||
|
|
5bb074611a | ||
|
|
46c1dd22fc | ||
|
|
06f6911d7b | ||
|
|
ae4799ad07 | ||
|
|
b88025b38f | ||
|
|
b59085db0c | ||
|
|
8048bbc7a2 | ||
|
|
d1591be3d7 | ||
|
|
6b7ad74e26 | ||
|
|
635a358962 | ||
|
|
8f798864a9 | ||
|
|
ac9fb5a302 | ||
|
|
775ee87776 | ||
|
|
0b1f8eb6f7 | ||
|
|
c887df12a3 | ||
|
|
d1b053afe2 | ||
|
|
5e1474cc92 | ||
|
|
dc43ebf96c | ||
|
|
a7060dae1c | ||
|
|
ba05549b0f | ||
|
|
fb0e397330 | ||
|
|
35ddb3abc7 | ||
|
|
237ddd72f1 | ||
|
|
c999b6c0f0 | ||
|
|
4e0de649bd | ||
|
|
6b0a8e3a0f | ||
|
|
eadfad7a50 | ||
|
|
14361eee24 | ||
|
|
c9e231508b | ||
|
|
6347686385 | ||
|
|
1a8f929111 | ||
|
|
56d3f5af6e | ||
|
|
c665e81a39 | ||
|
|
c6c49865fe | ||
|
|
52d27be5c2 | ||
|
|
6e0118231a | ||
|
|
da3786d2d1 | ||
|
|
8d770ece9a | ||
|
|
0a0cb190da | ||
|
|
79b079bdc0 | ||
|
|
dbb67194b2 | ||
|
|
c255e0140c | ||
|
|
2bd6aa54d6 | ||
|
|
c7535d084e | ||
|
|
c0d7afe15c | ||
|
|
6def7e38b4 | ||
|
|
73881d0e52 | ||
|
|
e3291c4e1f | ||
|
|
0fa5a17c98 | ||
|
|
757f9394bf | ||
|
|
daed8cc919 | ||
|
|
d1a941ea50 | ||
|
|
00a47c1e06 | ||
|
|
1fb24aba4b | ||
|
|
2d24b6000d | ||
|
|
8b5e2a5143 | ||
|
|
3ed5858902 | ||
|
|
7a8cdc4bb0 | ||
|
|
4c0ed02806 | ||
|
|
5d00b719f4 | ||
|
|
42132ed6b5 | ||
|
|
31f5efe453 | ||
|
|
78a7762e3f | ||
|
|
33f52fb611 | ||
|
|
81abe5b3bb | ||
|
|
4a09296771 | ||
|
|
6922124c4c | ||
|
|
59b844347c | ||
|
|
bde5ba6ae8 | ||
|
|
16240e21f9 | ||
|
|
33a0e66eb1 | ||
|
|
f7ff08de5a | ||
|
|
f1bae45c76 | ||
|
|
65c07b42e3 | ||
|
|
3888daac6a | ||
|
|
e966fef3eb | ||
|
|
a504edf724 | ||
|
|
dde788b59e | ||
|
|
58fc86452d | ||
|
|
c0cb119c0e | ||
|
|
9a21e1eef0 | ||
|
|
a0688a9874 | ||
|
|
d0ce2ced53 | ||
|
|
e05d2901ec | ||
|
|
c0710f557c | ||
|
|
f095027329 | ||
|
|
8d320bbdf8 | ||
|
|
776b83ddbc | ||
|
|
04ace2a558 | ||
|
|
46afb746f0 | ||
|
|
570dd13f55 | ||
|
|
63f877769c | ||
|
|
04c6bb4a72 | ||
|
|
131cc98491 | ||
|
|
13bcb63b73 | ||
|
|
0ba5d15b58 | ||
|
|
7e38446075 | ||
|
|
548aff34f4 | ||
|
|
8397eac382 | ||
|
|
a2c2d86d3d | ||
|
|
3bc360fc9d | ||
|
|
ae1da37558 | ||
|
|
f57f59b10d | ||
|
|
b65e3ebdb6 | ||
|
|
50acc339c5 | ||
|
|
f123ce8f8a | ||
|
|
c3629e37a2 | ||
|
|
cf5153c518 | ||
|
|
3b7dced8e6 | ||
|
|
03a410e03d | ||
|
|
0a6eaaa605 | ||
|
|
7f8f284ee5 | ||
|
|
09fb8b6989 | ||
|
|
9e6c62199a | ||
|
|
d47f7a249d | ||
|
|
7280263988 | ||
|
|
3e1fad2da4 | ||
|
|
d72940c56b | ||
|
|
ad4fad0965 | ||
|
|
aff9cb39ed | ||
|
|
0a3f234df7 | ||
|
|
efb70af001 | ||
|
|
e65303b903 | ||
|
|
413de4fbfa | ||
|
|
984351f86f | ||
|
|
f8796711e8 | ||
|
|
0b540067b1 | ||
|
|
3df347eded | ||
|
|
eb7c6d295a | ||
|
|
f126eb0d41 | ||
|
|
7256e43c48 | ||
|
|
a0a3af1dee | ||
|
|
48832d944f | ||
|
|
06bd61b571 | ||
|
|
a1c754c737 | ||
|
|
fef1276901 | ||
|
|
45f33cdbd6 | ||
|
|
1acfa211ae | ||
|
|
2f3fd1194e | ||
|
|
f08af3ed82 | ||
|
|
2720a1a405 | ||
|
|
31fd8d3fe8 | ||
|
|
6868ee373e | ||
|
|
b9a247b559 | ||
|
|
50a205d20f | ||
|
|
b0072bf658 | ||
|
|
2c810567dd | ||
|
|
0a1a29a7fe | ||
|
|
7d21871ed8 | ||
|
|
a38b97fae0 | ||
|
|
45313a8dfa | ||
|
|
b08135e7c1 | ||
|
|
4bac8488df | ||
|
|
de04302c15 | ||
|
|
997758f91c | ||
|
|
763214f7c0 | ||
|
|
77e8dad503 | ||
|
|
1758445a75 | ||
|
|
7a77a8047d | ||
|
|
d8767cbcb7 | ||
|
|
7924d3a456 | ||
|
|
ec84bafcd8 | ||
|
|
08c09b74cf | ||
|
|
7aece5e8e7 | ||
|
|
8d93eae64a | ||
|
|
9a3d660d1b | ||
|
|
7199d9b5d3 | ||
|
|
d19a4ab676 | ||
|
|
f105cb5471 | ||
|
|
4db4198722 | ||
|
|
616a3345c4 | ||
|
|
1f8d84a562 | ||
|
|
a54d757a3e | ||
|
|
b5eb374fb9 | ||
|
|
f1d69068c7 | ||
|
|
ee130e2306 | ||
|
|
9ba6bc6042 | ||
|
|
5e1a0fad08 | ||
|
|
c05118dc49 | ||
|
|
1adf89d5d2 | ||
|
|
666f71b2a1 | ||
|
|
2b7d5b18f3 | ||
|
|
18d5d25cb6 | ||
|
|
492d8ab7d9 | ||
|
|
2b93727bea | ||
|
|
18c5be69e9 | ||
|
|
5a70e97f51 | ||
|
|
f4707da97a | ||
|
|
51ab074d50 | ||
|
|
6d9e8a5a63 | ||
|
|
008de86533 | ||
|
|
ae49fd1aa9 | ||
|
|
79d18f7fd0 | ||
|
|
99d1859a44 | ||
|
|
866cd28ad4 | ||
|
|
71a9f498b5 | ||
|
|
b607da8ae9 | ||
|
|
a43d206b93 | ||
|
|
15863e7170 | ||
|
|
5e91877636 | ||
|
|
7e1d012161 | ||
|
|
de74605777 | ||
|
|
e8abf1fb25 | ||
|
|
b7fe7d25e1 | ||
|
|
138a65d6c1 | ||
|
|
9d0bdf69e5 | ||
|
|
9194dfb94b | ||
|
|
b7ebf54a29 | ||
|
|
3a80b72ac8 | ||
|
|
3e33012bd9 | ||
|
|
fd3f7ca2bb | ||
|
|
6e22c4f68a | ||
|
|
565ef29ae3 | ||
|
|
68398b2a5a | ||
|
|
5624e4a25f | ||
|
|
92e07f3b74 | ||
|
|
8447f0a323 | ||
|
|
f0a2fdd508 | ||
|
|
320784659d | ||
|
|
51ab8cd67d | ||
|
|
237253d83b | ||
|
|
fe100fb490 | ||
|
|
c7b646e23a | ||
|
|
41add6882b | ||
|
|
dd0d2c2f0a | ||
|
|
d38e32c036 | ||
|
|
73315c2edc | ||
|
|
6b51d11d08 | ||
|
|
59270c39a7 | ||
|
|
db82cf7778 | ||
|
|
ddb1d57766 | ||
|
|
5dd770746b | ||
|
|
fa436eb368 | ||
|
|
fcc658f106 | ||
|
|
2e7b8fb9a1 | ||
|
|
1778e2576e | ||
|
|
73c9e85642 | ||
|
|
76557d2eb3 | ||
|
|
9095c7361e | ||
|
|
c02c1432e8 | ||
|
|
8411ed4f80 | ||
|
|
4de95f320f | ||
|
|
aea18173d1 | ||
|
|
856fc0652f | ||
|
|
b01c1240cf | ||
|
|
836ec05920 | ||
|
|
9a52b30c3d | ||
|
|
76af73bc72 | ||
|
|
f7bc0b49cb | ||
|
|
9155e98911 | ||
|
|
7aee50de97 | ||
|
|
24966ffbda | ||
|
|
666ef53fd2 | ||
|
|
e02ba05034 | ||
|
|
b478912910 | ||
|
|
2001932c56 | ||
|
|
f54de95802 | ||
|
|
fa1c2454e6 | ||
|
|
6b94237679 | ||
|
|
aedff8a000 | ||
|
|
a0aa8dd851 | ||
|
|
440ef4873b | ||
|
|
ffad2fbe55 | ||
|
|
cc1354ebfa | ||
|
|
581d2ba8b4 | ||
|
|
61348b20b4 | ||
|
|
e619e06078 | ||
|
|
4f84d1693a | ||
|
|
71d244a5b6 | ||
|
|
f9a0f869e3 | ||
|
|
33c472d734 | ||
|
|
a8eb122c1f | ||
|
|
956b1a7697 | ||
|
|
472ce19183 | ||
|
|
740924fa61 | ||
|
|
01b4bb5447 | ||
|
|
ee3b02932a | ||
|
|
2a07d3d26b | ||
|
|
e238148d42 | ||
|
|
9d21695476 | ||
|
|
22d11a9ccb | ||
|
|
fc9248ea2b | ||
|
|
c302979738 | ||
|
|
e4d077bc98 | ||
|
|
76cd9b7f72 | ||
|
|
e71431ec78 | ||
|
|
7b335eb635 | ||
|
|
c0c086388b | ||
|
|
048c8302fe | ||
|
|
a7b051b172 | ||
|
|
5f7ad58f48 | ||
|
|
016b9fc052 | ||
|
|
99b40e8257 | ||
|
|
a734e447b5 | ||
|
|
37128c34a9 | ||
|
|
f5630ab88e | ||
|
|
6790587db8 | ||
|
|
445f696dc6 | ||
|
|
dd5c3a9c8e | ||
|
|
0f45e38b52 | ||
|
|
93bc3cb628 | ||
|
|
79faedfb9b | ||
|
|
17d9caae83 | ||
|
|
eea18e856e | ||
|
|
7e64eb5414 | ||
|
|
8a959bb1f4 | ||
|
|
8d3ef0729c | ||
|
|
275680bdb7 | ||
|
|
4d5d1f0f66 | ||
|
|
1ef677f264 | ||
|
|
07193e2a34 | ||
|
|
f7da94610d | ||
|
|
872368d25c | ||
|
|
36320b4bf4 | ||
|
|
7185faa857 | ||
|
|
0c80fcff2a | ||
|
|
51caff5dcf | ||
|
|
d643ff5dbc | ||
|
|
44ca89eff7 | ||
|
|
7afad19c77 | ||
|
|
765c4ab4f4 | ||
|
|
24eca792ff | ||
|
|
b1b17ee264 | ||
|
|
74600cfb14 | ||
|
|
171ec1583d | ||
|
|
80c5106015 | ||
|
|
e92fe4c1a4 | ||
|
|
11f402b44a | ||
|
|
18049fe3e0 | ||
|
|
b330c10492 | ||
|
|
25255c4ed1 | ||
|
|
16febebd28 | ||
|
|
339952c2af | ||
|
|
75715635e8 | ||
|
|
9863d8d1d2 | ||
|
|
3ecccb7410 | ||
|
|
3c7a7a1675 | ||
|
|
d14c475de7 | ||
|
|
a68a3feb60 | ||
|
|
43382a9b9c | ||
|
|
a149502c01 | ||
|
|
decace60da | ||
|
|
2c876b6765 | ||
|
|
6d0785a78f | ||
|
|
ec593a2549 | ||
|
|
978de6fb97 | ||
|
|
c53e2960a0 | ||
|
|
cf91ebf278 | ||
|
|
fd5f21af00 | ||
|
|
1b93cb8c0a | ||
|
|
a9e6268766 | ||
|
|
fc855084a0 | ||
|
|
b7bccf86c3 | ||
|
|
6ee2a51edc | ||
|
|
d2dc1597fe | ||
|
|
82647e79c7 | ||
|
|
ecbebe2847 | ||
|
|
816db977fd | ||
|
|
cbe77e2412 | ||
|
|
1eb67ca49d | ||
|
|
7a89d731f7 | ||
|
|
65503dad73 | ||
|
|
a347262468 | ||
|
|
6a6fa7027a | ||
|
|
86cdc91180 | ||
|
|
094465a710 | ||
|
|
6ae56f302e | ||
|
|
ad895fadb1 | ||
|
|
7c120281c7 | ||
|
|
8a4095b405 | ||
|
|
a7cc5b6a5d | ||
|
|
ac1dfd4662 | ||
|
|
abf2f7f05e | ||
|
|
1c209d711e | ||
|
|
91f521ef92 | ||
|
|
9ac3ae1270 | ||
|
|
d74579aa38 | ||
|
|
6deb1a83b5 | ||
|
|
6f3a7ef3c8 | ||
|
|
9f3687f917 | ||
|
|
5e77c4e936 | ||
|
|
97c376e06d | ||
|
|
8f4d674442 | ||
|
|
7f277fea94 | ||
|
|
52440cc2e6 | ||
|
|
3fe9243e1c | ||
|
|
05dae25a22 | ||
|
|
23ea270881 | ||
|
|
7247543da3 | ||
|
|
37a8d2acc1 | ||
|
|
4a7ba87d99 | ||
|
|
51e3764519 | ||
|
|
533d92aa8e | ||
|
|
19887b7b8c | ||
|
|
005e75bdc3 | ||
|
|
5f3470fcd0 | ||
|
|
adb237cfa8 | ||
|
|
29a29d6210 | ||
|
|
3a155ceda6 | ||
|
|
7195a23a9d | ||
|
|
0ae6ff8018 | ||
|
|
241769dc2f | ||
|
|
4a39ee9bbc | ||
|
|
1dedf7f0cd | ||
|
|
70ede09310 | ||
|
|
3da30304fc | ||
|
|
820c04c679 | ||
|
|
9d848e3f5e | ||
|
|
d5f71c2e1d | ||
|
|
36a7d23273 | ||
|
|
c4317177f3 | ||
|
|
e231a84b2f | ||
|
|
b56fb96b1b | ||
|
|
163c7e3460 | ||
|
|
4c1023dac6 | ||
|
|
563d238fa0 | ||
|
|
9021776963 | ||
|
|
18771f1b6a | ||
|
|
ed2af11102 | ||
|
|
7dd65e84e6 | ||
|
|
e260ec6e9d | ||
|
|
7ce3f3c1a6 | ||
|
|
a466755bbb | ||
|
|
901c9d8ae0 | ||
|
|
6145c82804 | ||
|
|
876c02206d | ||
|
|
3ca312033f | ||
|
|
1378475573 | ||
|
|
00b049866b | ||
|
|
d847e477f0 | ||
|
|
c55e164e87 | ||
|
|
531cd5dd14 | ||
|
|
ff0a9f763e | ||
|
|
228e0a3d79 | ||
|
|
f38e29d00a | ||
|
|
963283d7d0 | ||
|
|
c91044a4a7 | ||
|
|
f42c26adbd | ||
|
|
9efad43509 | ||
|
|
33d8f08964 | ||
|
|
e826e9281e | ||
|
|
780120c9a2 | ||
|
|
d6c0c85125 | ||
|
|
c81fb397bb | ||
|
|
caf4e46e06 | ||
|
|
ff1a30d80a | ||
|
|
d143f49a66 | ||
|
|
58698b789a | ||
|
|
ee3f2ffa19 | ||
|
|
c59124dfe2 | ||
|
|
7b14cf8558 | ||
|
|
05f796d2fa | ||
|
|
bd8c91b37d | ||
|
|
7294cdef3e | ||
|
|
4d7b6374c8 | ||
|
|
5855da5a15 | ||
|
|
34fd493512 | ||
|
|
da4bd9b110 | ||
|
|
7fbf6df09e | ||
|
|
68415d040f | ||
|
|
8ee74f6bff | ||
|
|
bf0fa4089f | ||
|
|
07ae149955 | ||
|
|
ecb93d97a5 | ||
|
|
f769d5e27f | ||
|
|
1e414c8f37 | ||
|
|
07e6994be1 | ||
|
|
0abf4f8fbb | ||
|
|
a13e4a77e0 | ||
|
|
6de2271e2a | ||
|
|
021e255282 | ||
|
|
92b1e038c1 | ||
|
|
a8c33ae219 | ||
|
|
e7bc30b409 | ||
|
|
efaefa21fc | ||
|
|
42bd417acf | ||
|
|
af58e8e8f9 | ||
|
|
4bf4a7668e | ||
|
|
c03ca9c73c | ||
|
|
d5884afcf3 | ||
|
|
a2aeafe85b | ||
|
|
0109b39f58 | ||
|
|
752e978d56 | ||
|
|
8b36a11f2b | ||
|
|
ccd448d626 | ||
|
|
44fb38949b | ||
|
|
ad1532ed57 | ||
|
|
caaec3bb05 | ||
|
|
df47fae287 | ||
|
|
b65bf48369 | ||
|
|
4c02acb728 | ||
|
|
8c9151c86b | ||
|
|
c075742bc8 | ||
|
|
b42cf317d6 | ||
|
|
f5429e4ce8 | ||
|
|
82dad8e629 | ||
|
|
59aa37fe2b | ||
|
|
0adb43f06e | ||
|
|
87e09a09da | ||
|
|
ba630816bc | ||
|
|
863fdafcd5 | ||
|
|
be5e6941bf | ||
|
|
7980115412 | ||
|
|
cab86a0deb | ||
|
|
be3a1da14a | ||
|
|
650c587875 | ||
|
|
d29c5760bd | ||
|
|
ee9d777d69 | ||
|
|
59582bafa3 | ||
|
|
1ad85ac9ee | ||
|
|
999a84c77a | ||
|
|
48e0d167aa | ||
|
|
f14da66ce5 | ||
|
|
14ab311d2f | ||
|
|
02ab4363b6 | ||
|
|
e1f7c73324 | ||
|
|
3042fc2a29 | ||
|
|
a622c1c2fe | ||
|
|
b3e467dcba | ||
|
|
c0259255b0 | ||
|
|
9398bc1764 | ||
|
|
fcf9fa3651 | ||
|
|
583df79be9 | ||
|
|
0e0b892493 | ||
|
|
78a8d64a92 | ||
|
|
5433e4dab8 | ||
|
|
c3c59b010b | ||
|
|
8eb481b6c6 | ||
|
|
d5efeb7df5 | ||
|
|
f663042893 | ||
|
|
f07c1a11a0 | ||
|
|
ce297bfa9e | ||
|
|
ba1682c120 | ||
|
|
e212154d8d | ||
|
|
ec0fe09138 | ||
|
|
8562ed3018 | ||
|
|
21b0ccf859 | ||
|
|
84c93c2fea | ||
|
|
e3c2305ff4 | ||
|
|
0e3c467a5b | ||
|
|
94880d8f36 | ||
|
|
7307bb6e9a | ||
|
|
4263410fe8 | ||
|
|
cb0eb855ca | ||
|
|
569d0ec7cc | ||
|
|
1021e87522 | ||
|
|
dc34cf362f | ||
|
|
e71749428c | ||
|
|
8f58b776b0 | ||
|
|
fb0a11636f | ||
|
|
7bf09734d7 | ||
|
|
853bcb3c64 | ||
|
|
4d32395fe1 | ||
|
|
a6a141d326 | ||
|
|
e0161e03db | ||
|
|
82d29d4c2a | ||
|
|
1a5791750b | ||
|
|
482d9b58b3 | ||
|
|
5903dd7d82 | ||
|
|
301b1ffbc7 | ||
|
|
759be64115 | ||
|
|
ece2a2d6c2 | ||
|
|
f31957c502 | ||
|
|
fb69541cfa | ||
|
|
e189679ebc | ||
|
|
18e7fcc37f | ||
|
|
1c8a657044 | ||
|
|
cdea5c8eef | ||
|
|
bcc386e3bb | ||
|
|
a2bd3bb75b | ||
|
|
b63d618e48 | ||
|
|
8864c2d59b | ||
|
|
c75073fbf4 | ||
|
|
cf4529d058 | ||
|
|
9b6900b058 | ||
|
|
7f7ef068fc | ||
|
|
a41790ce8a | ||
|
|
06615a556d | ||
|
|
94a69c2b31 | ||
|
|
425ff2f81d | ||
|
|
2257166e61 | ||
|
|
56cf5f4f67 | ||
|
|
668484ba8f | ||
|
|
f824078c14 | ||
|
|
3250833a62 | ||
|
|
8bc24912d1 | ||
|
|
52f6f7e0c7 | ||
|
|
ee8ee69c30 | ||
|
|
4941ebcc91 | ||
|
|
9adbea785b | ||
|
|
fd19413196 | ||
|
|
6300a8a0a2 | ||
|
|
66c1228c95 | ||
|
|
4585b23552 | ||
|
|
23a624f73a | ||
|
|
f3d7d2f7b1 | ||
|
|
0358983ee6 | ||
|
|
a0977266b4 | ||
|
|
76947f0074 | ||
|
|
f649754018 | ||
|
|
b1c5ce2517 | ||
|
|
f2db5ec4fb | ||
|
|
db08494776 | ||
|
|
9166d595e6 | ||
|
|
f1061c8763 | ||
|
|
fca9803bee | ||
|
|
0d841b5e05 | ||
|
|
216791c3fb | ||
|
|
12c4e68058 | ||
|
|
b4b451863d | ||
|
|
f2808de855 | ||
|
|
9b2897ccd9 | ||
|
|
3c4698435c | ||
|
|
98682e1073 | ||
|
|
d6bcb8b7e0 | ||
|
|
a501237ae3 | ||
|
|
f6622c2fbb | ||
|
|
b08b90d71c | ||
|
|
b46ed8c7a3 | ||
|
|
45869ce843 | ||
|
|
dff377a741 | ||
|
|
b24cf8d157 | ||
|
|
2ad90b7c41 | ||
|
|
a40fc41988 | ||
|
|
3416c6d91b | ||
|
|
54c2bcb60f | ||
|
|
44a5108e1d | ||
|
|
d8715871fa | ||
|
|
772fcc963c | ||
|
|
75b7104724 | ||
|
|
fe3c1f9061 | ||
|
|
e30818ce39 | ||
|
|
2e30886a0d | ||
|
|
b18ffbd08a | ||
|
|
16d2dc662f | ||
|
|
9832c911b3 | ||
|
|
23f5eeec20 | ||
|
|
16106b2978 | ||
|
|
c66e6be4a4 | ||
|
|
eda4c26d24 | ||
|
|
4b140e060b | ||
|
|
1fefa03329 | ||
|
|
37ff9b029c | ||
|
|
e798fe37e1 | ||
|
|
f4a8f7165c | ||
|
|
2d52e409c2 | ||
|
|
1b5e677d0c | ||
|
|
c508923f04 | ||
|
|
6c4024796e | ||
|
|
bd2c6cfa55 | ||
|
|
bd74db932e | ||
|
|
439337fb1b | ||
|
|
5ffe6f5acf | ||
|
|
f281f8cb75 | ||
|
|
3a46e2d86b | ||
|
|
6a84a1788b | ||
|
|
df870e5241 | ||
|
|
82afd3a891 | ||
|
|
514fc72050 | ||
|
|
4dba9aed22 | ||
|
|
a46dbe6941 | ||
|
|
394db7b738 | ||
|
|
3ad58ee1f5 | ||
|
|
00aa77f2d9 | ||
|
|
60fc79c717 | ||
|
|
f501186b18 | ||
|
|
fe6d9ed9ba | ||
|
|
c450d418ef | ||
|
|
c3b1af023b | ||
|
|
bf37be46b8 | ||
|
|
4466c31fc2 | ||
|
|
b2bebcf5ce | ||
|
|
de33ba029b | ||
|
|
465db44499 | ||
|
|
abdb8ee3f7 | ||
|
|
aa6b4b4970 | ||
|
|
25cbfcf34a | ||
|
|
cffc33a51c | ||
|
|
5db7b01fa2 | ||
|
|
1ca5ca8392 | ||
|
|
93761d9ab5 | ||
|
|
bb16d8816c | ||
|
|
e1cd500ac5 | ||
|
|
2d09cbfd21 | ||
|
|
d84b16caf9 | ||
|
|
95f06f0591 | ||
|
|
3bf4d635f2 | ||
|
|
a4fa18e92d | ||
|
|
f71af2a2ef | ||
|
|
3e62f8d9b7 | ||
|
|
028720c9ec | ||
|
|
d518970039 | ||
|
|
8363a6ab1e | ||
|
|
a540dcd2e2 | ||
|
|
58b2c6c4a5 | ||
|
|
34ffde6799 | ||
|
|
e7cd945000 | ||
|
|
ccf0f05e98 | ||
|
|
36672ad50e | ||
|
|
8bee3d89c5 | ||
|
|
cf212e55ac | ||
|
|
a00f61bd5d | ||
|
|
dca76de872 | ||
|
|
70540f9563 | ||
|
|
a545cb7cff | ||
|
|
9a86a3bd23 | ||
|
|
69673635ef | ||
|
|
77e6971bbb | ||
|
|
a9a1336502 | ||
|
|
9103674950 | ||
|
|
2af39ac017 | ||
|
|
d47b8fef18 | ||
|
|
f8fc214b11 | ||
|
|
7861bfa45e | ||
|
|
02734264a1 | ||
|
|
4a845f3d04 | ||
|
|
0452ebdfcd | ||
|
|
c8b8c4cf30 | ||
|
|
1ff1401ff1 | ||
|
|
3991bbe595 | ||
|
|
20beb093a1 | ||
|
|
3135642ff5 | ||
|
|
d5bb3b0039 | ||
|
|
f16216e270 | ||
|
|
de9e1a0693 | ||
|
|
47b18d89f6 | ||
|
|
3f5b474b16 | ||
|
|
b103fec939 | ||
|
|
728be68bfe | ||
|
|
5820e97abe | ||
|
|
4e81ea2a8a | ||
|
|
7bfdb31c77 | ||
|
|
44cec04294 | ||
|
|
c60a84b6f5 | ||
|
|
3b953cc763 | ||
|
|
859ce39666 | ||
|
|
7c6ea4ed00 | ||
|
|
3dab3be859 | ||
|
|
062ed99894 | ||
|
|
d275fc90cf | ||
|
|
dbc4c47b15 | ||
|
|
e6d97ce928 | ||
|
|
b7473285ec | ||
|
|
8b7107b81f | ||
|
|
d1251b2850 | ||
|
|
e972589554 | ||
|
|
0f19c958da | ||
|
|
2935fbc089 | ||
|
|
f47fc4f111 | ||
|
|
01c95cb07e | ||
|
|
1f94541732 | ||
|
|
ff43b4dca0 | ||
|
|
5d494e940f | ||
|
|
30de580afe | ||
|
|
0c13350ea4 | ||
|
|
83a661c360 | ||
|
|
38ec1325c4 | ||
|
|
2ca2e83ce5 | ||
|
|
a9908ba7bd | ||
|
|
9f874c00aa | ||
|
|
b52cdf6a95 | ||
|
|
40e637d9e1 | ||
|
|
21c76d97bb | ||
|
|
4b3147ede7 | ||
|
|
a037a66ea4 | ||
|
|
c071819c26 | ||
|
|
28e018de8a | ||
|
|
65102c0ba5 | ||
|
|
ff8e97310d | ||
|
|
2546661aeb | ||
|
|
fdeed49637 | ||
|
|
fab7693da5 | ||
|
|
582323d63c | ||
|
|
a6522d3706 | ||
|
|
28a0028762 | ||
|
|
ec19c32b63 | ||
|
|
ec9aceb96f | ||
|
|
0e1c2e3378 | ||
|
|
094b952d70 | ||
|
|
3821a4e054 | ||
|
|
d24404ca9a | ||
|
|
fb2d6e8870 | ||
|
|
e421cbac2a | ||
|
|
a71310f58b | ||
|
|
43c392626b | ||
|
|
d286573958 | ||
|
|
ff889c40da | ||
|
|
0ecdbe8614 | ||
|
|
8b3500a2a9 | ||
|
|
c5fd56606d | ||
|
|
dd86b85664 | ||
|
|
3ec9f5fa0b | ||
|
|
3bf3ce06f7 | ||
|
|
cc1d601722 | ||
|
|
e8c1b849b7 | ||
|
|
de44b71b12 | ||
|
|
df70c7136d | ||
|
|
bf2b9ea539 | ||
|
|
b0b46c331e | ||
|
|
b3269581ea | ||
|
|
699edd4393 | ||
|
|
9128c6c17b | ||
|
|
f121223ed8 | ||
|
|
3c0e360df1 | ||
|
|
1de6f5fcf6 | ||
|
|
5bf4b718d4 | ||
|
|
f912007fe8 | ||
|
|
377809a35b | ||
|
|
f0f981b80d | ||
|
|
2b9302632c | ||
|
|
a59a1552ad | ||
|
|
4a80e821df | ||
|
|
6822291f91 | ||
|
|
863aacaee3 | ||
|
|
00a2bf7120 | ||
|
|
6ac5acf765 | ||
|
|
ce7583f173 | ||
|
|
24b10ac585 | ||
|
|
706371e24f | ||
|
|
5de8639685 | ||
|
|
d42e26d59c | ||
|
|
6ea06e87bb | ||
|
|
5eb8a44317 | ||
|
|
c89fb0b828 | ||
|
|
52e111dbb7 | ||
|
|
36b5109387 | ||
|
|
c07b085c81 | ||
|
|
065c442141 | ||
|
|
83b570d981 | ||
|
|
2afdee9c7d | ||
|
|
a7e809e1f7 | ||
|
|
deb7cb708f | ||
|
|
fcd7db6cd1 | ||
|
|
68adbd2e05 | ||
|
|
b6258d612b | ||
|
|
93cb76a292 | ||
|
|
6191f69f0c | ||
|
|
d416e6c854 | ||
|
|
3a63d978dd | ||
|
|
d2a78c33df | ||
|
|
679f91482e | ||
|
|
d380a8554d | ||
|
|
4f36ad0cc1 | ||
|
|
90ba7fbf1f | ||
|
|
76658477af | ||
|
|
ffb6a9c74b | ||
|
|
21d334389f | ||
|
|
94a5e081e5 | ||
|
|
5e78d72ef2 | ||
|
|
5c303e2bb5 | ||
|
|
4c1cb388af | ||
|
|
144bd4a878 | ||
|
|
91737aff68 | ||
|
|
2391b40f47 | ||
|
|
6a8aff5a74 | ||
|
|
c0ec5d404b | ||
|
|
10e9a6b6cd | ||
|
|
a51aed7ce2 | ||
|
|
71e0106846 | ||
|
|
3ce9af7fce | ||
|
|
05e8aae95e | ||
|
|
381de6b7cb | ||
|
|
c077645f77 | ||
|
|
ebc3263987 | ||
|
|
cf6e5bf01f | ||
|
|
958c615a83 | ||
|
|
8e5070f469 | ||
|
|
4397b675cb | ||
|
|
9ed88f6a8d | ||
|
|
f12fde9132 | ||
|
|
1c4ea6d246 | ||
|
|
a6d76b3c48 | ||
|
|
5d0ace0577 | ||
|
|
7b88544d46 | ||
|
|
6767ea2456 | ||
|
|
459db3d64b | ||
|
|
d009cf618a | ||
|
|
9a9897a9de | ||
|
|
3f9fb13df6 | ||
|
|
52f414669a | ||
|
|
b34215906c | ||
|
|
fb768ac792 | ||
|
|
35289bffe2 | ||
|
|
ef00fdf472 | ||
|
|
3de7e8358f | ||
|
|
28ac2f49dc | ||
|
|
c38b5d5eb9 | ||
|
|
180d06613a | ||
|
|
c3ee4212f0 | ||
|
|
efafbe9a5c | ||
|
|
e38680a4df | ||
|
|
f28fc6f2e1 | ||
|
|
5ba8d36687 | ||
|
|
178236cc5f | ||
|
|
79a0533c69 | ||
|
|
64363995be | ||
|
|
426ad6e3a3 | ||
|
|
0d0e7a1008 | ||
|
|
806545df34 | ||
|
|
b8cc257ac5 | ||
|
|
bdb4d96678 | ||
|
|
0c5fb4a81b | ||
|
|
3ff48f27cf | ||
|
|
f0c732452f | ||
|
|
a4d1b1ba21 | ||
|
|
0447ea94c1 | ||
|
|
38fd7a84c7 | ||
|
|
ee17910ec5 | ||
|
|
717a7dbfde | ||
|
|
0fb6576511 | ||
|
|
383495c863 | ||
|
|
b55abf5730 | ||
|
|
3e1aa456b9 | ||
|
|
00558adda8 | ||
|
|
1c3273aab2 | ||
|
|
589b247926 | ||
|
|
6965e3e03c | ||
|
|
202d5ab754 | ||
|
|
1023be33fb | ||
|
|
595c00f55c | ||
|
|
5aaa5eab70 | ||
|
|
70b24b021a | ||
|
|
af96c721c4 | ||
|
|
a9b653db26 | ||
|
|
80c23d4519 | ||
|
|
821d7a8941 | ||
|
|
e7c8a22c67 | ||
|
|
5652ccc780 | ||
|
|
055d429ae1 | ||
|
|
8231897b26 | ||
|
|
df7e656034 | ||
|
|
d045409b9f | ||
|
|
7f3f4cfdd0 | ||
|
|
ef044d9f17 | ||
|
|
9642c7f990 | ||
|
|
0c5193c588 | ||
|
|
f2c2b3fc7a | ||
|
|
1228e0e925 | ||
|
|
3a3820bedc | ||
|
|
91ee6ed60f | ||
|
|
7e28fdc176 | ||
|
|
569bc02649 | ||
|
|
178309be47 | ||
|
|
2fb7ac9a58 | ||
|
|
2e493cb89a | ||
|
|
cdf0d77b20 | ||
|
|
ccdfaa9115 | ||
|
|
34af05ec30 | ||
|
|
6bd41e47ac | ||
|
|
45d11c53f0 | ||
|
|
50a68d7d59 | ||
|
|
cc47b5a78c | ||
|
|
34b4ec3624 | ||
|
|
86ed364dc0 | ||
|
|
438cde4e70 | ||
|
|
3b268d1656 | ||
|
|
0a97782339 | ||
|
|
1cf1d6146c | ||
|
|
f3217ac170 | ||
|
|
c8125f8710 | ||
|
|
1e3bc7c069 | ||
|
|
34df9f3dbf | ||
|
|
72bb159a7e | ||
|
|
afe4e345d2 | ||
|
|
855b5b513d | ||
|
|
b9d271c1a8 | ||
|
|
b3931741ef | ||
|
|
ede48e285f | ||
|
|
8890539f47 | ||
|
|
ff72dd8d2c | ||
|
|
e07b265009 | ||
|
|
8d0e5899b9 | ||
|
|
e6f8b59010 | ||
|
|
8e65846f32 | ||
|
|
96d4d3f3be | ||
|
|
811c01cc2e | ||
|
|
e24127771e | ||
|
|
b3f00d05a8 | ||
|
|
652d34b0a8 | ||
|
|
7539577b46 | ||
|
|
41ee6006c4 | ||
|
|
813ba42cfc | ||
|
|
80076276e1 | ||
|
|
3a78e8010d | ||
|
|
d9940f416b | ||
|
|
dd998e7fd3 | ||
|
|
747db4d940 | ||
|
|
ecd5c523dc | ||
|
|
3de14fc63e | ||
|
|
7f166eaee7 | ||
|
|
ab7b5e48c4 | ||
|
|
345b5cfc5c | ||
|
|
1ac93c3a72 | ||
|
|
4b8c29a708 | ||
|
|
04b057d22c | ||
|
|
fcfb8dd2ed | ||
|
|
4a2673772a | ||
|
|
b9e216ac6f | ||
|
|
e78e2885fe | ||
|
|
777f2e7547 | ||
|
|
27e494d25c | ||
|
|
d88156d998 | ||
|
|
44a3af51f0 | ||
|
|
79f090d92b | ||
|
|
54c65fdad0 | ||
|
|
e917802316 | ||
|
|
6a19a31171 | ||
|
|
a06b7f2ae0 | ||
|
|
405b1067e2 | ||
|
|
10cb93283a | ||
|
|
d28e8f537a | ||
|
|
24d7f54662 | ||
|
|
687a43e199 | ||
|
|
07ef7d750b | ||
|
|
ea2b1d36aa | ||
|
|
c7540fba94 | ||
|
|
3d9198592b | ||
|
|
d6357bacdd | ||
|
|
647551b8e4 | ||
|
|
b158c25dc3 | ||
|
|
bc8a3c5b6f | ||
|
|
c149db2205 | ||
|
|
b5495ec972 | ||
|
|
472c390e75 | ||
|
|
3d9a41e4b4 | ||
|
|
9f77b065d3 | ||
|
|
7abbe1e8d8 | ||
|
|
004b6ed60f | ||
|
|
d12f30f90c | ||
|
|
c433c2f2e2 | ||
|
|
9e52c330ae | ||
|
|
564deec2c4 | ||
|
|
6fd0ffccbf | ||
|
|
ee957a4285 | ||
|
|
c63331a303 | ||
|
|
4d2c44ca87 | ||
|
|
596b5cd732 | ||
|
|
8ff1ba325d | ||
|
|
a19d7e3680 | ||
|
|
90eeb25770 | ||
|
|
bfe8b81d18 | ||
|
|
ec71c19be7 | ||
|
|
cce1fc9c65 | ||
|
|
79fee501af | ||
|
|
12dfaa2d74 | ||
|
|
d4e5366fe6 | ||
|
|
d7388d7e80 | ||
|
|
5c363b76ee | ||
|
|
440adddcde | ||
|
|
af9ad1580a | ||
|
|
d569430cc6 | ||
|
|
c39bea2017 | ||
|
|
a361f618a1 | ||
|
|
8c2d8bc85f | ||
|
|
563b56e09c | ||
|
|
455f675806 | ||
|
|
3932e860ca | ||
|
|
b3368a85da | ||
|
|
defe0b25dd | ||
|
|
b68ed904b1 | ||
|
|
2eba4fb96b | ||
|
|
27ba604ad7 | ||
|
|
769982d058 | ||
|
|
674d702257 | ||
|
|
c974cb1b8e | ||
|
|
20c05a3add | ||
|
|
c27322ff04 | ||
|
|
6e624946d2 | ||
|
|
ab9a63bbea | ||
|
|
3a8438e1f8 | ||
|
|
0e49c6affd | ||
|
|
8bcf78cd78 | ||
|
|
ffc944976b | ||
|
|
1b52be6246 | ||
|
|
e7e1ec6e84 | ||
|
|
ff3c441023 | ||
|
|
aaf6e84373 | ||
|
|
380a357b08 | ||
|
|
8026d0b2e7 | ||
|
|
b41cad58cb | ||
|
|
39e12244cc | ||
|
|
c4c01b61e6 | ||
|
|
eb3cd22aa3 | ||
|
|
5b35f5fb69 | ||
|
|
11d875d043 | ||
|
|
ac946a4602 | ||
|
|
815e2f3d03 | ||
|
|
bd8bca87b2 | ||
|
|
9110aa09a4 | ||
|
|
fe085a631d | ||
|
|
c7489af844 | ||
|
|
32a653e67e | ||
|
|
d16c93aa08 | ||
|
|
46367a7a7b | ||
|
|
83a25c06ef | ||
|
|
db7db67851 | ||
|
|
8d7073abf6 | ||
|
|
f1c8dd887b | ||
|
|
08bc3b0386 | ||
|
|
2808de6084 | ||
|
|
028088f5f0 | ||
|
|
21178c3571 | ||
|
|
b8214e260c | ||
|
|
45d813b62c | ||
|
|
73b3e0e50e | ||
|
|
255fcbc3a5 | ||
|
|
47d93279ff | ||
|
|
5b93ae8628 | ||
|
|
436318a8c8 | ||
|
|
57a328c7a9 | ||
|
|
2cd3f046e5 | ||
|
|
5c88c1376c | ||
|
|
2d39e5d7a5 | ||
|
|
27e255fa75 | ||
|
|
195190b612 | ||
|
|
aeabfaf417 | ||
|
|
f62201ba9d | ||
|
|
5cf331d881 | ||
|
|
28c90cce6c | ||
|
|
ca5b10938a | ||
|
|
acd4cc6f5c | ||
|
|
7ac3a36229 | ||
|
|
a6178c1de6 | ||
|
|
990dd18474 | ||
|
|
c4642d4fda | ||
|
|
c7d3b83164 | ||
|
|
7c87bb35c4 | ||
|
|
f20530dce2 | ||
|
|
5d5adf7c7e | ||
|
|
fc01873d60 | ||
|
|
81b9e78565 | ||
|
|
cee4505172 | ||
|
|
4d4b29ea94 | ||
|
|
efd780f82a | ||
|
|
cc0ff6b0bf | ||
|
|
35e13cf5e8 | ||
|
|
238652b36c | ||
|
|
e4b728ccb9 | ||
|
|
68967aef72 | ||
|
|
fd67d46be7 | ||
|
|
ee0e8a3aad | ||
|
|
f4734d6b4d | ||
|
|
656628e69b | ||
|
|
6b1bca80ee | ||
|
|
537a50214a | ||
|
|
67d04dd9ba | ||
|
|
b8efd02c7f | ||
|
|
a600d8f4e2 | ||
|
|
de7793e918 | ||
|
|
a5e442d490 | ||
|
|
51513c4e6b | ||
|
|
5d0b813cec | ||
|
|
ba0c271774 | ||
|
|
7062c01b68 | ||
|
|
c0bad42eb1 | ||
|
|
af7ebd96a0 | ||
|
|
ac59fd1476 | ||
|
|
6561d70664 | ||
|
|
1a5c59326a | ||
|
|
d44375aece | ||
|
|
cf37058d7c | ||
|
|
dcb3fcbfa7 | ||
|
|
6ece3f6792 | ||
|
|
3b30e42551 | ||
|
|
b0ef524b9e | ||
|
|
b138aaae08 | ||
|
|
3953661078 | ||
|
|
b551844cc2 | ||
|
|
93f3e2b007 | ||
|
|
0a42a8bc46 | ||
|
|
8097b07661 | ||
|
|
1475cabfa0 | ||
|
|
6a1573c228 | ||
|
|
d26e1d783f | ||
|
|
fa720c1858 | ||
|
|
bc7c3e44d5 | ||
|
|
480ca88b68 | ||
|
|
aba0e602ed | ||
|
|
22a2f98ced | ||
|
|
aaa47850c3 | ||
|
|
7c2feb78d2 | ||
|
|
0c65d2cc0c | ||
|
|
13c5f806c6 | ||
|
|
84d3b4de46 | ||
|
|
925a772dce | ||
|
|
95015f1104 | ||
|
|
dcbc727813 | ||
|
|
3b9d4c8d50 | ||
|
|
40fe9e6d67 | ||
|
|
4da816e459 | ||
|
|
9c475467d5 | ||
|
|
0310cbad0a | ||
|
|
ef258914b2 | ||
|
|
c025f363f5 | ||
|
|
51187d06b3 | ||
|
|
8210b3c873 | ||
|
|
883e0826e2 | ||
|
|
003f9f7953 | ||
|
|
2880a679f0 | ||
|
|
4d6cff7eb8 | ||
|
|
d8806649ab | ||
|
|
dc9a65923a | ||
|
|
751d2a0fe7 | ||
|
|
e3e2dc1f6e | ||
|
|
4f329cbb45 | ||
|
|
0e8995aa7e | ||
|
|
7812030886 | ||
|
|
6fb9794200 | ||
|
|
9e419fdaf7 | ||
|
|
e634cd0d62 | ||
|
|
676f8f189f | ||
|
|
df44837b07 | ||
|
|
16998b4b6d | ||
|
|
f57c4fd0c2 | ||
|
|
5743cca5f8 | ||
|
|
e716a316f6 | ||
|
|
c2b0a8101b | ||
|
|
f88a57e5d7 | ||
|
|
1776120dba | ||
|
|
f4601aff8b | ||
|
|
14799e25c6 | ||
|
|
eea61ee5e4 | ||
|
|
ff6d246efd | ||
|
|
a7f08e9b36 | ||
|
|
06363c01e4 | ||
|
|
ec398229b1 | ||
|
|
a19c8a4ea3 | ||
|
|
f8de2fc8eb | ||
|
|
0380840348 | ||
|
|
9cd5752e38 | ||
|
|
65f7f8dc50 | ||
|
|
36c8d85f43 | ||
|
|
d2bfeaa5e2 | ||
|
|
025bc9fbe1 | ||
|
|
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 |
67
.travis.yml
Normal file
67
.travis.yml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
language: c
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-multilib
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
||||||
|
- os: linux
|
||||||
|
compiler: clang-3.9
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
sudo: true
|
||||||
|
- os: linux
|
||||||
|
compiler: x86_64-w64-mingw32-gcc
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-mingw-w64-base
|
||||||
|
- binutils-mingw-w64-x86-64
|
||||||
|
- gcc-mingw-w64-x86-64
|
||||||
|
- gcc-mingw-w64
|
||||||
|
- os: linux
|
||||||
|
compiler: x86_64-w64-mingw32-gcc
|
||||||
|
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- gcc-mingw-w64-base
|
||||||
|
- binutils-mingw-w64-i686
|
||||||
|
- gcc-mingw-w64-i686
|
||||||
|
- gcc-mingw-w64
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc-4.8
|
||||||
|
env: OPJ_CI_ABI_CHECK=1
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- gcc-4.8
|
||||||
|
- libelf-dev
|
||||||
|
- elfutils
|
||||||
|
- texinfo
|
||||||
|
- exuberant-ctags
|
||||||
|
|
||||||
|
install:
|
||||||
|
- ./tools/travis-ci/install.sh
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./tools/travis-ci/run.sh
|
||||||
|
- ./tools/travis-ci/abi-check.sh
|
||||||
15
AUTHORS
Normal file
15
AUTHORS
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
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 2.0.
|
||||||
|
Giuseppe Baruffa added the JPWL functionalities.
|
||||||
|
Micka<EFBFBD>l Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
|
||||||
|
Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
|
||||||
|
Yannick Verschueren,
|
||||||
|
Herve Drolon,
|
||||||
|
Francois-Olivier Devaux,
|
||||||
|
Antonin Descampe
|
||||||
|
improved the libraries and utilities.
|
||||||
|
|
||||||
384
CMakeLists.txt
Normal file
384
CMakeLists.txt
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
# 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.8.2)
|
||||||
|
|
||||||
|
if(COMMAND CMAKE_POLICY)
|
||||||
|
cmake_policy(SET CMP0003 NEW)
|
||||||
|
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||||
|
cmake_policy(SET CMP0042 NEW)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_NAMESPACE)
|
||||||
|
set(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||||
|
set(OPENJPEG_STANDALONE 1)
|
||||||
|
endif()
|
||||||
|
# In all cases:
|
||||||
|
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||||
|
set(OPENJPEG_LIBRARY_NAME openjp2)
|
||||||
|
|
||||||
|
project(${OPENJPEG_NAMESPACE} C)
|
||||||
|
|
||||||
|
# Do full dependency headers.
|
||||||
|
include_regular_expression("^.*$")
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
|
set(OPENJPEG_VERSION_MAJOR 2)
|
||||||
|
set(OPENJPEG_VERSION_MINOR 1)
|
||||||
|
set(OPENJPEG_VERSION_BUILD 0)
|
||||||
|
set(OPENJPEG_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
set(PACKAGE_VERSION
|
||||||
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
|
||||||
|
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||||
|
# two numbering, one for the openjpeg version and one for openjpeg soversion
|
||||||
|
# version | soversion
|
||||||
|
# 1.0 | 0
|
||||||
|
# 1.1 | 1
|
||||||
|
# 1.2 | 2
|
||||||
|
# 1.3 | 3
|
||||||
|
# 1.4 | 4
|
||||||
|
# 1.5 | 5
|
||||||
|
# 1.5.1 | 5
|
||||||
|
# 2.0 | 6
|
||||||
|
# 2.0.1 | 6
|
||||||
|
# 2.1 | 7
|
||||||
|
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||||
|
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||||
|
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||||
|
if(NOT OPENJPEG_SOVERSION)
|
||||||
|
set(OPENJPEG_SOVERSION 7)
|
||||||
|
endif(NOT OPENJPEG_SOVERSION)
|
||||||
|
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
|
SOVERSION "${OPENJPEG_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()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Install directories
|
||||||
|
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||||
|
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||||
|
|
||||||
|
string(TOLOWER ${PROJECT_NAME} projectname)
|
||||||
|
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_DOC)
|
||||||
|
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||||
|
if(WIN32)
|
||||||
|
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
||||||
|
else()
|
||||||
|
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
|
# We could install *.cmake files in share/ however those files contains
|
||||||
|
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
||||||
|
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
||||||
|
set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
|
||||||
|
option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Big endian test:
|
||||||
|
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||||
|
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()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# 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(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (1/2)
|
||||||
|
|
||||||
|
# Check if some include files are provided by the system
|
||||||
|
include(EnsureFileInclude)
|
||||||
|
# These files are mandatory
|
||||||
|
ensure_file_include("string.h" HAVE_STRING_H YES)
|
||||||
|
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
|
||||||
|
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
|
||||||
|
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
|
||||||
|
ensure_file_include("math.h" HAVE_MATH_H YES)
|
||||||
|
ensure_file_include("float.h" HAVE_FLOAT_H YES)
|
||||||
|
ensure_file_include("time.h" HAVE_TIME_H YES)
|
||||||
|
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
|
||||||
|
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
|
||||||
|
ensure_file_include("assert.h" HAVE_ASSERT_H YES)
|
||||||
|
|
||||||
|
# For the following files, we provide an alternative, they are not mandatory
|
||||||
|
ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
|
||||||
|
ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
|
||||||
|
|
||||||
|
# why check this one ? for openjpip ?
|
||||||
|
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
||||||
|
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
|
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
|
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||||
|
|
||||||
|
# Enable Large file support
|
||||||
|
include(TestLargeFiles)
|
||||||
|
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||||
|
|
||||||
|
# Allocating Aligned Memory Blocks
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
||||||
|
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
|
# posix_memalign (needs _POSIX_C_SOURCE >= 200112L on Linux)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
|
||||||
|
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
|
||||||
|
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||||
|
# memalign (obsolete)
|
||||||
|
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Build Library
|
||||||
|
if(BUILD_JPIP_SERVER)
|
||||||
|
find_package(CURL REQUIRED)
|
||||||
|
find_package(FCGI REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
if(NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
|
message(FATAL_ERROR "Only pthread are supported")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
add_subdirectory(src/lib)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Build Applications
|
||||||
|
option(BUILD_CODEC "Build the CODEC executables" ON)
|
||||||
|
option(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||||
|
option(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||||
|
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||||
|
endif()
|
||||||
|
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||||
|
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||||
|
option(BUILD_JP3D "Build the JP3D comp" OFF)
|
||||||
|
mark_as_advanced(BUILD_VIEWER)
|
||||||
|
mark_as_advanced(BUILD_JAVA)
|
||||||
|
mark_as_advanced(BUILD_JP3D)
|
||||||
|
|
||||||
|
if(BUILD_CODEC OR BUILD_MJ2)
|
||||||
|
# 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(src/bin)
|
||||||
|
endif ()
|
||||||
|
add_subdirectory(wrapping)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_config.h generation (2/2)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# build documentation in doc subdir:
|
||||||
|
if(BUILD_DOC)
|
||||||
|
add_subdirectory(doc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Buld Testing
|
||||||
|
option(BUILD_TESTING "Build the tests." OFF)
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
if(BUILD_CODEC)
|
||||||
|
enable_testing()
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
|
# Search openjpeg data needed for the tests
|
||||||
|
# They could be found via git on the OpenJPEG GitHub code project
|
||||||
|
# git clone https://github.com/uclouvain/openjpeg-data.git
|
||||||
|
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
||||||
|
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||||
|
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add repository where to find tests
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "You need build codec to run the tests")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install all targets referenced as OPENJPEGTargets
|
||||||
|
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||||
|
configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
||||||
|
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# install CHANGES and LICENSE
|
||||||
|
if(BUILD_DOC)
|
||||||
|
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||||
|
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include (cmake/OpenJPEGCPack.cmake)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# pkgconfig support
|
||||||
|
# enabled by default on Unix, disabled by default on other platforms
|
||||||
|
if(UNIX)
|
||||||
|
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
|
||||||
|
else()
|
||||||
|
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
|
||||||
|
endif()
|
||||||
|
if(BUILD_PKGCONFIG_FILES)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
#
|
||||||
|
if(BUILD_JPWL)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpwl/libopenjpwl.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpwl.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
#
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjpip/libopenjpip.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpip.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
#
|
||||||
|
if(BUILD_JP3D)
|
||||||
|
# install in lib and not share (see multi-arch note above)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp3d/libopenjp3d.pc.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc @ONLY)
|
||||||
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjp3d.pc DESTINATION
|
||||||
|
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
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)
|
||||||
69
INSTALL
Normal file
69
INSTALL
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
How to build and install openjpeg binaries
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
UNIX/LINUX/MacOSX/Windows systems
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
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 documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
|
||||||
|
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||||
|
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||||
|
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
||||||
|
** To build the JPIP server: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
|
||||||
|
* To build the JP3D library and utilities: '-DBUILD_JP3D:bool=on' (default: 'OFF') (experimental)
|
||||||
|
* To build the Java binding: '-DBUILD_JAVA:bool=on' (default: 'OFF') (experimental).
|
||||||
|
** to choose which java implementation, you can set your JAVA_HOME env var.
|
||||||
|
* To build the wxWidgets/C++ viewer: 'BUILD_VIEWER:BOOL=ON' (default OFF) (experimental)
|
||||||
|
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||||
|
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
||||||
|
make
|
||||||
|
make Experimental
|
||||||
|
Note : JPEG2000 test files are available with 'git clone https://github.com/uclouvain/openjpeg-data.git'.
|
||||||
|
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
||||||
|
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
||||||
|
been checked out of course).
|
||||||
|
|
||||||
|
MACOSX
|
||||||
|
------
|
||||||
|
|
||||||
|
The same building procedures as above work for MACOSX.
|
||||||
|
The xcode project file can also be used.
|
||||||
|
|
||||||
|
If it does not work, try adding the following flag to the cmake command :
|
||||||
|
'-DCMAKE_OSX_ARCHITECTURES:STRING=i386'
|
||||||
|
|
||||||
|
WINDOWS
|
||||||
|
-------
|
||||||
|
|
||||||
|
You can use cmake to generate project files for the IDE you are using (VS2010, NMake, etc).
|
||||||
|
Type 'cmake --help' for available generators on your platform.
|
||||||
|
|
||||||
|
Make sure to build the third party libs (png, zlib ...):
|
||||||
|
|
||||||
|
'-DBUILD_THIRDPARTY:BOOL=ON'
|
||||||
@@ -1,7 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2003-2009, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
||||||
|
* Copyright (c) 2012, CS Systemes d'Information, France
|
||||||
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -25,15 +37,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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "j2k.h"
|
|
||||||
|
|
||||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
|
||||||
int subsampling_dy, int Dim[2]);
|
|
||||||
|
|
||||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
|
||||||
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]);
|
|
||||||
61
NEWS
Normal file
61
NEWS
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
OpenJPEG NEWS - user visible changes
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.X.X
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
New Features:
|
||||||
|
|
||||||
|
* Digital Cinema profiles have been fixed and updated
|
||||||
|
* New option to disable MCT if needed
|
||||||
|
* extended RAW support: it is now possible to input raw images
|
||||||
|
with subsampled color components (422, 420, etc)
|
||||||
|
* New way to deal with profiles
|
||||||
|
|
||||||
|
API/ABI modifications: (see abi_compat_report in dev-utils/scripts)
|
||||||
|
|
||||||
|
* Removed deprecated functions
|
||||||
|
- opj_stream_create_default_file_stream(FILE*,...)
|
||||||
|
- opj_stream_create_file_stream(FILE*,...)
|
||||||
|
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
|
||||||
|
* Added
|
||||||
|
- opj_stream_create_default_file_stream(char*,...)
|
||||||
|
- opj_stream_create_file_stream(char*,...)
|
||||||
|
- opj_stream_destroy(opj_stream_t*)
|
||||||
|
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
|
||||||
|
... opj_stream_free_user_data_fn p_function)
|
||||||
|
- JPEG 2000 profiles and Part-2 extensions defined through '#define'
|
||||||
|
* Changed
|
||||||
|
- 'alpha' field added to 'opj_image_comp' structure
|
||||||
|
- 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
|
||||||
|
- 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
|
||||||
|
- 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
|
||||||
|
(not yet used in use)
|
||||||
|
- 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
|
||||||
|
|
||||||
|
Misc:
|
||||||
|
|
||||||
|
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
||||||
|
and will soon become official reference software at the
|
||||||
|
JPEG committee.
|
||||||
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
|
|
||||||
|
|
||||||
|
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
New Features:
|
||||||
|
|
||||||
|
* streaming capabilities
|
||||||
|
* merge JP3D
|
||||||
|
|
||||||
|
API modifications:
|
||||||
|
|
||||||
|
* Use a 64bits capable API
|
||||||
|
|
||||||
|
Misc:
|
||||||
|
|
||||||
|
* removed autotools build system
|
||||||
|
* folders hierarchies reorganisation
|
||||||
|
* Huge amount of bug fixes. See CHANGES for details.
|
||||||
79
README.md
Normal file
79
README.md
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
# OPENJPEG Library and Applications
|
||||||
|
|
||||||
|
## What is OpenJPEG ?
|
||||||
|
|
||||||
|
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
|
||||||
|
|
||||||
|
## Who can use the code ?
|
||||||
|
[![badge-license]][link-license]
|
||||||
|
|
||||||
|
Anyone. As the OpenJPEG code is released under the [BSD 2-clause "Simplified" License][link-license], anyone can use or modify the code, even for commercial applications. The only restriction is to retain the copyright in the sources or in the binaries documentation. Of course, if you modified the code in a way that might be of interest for other users, you are encouraged to share it (through a [github pull request](https://github.com/uclouvain/openjpeg/pulls) or by filling an [issue](https://github.com/uclouvain/openjpeg/issues)) but this is not a requirement.
|
||||||
|
|
||||||
|
## How to install and use OpenJPEG ?
|
||||||
|
API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec).
|
||||||
|
|
||||||
|
## Current Status
|
||||||
|
[![badge-build]][link-build]
|
||||||
|
|
||||||
|
[![badge-msvc-build]][link-msvc-build]
|
||||||
|
|
||||||
|
[![badge-coverity]][link-coverity]
|
||||||
|
|
||||||
|
## Who are the developers ?
|
||||||
|
|
||||||
|
The library is developed and maintained by the Image and Signal Processing Group ([ISPGroup](http://sites.uclouvain.be/ispgroup/)), in the Université catholique de Louvain ([UCL](http://www.uclouvain.be/en-index.html), with the support of the [CNES](https://cnes.fr/), the [CS](http://www.c-s.fr/) company and the [intoPIX](http://www.intopix.com) company. The JPWL module has been developed by the Digital Signal Processing Lab ([DSPLab](http://dsplab.diei.unipg.it/)) of the University of Perugia, Italy ([UNIPG](http://www.unipg.it/)).
|
||||||
|
|
||||||
|
## Details on folders hierarchy
|
||||||
|
|
||||||
|
* src
|
||||||
|
* lib
|
||||||
|
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
|
||||||
|
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||||
|
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||||
|
* openjp3d: JP3D implementation
|
||||||
|
* openmj2: MJ2 implementation
|
||||||
|
* bin: contains all applications that use the openjpeg library
|
||||||
|
* common: common files to all applications
|
||||||
|
* jp2: a basic codec
|
||||||
|
* mj2: motion jpeg 2000 executables
|
||||||
|
* jpip: OpenJPIP applications (server and dec server)
|
||||||
|
* java: a Java client viewer for JPIP
|
||||||
|
* jp3d: JP3D applications
|
||||||
|
* tcltk: a test tool for JP3D
|
||||||
|
* wx
|
||||||
|
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||||
|
* wrapping
|
||||||
|
* java: java jni to use openjpeg in a java program
|
||||||
|
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||||
|
* doc: doxygen documentation setup file and man pages
|
||||||
|
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in [openjpeg-data](https://github.com/uclouvain/openjpeg-data) repository.
|
||||||
|
* cmake: cmake related files
|
||||||
|
|
||||||
|
See [LICENSE][link-license] for license and copyright information.
|
||||||
|
|
||||||
|
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL) for installation procedures.
|
||||||
|
|
||||||
|
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS) for user visible changes in successive releases.
|
||||||
|
|
||||||
|
## API/ABI
|
||||||
|
|
||||||
|
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
||||||
|
only exposes a limited subset of its functions. It uses a mechanism of
|
||||||
|
exporting/hiding functions. If you are unsure which functions you can use in
|
||||||
|
your applications, you should compile OpenJPEG using something similar to gcc:
|
||||||
|
`-fvisibility=hidden` compilation flag.
|
||||||
|
See also: http://gcc.gnu.org/wiki/Visibility
|
||||||
|
|
||||||
|
On windows, MSVC directly supports export/hiding function and as such the only
|
||||||
|
API available is the one supported by OpenJPEG.
|
||||||
|
|
||||||
|
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
|
||||||
|
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause "Simplified" License"
|
||||||
|
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause "Simplified" License"
|
||||||
|
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=master "Build Status"
|
||||||
|
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
|
||||||
|
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
|
||||||
|
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
|
||||||
|
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
|
||||||
|
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
|
||||||
35
THANKS
Normal file
35
THANKS
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
|
Giuseppe Baruffa
|
||||||
|
Ben Boeckel
|
||||||
|
Aaron Boxer
|
||||||
|
David Burken
|
||||||
|
Matthieu Darbois
|
||||||
|
Rex Dieter
|
||||||
|
Herve Drolon
|
||||||
|
Antonin Descampe
|
||||||
|
Francois-Olivier Devaux
|
||||||
|
Parvatha Elangovan
|
||||||
|
Jerôme Fimes
|
||||||
|
Bob Friesenhahn
|
||||||
|
Kaori Hagihara
|
||||||
|
Luc Hermitte
|
||||||
|
Luis Ibanez
|
||||||
|
David Janssens
|
||||||
|
Hans Johnson
|
||||||
|
Callum Lerwick
|
||||||
|
Sebastien Lugan
|
||||||
|
Benoit Macq
|
||||||
|
Arnaud Maye
|
||||||
|
Julien Malik
|
||||||
|
Vincent Nicolas
|
||||||
|
Glenn Pearson
|
||||||
|
Dzonatas Sol
|
||||||
|
Winfried Szukalski
|
||||||
|
Vincent Torri
|
||||||
|
Yannick Verschueren
|
||||||
|
Peter Wimmer
|
||||||
23
appveyor.yml
Normal file
23
appveyor.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
version: 2.1.1.{build}
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- coverity_scan
|
||||||
|
skip_tags: true
|
||||||
|
clone_depth: 50
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- OPJ_CI_ARCH: x86
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||||
|
- OPJ_CI_ARCH: x64
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||||
|
- OPJ_CI_ARCH: x86
|
||||||
|
OPJ_CI_VSCOMNTOOLS: $(VS100COMNTOOLS)
|
||||||
|
install:
|
||||||
|
- cmd: c:\cygwin\bin\bash ./tools/travis-ci/install.sh
|
||||||
|
build_script:
|
||||||
|
- cmd: >-
|
||||||
|
"%OPJ_CI_VSCOMNTOOLS%..\..\VC\vcvarsall.bat" %OPJ_CI_ARCH%
|
||||||
|
|
||||||
|
bash ./tools/travis-ci/run.sh
|
||||||
|
test: off
|
||||||
|
deploy: off
|
||||||
40
cmake/CTestCustom.cmake.in
Normal file
40
cmake/CTestCustom.cmake.in
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# 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}
|
||||||
|
|
||||||
|
# Ignore clang's summary warning, assuming prior text has matched some
|
||||||
|
# other warning expression:
|
||||||
|
"[0-9,]+ warnings? generated."
|
||||||
|
# Suppress warning caused by intentional messages about deprecation
|
||||||
|
".*warning,.* is deprecated"
|
||||||
|
# java also warns about deprecated API
|
||||||
|
".*java.*deprecation"
|
||||||
|
".*deprecation.*"
|
||||||
|
# suppress warnings caused by 3rd party libs:
|
||||||
|
".*thirdparty.*"
|
||||||
|
"libtiff.*has no symbols"
|
||||||
|
"libpng.*has no symbols"
|
||||||
|
)
|
||||||
26
cmake/EnsureFileInclude.cmake
Normal file
26
cmake/EnsureFileInclude.cmake
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Ensure that an include file is provided by the system
|
||||||
|
# Add the check about the mandatory status to the check_include_file macro
|
||||||
|
# provided by cmake
|
||||||
|
|
||||||
|
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
|
||||||
|
macro(ensure_file_include INCLUDE_FILENAME VARIABLE_NAME MANDATORY_STATUS)
|
||||||
|
|
||||||
|
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||||
|
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||||
|
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||||
|
|
||||||
|
CHECK_INCLUDE_FILE(${INCLUDE_FILENAME} ${VARIABLE_NAME})
|
||||||
|
|
||||||
|
#message(WARNING "INCLUDE_FILENAME=${INCLUDE_FILENAME} \n"
|
||||||
|
# "VARIABLE_NAME=${VARIABLE_NAME} \n"
|
||||||
|
# "VARIABLE_NAME_VALUE=${${VARIABLE_NAME}} \n"
|
||||||
|
# "MANDATORY_STATUS=${MANDATORY_STATUS}")
|
||||||
|
|
||||||
|
if (NOT ${${VARIABLE_NAME}})
|
||||||
|
if (${MANDATORY_STATUS})
|
||||||
|
message(FATAL_ERROR "The file ${INCLUDE_FILENAME} is mandatory but not found on your system")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endmacro()
|
||||||
16
cmake/FindCPPCHECK.cmake
Normal file
16
cmake/FindCPPCHECK.cmake
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# cppcheck
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(CPPCHECK_EXECUTABLE
|
||||||
|
cppcheck
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
CPPCHECK_EXECUTABLE
|
||||||
|
)
|
||||||
20
cmake/FindFCGI.cmake
Normal file
20
cmake/FindFCGI.cmake
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Look for the header file.
|
||||||
|
find_path(FCGI_INCLUDE_DIR NAMES fastcgi.h)
|
||||||
|
|
||||||
|
# Look for the library.
|
||||||
|
find_library(FCGI_LIBRARY NAMES fcgi)
|
||||||
|
|
||||||
|
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
|
||||||
|
|
||||||
|
# Copy the results to the output variables.
|
||||||
|
if(FCGI_FOUND)
|
||||||
|
set(FCGI_LIBRARIES ${FCGI_LIBRARY})
|
||||||
|
set(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
set(FCGI_LIBRARIES)
|
||||||
|
set(FCGI_INCLUDE_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||||
12
cmake/FindJPYLYZER.cmake
Normal file
12
cmake/FindJPYLYZER.cmake
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# this module looks for JPYLYZER
|
||||||
|
# http://jpylyzer.openpreservation.org
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(JPYLYZER_EXECUTABLE
|
||||||
|
jpylyzer
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
JPYLYZER_EXECUTABLE
|
||||||
|
)
|
||||||
24
cmake/FindKAKADU.cmake
Normal file
24
cmake/FindKAKADU.cmake
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#
|
||||||
|
# this module looks for KAKADU
|
||||||
|
# http://www.kakadusoftware.com/
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006-2014 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
find_program(KDU_EXPAND_EXECUTABLE
|
||||||
|
kdu_expand
|
||||||
|
)
|
||||||
|
|
||||||
|
find_program(KDU_COMPRESS_EXECUTABLE
|
||||||
|
kdu_compress
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
KDU_EXPAND_EXECUTABLE
|
||||||
|
KDU_COMPRESS_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()
|
||||||
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()
|
||||||
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}")
|
||||||
72
cmake/OpenJPEGCPack.cmake
Normal file
72
cmake/OpenJPEGCPack.cmake
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# 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()
|
||||||
|
|
||||||
|
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()
|
||||||
|
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||||
|
if(CMAKE_CL_64)
|
||||||
|
set(CPACK_SYSTEM_NAME win64-x64)
|
||||||
|
else()
|
||||||
|
set(CPACK_SYSTEM_NAME win32-x86)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||||
|
# if 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()
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME
|
||||||
|
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||||
|
if(APPLE)
|
||||||
|
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
set(CPACK_BUNDLE_PLIST
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||||
|
#include(BundleUtilities)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||||
48
cmake/OpenJPEGConfig.cmake.in
Normal file
48
cmake/OpenJPEGConfig.cmake.in
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# 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)
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
# This is an install tree
|
||||||
|
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||||
|
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||||
|
|
||||||
|
else()
|
||||||
|
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
# This is a build tree
|
||||||
|
set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||||
|
|
||||||
|
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "ooops")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||||
|
|
||||||
|
# Backward compatible part:
|
||||||
|
set(OPENJPEG_FOUND TRUE)
|
||||||
|
|
||||||
11
cmake/TestFileOffsetBits.c
Normal file
11
cmake/TestFileOffsetBits.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* Cause a compile-time error if off_t is smaller than 64 bits */
|
||||||
|
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||||
|
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
23
cmake/TestLargeFiles.c.cmake.in
Normal file
23
cmake/TestLargeFiles.c.cmake.in
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#cmakedefine _LARGEFILE_SOURCE
|
||||||
|
#cmakedefine _LARGE_FILES
|
||||||
|
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Cause a compile-time error if off_t is smaller than 64 bits,
|
||||||
|
* and make sure we have ftello / fseeko.
|
||||||
|
*/
|
||||||
|
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||||
|
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
|
||||||
|
FILE *fp = fopen(argv[0],"r");
|
||||||
|
off_t offset = ftello( fp );
|
||||||
|
|
||||||
|
fseeko( fp, offset, SEEK_CUR );
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
134
cmake/TestLargeFiles.cmake
Normal file
134
cmake/TestLargeFiles.cmake
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
# - Define macro to check large file support
|
||||||
|
#
|
||||||
|
# OPJ_TEST_LARGE_FILES(VARIABLE)
|
||||||
|
#
|
||||||
|
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
|
||||||
|
# This macro will also defines the necessary variable enable large file support, for instance
|
||||||
|
# _LARGE_FILES
|
||||||
|
# _LARGEFILE_SOURCE
|
||||||
|
# _FILE_OFFSET_BITS 64
|
||||||
|
# OPJ_HAVE_FSEEKO
|
||||||
|
#
|
||||||
|
# However, it is YOUR job to make sure these defines are set in a #cmakedefine so they
|
||||||
|
# end up in a config.h file that is included in your source if necessary!
|
||||||
|
#
|
||||||
|
# Adapted from Gromacs project (http://www.gromacs.org/)
|
||||||
|
# by Julien Malik
|
||||||
|
#
|
||||||
|
|
||||||
|
macro(OPJ_TEST_LARGE_FILES VARIABLE)
|
||||||
|
if(NOT DEFINED ${VARIABLE})
|
||||||
|
|
||||||
|
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
|
||||||
|
# and then separately fseeko. However, in the future we might have 128-bit filesystems
|
||||||
|
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
|
||||||
|
|
||||||
|
message(STATUS "Checking for 64-bit off_t")
|
||||||
|
|
||||||
|
# First check without any special flags
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c")
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _FILE_OFFSET_BITS=64
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
|
||||||
|
set(_FILE_OFFSET_BITS 64)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _LARGE_FILES
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
|
||||||
|
set(_LARGE_FILES 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
# Test with _LARGEFILE_SOURCE
|
||||||
|
try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||||
|
if(FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
|
||||||
|
set(_LARGEFILE_SOURCE 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
#if(NOT FILE64_OK)
|
||||||
|
# # now check for Windows stuff
|
||||||
|
# try_compile(FILE64_OK "${PROJECT_BINARY_DIR}"
|
||||||
|
# "${PROJECT_SOURCE_DIR}/cmake/TestWindowsFSeek.c")
|
||||||
|
# if(FILE64_OK)
|
||||||
|
# message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
|
||||||
|
# set(HAVE__FSEEKI64 1)
|
||||||
|
# endif()
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
if(NOT FILE64_OK)
|
||||||
|
message(STATUS "Checking for 64-bit off_t - not present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64")
|
||||||
|
set(_LARGE_FILES ${_LARGE_FILES} CACHE INTERNAL "Result of test for needed _LARGE_FILES")
|
||||||
|
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||||
|
|
||||||
|
# Set the flags we might have determined to be required above
|
||||||
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||||
|
|
||||||
|
message(STATUS "Checking for fseeko/ftello")
|
||||||
|
|
||||||
|
# Test if ftello/fseeko are available
|
||||||
|
try_compile(FSEEKO_COMPILE_OK
|
||||||
|
"${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Checking for fseeko/ftello - present")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FSEEKO_COMPILE_OK)
|
||||||
|
# glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...)
|
||||||
|
try_compile(FSEEKO_COMPILE_OK
|
||||||
|
"${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
|
||||||
|
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
|
||||||
|
set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FSEEKO_COMPILE_OK)
|
||||||
|
set(OPJ_HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||||
|
else()
|
||||||
|
message(STATUS "Checking for fseeko/ftello - not found")
|
||||||
|
set(OPJ_HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FILE64_OK AND FSEEKO_COMPILE_OK)
|
||||||
|
message(STATUS "Large File support - found")
|
||||||
|
set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support")
|
||||||
|
else()
|
||||||
|
message(STATUS "Large File support - not found")
|
||||||
|
set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
11
cmake/TestWindowsFSeek.c
Normal file
11
cmake/TestWindowsFSeek.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__int64 off=0;
|
||||||
|
|
||||||
|
_fseeki64(NULL, off, SEEK_SET);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
39
cmake/openjpeg_valgrind.supp
Normal file
39
cmake/openjpeg_valgrind.supp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Cond
|
||||||
|
fun:deflate
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_row
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Value8
|
||||||
|
fun:crc32
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_chunk
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
obj:/lib/libpng12.so.0.42.0
|
||||||
|
fun:png_write_row
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
||||||
|
{
|
||||||
|
<Appears with libpng uses with Ubuntu10.04 (hulk)>
|
||||||
|
Memcheck:Param
|
||||||
|
write(buf)
|
||||||
|
fun:__write_nocancel
|
||||||
|
fun:_IO_file_write@@GLIBC_2.2.5
|
||||||
|
fun:_IO_do_write@@GLIBC_2.2.5
|
||||||
|
fun:_IO_file_close_it@@GLIBC_2.2.5
|
||||||
|
fun:fclose@@GLIBC_2.2.5
|
||||||
|
fun:imagetopng
|
||||||
|
fun:main
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
obj
|
|
||||||
obj.w32
|
|
||||||
bin
|
|
||||||
bin.w32
|
|
||||||
lib
|
|
||||||
lib.w32
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
# $Id$
|
|
||||||
#
|
|
||||||
# makefile for OpenJPEG codec
|
|
||||||
|
|
||||||
OPENJPEG_DIR = ../libopenjpeg
|
|
||||||
|
|
||||||
ifndef DEBUG
|
|
||||||
LDFLAGS = -s -lm
|
|
||||||
else
|
|
||||||
LDFLAGS = -lm
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS = -Wall -O3 -fno-strength-reduce -fomit-frame-pointer -I$(OPENJPEG_DIR)
|
|
||||||
|
|
||||||
OBJ_DIR_W32 = obj.w32
|
|
||||||
BIN_DIR_W32 = bin.w32
|
|
||||||
LIB_DIR_W32 = $(OPENJPEG_DIR)/lib.w32
|
|
||||||
|
|
||||||
ifdef MINGW32
|
|
||||||
CC = i386-mingw32-gcc
|
|
||||||
CFLAGS += -DDONT_HAVE_GETOPT
|
|
||||||
OBJ_DIR = $(OBJ_DIR_W32)
|
|
||||||
BIN_DIR = $(BIN_DIR_W32)
|
|
||||||
LIB_DIR = lib.w32
|
|
||||||
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
|
|
||||||
$(addprefix $(BIN_DIR)/,j2k_to_image.exe image_to_j2k.exe)
|
|
||||||
else
|
|
||||||
CC = gcc
|
|
||||||
OBJ_DIR = obj
|
|
||||||
BIN_DIR = bin
|
|
||||||
LIB_DIR = lib
|
|
||||||
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
|
|
||||||
$(addprefix $(BIN_DIR)/,j2k_to_image image_to_j2k)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef DYNAMIC
|
|
||||||
ifdef MINGW32
|
|
||||||
LIB_OPENJPEG = $(LIB_DIR)/libopenjpeg.dll
|
|
||||||
LDFLAGS += -L$(LIB_DIR) -lopenjpeg
|
|
||||||
else
|
|
||||||
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so
|
|
||||||
LDFLAGS += -L$(OPENJPEG_DIR)/$(LIB_DIR) -lopenjpeg
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a
|
|
||||||
LDFLAGS += $(LIB_OPENJPEG)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(BIN_DIR):
|
|
||||||
mkdir $(BIN_DIR)
|
|
||||||
|
|
||||||
$(OBJ_DIR):
|
|
||||||
mkdir $(OBJ_DIR)
|
|
||||||
|
|
||||||
$(LIB_DIR):
|
|
||||||
mkdir $(LIB_DIR)
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.dll: $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll
|
|
||||||
ln -sf ../$< $@
|
|
||||||
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll:
|
|
||||||
cd $(OPENJPEG_DIR) && \
|
|
||||||
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.dll
|
|
||||||
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a:
|
|
||||||
cd $(OPENJPEG_DIR) && \
|
|
||||||
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.a
|
|
||||||
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so:
|
|
||||||
cd $(OPENJPEG_DIR) && \
|
|
||||||
$(MAKE) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.so
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o:
|
|
||||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
$(OBJ_DIR)/getopt.o: compat/getopt.c
|
|
||||||
$(OBJ_DIR)/convert.o: convert.c
|
|
||||||
$(OBJ_DIR)/j2k_to_image.o: j2k_to_image.c
|
|
||||||
$(OBJ_DIR)/image_to_j2k.o: image_to_j2k.c convert.h
|
|
||||||
|
|
||||||
J2I_OBJS = $(addprefix $(OBJ_DIR)/,j2k_to_image.o)
|
|
||||||
I2J_OBJS = $(addprefix $(OBJ_DIR)/,image_to_j2k.o convert.o)
|
|
||||||
|
|
||||||
$(BIN_DIR)/j2k_to_image: $(J2I_OBJS) $(LIB_OPENJPEG)
|
|
||||||
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
|
|
||||||
|
|
||||||
$(BIN_DIR)/image_to_j2k: $(I2J_OBJS) $(LIB_OPENJPEG)
|
|
||||||
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS}
|
|
||||||
|
|
||||||
$(BIN_DIR)/j2k_to_image.exe: $(J2I_OBJS) $(LIB_OPENJPEG)
|
|
||||||
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
|
|
||||||
|
|
||||||
$(BIN_DIR)/image_to_j2k.exe: $(I2J_OBJS) $(LIB_OPENJPEG) $(OBJ_DIR)/getopt.o
|
|
||||||
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS} $(OBJ_DIR)/getopt.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BIN_DIR_W32)/* $(BIN_DIR)/* $(OBJ_DIR_W32)/* $(OBJ_DIR)/*
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/* last review : october 29th, 2002 */
|
|
||||||
|
|
||||||
#ifndef _GETOPT_H_
|
|
||||||
#define _GETOPT_H_
|
|
||||||
|
|
||||||
extern int opterr;
|
|
||||||
extern int optind;
|
|
||||||
extern int optopt;
|
|
||||||
extern int optreset;
|
|
||||||
extern char *optarg;
|
|
||||||
|
|
||||||
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
|
||||||
|
|
||||||
#endif /* _GETOPT_H_ */
|
|
||||||
950
codec/convert.c
950
codec/convert.c
@@ -1,950 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <openjpeg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
BMP IMAGE FORMAT
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
|
|
||||||
/* UINT2 defines a two byte word */
|
|
||||||
typedef unsigned short int UINT2;
|
|
||||||
|
|
||||||
/* UINT4 defines a four byte word */
|
|
||||||
typedef unsigned long int UINT4;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT2 bfType; /* 'BM' for Bitmap (19776) */
|
|
||||||
UINT4 bfSize; /* Size of the file */
|
|
||||||
UINT2 bfReserved1; /* Reserved : 0 */
|
|
||||||
UINT2 bfReserved2; /* Reserved : 0 */
|
|
||||||
UINT4 bfOffBits; /* Offset */
|
|
||||||
} BITMAPFILEHEADER_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT4 biSize; /* Size of the structure in bytes */
|
|
||||||
UINT4 biWidth; /* Width of the image in pixels */
|
|
||||||
UINT4 biHeight; /* Heigth of the image in pixels */
|
|
||||||
UINT2 biPlanes; /* 1 */
|
|
||||||
UINT2 biBitCount; /* Number of color bits by pixels */
|
|
||||||
UINT4 biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
|
|
||||||
UINT4 biSizeImage; /* Size of the image in bytes */
|
|
||||||
UINT4 biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
|
|
||||||
UINT4 biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
|
|
||||||
UINT4 biClrUsed; /* Number of color used in the image (0: ALL) */
|
|
||||||
UINT4 biClrImportant; /* Number of important color (0: ALL) */
|
|
||||||
} BITMAPINFOHEADER_t;
|
|
||||||
|
|
||||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
|
||||||
int subsampling_dy, int Dim[2])
|
|
||||||
{
|
|
||||||
FILE *IN;
|
|
||||||
FILE *Compo0 = NULL, *Compo1 = NULL, *Compo2 = NULL;
|
|
||||||
BITMAPFILEHEADER_t File_h;
|
|
||||||
BITMAPINFOHEADER_t Info_h;
|
|
||||||
unsigned char *RGB;
|
|
||||||
unsigned char *table_R, *table_G, *table_B;
|
|
||||||
unsigned int j, w, h, PAD, type = 0;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
int gray_scale = 1, not_end_file = 1;
|
|
||||||
|
|
||||||
unsigned int line = 0, col = 0;
|
|
||||||
unsigned char v, v2;
|
|
||||||
UINT4 W, H;
|
|
||||||
|
|
||||||
IN = fopen(filename, "rb");
|
|
||||||
if (!IN) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open %s for reading !!\033[0;39m\n",
|
|
||||||
filename);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
File_h.bfType = getc(IN);
|
|
||||||
File_h.bfType = (getc(IN) << 8) + File_h.bfType;
|
|
||||||
|
|
||||||
if (File_h.bfType != 19778) {
|
|
||||||
fprintf(stderr,"Error, not a BMP file!\n");
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
/* FILE HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
File_h.bfSize = getc(IN);
|
|
||||||
File_h.bfSize = (getc(IN) << 8) + File_h.bfSize;
|
|
||||||
File_h.bfSize = (getc(IN) << 16) + File_h.bfSize;
|
|
||||||
File_h.bfSize = (getc(IN) << 24) + File_h.bfSize;
|
|
||||||
|
|
||||||
File_h.bfReserved1 = getc(IN);
|
|
||||||
File_h.bfReserved1 = (getc(IN) << 8) + File_h.bfReserved1;
|
|
||||||
|
|
||||||
File_h.bfReserved2 = getc(IN);
|
|
||||||
File_h.bfReserved2 = (getc(IN) << 8) + File_h.bfReserved2;
|
|
||||||
|
|
||||||
File_h.bfOffBits = getc(IN);
|
|
||||||
File_h.bfOffBits = (getc(IN) << 8) + File_h.bfOffBits;
|
|
||||||
File_h.bfOffBits = (getc(IN) << 16) + File_h.bfOffBits;
|
|
||||||
File_h.bfOffBits = (getc(IN) << 24) + File_h.bfOffBits;
|
|
||||||
|
|
||||||
/* INFO HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
|
|
||||||
Info_h.biSize = getc(IN);
|
|
||||||
Info_h.biSize = (getc(IN) << 8) + Info_h.biSize;
|
|
||||||
Info_h.biSize = (getc(IN) << 16) + Info_h.biSize;
|
|
||||||
Info_h.biSize = (getc(IN) << 24) + Info_h.biSize;
|
|
||||||
|
|
||||||
Info_h.biWidth = getc(IN);
|
|
||||||
Info_h.biWidth = (getc(IN) << 8) + Info_h.biWidth;
|
|
||||||
Info_h.biWidth = (getc(IN) << 16) + Info_h.biWidth;
|
|
||||||
Info_h.biWidth = (getc(IN) << 24) + Info_h.biWidth;
|
|
||||||
w = Info_h.biWidth;
|
|
||||||
|
|
||||||
Info_h.biHeight = getc(IN);
|
|
||||||
Info_h.biHeight = (getc(IN) << 8) + Info_h.biHeight;
|
|
||||||
Info_h.biHeight = (getc(IN) << 16) + Info_h.biHeight;
|
|
||||||
Info_h.biHeight = (getc(IN) << 24) + Info_h.biHeight;
|
|
||||||
h = Info_h.biHeight;
|
|
||||||
|
|
||||||
Info_h.biPlanes = getc(IN);
|
|
||||||
Info_h.biPlanes = (getc(IN) << 8) + Info_h.biPlanes;
|
|
||||||
|
|
||||||
Info_h.biBitCount = getc(IN);
|
|
||||||
Info_h.biBitCount = (getc(IN) << 8) + Info_h.biBitCount;
|
|
||||||
|
|
||||||
Info_h.biCompression = getc(IN);
|
|
||||||
Info_h.biCompression = (getc(IN) << 8) + Info_h.biCompression;
|
|
||||||
Info_h.biCompression = (getc(IN) << 16) + Info_h.biCompression;
|
|
||||||
Info_h.biCompression = (getc(IN) << 24) + Info_h.biCompression;
|
|
||||||
|
|
||||||
Info_h.biSizeImage = getc(IN);
|
|
||||||
Info_h.biSizeImage = (getc(IN) << 8) + Info_h.biSizeImage;
|
|
||||||
Info_h.biSizeImage = (getc(IN) << 16) + Info_h.biSizeImage;
|
|
||||||
Info_h.biSizeImage = (getc(IN) << 24) + Info_h.biSizeImage;
|
|
||||||
|
|
||||||
Info_h.biXpelsPerMeter = getc(IN);
|
|
||||||
Info_h.biXpelsPerMeter = (getc(IN) << 8) + Info_h.biXpelsPerMeter;
|
|
||||||
Info_h.biXpelsPerMeter = (getc(IN) << 16) + Info_h.biXpelsPerMeter;
|
|
||||||
Info_h.biXpelsPerMeter = (getc(IN) << 24) + Info_h.biXpelsPerMeter;
|
|
||||||
|
|
||||||
Info_h.biYpelsPerMeter = getc(IN);
|
|
||||||
Info_h.biYpelsPerMeter = (getc(IN) << 8) + Info_h.biYpelsPerMeter;
|
|
||||||
Info_h.biYpelsPerMeter = (getc(IN) << 16) + Info_h.biYpelsPerMeter;
|
|
||||||
Info_h.biYpelsPerMeter = (getc(IN) << 24) + Info_h.biYpelsPerMeter;
|
|
||||||
|
|
||||||
Info_h.biClrUsed = getc(IN);
|
|
||||||
Info_h.biClrUsed = (getc(IN) << 8) + Info_h.biClrUsed;
|
|
||||||
Info_h.biClrUsed = (getc(IN) << 16) + Info_h.biClrUsed;
|
|
||||||
Info_h.biClrUsed = (getc(IN) << 24) + Info_h.biClrUsed;
|
|
||||||
|
|
||||||
Info_h.biClrImportant = getc(IN);
|
|
||||||
Info_h.biClrImportant = (getc(IN) << 8) + Info_h.biClrImportant;
|
|
||||||
Info_h.biClrImportant = (getc(IN) << 16) + Info_h.biClrImportant;
|
|
||||||
Info_h.biClrImportant = (getc(IN) << 24) + Info_h.biClrImportant;
|
|
||||||
|
|
||||||
/* Read the data and store them in the OUT file */
|
|
||||||
|
|
||||||
if (Info_h.biBitCount == 24) {
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->color_space = 1;
|
|
||||||
img->comps =
|
|
||||||
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
}
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo1 = fopen("Compo1", "wb");
|
|
||||||
if (!Compo1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo2 = fopen("Compo2", "wb");
|
|
||||||
if (!Compo2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Place the cursor at the beginning of the image information */
|
|
||||||
fseek(IN, 0, SEEK_SET);
|
|
||||||
fseek(IN, File_h.bfOffBits, SEEK_SET);
|
|
||||||
|
|
||||||
W = Info_h.biWidth;
|
|
||||||
H = Info_h.biHeight;
|
|
||||||
|
|
||||||
// PAD = 4 - (3 * W) % 4;
|
|
||||||
// PAD = (PAD == 4) ? 0 : PAD;
|
|
||||||
PAD = (3 * W) % 4 ? 4 - (3 * W) % 4 : 0;
|
|
||||||
|
|
||||||
|
|
||||||
RGB =
|
|
||||||
(unsigned char *) malloc((3 * W + PAD) * H *
|
|
||||||
sizeof(unsigned char));
|
|
||||||
|
|
||||||
fread(RGB, sizeof(unsigned char), (3 * W + PAD) * H, IN);
|
|
||||||
|
|
||||||
for (j = 0; j < (3 * W + PAD) * H; j++) {
|
|
||||||
unsigned char elmt;
|
|
||||||
int Wp = 3 * W + PAD;
|
|
||||||
|
|
||||||
elmt = RGB[(H - (j / Wp + 1)) * Wp + j % Wp];
|
|
||||||
if ((j % Wp) < (3 * W)) {
|
|
||||||
switch (type) {
|
|
||||||
case 0:
|
|
||||||
fprintf(Compo2, "%c", elmt);
|
|
||||||
type = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
fprintf(Compo1, "%c", elmt);
|
|
||||||
type = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
fprintf(Compo0, "%c", elmt);
|
|
||||||
type = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(Compo0);
|
|
||||||
fclose(Compo1);
|
|
||||||
fclose(Compo2);
|
|
||||||
free(RGB);
|
|
||||||
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) {
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
|
|
||||||
table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
|
|
||||||
for (j = 0; j < Info_h.biClrUsed; j++) {
|
|
||||||
table_B[j] = getc(IN);
|
|
||||||
table_G[j] = getc(IN);
|
|
||||||
table_R[j] = getc(IN);
|
|
||||||
getc(IN);
|
|
||||||
if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
|
|
||||||
&& table_G[j] != table_B[j])
|
|
||||||
gray_scale = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Place the cursor at the beginning of the image information */
|
|
||||||
fseek(IN, 0, SEEK_SET);
|
|
||||||
fseek(IN, File_h.bfOffBits, SEEK_SET);
|
|
||||||
|
|
||||||
W = Info_h.biWidth;
|
|
||||||
H = Info_h.biHeight;
|
|
||||||
if (Info_h.biWidth % 2)
|
|
||||||
W++;
|
|
||||||
|
|
||||||
RGB = (unsigned char *) malloc(W * H * sizeof(unsigned char));
|
|
||||||
|
|
||||||
fread(RGB, sizeof(unsigned char), W * H, IN);
|
|
||||||
if (gray_scale) {
|
|
||||||
img->numcomps = 1;
|
|
||||||
img->comps =
|
|
||||||
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
img->comps[0].prec = 8;
|
|
||||||
img->comps[0].bpp = 8;
|
|
||||||
img->comps[0].sgnd = 0;
|
|
||||||
img->comps[0].dx = subsampling_dx;
|
|
||||||
img->comps[0].dy = subsampling_dy;
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
for (j = 0; j < W * H; j++) {
|
|
||||||
if ((j % W < W - 1 && Info_h.biWidth % 2)
|
|
||||||
|| !(Info_h.biWidth % 2))
|
|
||||||
fprintf(Compo0, "%c",
|
|
||||||
table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
} else {
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->comps =
|
|
||||||
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo1 = fopen("Compo1", "wb");
|
|
||||||
if (!Compo1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo2 = fopen("Compo2", "wb");
|
|
||||||
if (!Compo2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < W * H; j++) {
|
|
||||||
if ((j % W < W - 1 && Info_h.biWidth % 2)
|
|
||||||
|| !(Info_h.biWidth % 2)) {
|
|
||||||
fprintf(Compo0, "%c",
|
|
||||||
table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
|
|
||||||
fprintf(Compo1, "%c",
|
|
||||||
table_G[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
|
|
||||||
fprintf(Compo2, "%c",
|
|
||||||
table_B[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
fclose(Compo1);
|
|
||||||
fclose(Compo2);
|
|
||||||
}
|
|
||||||
free(RGB);
|
|
||||||
|
|
||||||
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) {
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
|
|
||||||
table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
|
|
||||||
|
|
||||||
for (j = 0; j < Info_h.biClrUsed; j++) {
|
|
||||||
table_B[j] = getc(IN);
|
|
||||||
table_G[j] = getc(IN);
|
|
||||||
table_R[j] = getc(IN);
|
|
||||||
getc(IN);
|
|
||||||
if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
|
|
||||||
&& table_G[j] != table_B[j])
|
|
||||||
gray_scale = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Place the cursor at the beginning of the image information */
|
|
||||||
fseek(IN, 0, SEEK_SET);
|
|
||||||
fseek(IN, File_h.bfOffBits, SEEK_SET);
|
|
||||||
|
|
||||||
if (gray_scale) {
|
|
||||||
img->numcomps = 1;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
|
|
||||||
img->comps[0].prec = 8;
|
|
||||||
img->comps[0].bpp = 8;
|
|
||||||
img->comps[0].sgnd = 0;
|
|
||||||
img->comps[0].dx = subsampling_dx;
|
|
||||||
img->comps[0].dy = subsampling_dy;
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->comps =
|
|
||||||
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
}
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo1 = fopen("Compo1", "wb");
|
|
||||||
if (!Compo1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
Compo2 = fopen("Compo2", "wb");
|
|
||||||
if (!Compo2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RGB =
|
|
||||||
(unsigned char *) malloc(Info_h.biWidth * Info_h.biHeight *
|
|
||||||
sizeof(unsigned char));
|
|
||||||
|
|
||||||
while (not_end_file) {
|
|
||||||
v = getc(IN);
|
|
||||||
if (v) {
|
|
||||||
v2 = getc(IN);
|
|
||||||
for (i = 0; i < (int) v; i++) {
|
|
||||||
RGB[line * Info_h.biWidth + col] = v2;
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
v = getc(IN);
|
|
||||||
switch (v) {
|
|
||||||
case 0:
|
|
||||||
col = 0;
|
|
||||||
line++;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
line++;
|
|
||||||
not_end_file = 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
fprintf(stderr,"No Delta supported\n");
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
for (i = 0; i < v; i++) {
|
|
||||||
v2 = getc(IN);
|
|
||||||
RGB[line * Info_h.biWidth + col] = v2;
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
if (v % 2)
|
|
||||||
v2 = getc(IN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gray_scale) {
|
|
||||||
for (line = 0; line < Info_h.biHeight; line++)
|
|
||||||
for (col = 0; col < Info_h.biWidth; col++)
|
|
||||||
fprintf(Compo0, "%c", table_R[(int)
|
|
||||||
RGB[(Info_h.biHeight - line -
|
|
||||||
1) * Info_h.biWidth +
|
|
||||||
col]]);
|
|
||||||
fclose(Compo0);
|
|
||||||
} else {
|
|
||||||
for (line = 0; line < Info_h.biHeight; line++)
|
|
||||||
for (col = 0; col < Info_h.biWidth; col++) {
|
|
||||||
fprintf(Compo0, "%c", table_R[(int)
|
|
||||||
RGB[(Info_h.biHeight - line -
|
|
||||||
1) * Info_h.biWidth +
|
|
||||||
col]]);
|
|
||||||
fprintf(Compo1, "%c", table_G[(int)
|
|
||||||
RGB[(Info_h.biHeight - line -
|
|
||||||
1) * Info_h.biWidth +
|
|
||||||
col]]);
|
|
||||||
fprintf(Compo2, "%c", table_B[(int)
|
|
||||||
RGB[(Info_h.biHeight - line -
|
|
||||||
1) * Info_h.biWidth +
|
|
||||||
col]]);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
fclose(Compo1);
|
|
||||||
fclose(Compo2);
|
|
||||||
}
|
|
||||||
free(RGB);
|
|
||||||
} else
|
|
||||||
fprintf(stderr,
|
|
||||||
"Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n",
|
|
||||||
Info_h.biBitCount);
|
|
||||||
|
|
||||||
fclose(IN);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
PGX IMAGE FORMAT
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char readuchar(FILE * f)
|
|
||||||
{
|
|
||||||
unsigned char c1;
|
|
||||||
fread(&c1, 1, 1, f);
|
|
||||||
return c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short readushort(FILE * f, int bigendian)
|
|
||||||
{
|
|
||||||
unsigned char c1, c2;
|
|
||||||
fread(&c1, 1, 1, f);
|
|
||||||
fread(&c2, 1, 1, f);
|
|
||||||
if (bigendian)
|
|
||||||
return (c1 << 8) + c2;
|
|
||||||
else
|
|
||||||
return (c2 << 8) + c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int readuint(FILE * f, int bigendian)
|
|
||||||
{
|
|
||||||
unsigned char c1, c2, c3, c4;
|
|
||||||
fread(&c1, 1, 1, f);
|
|
||||||
fread(&c2, 1, 1, f);
|
|
||||||
fread(&c3, 1, 1, f);
|
|
||||||
fread(&c4, 1, 1, f);
|
|
||||||
if (bigendian)
|
|
||||||
return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4;
|
|
||||||
else
|
|
||||||
return (c4 << 24) + (c3 << 16) + (c2 << 8) + c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
|
||||||
int subsampling_dx, int subsampling_dy, int Dim[2],
|
|
||||||
j2k_cp_t cp)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
int w, h, prec;
|
|
||||||
int i, compno, bandno;
|
|
||||||
char str[256];
|
|
||||||
|
|
||||||
char endian1,endian2,sign;
|
|
||||||
char signtmp[32];
|
|
||||||
|
|
||||||
char temp[32];
|
|
||||||
int bigendian;
|
|
||||||
j2k_comp_t *comp;
|
|
||||||
|
|
||||||
img->numcomps = 1;
|
|
||||||
img->color_space = 2;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (compno = 0; compno < img->numcomps; compno++) {
|
|
||||||
FILE *src;
|
|
||||||
char tmp[16];
|
|
||||||
int max = 0;
|
|
||||||
int Y1;
|
|
||||||
|
|
||||||
|
|
||||||
comp = &img->comps[compno];
|
|
||||||
sprintf(str, "%s", filename);
|
|
||||||
|
|
||||||
|
|
||||||
f = fopen(str, "rb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "Failed to open %s for reading !\n", str);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
|
|
||||||
fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i=0;
|
|
||||||
|
|
||||||
sign='+';
|
|
||||||
|
|
||||||
while (signtmp[i]!='\0') {
|
|
||||||
|
|
||||||
if (signtmp[i]=='-') sign='-';
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fgetc(f);
|
|
||||||
if (endian1=='M' && endian2=='L')
|
|
||||||
bigendian = 1;
|
|
||||||
else if (endian2=='M' && endian1=='L')
|
|
||||||
bigendian = 0;
|
|
||||||
|
|
||||||
else {
|
|
||||||
|
|
||||||
fprintf(stderr, "Bad pgx header, please check input file\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (compno == 0) {
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
} else {
|
|
||||||
if (w != img->x1 || h != img->y1)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sign == '-') {
|
|
||||||
comp->sgnd = 1;
|
|
||||||
} else {
|
|
||||||
comp->sgnd = 0;
|
|
||||||
}
|
|
||||||
comp->prec = prec;
|
|
||||||
comp->dx = subsampling_dx;
|
|
||||||
comp->dy = subsampling_dy;
|
|
||||||
bandno = 1;
|
|
||||||
|
|
||||||
Y1 = cp.ty0 + bandno * cp.tdy <
|
|
||||||
img->y1 ? cp.ty0 + bandno * cp.tdy : img->y1;
|
|
||||||
Y1 -= img->y0;
|
|
||||||
|
|
||||||
sprintf(tmp, "bandtile%d", bandno); /* bandtile file */
|
|
||||||
src = fopen(tmp, "wb");
|
|
||||||
if (!src) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing !\n", tmp);
|
|
||||||
}
|
|
||||||
for (i = 0; i < w * h; i++) {
|
|
||||||
int v;
|
|
||||||
if (i == Y1 * w / subsampling_dy && tdy != -1) { /* bandtile is full */
|
|
||||||
fclose(src);
|
|
||||||
bandno++;
|
|
||||||
sprintf(tmp, "bandtile%d", bandno);
|
|
||||||
src = fopen(tmp, "wb");
|
|
||||||
if (!src) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing !\n", tmp);
|
|
||||||
}
|
|
||||||
Y1 = cp.ty0 + bandno * cp.tdy <
|
|
||||||
img->y1 ? cp.ty0 + bandno * cp.tdy : img->y1;
|
|
||||||
Y1 -= img->y0;
|
|
||||||
}
|
|
||||||
if (comp->prec <= 8) {
|
|
||||||
if (!comp->sgnd) {
|
|
||||||
v = readuchar(f);
|
|
||||||
} else {
|
|
||||||
v = (char) readuchar(f);
|
|
||||||
}
|
|
||||||
} else if (comp->prec <= 16) {
|
|
||||||
if (!comp->sgnd) {
|
|
||||||
v = readushort(f, bigendian);
|
|
||||||
} else {
|
|
||||||
v = (short) readushort(f, bigendian);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!comp->sgnd) {
|
|
||||||
v = readuint(f, bigendian);
|
|
||||||
} else {
|
|
||||||
v = (int) readuint(f, bigendian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (v > max)
|
|
||||||
max = v;
|
|
||||||
fprintf(src, "%d ", v);
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
fclose(src);
|
|
||||||
comp->bpp = int_floorlog2(max) + 1;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
PNM IMAGE FORMAT
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
|
|
||||||
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
|
||||||
int subsampling_dy, int Dim[2])
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
FILE *Compo0, *Compo1, *Compo2;
|
|
||||||
int w, h;
|
|
||||||
int i;
|
|
||||||
char value;
|
|
||||||
char comment[256];
|
|
||||||
|
|
||||||
f = fopen(filename, "rb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open %s for reading !!\033[0;39m\n",
|
|
||||||
filename);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fgetc(f) != 'P')
|
|
||||||
return 0;
|
|
||||||
value = fgetc(f);
|
|
||||||
|
|
||||||
if (value == '2') {
|
|
||||||
fgetc(f);
|
|
||||||
if (fgetc(f) == '#') {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P2\n");
|
|
||||||
fgets(comment, 256, f);
|
|
||||||
fscanf(f, "%d %d\n255", &w, &h);
|
|
||||||
} else {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P2\n%d %d\n255", &w, &h);
|
|
||||||
}
|
|
||||||
|
|
||||||
fgetc(f);
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
|
|
||||||
img->numcomps = 1;
|
|
||||||
img->color_space = 2;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
|
|
||||||
img->comps[0].prec = 8;
|
|
||||||
img->comps[0].bpp = 8;
|
|
||||||
img->comps[0].sgnd = 0;
|
|
||||||
img->comps[0].dx = subsampling_dx;
|
|
||||||
img->comps[0].dy = subsampling_dy;
|
|
||||||
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
for (i = 0; i < w * h; i++) {
|
|
||||||
unsigned int l;
|
|
||||||
fscanf(f, "%d", &l);
|
|
||||||
fprintf(Compo0, "%c", l);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
} else if (value == '5') {
|
|
||||||
fgetc(f);
|
|
||||||
if (fgetc(f) == '#') {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P5\n");
|
|
||||||
fgets(comment, 256, f);
|
|
||||||
fscanf(f, "%d %d\n255", &w, &h);
|
|
||||||
} else {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P5\n%d %d\n255", &w, &h);
|
|
||||||
}
|
|
||||||
|
|
||||||
fgetc(f);
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
|
|
||||||
img->numcomps = 1;
|
|
||||||
img->color_space = 2;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
|
|
||||||
img->comps[0].prec = 8;
|
|
||||||
img->comps[0].bpp = 8;
|
|
||||||
img->comps[0].sgnd = 0;
|
|
||||||
img->comps[0].dx = subsampling_dx;
|
|
||||||
img->comps[0].dy = subsampling_dy;
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
for (i = 0; i < w * h; i++) {
|
|
||||||
unsigned char l;
|
|
||||||
fread(&l, 1, 1, f);
|
|
||||||
fwrite(&l, 1, 1, Compo0);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
} else if (value == '3') {
|
|
||||||
fgetc(f);
|
|
||||||
if (fgetc(f) == '#') {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P3\n");
|
|
||||||
fgets(comment, 256, f);
|
|
||||||
fscanf(f, "%d %d\n255", &w, &h);
|
|
||||||
} else {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P3\n%d %d\n255", &w, &h);
|
|
||||||
}
|
|
||||||
|
|
||||||
fgetc(f);
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->color_space = 1;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
}
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo1 = fopen("Compo1", "wb");
|
|
||||||
if (!Compo1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo2 = fopen("Compo2", "wb");
|
|
||||||
if (!Compo2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < w * h; i++) {
|
|
||||||
unsigned int r, g, b;
|
|
||||||
fscanf(f, "%d", &r);
|
|
||||||
fscanf(f, "%d", &g);
|
|
||||||
fscanf(f, "%d", &b);
|
|
||||||
fprintf(Compo0, "%c", r);
|
|
||||||
fprintf(Compo1, "%c", g);
|
|
||||||
fprintf(Compo2, "%c", b);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
fclose(Compo1);
|
|
||||||
fclose(Compo2);
|
|
||||||
} else if (value == '6') {
|
|
||||||
fgetc(f);
|
|
||||||
if (fgetc(f) == '#') {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P6\n");
|
|
||||||
fgets(comment, 256, f);
|
|
||||||
fscanf(f, "%d %d\n255", &w, &h);
|
|
||||||
} else {
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fscanf(f, "P6\n%d %d\n255", &w, &h);
|
|
||||||
}
|
|
||||||
|
|
||||||
fgetc(f);
|
|
||||||
img->x0 = Dim[0];
|
|
||||||
img->y0 = Dim[1];
|
|
||||||
img->x1 =
|
|
||||||
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
img->y1 =
|
|
||||||
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->color_space = 1;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
}
|
|
||||||
Compo0 = fopen("Compo0", "wb");
|
|
||||||
if (!Compo0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo1 = fopen("Compo1", "wb");
|
|
||||||
if (!Compo1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo2 = fopen("Compo2", "wb");
|
|
||||||
if (!Compo2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < w * h; i++) {
|
|
||||||
unsigned char r, g, b;
|
|
||||||
fread(&r, 1, 1, f);
|
|
||||||
fread(&g, 1, 1, f);
|
|
||||||
fread(&b, 1, 1, f);
|
|
||||||
fwrite(&r, 1, 1, Compo0);
|
|
||||||
fwrite(&g, 1, 1, Compo1);
|
|
||||||
fwrite(&b, 1, 1, Compo2);
|
|
||||||
}
|
|
||||||
fclose(Compo0);
|
|
||||||
fclose(Compo1);
|
|
||||||
fclose(Compo2);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
1004
codec/image_to_j2k.c
1004
codec/image_to_j2k.c
File diff suppressed because it is too large
Load Diff
@@ -1,249 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="image_to_j2k" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=image_to_j2k - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "image_to_j2k.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "image_to_j2k.mak" CFG="image_to_j2k - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "image_to_j2k - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "image_to_j2k - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "image_to_j2k - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x80c /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x80c /i "../libopenjpeg" /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "image_to_j2k - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "_DEBUG" /D "DONT_HAVE_GETOPT" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x80c /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x80c /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "image_to_j2k - Win32 Release"
|
|
||||||
# Name "image_to_j2k - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\convert.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\image_to_j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\convert.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\openjpeg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,746 +0,0 @@
|
|||||||
/* Copyright (c) 2001 David Janssens
|
|
||||||
* Copyright (c) 2002-2003 Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003 Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
|
|
||||||
#include <stdlib.h> // Must be included first
|
|
||||||
|
|
||||||
#include <crtdbg.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <openjpeg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#ifndef DONT_HAVE_GETOPT
|
|
||||||
#include <getopt.h>
|
|
||||||
#else
|
|
||||||
#include "compat/getopt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void usage_display(char *prgm)
|
|
||||||
{
|
|
||||||
fprintf(stdout,"Usage:\n");
|
|
||||||
fprintf(stdout," %s...\n",prgm);
|
|
||||||
fprintf(stdout," -i <compressed file>\n");
|
|
||||||
fprintf(stdout," REQUIRED\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");
|
|
||||||
fprintf(stdout," -u\n");
|
|
||||||
fprintf(stdout," print an usage statement\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
FILE *fsrc=NULL;
|
|
||||||
FILE *fdest=NULL;
|
|
||||||
char *infile=NULL;
|
|
||||||
char *outfile=NULL;
|
|
||||||
char *tmp=NULL;
|
|
||||||
char S1, S2, S3;
|
|
||||||
|
|
||||||
char *src=NULL;
|
|
||||||
|
|
||||||
int len;
|
|
||||||
|
|
||||||
j2k_image_t img;
|
|
||||||
j2k_cp_t cp;
|
|
||||||
jp2_struct_t *jp2_struct=NULL;
|
|
||||||
|
|
||||||
int w, wr, wrr, h, hr, hrr, max;
|
|
||||||
int i, compno, pad, j;
|
|
||||||
int adjust;
|
|
||||||
|
|
||||||
cp.layer=0;
|
|
||||||
cp.reduce=0;
|
|
||||||
cp.decod_format=-1;
|
|
||||||
cp.cod_format=-1;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
int c = getopt(argc, argv,"i:o:r:l:u");
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
switch (c) {
|
|
||||||
|
|
||||||
//Input file
|
|
||||||
case 'i':
|
|
||||||
infile = optarg;
|
|
||||||
tmp = optarg;
|
|
||||||
while (*tmp) {
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
tmp--;
|
|
||||||
S3 = *tmp;
|
|
||||||
tmp--;
|
|
||||||
S2 = *tmp;
|
|
||||||
tmp--;
|
|
||||||
S1 = *tmp;
|
|
||||||
|
|
||||||
/* J2K format */
|
|
||||||
if ((S1 == 'j' && S2 == '2' && S3 == 'k')
|
|
||||||
|| (S1 == 'J' && S2 == '2' && S3 == 'K')
|
|
||||||
|| (S1 == 'j' && S2 == '2' && S3 == 'c')
|
|
||||||
|| (S1 == 'J' && S2 == '2' && S3 == 'C')) {
|
|
||||||
cp.cod_format=J2K_CFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* JP2 format */
|
|
||||||
if ((S1 == 'j' && S2 == 'p' && S3 == '2')
|
|
||||||
|| (S1 == 'J' && S2 == 'P' && S3 == '2')) {
|
|
||||||
cp.cod_format=JP2_CFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* JPT format */
|
|
||||||
if ((S1 == 'j' && S2 == 'p' && S3 == 't')
|
|
||||||
|| (S1 == 'J' && S2 == 'P' && S3 == 'T')) {
|
|
||||||
cp.cod_format=JPT_CFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"j2k_to_image : Unknown input image format *.%c%c%c [only *.j2k, *.jp2, *.jpc or *.jpt]!! \n",
|
|
||||||
S1, S2, S3);
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
|
|
||||||
//Output file
|
|
||||||
case 'o':
|
|
||||||
outfile = optarg;
|
|
||||||
tmp = optarg;
|
|
||||||
while (*tmp) {
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
tmp--;
|
|
||||||
S3 = *tmp;
|
|
||||||
tmp--;
|
|
||||||
S2 = *tmp;
|
|
||||||
tmp--;
|
|
||||||
S1 = *tmp;
|
|
||||||
|
|
||||||
// PGX format
|
|
||||||
if ((S1 == 'p' && S2 == 'g' && S3 == 'x')
|
|
||||||
|| (S1 == 'P' && S2 == 'G' && S3 == 'X')) {
|
|
||||||
cp.decod_format = PGX_DFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PxM format
|
|
||||||
if ((S1 == 'p' && S2 == 'n' && S3 == 'm')
|
|
||||||
|| (S1 == 'P' && S2 == 'N' && S3 == 'M')
|
|
||||||
|| (S1 == 'p' && S2 == 'g' && S3 == 'm')
|
|
||||||
|| (S1 == 'P' && S2 == 'G' && S3 == 'M')
|
|
||||||
|| (S1 == 'P' && S2 == 'P' && S3 == 'M')
|
|
||||||
|| (S1 == 'p' && S2 == 'p' && S3 == 'm')) {
|
|
||||||
cp.decod_format = PXM_DFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BMP format
|
|
||||||
if ((S1 == 'b' && S2 == 'm' && S3 == 'p')
|
|
||||||
|| (S1 == 'B' && S2 == 'M' && S3 == 'P')) {
|
|
||||||
cp.decod_format = BMP_DFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise : error
|
|
||||||
fprintf(stderr,
|
|
||||||
"!! Unrecognized output image format *.%c%c%c [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n",
|
|
||||||
S1, S2, S3);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
|
|
||||||
//Reduce option
|
|
||||||
case 'r':
|
|
||||||
tmp=optarg;
|
|
||||||
sscanf(tmp, "%d", &cp.reduce);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
|
|
||||||
//Layering option
|
|
||||||
case 'l':
|
|
||||||
tmp=optarg;
|
|
||||||
sscanf(tmp, "%d", &cp.layer);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
|
|
||||||
case 'u':
|
|
||||||
usage_display(argv[0]);
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c,optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check required arguments
|
|
||||||
//------------------------
|
|
||||||
if (!infile || !outfile) {
|
|
||||||
fprintf(stderr,"ERROR -> At least one required argument is missing\nCheck j2k_to_image -u for usage information\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Read the input file and put it in memory
|
|
||||||
//----------------------------------------
|
|
||||||
fsrc = fopen(infile, "rb");
|
|
||||||
if (!fsrc) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", infile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fseek(fsrc, 0, SEEK_END);
|
|
||||||
len = ftell(fsrc);
|
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
|
||||||
src = (char *) malloc(len);
|
|
||||||
fread(src, 1, len, fsrc);
|
|
||||||
fclose(fsrc);
|
|
||||||
|
|
||||||
//Decode the code-stream
|
|
||||||
//----------------------
|
|
||||||
switch(cp.cod_format) {
|
|
||||||
|
|
||||||
case J2K_CFMT:
|
|
||||||
if (!j2k_decode(src, len, &img, &cp)) {
|
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JP2_CFMT:
|
|
||||||
jp2_struct = (jp2_struct_t *) malloc(sizeof(jp2_struct_t));
|
|
||||||
jp2_struct->image = &img;
|
|
||||||
|
|
||||||
if (jp2_read_struct(src, jp2_struct, len)) {
|
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode jp2 structure!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!j2k_decode(src + jp2_struct->j2k_codestream_offset, jp2_struct->j2k_codestream_len, &img, &cp)) {
|
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Insert code here if you want to create actions on jp2_struct before deleting it */
|
|
||||||
|
|
||||||
free(jp2_struct);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JPT_CFMT:
|
|
||||||
if (!j2k_decode_jpt_stream(src, len, &img, &cp)) {
|
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode JPT-file!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR -> j2k_to_image : Unknown input image format\n");
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Free the memory containing the code-stream
|
|
||||||
//------------------------------------------
|
|
||||||
|
|
||||||
free(src);
|
|
||||||
|
|
||||||
|
|
||||||
//Create output image
|
|
||||||
//-------------------
|
|
||||||
|
|
||||||
/* ---------------------------- / */
|
|
||||||
/* / / */
|
|
||||||
/* / FORMAT : PNM, PGM or PPM / */
|
|
||||||
/* / / */
|
|
||||||
/* ---------------------------- / */
|
|
||||||
|
|
||||||
switch (cp.decod_format) {
|
|
||||||
case PXM_DFMT: /* PNM PGM PPM */
|
|
||||||
|
|
||||||
tmp=outfile;
|
|
||||||
while (*tmp) {
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
tmp--;
|
|
||||||
tmp--;
|
|
||||||
S2 = *tmp;
|
|
||||||
|
|
||||||
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
|
|
||||||
&& img.comps[1].dx == img.comps[2].dx
|
|
||||||
&& img.comps[0].dy == img.comps[1].dy
|
|
||||||
&& img.comps[1].dy == img.comps[2].dy
|
|
||||||
&& img.comps[0].prec == img.comps[1].prec
|
|
||||||
&& img.comps[1].prec == img.comps[2].prec
|
|
||||||
&& S2 !='g' && S2 !='G') {
|
|
||||||
|
|
||||||
fdest = fopen(outfile, "wb");
|
|
||||||
if (!fdest) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
w = int_ceildiv(img.x1 - img.x0, img.comps[0].dx);
|
|
||||||
// wr = int_ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[0].dx);
|
|
||||||
wr = img.comps[0].w;
|
|
||||||
wrr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
|
|
||||||
|
|
||||||
h = int_ceildiv(img.y1 - img.y0, img.comps[0].dy);
|
|
||||||
// hr = int_ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
|
|
||||||
hr = img.comps[0].h;
|
|
||||||
hrr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
|
|
||||||
|
|
||||||
max = img.comps[0].prec > 8 ? 255 : (1 << img.comps[0].prec) - 1;
|
|
||||||
|
|
||||||
img.comps[0].x0 =
|
|
||||||
int_ceildivpow2(img.comps[0].x0 -
|
|
||||||
int_ceildiv(img.x0, img.comps[0].dx),
|
|
||||||
img.comps[0].factor);
|
|
||||||
img.comps[0].y0 =
|
|
||||||
int_ceildivpow2(img.comps[0].y0 -
|
|
||||||
int_ceildiv(img.y0, img.comps[0].dy),
|
|
||||||
img.comps[0].factor);
|
|
||||||
|
|
||||||
|
|
||||||
fprintf(fdest, "P6\n%d %d\n%d\n", wrr, hrr, max);
|
|
||||||
adjust = img.comps[0].prec > 8 ? img.comps[0].prec - 8 : 0;
|
|
||||||
for (i = 0; i < wrr * hrr; i++) {
|
|
||||||
int r, g, b;
|
|
||||||
unsigned char rc,gc,bc;
|
|
||||||
r = img.comps[0].data[i / wrr * wr + i % wrr];
|
|
||||||
r += (img.comps[0].sgnd ? 1 << (img.comps[0].prec - 1) : 0);
|
|
||||||
rc = (unsigned char) ((r >> adjust)+((r >> (adjust-1))%2));
|
|
||||||
|
|
||||||
g = img.comps[1].data[i / wrr * wr + i % wrr];
|
|
||||||
g += (img.comps[1].sgnd ? 1 << (img.comps[1].prec - 1) : 0);
|
|
||||||
gc = (unsigned char) ((g >> adjust)+((g >> (adjust-1))%2));
|
|
||||||
|
|
||||||
b = img.comps[2].data[i / wrr * wr + i % wrr];
|
|
||||||
b += (img.comps[2].sgnd ? 1 << (img.comps[2].prec - 1) : 0);
|
|
||||||
bc = (unsigned char) ((b >> adjust)+((b >> (adjust-1))%2));
|
|
||||||
|
|
||||||
fprintf(fdest, "%c%c%c", rc, gc, bc);
|
|
||||||
}
|
|
||||||
free(img.comps[0].data);
|
|
||||||
free(img.comps[1].data);
|
|
||||||
free(img.comps[2].data);
|
|
||||||
fclose(fdest);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
int ncomp=(S2=='g' || S2=='G')?1:img.numcomps;
|
|
||||||
if (img.numcomps>ncomp) {
|
|
||||||
fprintf(stderr,"WARNING -> [PGM files] Only the first component\n");
|
|
||||||
fprintf(stderr," is written to the file\n");
|
|
||||||
}
|
|
||||||
for (compno = 0; compno < ncomp; compno++) {
|
|
||||||
char name[256];
|
|
||||||
if (ncomp > 1) {
|
|
||||||
sprintf(name, "%d.%s", compno, outfile);
|
|
||||||
} else {
|
|
||||||
sprintf(name, "%s", outfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
fdest = fopen(name, "wb");
|
|
||||||
if (!fdest) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
w = int_ceildiv(img.x1 - img.x0, img.comps[compno].dx);
|
|
||||||
// wr = int_ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[compno].dx);
|
|
||||||
wr = img.comps[compno].w;
|
|
||||||
wrr =
|
|
||||||
int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
|
|
||||||
|
|
||||||
h = int_ceildiv(img.y1 - img.y0, img.comps[compno].dy);
|
|
||||||
// hr = int_ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[compno].dy);
|
|
||||||
hr = img.comps[compno].h;
|
|
||||||
hrr =
|
|
||||||
int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
|
|
||||||
|
|
||||||
max =
|
|
||||||
img.comps[compno].prec >
|
|
||||||
8 ? 255 : (1 << img.comps[compno].prec) - 1;
|
|
||||||
|
|
||||||
img.comps[compno].x0 =
|
|
||||||
int_ceildivpow2(img.comps[compno].x0 -
|
|
||||||
int_ceildiv(img.x0,
|
|
||||||
img.comps[compno].dx),
|
|
||||||
img.comps[compno].factor);
|
|
||||||
img.comps[compno].y0 =
|
|
||||||
int_ceildivpow2(img.comps[compno].y0 -
|
|
||||||
int_ceildiv(img.y0,
|
|
||||||
img.comps[compno].dy),
|
|
||||||
img.comps[compno].factor);
|
|
||||||
|
|
||||||
fprintf(fdest, "P5\n%d %d\n%d\n", wrr, hrr, max);
|
|
||||||
adjust =
|
|
||||||
img.comps[compno].prec > 8 ? img.comps[compno].prec - 8 : 0;
|
|
||||||
for (i = 0; i < wrr * hrr; i++) {
|
|
||||||
int l;
|
|
||||||
unsigned char lc;
|
|
||||||
l = img.comps[compno].data[i / wrr * wr + i % wrr];
|
|
||||||
l += (img.comps[compno].
|
|
||||||
sgnd ? 1 << (img.comps[compno].prec - 1) : 0);
|
|
||||||
lc = (unsigned char) ((l >> adjust)+((l >> (adjust-1))%2));
|
|
||||||
fprintf(fdest, "%c", lc);
|
|
||||||
}
|
|
||||||
fclose(fdest);
|
|
||||||
free(img.comps[compno].data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ------------------------ / */
|
|
||||||
/* / / */
|
|
||||||
/* / FORMAT : PGX / */
|
|
||||||
/* / / */
|
|
||||||
/* /----------------------- / */
|
|
||||||
case PGX_DFMT: /* PGX */
|
|
||||||
for (compno = 0; compno < img.numcomps; compno++) {
|
|
||||||
j2k_comp_t *comp = &img.comps[compno];
|
|
||||||
char name[256];
|
|
||||||
int nbytes = 0;
|
|
||||||
tmp = outfile;
|
|
||||||
while (*tmp) {
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
while (*tmp!='.') {
|
|
||||||
tmp--;
|
|
||||||
}
|
|
||||||
*tmp='\0';
|
|
||||||
|
|
||||||
if (img.numcomps > 1)
|
|
||||||
sprintf(name, "%s-%d.pgx", outfile, compno);
|
|
||||||
else
|
|
||||||
sprintf(name, "%s.pgx", outfile);
|
|
||||||
|
|
||||||
fdest = fopen(name, "wb");
|
|
||||||
if (!fdest) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// w = int_ceildiv(img.x1 - img.x0, comp->dx);
|
|
||||||
// wr = int_ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), comp->dx);
|
|
||||||
w = img.comps[compno].w;
|
|
||||||
wr = int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
|
|
||||||
|
|
||||||
// h = int_ceildiv(img.y1 - img.y0, comp->dy);
|
|
||||||
// hr = int_ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), comp->dy);
|
|
||||||
h = img.comps[compno].h;
|
|
||||||
hr = int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
|
|
||||||
|
|
||||||
fprintf(fdest, "PG ML %c %d %d %d\n", comp->sgnd ? '-' : '+',
|
|
||||||
comp->prec, wr, hr);
|
|
||||||
|
|
||||||
if (comp->prec <= 8)
|
|
||||||
nbytes = 1;
|
|
||||||
|
|
||||||
else if (comp->prec <= 16)
|
|
||||||
nbytes = 2;
|
|
||||||
|
|
||||||
else
|
|
||||||
nbytes = 4;
|
|
||||||
for (i = 0; i < wr * hr; i++) {
|
|
||||||
int v = img.comps[compno].data[i / wr * w + i % wr];
|
|
||||||
|
|
||||||
for (j = nbytes - 1; j >= 0; j--) {
|
|
||||||
|
|
||||||
char byte = (char) (v >> (j * 8));
|
|
||||||
|
|
||||||
fwrite(&byte, 1, 1, fdest);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(img.comps[compno].data);
|
|
||||||
fclose(fdest);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ------------------------ / */
|
|
||||||
/* / / */
|
|
||||||
/* / FORMAT : BMP / */
|
|
||||||
/* / / */
|
|
||||||
/* /----------------------- / */
|
|
||||||
|
|
||||||
case BMP_DFMT: /* BMP */
|
|
||||||
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
|
|
||||||
&& img.comps[1].dx == img.comps[2].dx
|
|
||||||
&& img.comps[0].dy == img.comps[1].dy
|
|
||||||
&& img.comps[1].dy == img.comps[2].dy
|
|
||||||
&& img.comps[0].prec == img.comps[1].prec
|
|
||||||
&& img.comps[1].prec == img.comps[2].prec) {
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
24 bits color
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
|
|
||||||
fdest = fopen(outfile, "wb");
|
|
||||||
if (!fdest) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// w = int_ceildiv(img.x1 - img.x0, img.comps[0].dx);
|
|
||||||
// wr = int_ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
|
|
||||||
w = img.comps[0].w;
|
|
||||||
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
|
|
||||||
|
|
||||||
// h = int_ceildiv(img.y1 - img.y0, img.comps[0].dy);
|
|
||||||
// hr = int_ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
|
|
||||||
h = img.comps[0].h;
|
|
||||||
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
|
|
||||||
|
|
||||||
fprintf(fdest, "BM");
|
|
||||||
|
|
||||||
/* FILE HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(fdest, "%c%c%c%c",
|
|
||||||
(unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
|
|
||||||
54) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
|
|
||||||
((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
|
||||||
|
|
||||||
/* INFO HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
|
|
||||||
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
|
|
||||||
(unsigned char) ((wr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
|
|
||||||
(unsigned char) ((hr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c",
|
|
||||||
(unsigned char) (3 * hr * wr +
|
|
||||||
3 * hr * (wr % 2)) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
8) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
16) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
|
|
||||||
for (i = 0; i < wr * hr; i++) {
|
|
||||||
unsigned char R, G, B;
|
|
||||||
/* a modifier */
|
|
||||||
// R = img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
R = img.comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
// G = img.comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
G = img.comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
// B = img.comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
B = img.comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
fprintf(fdest, "%c%c%c", B, G, R);
|
|
||||||
|
|
||||||
if ((i + 1) % wr == 0) {
|
|
||||||
for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */
|
|
||||||
fprintf(fdest, "%c", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fdest);
|
|
||||||
free(img.comps[1].data);
|
|
||||||
free(img.comps[2].data);
|
|
||||||
} else { /* Gray-scale */
|
|
||||||
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
8 bits non code (Gray scale)
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
fdest = fopen(outfile, "wb");
|
|
||||||
// w = int_ceildiv(img.x1 - img.x0, img.comps[0].dx);
|
|
||||||
// wr = int_ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
|
|
||||||
w = img.comps[0].w;
|
|
||||||
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
|
|
||||||
|
|
||||||
// h = int_ceildiv(img.y1 - img.y0, img.comps[0].dy);
|
|
||||||
// hr = int_ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
|
|
||||||
h = img.comps[0].h;
|
|
||||||
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
|
|
||||||
|
|
||||||
fprintf(fdest, "BM");
|
|
||||||
|
|
||||||
/* FILE HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(fdest, "%c%c%c%c",
|
|
||||||
(unsigned char) (hr * wr + 54 + 1024 +
|
|
||||||
hr * (wr % 2)) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
|
|
||||||
>> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
|
|
||||||
>> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr + 54 + 1024 + wr * (wr % 2))
|
|
||||||
>> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff,
|
|
||||||
((54 + 1024) >> 8) & 0xff, ((54 + 1024) >> 16) & 0xff,
|
|
||||||
((54 + 1024) >> 24) & 0xff);
|
|
||||||
|
|
||||||
/* INFO HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
|
|
||||||
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
|
|
||||||
(unsigned char) ((wr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
|
|
||||||
(unsigned char) ((hr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c",
|
|
||||||
(unsigned char) (hr * wr + hr * (wr % 2)) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 8) &
|
|
||||||
0xff,
|
|
||||||
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 16) &
|
|
||||||
0xff,
|
|
||||||
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
|
|
||||||
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
|
||||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
|
|
||||||
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
fprintf(fdest, "%c%c%c%c", i, i, i, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < wr * hr; i++) {
|
|
||||||
/* a modifier !! */
|
|
||||||
// fprintf(fdest, "%c", img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)]);
|
|
||||||
fprintf(fdest, "%c",
|
|
||||||
img.comps[0].data[w * hr - ((i) / (wr) + 1) * w +
|
|
||||||
(i) % (wr)]);
|
|
||||||
/*if (((i + 1) % w == 0 && w % 2))
|
|
||||||
fprintf(fdest, "%c", 0); */
|
|
||||||
if ((i + 1) % wr == 0) {
|
|
||||||
for (pad = wr % 4 ? 4 - wr % 4 : 0; pad > 0; pad--) /* ADD */
|
|
||||||
fprintf(fdest, "%c", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fdest);
|
|
||||||
free(img.comps[0].data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR -> j2k_to_image : Unknown output image format\n");
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Free remaining structures
|
|
||||||
//--------------------------
|
|
||||||
j2k_dec_release();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check memory leaks if debug mode
|
|
||||||
//---------------------------------
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
|
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,240 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="j2k_to_image" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=j2k_to_image - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "j2k_to_image.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "j2k_to_image.mak" CFG="j2k_to_image - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "j2k_to_image - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "j2k_to_image - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "j2k_to_image - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x80c /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x80c /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "j2k_to_image - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "j2k_to_image___Win32_Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "j2k_to_image___Win32_Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "j2k_to_image___Win32_Debug"
|
|
||||||
# PROP Intermediate_Dir "j2k_to_image___Win32_Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x80c /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x80c /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "j2k_to_image - Win32 Release"
|
|
||||||
# Name "j2k_to_image - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\j2k_to_image.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\openjpeg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
105
codec/readme.txt
105
codec/readme.txt
@@ -1,105 +0,0 @@
|
|||||||
List of parameters for the coder JPEG 2000 :
|
|
||||||
|
|
||||||
Date : June the 25th, 2003
|
|
||||||
Author : Yannick Verschueren
|
|
||||||
Contact : verschueren@tele.ucl.ac.be
|
|
||||||
|
|
||||||
- the option -help displays the readme.txt file on screen
|
|
||||||
|
|
||||||
- The markers COD and QCD are writed both of two in the main_header and never appear in the tile_header. The markers in the main header are : SOC SIZ COD QCD COM.
|
|
||||||
|
|
||||||
- This coder can encode mega image, a test was made on a 24000x24000 pixels color image. You need enough disk space memory (twice the original) to encode the image. (i.e. for a 1.5 Gb image you need a minimum of 3Gb of disk memory)
|
|
||||||
|
|
||||||
REMARKS :
|
|
||||||
---------
|
|
||||||
|
|
||||||
* the value of rate enter in the code line is the compression factor !
|
|
||||||
exemple :
|
|
||||||
|
|
||||||
-r 20,10,1 means quality 1 : compress 20x, quality 2 : compress 10x and quality 3 : compress 1x = lossless
|
|
||||||
|
|
||||||
* The number of resolution can be modified by the program in view to respect profile-0 conditions (Taubman, Marcelin (2002), "JPEG2000, image compression fundamentals, standards and practice", p700)
|
|
||||||
|
|
||||||
By default :
|
|
||||||
------------
|
|
||||||
|
|
||||||
* lossless
|
|
||||||
* 1 tile
|
|
||||||
* size of precinct 2^15 x 2^15 (means 1 precinct)
|
|
||||||
* size of code-block 64 x 64
|
|
||||||
* Number of resolution : 6
|
|
||||||
* No SOP marker in the codestream
|
|
||||||
* No EPH marker in the codestream
|
|
||||||
* No sub-sampling in x and y direction
|
|
||||||
* No mode switch activated
|
|
||||||
* progression order : LRCP
|
|
||||||
* No index file
|
|
||||||
* No ROI upshifted
|
|
||||||
* No offset of the origin of the image
|
|
||||||
* No offset of the origin of the tiles
|
|
||||||
* Reversible DWT 5-3
|
|
||||||
|
|
||||||
Parameters :
|
|
||||||
------------
|
|
||||||
|
|
||||||
-i : source file (-i source.pnm also *.pgm, *.ppm) "required"
|
|
||||||
|
|
||||||
-o : destination file (-o dest.j2k) "required"
|
|
||||||
|
|
||||||
-r : different rates (-r 20,10,5) "optional"
|
|
||||||
|
|
||||||
-n : Number of resolution (-n 3) "optional"
|
|
||||||
|
|
||||||
-b : size of code block (-b 32,32) "optional"
|
|
||||||
|
|
||||||
-c : size of precinct (-c 128,128) "optional"
|
|
||||||
|
|
||||||
-t : size of tile (-t 512,512) "optional"
|
|
||||||
|
|
||||||
-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] "optional"
|
|
||||||
|
|
||||||
-s : subsampling factor (-s 2,2) [-s X,Y] "optional"
|
|
||||||
|
|
||||||
-SOP : write SOP marker before each packet "optional"
|
|
||||||
|
|
||||||
-EPH : write EPH marker after each header packet "optional"
|
|
||||||
|
|
||||||
-M : mode switch (-M 3) [1= BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] "optional"
|
|
||||||
for several mode switch you have to add the value of each mode you want
|
|
||||||
ex : RESTART(4) + RESET(2) + SEGMARK(32) = -M 38
|
|
||||||
|
|
||||||
-x : Create an index file *.Idx (-x index_name.Idx) "optional"
|
|
||||||
|
|
||||||
-ROI:c=%d,U=%d : quantization indices upshifted for component c=%d [%d = 0,1,2]
|
|
||||||
with a value of U=%d [0 <= %d <= 37] (i.e. -ROI:c=0,U=25) "optional"
|
|
||||||
|
|
||||||
-d : offset of the origin of the image (-d 150,300) "optional"
|
|
||||||
|
|
||||||
-T : offset of the origin of the tiles (-T 100,75) "optional"
|
|
||||||
|
|
||||||
-I : Use the irreversible DWT 9-7 (-I) "optional"
|
|
||||||
|
|
||||||
IMPORTANT :
|
|
||||||
-----------
|
|
||||||
|
|
||||||
* subsampling bigger than 2 can produce error
|
|
||||||
|
|
||||||
The index file respect the structure below :
|
|
||||||
---------------------------------------------
|
|
||||||
|
|
||||||
Image_height Image_width
|
|
||||||
progression order
|
|
||||||
Tiles_size_X Tiles_size_Y
|
|
||||||
Components_nb
|
|
||||||
Layers_nb
|
|
||||||
decomposition_levels
|
|
||||||
Precincts_size_X Precincts_size_Y
|
|
||||||
Main_header_end_position
|
|
||||||
Codestream_size
|
|
||||||
Tile0 start_pos end_Theader end_pos
|
|
||||||
Tile1 " " "
|
|
||||||
...
|
|
||||||
TileN " " "
|
|
||||||
Tpacket_0 Tile layer res. comp. prec. start_pos end_pos
|
|
||||||
...
|
|
||||||
Tpacket_M " " " " " " "
|
|
||||||
52
doc/CMakeLists.txt
Normal file
52
doc/CMakeLists.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Generate target to build the html documentation through CMake tool
|
||||||
|
# After having configured the project with the BUILD_DOC option you can run make doc
|
||||||
|
# to generate the html documentation in the doc/html repository of the build folder.
|
||||||
|
|
||||||
|
# Try to find the doxygen tool
|
||||||
|
find_package(Doxygen)
|
||||||
|
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
# Configure the doxygen config file with variable from CMake and move it
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
|
||||||
|
|
||||||
|
# Configure the html mainpage file of the doxygen documentation with variable
|
||||||
|
# from CMake and move it
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpip.dox.in
|
||||||
|
${CMAKE_BINARY_DIR}/doc/openjpip.dox @ONLY)
|
||||||
|
# copy png file to make local (binary tree) documentation valid:
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_architect.png
|
||||||
|
${CMAKE_BINARY_DIR}/doc/html/jpip_architect.png COPYONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jpip_protocol.png
|
||||||
|
${CMAKE_BINARY_DIR}/doc/html/jpip_protocol.png COPYONLY)
|
||||||
|
|
||||||
|
file(GLOB headers
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/*.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjpip/*.c
|
||||||
|
)
|
||||||
|
# Generate new target to build the html documentation
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
|
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
|
||||||
|
${CMAKE_BINARY_DIR}/doc/mainpage.dox
|
||||||
|
${CMAKE_BINARY_DIR}/doc/openjpip.dox
|
||||||
|
${headers}
|
||||||
|
)
|
||||||
|
add_custom_target(doc ALL
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
|
||||||
|
COMMENT "Building doxygen documentation"
|
||||||
|
)
|
||||||
|
|
||||||
|
# install HTML documentation (install png files too):
|
||||||
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
|
||||||
|
DESTINATION share/doc
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Doxygen not found, we cannot generate the documentation")
|
||||||
|
endif()
|
||||||
285
doc/Doxyfile.dox.cmake.in
Normal file
285
doc/Doxyfile.dox.cmake.in
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
# Doxyfile 1.7.1
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
DOXYFILE_ENCODING = UTF-8
|
||||||
|
PROJECT_NAME = OpenJPEG
|
||||||
|
PROJECT_NUMBER = @OPENJPEG_VERSION@
|
||||||
|
OUTPUT_DIRECTORY = @OPENJPEG_BINARY_DIR@/doc
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
BRIEF_MEMBER_DESC = YES
|
||||||
|
REPEAT_BRIEF = YES
|
||||||
|
ABBREVIATE_BRIEF = "The $name class" \
|
||||||
|
"The $name widget" \
|
||||||
|
"The $name file" \
|
||||||
|
is \
|
||||||
|
provides \
|
||||||
|
specifies \
|
||||||
|
contains \
|
||||||
|
represents \
|
||||||
|
a \
|
||||||
|
an \
|
||||||
|
the
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = NO
|
||||||
|
STRIP_FROM_PATH = C://
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = YES
|
||||||
|
QT_AUTOBRIEF = NO
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
SEPARATE_MEMBER_PAGES = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
OPTIMIZE_FOR_FORTRAN = NO
|
||||||
|
OPTIMIZE_OUTPUT_VHDL = NO
|
||||||
|
EXTENSION_MAPPING =
|
||||||
|
BUILTIN_STL_SUPPORT = NO
|
||||||
|
CPP_CLI_SUPPORT = NO
|
||||||
|
SIP_SUPPORT = NO
|
||||||
|
IDL_PROPERTY_SUPPORT = YES
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
TYPEDEF_HIDES_STRUCT = NO
|
||||||
|
SYMBOL_CACHE_SIZE = 0
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = YES
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = NO
|
||||||
|
EXTRACT_ANON_NSPACES = NO
|
||||||
|
HIDE_UNDOC_MEMBERS = NO
|
||||||
|
HIDE_UNDOC_CLASSES = NO
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = NO
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = YES
|
||||||
|
FORCE_LOCAL_INCLUDES = NO
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = YES
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_MEMBERS_CTORS_1ST = NO
|
||||||
|
SORT_GROUP_NAMES = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
SHOW_DIRECTORIES = NO
|
||||||
|
SHOW_FILES = YES
|
||||||
|
SHOW_NAMESPACES = YES
|
||||||
|
FILE_VERSION_FILTER =
|
||||||
|
LAYOUT_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = NO
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_NO_PARAMDOC = NO
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = @OPENJPEG_SOURCE_DIR@/src/lib/openjp2 \
|
||||||
|
@OPENJPEG_SOURCE_DIR@/src/lib/openjpip \
|
||||||
|
@OPENJPEG_BINARY_DIR@/doc
|
||||||
|
INPUT_ENCODING = UTF-8
|
||||||
|
FILE_PATTERNS = *.h \
|
||||||
|
*.c \
|
||||||
|
*.dox
|
||||||
|
RECURSIVE = YES
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS = */.svn/*
|
||||||
|
EXCLUDE_SYMBOLS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS = *
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH = @OPENJPEG_SOURCE_DIR@/doc
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_PATTERNS =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = NO
|
||||||
|
INLINE_SOURCES = NO
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = YES
|
||||||
|
REFERENCES_RELATION = YES
|
||||||
|
REFERENCES_LINK_SOURCE = YES
|
||||||
|
USE_HTAGS = NO
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = NO
|
||||||
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
|
IGNORE_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = ./html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_COLORSTYLE_HUE = 220
|
||||||
|
HTML_COLORSTYLE_SAT = 100
|
||||||
|
HTML_COLORSTYLE_GAMMA = 80
|
||||||
|
HTML_TIMESTAMP = NO
|
||||||
|
HTML_ALIGN_MEMBERS = YES
|
||||||
|
HTML_DYNAMIC_SECTIONS = NO
|
||||||
|
GENERATE_DOCSET = NO
|
||||||
|
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||||
|
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||||
|
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||||
|
DOCSET_PUBLISHER_NAME = Publisher
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
CHM_INDEX_ENCODING =
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
GENERATE_QHP = NO
|
||||||
|
QCH_FILE =
|
||||||
|
QHP_NAMESPACE = org.doxygen.Project
|
||||||
|
QHP_VIRTUAL_FOLDER = doc
|
||||||
|
QHP_CUST_FILTER_NAME =
|
||||||
|
QHP_CUST_FILTER_ATTRS =
|
||||||
|
QHP_SECT_FILTER_ATTRS =
|
||||||
|
QHG_LOCATION =
|
||||||
|
GENERATE_ECLIPSEHELP = NO
|
||||||
|
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = NO
|
||||||
|
USE_INLINE_TREES = NO
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
EXT_LINKS_IN_WINDOW = NO
|
||||||
|
FORMULA_FONTSIZE = 10
|
||||||
|
FORMULA_TRANSPARENT = YES
|
||||||
|
SEARCHENGINE = NO
|
||||||
|
SERVER_BASED_SEARCH = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = NO
|
||||||
|
USE_PDFLATEX = NO
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
LATEX_SOURCE_CODE = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_SCHEMA =
|
||||||
|
XML_DTD =
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED = USE_JPWL \
|
||||||
|
USE_JPSEC
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES =
|
||||||
|
GENERATE_TAGFILE =
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
MSCGEN_PATH =
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = NO
|
||||||
|
DOT_NUM_THREADS = 0
|
||||||
|
DOT_FONTNAME = Helvetica
|
||||||
|
DOT_FONTSIZE = 10
|
||||||
|
DOT_FONTPATH =
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
GROUP_GRAPHS = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
CALLER_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DIRECTORY_GRAPH = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
DOT_GRAPH_MAX_NODES = 50
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 1000
|
||||||
|
DOT_TRANSPARENT = NO
|
||||||
|
DOT_MULTI_TARGETS = NO
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
||||||
BIN
doc/jpip_architect.png
Normal file
BIN
doc/jpip_architect.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
doc/jpip_protocol.png
Normal file
BIN
doc/jpip_protocol.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
62
doc/mainpage.dox.in
Normal file
62
doc/mainpage.dox.in
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \mainpage OpenJPEG v@OPENJPEG_VERSION@ Documentation
|
||||||
|
*
|
||||||
|
* \section intro Introduction
|
||||||
|
* This manual documents the low-level OpenJPEG C API.\n
|
||||||
|
* The OpenJPEG library is an open-source JPEG 2000 library developed in order to promote the use of JPEG 2000.\n
|
||||||
|
* This documents is focused on the main part of the library which try to implement Part 1 and Part 2 of the JPEG2000 norm.\n
|
||||||
|
*
|
||||||
|
* \section home Home page
|
||||||
|
*
|
||||||
|
* The Home Page of the OpenJPEG project can be found at:
|
||||||
|
*
|
||||||
|
* http://www.openjpeg.org/
|
||||||
|
*
|
||||||
|
* The source code repository is available here:
|
||||||
|
*
|
||||||
|
* http://github.com/uclouvain/openjpeg
|
||||||
|
*
|
||||||
|
* The OpenJPEG mailing list is located here:
|
||||||
|
*
|
||||||
|
* http://groups.google.com/group/openjpeg
|
||||||
|
*
|
||||||
|
* The test files repository is available here:
|
||||||
|
*
|
||||||
|
* http://github.com/uclouvain/openjpeg-data
|
||||||
|
*
|
||||||
|
* \section license License
|
||||||
|
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||||
|
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||||
|
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
*
|
||||||
|
* \author OpenJPEG Team
|
||||||
|
*
|
||||||
|
*/
|
||||||
222
doc/man/man1/opj_compress.1
Normal file
222
doc/man/man1/opj_compress.1
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_compress -
|
||||||
|
This program reads in an image of a certain type and converts it to a
|
||||||
|
jpeg2000 file. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||||
|
.SP
|
||||||
|
Valid output image extensions are
|
||||||
|
.B .j2k, .jp2
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_compress -i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||||
|
.P
|
||||||
|
.B opj_compress -ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||||
|
.P
|
||||||
|
.B opj_compress -h \fRPrint a help message and exit.
|
||||||
|
.P
|
||||||
|
.R See JPWL OPTIONS for special options
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^b " n,n"
|
||||||
|
(Size of code block (e.g. -b 32,32). Default: 64 x 64)
|
||||||
|
.TP
|
||||||
|
.B \-\^c " n"
|
||||||
|
(Size of precinct (e.g. -c 128,128). Default: 2^15 x 2^15)
|
||||||
|
.TP
|
||||||
|
.B \-\^cinema2K " fps"
|
||||||
|
Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or 48.
|
||||||
|
.TP
|
||||||
|
.B \-\^cinema4K
|
||||||
|
Digital Cinema 4K profile compliant codestream. Does not need an fps: default is 24 fps.
|
||||||
|
.TP
|
||||||
|
.B \-\^d " X,Y"
|
||||||
|
(Offset of image origin (e.g. -d 150,300))
|
||||||
|
.TP
|
||||||
|
.B \-\^h
|
||||||
|
Print a help message and exit.
|
||||||
|
.TP
|
||||||
|
.B \-\^i " name"
|
||||||
|
(input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^n " n"
|
||||||
|
(Number of resolutions. Default: 6)
|
||||||
|
.TP
|
||||||
|
.B \-\^o " name"
|
||||||
|
(output file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^p " name"
|
||||||
|
Progression order. \fBname\fR can be one out of:LRCP, RLCP, RPCL, PCRL, CPRL. Default: LRCP.
|
||||||
|
.TP
|
||||||
|
.B \-\^q " n"
|
||||||
|
different psnr for successive layers
|
||||||
|
.br
|
||||||
|
.B Note: \fR(options -r and -q cannot be used together)
|
||||||
|
.TP
|
||||||
|
.B \-\^r " n"
|
||||||
|
different compression ratio(s) for successive layers. The rate specified for each quality level is the desired compression factor.
|
||||||
|
.br
|
||||||
|
.B Note: \fR(options -r and -q cannot be used together)
|
||||||
|
.TP
|
||||||
|
.B \-\^s " X,Y"
|
||||||
|
sub-sampling factor (e.g. -s 2,2). Default: No sub-sampling in x or y direction.
|
||||||
|
.br
|
||||||
|
.B Remark: \fRsub-sampling bigger than 2 can produce errors.
|
||||||
|
.TP
|
||||||
|
.B \-\^t " W,H"
|
||||||
|
(Size of tile (e.g. -t 512,512) )
|
||||||
|
.TP
|
||||||
|
.B \-\^x " name"
|
||||||
|
(Create index file and fill it. Default: no index file)
|
||||||
|
.TP
|
||||||
|
.B \-\^EPH
|
||||||
|
(Write EPH marker after each header packet. Default:no EPH)
|
||||||
|
.TP
|
||||||
|
.B \-\^F " rawWidth,rawHeight,rawComp,rawBitDepth,s_or_u"
|
||||||
|
characteristics of the raw input image
|
||||||
|
.TP
|
||||||
|
.B \-\^I
|
||||||
|
(Use the irreversible DWT 9-7. Default: Reversible DWT 5-3)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir " directory_name"
|
||||||
|
(directory containing input files)
|
||||||
|
.TP
|
||||||
|
.B \-\^M " n"
|
||||||
|
mode switch with values: 1, 2, 4, 8, 16, 32. Default:No mode switch activated.
|
||||||
|
.br
|
||||||
|
\fIMeaning:\fR
|
||||||
|
.br
|
||||||
|
BYPASS(1)
|
||||||
|
.br
|
||||||
|
RESET(2)
|
||||||
|
.br
|
||||||
|
RESTART(4)
|
||||||
|
.br
|
||||||
|
VSC(8)
|
||||||
|
.br
|
||||||
|
ERTERM(16)
|
||||||
|
.br
|
||||||
|
SEGMARK(32)
|
||||||
|
.br
|
||||||
|
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38
|
||||||
|
.TP
|
||||||
|
.B \-\^OutFor "ext"
|
||||||
|
(extension for output files)
|
||||||
|
.TP
|
||||||
|
.B \-\^POC "TtileNr=resolutionStart, componentStart, layerEnd, resolutionEnd, componentEnd, progressionOrder"
|
||||||
|
(see Examples)
|
||||||
|
.TP
|
||||||
|
.B \-\^ROI "c=n,U=n"
|
||||||
|
quantization indices upshifted for component c (0 or 1 or 2) with a value of U (>= 0 and <= 37)
|
||||||
|
.br
|
||||||
|
e.g. \fB-ROI c=0,U=25\fR
|
||||||
|
.TP
|
||||||
|
.B \-\^SOP
|
||||||
|
(Write SOP marker before each packet. Default: No SOP marker in the codestream.)
|
||||||
|
.TP
|
||||||
|
.B \-\^T "X,Y"
|
||||||
|
(Offset of the origin of the tiles (e.g. -T 100,75) )
|
||||||
|
.TP
|
||||||
|
.B \-\^W
|
||||||
|
(see JPWL OPTIONS)
|
||||||
|
.P
|
||||||
|
.SH JPWL OPTIONS
|
||||||
|
Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||||
|
.P
|
||||||
|
.B -W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
|
||||||
|
.P
|
||||||
|
.B h\fR selects the header error protection (EPB): \fBtype\fR can be
|
||||||
|
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
|
||||||
|
if \fBtilepart\fR is absent, it is for main and tile headers
|
||||||
|
if \fBtilepart\fR is present, it applies from that tile
|
||||||
|
onwards, up to the next h<> spec, or to the last tilepart
|
||||||
|
in the codestream (max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B p \fRselects the packet error protection (EEP/UEP with EPBs)
|
||||||
|
to be applied to raw data: \fBtype\fR can be
|
||||||
|
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
|
||||||
|
if \fBtilepart:pack\fR is absent, it is from tile 0, packet 0
|
||||||
|
if \fBtilepart:pack\fR is present, it applies from that tile
|
||||||
|
and that packet onwards, up to the next packet spec
|
||||||
|
or to the last packet in the last tilepart in the stream
|
||||||
|
(max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B s \fRenables sensitivity data insertion (ESD): \fBmethod\fR can be
|
||||||
|
[-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
|
||||||
|
4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
|
||||||
|
if \fBtilepart\fR is absent, it is for main header only
|
||||||
|
if \fBtilepart\fR is present, it applies from that tile
|
||||||
|
onwards, up to the next s<> spec, or to the last tilepart
|
||||||
|
in the codestream (max. 16 specs)
|
||||||
|
.P
|
||||||
|
.B g \fRdetermines the addressing mode: \fBrange\fR can be
|
||||||
|
[0=PACKET 1=BYTE RANGE 2=PACKET RANGE]
|
||||||
|
.P
|
||||||
|
.B a \fRdetermines the size of data addressing: \fBaddr\fR can be
|
||||||
|
2/4 bytes (small/large codestreams). If not set, auto-mode
|
||||||
|
.P
|
||||||
|
.B z \fRdetermines the size of sensitivity values: \fBsize\fR can be
|
||||||
|
1/2 bytes, for the transformed pseudo-floating point value
|
||||||
|
.P
|
||||||
|
.SH EXAMPLES
|
||||||
|
.P
|
||||||
|
.B opj_compress -i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||||
|
.P
|
||||||
|
.B opj_compress -i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||||
|
.P
|
||||||
|
.B opj_compress -i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||||
|
.P
|
||||||
|
.B opj_compress -i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||||
|
.P
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
.br
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
.br
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
.br
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
.br
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_decompress(1) opj_dump(1)
|
||||||
|
|
||||||
119
doc/man/man1/opj_decompress.1
Normal file
119
doc/man/man1/opj_decompress.1
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_decompress -
|
||||||
|
This program reads in a jpeg2000 image and converts it to another
|
||||||
|
image type. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .j2k, .jp2, .j2c, .jpt
|
||||||
|
.SP
|
||||||
|
Valid output image extensions are
|
||||||
|
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_decompress -i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||||
|
.P
|
||||||
|
.B opj_decompress -ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||||
|
.P
|
||||||
|
.B opj_decompress -h \fRPrint help message and exit
|
||||||
|
.P
|
||||||
|
.R See JPWL OPTIONS for special options
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^i "name"
|
||||||
|
(jpeg2000 input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^l "n"
|
||||||
|
n is the maximum number of quality layers to decode. See LAYERS below)
|
||||||
|
.TP
|
||||||
|
.B \-\^o "name"
|
||||||
|
(output file name with extension)
|
||||||
|
.TP
|
||||||
|
.B \-\^r "n"
|
||||||
|
(n is the highest resolution level to be discarded. See REDUCTION below)
|
||||||
|
.TP
|
||||||
|
.B \-\^x "name"
|
||||||
|
(use name as index file and fill it)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir "directory_name"
|
||||||
|
(directory containing input files)
|
||||||
|
.TP
|
||||||
|
.B \-\^OutFor "ext"
|
||||||
|
(extension for output files)
|
||||||
|
.P
|
||||||
|
.SH JPIP OPTIONS
|
||||||
|
Options usable only if the library has been compiled with
|
||||||
|
.B BUILD_JPIP
|
||||||
|
.TP
|
||||||
|
.B -jpip
|
||||||
|
Embed index table box into the output JP2 file (compulsory for JPIP)
|
||||||
|
.TP
|
||||||
|
.B -TP R
|
||||||
|
Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream)
|
||||||
|
.P
|
||||||
|
.SH JPWL OPTIONS
|
||||||
|
Options usable only if the library has been compiled with
|
||||||
|
.B BUILD_JPWL
|
||||||
|
.TP
|
||||||
|
.B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3)
|
||||||
|
.TP
|
||||||
|
.B -W t\fR[=Nt] (Nt is the maximum number of tiles in the codestream; default:8192)
|
||||||
|
.TP
|
||||||
|
.B -W c\fR[=Nc]\fB, t\fR[=Nt] \fR(same as above)
|
||||||
|
.P
|
||||||
|
.SH REDUCTION
|
||||||
|
Set the number of highest resolution levels to be discarded.
|
||||||
|
The image resolution is effectively divided by 2 to the power of the number of discarded levels. The reduce factor is limited by the smallest total number of decomposition levels among tiles.
|
||||||
|
.SH TILES
|
||||||
|
Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
|
||||||
|
.P
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
.br
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
.br
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
.br
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
.br
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
.br
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_compress(1) opj_dump(1)
|
||||||
62
doc/man/man1/opj_dump.1
Normal file
62
doc/man/man1/opj_dump.1
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
opj_dump -
|
||||||
|
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
|
||||||
|
.SP
|
||||||
|
Valid input image extensions are
|
||||||
|
.B .j2k, .jp2, .jpt
|
||||||
|
.SP
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B opj_dump -i \fRinfile.j2k
|
||||||
|
.P
|
||||||
|
.B opj_dump -ImgDir \fRimages/ \fRDump all files in images/
|
||||||
|
.P
|
||||||
|
.B opj_dump -h \fRPrint help message and exit
|
||||||
|
.P
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-\^i "name"
|
||||||
|
(jpeg2000 input file name)
|
||||||
|
.TP
|
||||||
|
.B \-\^ImgDir "directory_name"
|
||||||
|
(directory containing jpeg2000 input files)
|
||||||
|
.P
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2010, Mathieu Malaterre
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
opj_compress(1) opj_decompress(1)
|
||||||
337
doc/man/man3/libopenjp2.3
Normal file
337
doc/man/man3/libopenjp2.3
Normal file
@@ -0,0 +1,337 @@
|
|||||||
|
'\" t
|
||||||
|
'\" The line above instructs most `man' programs to invoke tbl
|
||||||
|
'\"
|
||||||
|
'\" Separate paragraphs; not the same as PP which resets indent level.
|
||||||
|
.de SP
|
||||||
|
.if t .sp .5
|
||||||
|
.if n .sp
|
||||||
|
..
|
||||||
|
'\"
|
||||||
|
'\" Replacement em-dash for nroff (default is too short).
|
||||||
|
.ie n .ds m " -
|
||||||
|
.el .ds m \(em
|
||||||
|
'\"
|
||||||
|
'\" Placeholder macro for if longer nroff arrow is needed.
|
||||||
|
.ds RA \(->
|
||||||
|
'\"
|
||||||
|
'\" Decimal point set slightly raised
|
||||||
|
.if t .ds d \v'-.15m'.\v'+.15m'
|
||||||
|
.if n .ds d .
|
||||||
|
'\"
|
||||||
|
'\" Enclosure macro for examples
|
||||||
|
.de EX
|
||||||
|
.SP
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
..
|
||||||
|
.de EE
|
||||||
|
.ft R
|
||||||
|
.SP
|
||||||
|
.fi
|
||||||
|
..
|
||||||
|
.TH libopenjp2 3 "Oct 2010" "Version 1.4.0" "Oct 2010"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
libopenjp2 -
|
||||||
|
a library for reading and writing JPEG2000 image files.
|
||||||
|
.SP
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
.B #include <openjpeg.h>
|
||||||
|
.P
|
||||||
|
.SS CONVERSION FORMATS
|
||||||
|
.B PGX: imagetopgx() \fR/\fB pgxtoimage()
|
||||||
|
.P
|
||||||
|
.B PXM: imagetopnm() \fR/\fB pnmtoimage()
|
||||||
|
.P
|
||||||
|
.B BMP: imagetobmp() \fR/\fB bmptoimage()
|
||||||
|
.P
|
||||||
|
.B TIF: imagetotif() \fR/\fB tiftoimage()
|
||||||
|
.P
|
||||||
|
.B RAW: imagetoraw() \fR/\fB rawtoimage()
|
||||||
|
.P
|
||||||
|
.B TGA: imagetotga() \fR/\fB tgatoimage()
|
||||||
|
.P
|
||||||
|
.B PNG: imagetopng() \fR/\fB pngtoimage()
|
||||||
|
.P
|
||||||
|
.B YUV: imagetoyuv() \fR/\fB yuvtoimage() \fR(MJ2)
|
||||||
|
.P
|
||||||
|
.SS READ
|
||||||
|
.B opj_set_default_decoder_parameters(opj_dparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
.B opj_dinfo_t *opj_create_decompress(OPJ_CODEC_FORMAT \fIformat\fB);
|
||||||
|
.P
|
||||||
|
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_setup_decoder(opj_dinfo_t *\fIdinfo\fB, opj_dparameters_t * \fIparams\fB);
|
||||||
|
.P
|
||||||
|
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIinfo\fB, unsigned char *\fIbuf\fB, int \fIbuf_len\fB);
|
||||||
|
.P
|
||||||
|
.B opj_image_t *opj_decode(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_decompress(opj_dinfo_t *\fIdinfo\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.SS WRITE
|
||||||
|
.B void opj_set_default_encoder_parameters(opj_cparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
/*
|
||||||
|
.B opj_image_t *FORMATtoimage(const char *\fIfname\fB, opj_cparameters_t *\fIparams\fB);
|
||||||
|
.P
|
||||||
|
*/
|
||||||
|
.br
|
||||||
|
.B opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT \fIformat\fB);
|
||||||
|
.P
|
||||||
|
.B opj_event_mgr_t *opj_set_event_mgr(opj_common_ptr \fIinfo\fB, opj_event_mgr_t *\fIevent_mgr\fB, void *\fIcontext\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_setup_encoder(opj_cinfo_t *\fIcinfo\fB, opj_cparameters_t *\fIparams\fB, opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.B opj_cio_t *opj_cio_open(opj_common_ptr \fIcinfo\fB, \fINULL\fB, \fI0\fB);
|
||||||
|
.P
|
||||||
|
.B bool opj_encode(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, char *\fIindex\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_cio_close(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_compress(opj_cinfo_t *\fIcinfo\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_image_destroy(opj_image_t *\fIimage\fB);
|
||||||
|
.P
|
||||||
|
.SS GENERAL
|
||||||
|
.P
|
||||||
|
.B void opj_image_create(int \fInumcmpts\fB, opj_image_cmptparm_t *\fIcmptparms\fB, OPJ_COLOR_SPACE \fIclrspc\fB);
|
||||||
|
.P
|
||||||
|
.B int cio_tell(opj_cio_t *\fIcio\fB);
|
||||||
|
.P
|
||||||
|
.B void cio_seek(opj_cio_t *\fIcio\fB, int \fIpos\fB);
|
||||||
|
.P
|
||||||
|
.B opj_image_t *opj_decode_with_info(opj_dinfo_t *\fIdinfo\fB, opj_cio_t *\fIcio\fB, opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B bool opj_encode_with_info(opj_cinfo_t *\fIcinfo\fB, opj_cio_t *\fIcio\fB, opj_image_t *\fIimage\fB, opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B void opj_destroy_cstr_info(opj_codestream_info_t *\fIcstr_info\fB);
|
||||||
|
.P
|
||||||
|
.B const char *opj_version(\fIvoid\fB);
|
||||||
|
.P
|
||||||
|
.SH OPJ_CODEC_FORMAT
|
||||||
|
.P
|
||||||
|
.B CODEC_J2K\fR or \fBCODEC_JPT\fR or \fBCODEC_JP2
|
||||||
|
.P
|
||||||
|
.SH OPJ_COLOR_SPACE
|
||||||
|
.P
|
||||||
|
.B CLRSPC_UNKNOWN\fR or \fBCLRSPC_UNSPECIFIED\fR or \fBCLRSPC_SRGB\fR or \fBCLRSPC_GRAY\fR or \fBCLRSPC_SYCC
|
||||||
|
.P
|
||||||
|
.SH DECOMPRESSION PARAMETERS
|
||||||
|
.p
|
||||||
|
typedef struct opj_dparameters
|
||||||
|
.br
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Set the number of highest resolution levels to be discarded.
|
||||||
|
The image resolution is effectively divided by 2 to the power
|
||||||
|
of the number of discarded levels.
|
||||||
|
The reduce factor is limited by the smallest total number of
|
||||||
|
decomposition levels among tiles.
|
||||||
|
if != 0, then original dimension divided by 2^(reduce);
|
||||||
|
if == 0 or not used, image is decoded to the full resolution
|
||||||
|
*/
|
||||||
|
\fBint\fR cp_reduce;
|
||||||
|
/*
|
||||||
|
Set the maximum number of quality layers to decode.
|
||||||
|
If there are less quality layers than the specified number,
|
||||||
|
all the quality layers are decoded.
|
||||||
|
if != 0, then only the first "layer" layers are decoded;
|
||||||
|
if == 0 or not used, all the quality layers are decoded
|
||||||
|
*/
|
||||||
|
\fBint\fR cp_layer;
|
||||||
|
|
||||||
|
/*command line encoder parameters (not used inside the library) */
|
||||||
|
/* input file name */
|
||||||
|
\fBchar\fR infile[OPJ_PATH_LEN];
|
||||||
|
/* output file name */
|
||||||
|
\fBchar\fR outfile[OPJ_PATH_LEN];
|
||||||
|
/* input file format: see OPJ_CODEC_FORMAT */
|
||||||
|
\fBint\fR decod_format;
|
||||||
|
/* output file format */
|
||||||
|
\fBint\fR cod_format;
|
||||||
|
|
||||||
|
/*JPWL decoding parameters */
|
||||||
|
/* activates the JPWL correction capabilities */
|
||||||
|
\fBbool\fR jpwl_correct;
|
||||||
|
/* expected number of components */
|
||||||
|
\fBint\fR jpwl_exp_comps;
|
||||||
|
/* maximum number of tiles */
|
||||||
|
\fBint\fR jpwl_max_tiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Specify whether the decoding should be done on the entire
|
||||||
|
codestream, or be limited to the main header
|
||||||
|
Limiting the decoding to the main header makes it possible
|
||||||
|
to extract the characteristics of the codestream
|
||||||
|
if == NO_LIMITATION, the entire codestream is decoded;
|
||||||
|
if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
|
||||||
|
*/
|
||||||
|
\fBOPJ_LIMIT_DECODING\fR cp_limit_decoding;
|
||||||
|
.br
|
||||||
|
} opj_dparameters_t;
|
||||||
|
|
||||||
|
.SH COMPRESSION PARAMETERS
|
||||||
|
.P
|
||||||
|
typedef struct opj_cparameters
|
||||||
|
.br
|
||||||
|
{
|
||||||
|
/* size of tile: tile_size_on = false (not in argument)
|
||||||
|
or tile_size_on = true (in argument) */
|
||||||
|
\fBbool\fR tile_size_on;
|
||||||
|
/* XTOsiz */
|
||||||
|
\fBint\fR cp_tx0;
|
||||||
|
/* YTOsiz */
|
||||||
|
\fBint\fR cp_ty0;
|
||||||
|
/* XTsiz */
|
||||||
|
\fBint\fR cp_tdx;
|
||||||
|
/* YTsiz */
|
||||||
|
\fBint\fR cp_tdy;
|
||||||
|
/* allocation by rate/distortion */
|
||||||
|
\fBint\fR cp_disto_alloc;
|
||||||
|
/* allocation by fixed layer */
|
||||||
|
\fBint\fR cp_fixed_alloc;
|
||||||
|
/* add fixed_quality */
|
||||||
|
\fBint\fR cp_fixed_quality;
|
||||||
|
/* fixed layer */
|
||||||
|
\fBint *\fRcp_matrice;
|
||||||
|
/* comment for coding */
|
||||||
|
\fBchar *\fRcp_comment;
|
||||||
|
/* coding style */
|
||||||
|
\fBint\fR csty;
|
||||||
|
/* progression order:
|
||||||
|
PROG_UNKNOWN, LRCP(default), RLCP, RPCL, PCRL, CPRL */
|
||||||
|
\fBOPJ_PROG_ORDER\fR prog_order;
|
||||||
|
/* progression order changes */
|
||||||
|
\fBopj_poc_t\fR POC[32];
|
||||||
|
/* number of progression order changes (POC), default: 0 */
|
||||||
|
\fBint\fR numpocs;
|
||||||
|
/* number of layers */
|
||||||
|
\fBint\fR tcp_numlayers;
|
||||||
|
/* rates of layers */
|
||||||
|
\fBfloat\fR tcp_rates[100];
|
||||||
|
/* different psnr for successive layers */
|
||||||
|
\fBfloat\fR tcp_distoratio[100];
|
||||||
|
/* number of resolutions */
|
||||||
|
\fBint\fR numresolution;
|
||||||
|
/* initial code block width, default: 64 */
|
||||||
|
\fBint\fR cblockw_init;
|
||||||
|
/* initial code block height, default: 64 */
|
||||||
|
\fBint\fR cblockh_init;
|
||||||
|
/* mode switch (cblk_style) */
|
||||||
|
/* 1 : use the irreversible DWT 9-7,
|
||||||
|
0 : use lossless compression (default) */
|
||||||
|
\fBint\fR irreversible;
|
||||||
|
/* region of interest: affected component in [0..3],
|
||||||
|
-1 means no ROI */
|
||||||
|
\fBint\fR roi_compno;
|
||||||
|
/* region of interest: upshift value */
|
||||||
|
\fBint\fR roi_shift;
|
||||||
|
/* number of precinct size specifications */
|
||||||
|
\fBint\fR res_spec;
|
||||||
|
/* initial precinct width */
|
||||||
|
\fBint\fR prcw_init[J2K_MAXRLVLS];
|
||||||
|
/* initial precinct height */
|
||||||
|
\fBint\fR prch_init[J2K_MAXRLVLS];
|
||||||
|
|
||||||
|
/*command line encoder parameters (not used inside the library) */
|
||||||
|
/* input file name */
|
||||||
|
\fBchar\fR infile[OPJ_PATH_LEN];
|
||||||
|
/* output file name */
|
||||||
|
\fBchar\fR outfile[OPJ_PATH_LEN];
|
||||||
|
/* DEPRECATED. Index generation is now handeld with the
|
||||||
|
opj_encode_with_info() function. Set to NULL */
|
||||||
|
\fBint\fR index_on;
|
||||||
|
/* DEPRECATED. Index generation is now handeld with the
|
||||||
|
opj_encode_with_info() function. Set to NULL */
|
||||||
|
\fBchar\fR index[OPJ_PATH_LEN];
|
||||||
|
/* subimage encoding: origin image offset in x direction */
|
||||||
|
\fBint\fR image_offset_x0;
|
||||||
|
/* subimage encoding: origin image offset in y direction */
|
||||||
|
\fBint\fR image_offset_y0;
|
||||||
|
/* subsampling value for dx */
|
||||||
|
\fBint\fR subsampling_dx;
|
||||||
|
/* subsampling value for dy */
|
||||||
|
\fBint\fR subsampling_dy;
|
||||||
|
/* input file format */
|
||||||
|
\fBint\fR decod_format;
|
||||||
|
/* output file format: see OPJ_CODEC_FORMAT */
|
||||||
|
\fBint\fR cod_format;
|
||||||
|
|
||||||
|
/*JPWL encoding parameters */
|
||||||
|
/* enables writing of EPC in MH, thus activating JPWL */
|
||||||
|
\fBbool\fR jpwl_epc_on;
|
||||||
|
/* error protection method for MH (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_hprot_MH;
|
||||||
|
/* tile number of header protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* error protection methods for TPHs (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* tile number of packet protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* packet number of packet protection specification (>=0) */
|
||||||
|
\fBint\fR jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* error protection methods for packets (0,1,16,32,37-128) */
|
||||||
|
\fBint\fR jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
|
||||||
|
/* enables writing of ESD, (0=no/1/2 bytes) */
|
||||||
|
\fBint\fR jpwl_sens_size;
|
||||||
|
/* sensitivity addressing size (0=auto/2/4 bytes) */
|
||||||
|
\fBint\fR jpwl_sens_addr;
|
||||||
|
/* sensitivity range (0-3) */
|
||||||
|
\fBint\fR jpwl_sens_range;
|
||||||
|
/* sensitivity method for MH (-1=no,0-7) */
|
||||||
|
\fBint\fR jpwl_sens_MH;
|
||||||
|
/* tile number of sensitivity specification (>=0) */
|
||||||
|
\fBint\fR jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
|
||||||
|
/* sensitivity methods for TPHs (-1=no,0-7) */
|
||||||
|
\fBint\fR jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
|
||||||
|
|
||||||
|
/* Digital Cinema compliance: OFF-not compliant,
|
||||||
|
CINEMA2K_24, CINEMA2K_48, CINEMA4K_24 */
|
||||||
|
\fBOPJ_CINEMA_MODE\fR cp_cinema;
|
||||||
|
/* Maximum rate for each component.
|
||||||
|
If == 0, component size limitation is not considered */
|
||||||
|
\fBint\fR max_comp_size;
|
||||||
|
/* Profile name*/
|
||||||
|
\fBOPJ_RSIZ_CAPABILITIES\fR cp_rsiz;
|
||||||
|
/* Tile part generation*/
|
||||||
|
\fBchar\fR tp_on;
|
||||||
|
/* Flag for Tile part generation*/
|
||||||
|
\fBchar\fR tp_flag;
|
||||||
|
/* MCT (multiple component transform) */
|
||||||
|
\fBchar\fR tcp_mct;
|
||||||
|
.br
|
||||||
|
} opj_cparameters_t;
|
||||||
|
|
||||||
|
|
||||||
|
'\".SH OPTIONS
|
||||||
|
'\".SH BUGS
|
||||||
|
.SH AUTHORS
|
||||||
|
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
|
||||||
|
Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
|
||||||
|
Copyright (c) 2001-2003, David Janssens
|
||||||
|
|
||||||
|
Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
|
||||||
|
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
|
|
||||||
|
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
|
||||||
|
Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
|
||||||
|
.P
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBimage_to_j2k\fR(1) \fBj2k_to_image\fR(1) \fBj2k_dump\fR(1)
|
||||||
|
|
||||||
|
\fBJPWL_image_to_j2k\fR(1) \fBJPWL_j2k_to_image\fR(1)
|
||||||
|
|
||||||
|
\fBextract_j2k_from_mj2\fR(1) \fBwrap_j2k_in_mj2\fR(1)
|
||||||
|
\fBframes_to_mj2\fR(1) \fBmj2_to_frames\fR(1)
|
||||||
94
doc/openjpip.dox.in
Normal file
94
doc/openjpip.dox.in
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \page openjpippage OpenJPIP v@OPENJPEG_VERSION@ Documentation
|
||||||
|
*
|
||||||
|
* \section intro Introduction
|
||||||
|
* This manual documents the low-level OpenJPIP C API.\n
|
||||||
|
* OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).\n
|
||||||
|
* ( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)\n
|
||||||
|
*
|
||||||
|
* This whole documents covers the following six programs.\n
|
||||||
|
* - opj_server.c JPIP server supporting HTTP connection and JPT/JPP-stream
|
||||||
|
* - opj_dec_server.c Server to decode JPT/JPP-stream and communicate locally with JPIP client, which is coded in java
|
||||||
|
* - opj_jpip_addxml.c To Embed metadata into JP2 file
|
||||||
|
* - opj_jpip_transcode.c To Convert JPT/JPP-stream to JP2 or J2K
|
||||||
|
* - opj_jpip_test.c To test index code format of a JP2 file
|
||||||
|
*
|
||||||
|
* \section license License
|
||||||
|
* This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.\n
|
||||||
|
* The only restriction is to retain the copyright in the sources or the binaries documentation.\n
|
||||||
|
* Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section reqlibs Required libraries
|
||||||
|
* - OpenJPEG library
|
||||||
|
* - FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||||
|
* - libcURL library
|
||||||
|
*
|
||||||
|
* We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section compilenotes Compiling Notes
|
||||||
|
* When you are making opj_server, set anything (e.g. yes) to the parameter jpipserver to define itself in the Makefile, which enables to make it in server mode.\n
|
||||||
|
* Otherwise do not define (or do not set to) the parameter jpipserver.\n
|
||||||
|
* Be sure that any object files and library file libopenjpip.a are not reused to compile in the two different mode (server mode and non server mode).\n
|
||||||
|
* In other words, do make clean before making new targets which are in different modes as previous make.\n
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \section sysarchtect System Architecture
|
||||||
|
* JPIP protocol is implemented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n
|
||||||
|
* Figure below represents the overview of our system architecture.\n
|
||||||
|
* The JPIP server parses JPIP query and sends corresponding JPT/JPP-stream.
|
||||||
|
* The JPIP client viewer is an image viewer with GUI to publish JPIP requests and receive JPT/JPP-stream.\n
|
||||||
|
* Particularly, our system has the image decoding module implemented on a server (opj_dec_server, Image decoding Server).
|
||||||
|
* Image decoding Server and JPIP client viewer communicate closely.
|
||||||
|
* This specific architecture enables sharing cache of image codestream data among all viewers connected to the same Image decoding Server not only locally but also remotely.
|
||||||
|
*
|
||||||
|
* \image html jpip_architect.png "OpenJPIP system architecture"
|
||||||
|
*
|
||||||
|
* JPIP server follows up the client cache during a session. \n
|
||||||
|
* Concretely, the JPIP server models cache in each session, to which Channel IDs are associated.
|
||||||
|
* A Channel ID identifies a JPIP client viewer.
|
||||||
|
* And, new viewers can belong to a session by referring to one of its channel ID.
|
||||||
|
* The Image decoding Server maintains the association between channel IDs and targets, and provides a reference channel ID to a Viewer on demand.\n
|
||||||
|
*
|
||||||
|
* Typical requests and replies among JPIP server, JPIP client, and Image decoding server is presented below.\n
|
||||||
|
* The JPIP server parses HTTP query and sends corresponding JPT/JPP-stream back to the JPIP client (Viewer).
|
||||||
|
* JPT/JPP-stream is unreadable by JPIP client, and it is directly passed to Image decoding Server, and which provides the image in raw format (PGM or PPM) to the JPIP client.
|
||||||
|
* The Image decoding Server handles the decoding and caching of JPT/JPP-stream.
|
||||||
|
* JPIP client can read PGM and PPM images natively.
|
||||||
|
* Before connecting to the JPIP server, every JPIP client checks local cache data of the requesting image with the image decoding server.
|
||||||
|
* If its cache exists, the image decoding server provides ChannelID (CID), which identifies the image and its cache model on the JPIP server, and the whole system can continue the session using the CID.
|
||||||
|
*
|
||||||
|
* \image html jpip_protocol.png "Message Sequence Chart of OpenJPIP impementation"
|
||||||
|
*
|
||||||
|
* \author Kaori Hagihara UCL/SST/ICTM/ELEN
|
||||||
|
*/
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
obj
|
|
||||||
obj.w32
|
|
||||||
bin
|
|
||||||
bin.w32
|
|
||||||
lib
|
|
||||||
lib.w32
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
# $Id$
|
|
||||||
#
|
|
||||||
# makefile for OpenJPEG library
|
|
||||||
|
|
||||||
CFLAGS = -Wall -O3 -fno-strength-reduce -fomit-frame-pointer
|
|
||||||
|
|
||||||
ifndef DEBUG
|
|
||||||
LDFLAGS = -s -lm
|
|
||||||
else
|
|
||||||
LDFLAGS = -lm
|
|
||||||
endif
|
|
||||||
|
|
||||||
OBJ_DIR_W32 = obj.w32
|
|
||||||
LIB_DIR_W32 = lib.w32
|
|
||||||
|
|
||||||
ifdef MINGW32
|
|
||||||
CC = i386-mingw32-gcc
|
|
||||||
AR = i386-mingw32-ar
|
|
||||||
OBJ_DIR = $(OBJ_DIR_W32)
|
|
||||||
LIB_DIR = $(LIB_DIR_W32)
|
|
||||||
all: $(OBJ_DIR) $(LIB_DIR) \
|
|
||||||
$(LIB_DIR)/libopenjpeg.a $(LIB_DIR)/libopenjpeg.dll
|
|
||||||
else
|
|
||||||
CC = gcc
|
|
||||||
AR = ar
|
|
||||||
OBJ_DIR = obj
|
|
||||||
LIB_DIR = lib
|
|
||||||
all: $(OBJ_DIR) $(LIB_DIR) \
|
|
||||||
$(LIB_DIR)/libopenjpeg.a $(LIB_DIR)/libopenjpeg.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OBJ_DIR):
|
|
||||||
mkdir $(OBJ_DIR)
|
|
||||||
|
|
||||||
$(LIB_DIR):
|
|
||||||
mkdir $(LIB_DIR)
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o:
|
|
||||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
$(OBJ_DIR)/bio.o: bio.c bio.h
|
|
||||||
$(OBJ_DIR)/cio.o: cio.c cio.h
|
|
||||||
$(OBJ_DIR)/dwt.o: dwt.c dwt.h int.h fix.h tcd.h
|
|
||||||
$(OBJ_DIR)/fix.o: fix.c fix.h
|
|
||||||
$(OBJ_DIR)/int.o: int.c
|
|
||||||
$(OBJ_DIR)/j2k.o: j2k.c j2k.h cio.h tcd.h dwt.h int.h
|
|
||||||
$(OBJ_DIR)/mct.o: mct.c mct.h fix.h
|
|
||||||
$(OBJ_DIR)/mqc.o: mqc.c mqc.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)/pi.o: pi.c pi.h int.h
|
|
||||||
$(OBJ_DIR)/raw.o: raw.c raw.h
|
|
||||||
$(OBJ_DIR)/t1.o: t1.c t1.h j2k.h mqc.h raw.h int.h mct.h dwt.h fix.h
|
|
||||||
$(OBJ_DIR)/t2.o: t2.c t2.h tcd.h bio.h j2k.h pi.h tgt.h int.h cio.h
|
|
||||||
$(OBJ_DIR)/tcd.o: tcd.c tcd.h int.h t1.h t2.h dwt.h mct.h
|
|
||||||
$(OBJ_DIR)/tgt.o: tgt.c tgt.h bio.h
|
|
||||||
$(OBJ_DIR)/jpt.o: jpt.c jpt.h cio.h
|
|
||||||
$(OBJ_DIR)/jp2.o: jp2.c jp2.h
|
|
||||||
|
|
||||||
COM_OBJS = $(addprefix $(OBJ_DIR)/, j2k.o bio.o cio.o dwt.o fix.o int.o mct.o \
|
|
||||||
mqc.o pi.o t1.o t2.o tgt.o tcd.o raw.o jpt.o jp2.o)
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.a: ${COM_OBJS}
|
|
||||||
$(AR) -sr $@ $^
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.dll: ${COM_OBJS}
|
|
||||||
${CC} -s -shared -Wl,-soname,libopenjpeg.dll -o $@ $^
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.so.1.0: ${COM_OBJS}
|
|
||||||
${CC} -s -shared -Wl,-soname,libopenjpeg.so.1 -o $@ $^
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.so.1: $(LIB_DIR)/libopenjpeg.so.1.0
|
|
||||||
ln -s libopenjpeg.so.1.0 $(LIB_DIR)/libopenjpeg.so.1
|
|
||||||
|
|
||||||
$(LIB_DIR)/libopenjpeg.so: $(LIB_DIR)/libopenjpeg.so.1
|
|
||||||
ln -s libopenjpeg.so.1 $(LIB_DIR)/libopenjpeg.so
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJ_DIR_W32)/* $(OBJ_DIR)/* $(LIB_DIR_W32)/* $(LIB_DIR)/*
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
***/
|
|
||||||
|
|
||||||
#include "bio.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
static unsigned char *bio_start; /* pointer to the start of the buffer */
|
|
||||||
static unsigned char *bio_end; /* pointer to the end of the buffer */
|
|
||||||
static unsigned char *bio_bp; /* pointer to the present position in the buffer */
|
|
||||||
static unsigned int bio_buf; /* temporary place where each byte is read or written */
|
|
||||||
static int bio_ct; /* coder : number of bits free to write // decoder : number of bits read */
|
|
||||||
|
|
||||||
extern jmp_buf j2k_error;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of bytes written.
|
|
||||||
*/
|
|
||||||
int bio_numbytes()
|
|
||||||
{
|
|
||||||
return bio_bp - bio_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init encoder.
|
|
||||||
*
|
|
||||||
* bp : Output buffer
|
|
||||||
* len : Output buffer length
|
|
||||||
*/
|
|
||||||
void bio_init_enc(unsigned char *bp, int len)
|
|
||||||
{
|
|
||||||
bio_start = bp;
|
|
||||||
bio_end = bp + len;
|
|
||||||
bio_bp = bp;
|
|
||||||
bio_buf = 0;
|
|
||||||
bio_ct = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init decoder.
|
|
||||||
*
|
|
||||||
* bp : Input buffer
|
|
||||||
* len : Input buffer length
|
|
||||||
*/
|
|
||||||
void bio_init_dec(unsigned char *bp, int len)
|
|
||||||
{
|
|
||||||
bio_start = bp;
|
|
||||||
bio_end = bp + len;
|
|
||||||
bio_bp = bp;
|
|
||||||
bio_buf = 0;
|
|
||||||
bio_ct = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write byte. --> function modified to eliminate longjmp !!!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int bio_byteout()
|
|
||||||
{
|
|
||||||
bio_buf = (bio_buf << 8) & 0xffff;
|
|
||||||
bio_ct = bio_buf == 0xff00 ? 7 : 8;
|
|
||||||
if (bio_bp >= bio_end)
|
|
||||||
return 1;
|
|
||||||
*bio_bp++ = bio_buf >> 8;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read byte. --> function modified to eliminate longjmp !!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int bio_bytein()
|
|
||||||
{
|
|
||||||
bio_buf = (bio_buf << 8) & 0xffff;
|
|
||||||
bio_ct = bio_buf == 0xff00 ? 7 : 8;
|
|
||||||
if (bio_bp >= bio_end)
|
|
||||||
return 1;
|
|
||||||
bio_buf |= *bio_bp++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write bit.
|
|
||||||
*
|
|
||||||
* b : Bit to write (0 or 1)
|
|
||||||
*/
|
|
||||||
void bio_putbit(int b)
|
|
||||||
{
|
|
||||||
if (bio_ct == 0) {
|
|
||||||
bio_byteout();
|
|
||||||
}
|
|
||||||
bio_ct--;
|
|
||||||
bio_buf |= b << bio_ct;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read bit.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int bio_getbit()
|
|
||||||
{
|
|
||||||
if (bio_ct == 0) {
|
|
||||||
bio_bytein();
|
|
||||||
}
|
|
||||||
bio_ct--;
|
|
||||||
return (bio_buf >> bio_ct) & 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write bits.
|
|
||||||
*
|
|
||||||
* v : Value of bits
|
|
||||||
* n : Number of bits to write
|
|
||||||
*/
|
|
||||||
void bio_write(int v, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = n - 1; i >= 0; i--) {
|
|
||||||
bio_putbit((v >> i) & 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read bits.
|
|
||||||
*
|
|
||||||
* n : Number of bits to read
|
|
||||||
*/
|
|
||||||
int bio_read(int n)
|
|
||||||
{
|
|
||||||
int i, v;
|
|
||||||
v = 0;
|
|
||||||
for (i = n - 1; i >= 0; i--) {
|
|
||||||
v += bio_getbit() << i;
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flush bits. Modified to eliminate longjmp !!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int bio_flush()
|
|
||||||
{
|
|
||||||
bio_ct = 0;
|
|
||||||
if (bio_byteout())
|
|
||||||
return 1;
|
|
||||||
if (bio_ct == 7) {
|
|
||||||
bio_ct = 0;
|
|
||||||
|
|
||||||
if (bio_byteout())
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Passes the ending bits (coming from flushing)
|
|
||||||
*/
|
|
||||||
int bio_inalign()
|
|
||||||
{
|
|
||||||
bio_ct = 0;
|
|
||||||
if ((bio_buf & 0xff) == 0xff) {
|
|
||||||
if (bio_bytein())
|
|
||||||
return 1;
|
|
||||||
bio_ct = 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 "cio.h"
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
static unsigned char *cio_start; /* pointer to the start of the stream */
|
|
||||||
static unsigned char *cio_end; /* pointer to the end of the stream */
|
|
||||||
static unsigned char *cio_bp; /* pointer to the present position */
|
|
||||||
|
|
||||||
extern jmp_buf j2k_error;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of bytes written.
|
|
||||||
*/
|
|
||||||
int cio_numbytes()
|
|
||||||
{
|
|
||||||
return cio_bp - cio_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get position in byte stream.
|
|
||||||
*/
|
|
||||||
int cio_tell()
|
|
||||||
{
|
|
||||||
return cio_bp - cio_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set position in byte stream.
|
|
||||||
*
|
|
||||||
* pos : position, in number of bytes, from the beginning of the stream
|
|
||||||
*/
|
|
||||||
void cio_seek(int pos)
|
|
||||||
{
|
|
||||||
cio_bp = cio_start + pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of bytes left before the end of the stream.
|
|
||||||
*/
|
|
||||||
int cio_numbytesleft()
|
|
||||||
{
|
|
||||||
return cio_end - cio_bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get pointer to the current position in the stream.
|
|
||||||
*/
|
|
||||||
unsigned char *cio_getbp()
|
|
||||||
{
|
|
||||||
return cio_bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize byte IO
|
|
||||||
*
|
|
||||||
* bp : destination/source stream
|
|
||||||
* len : length of the stream
|
|
||||||
*/
|
|
||||||
void cio_init(unsigned char *bp, int len)
|
|
||||||
{
|
|
||||||
cio_start = bp;
|
|
||||||
cio_end = bp + len;
|
|
||||||
cio_bp = bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write a byte.
|
|
||||||
*/
|
|
||||||
void cio_byteout(unsigned char v)
|
|
||||||
{
|
|
||||||
if (cio_bp >= cio_end)
|
|
||||||
longjmp(j2k_error, 1);
|
|
||||||
*cio_bp++ = v;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read a byte.
|
|
||||||
*/
|
|
||||||
unsigned char cio_bytein()
|
|
||||||
{
|
|
||||||
if (cio_bp >= cio_end)
|
|
||||||
longjmp(j2k_error, 1);
|
|
||||||
return *cio_bp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write some bytes.
|
|
||||||
*
|
|
||||||
* v : value to write
|
|
||||||
* n : number of bytes to write
|
|
||||||
*/
|
|
||||||
void cio_write(unsigned int v, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = n - 1; i >= 0; i--) {
|
|
||||||
cio_byteout((unsigned char) ((v >> (i << 3)) & 0xff));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read some bytes.
|
|
||||||
*
|
|
||||||
* n : number of bytes to read
|
|
||||||
*
|
|
||||||
* return : value of the n bytes read
|
|
||||||
*/
|
|
||||||
unsigned int cio_read(int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
unsigned int v;
|
|
||||||
v = 0;
|
|
||||||
for (i = n - 1; i >= 0; i--) {
|
|
||||||
v += cio_bytein() << (i << 3);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip some bytes.
|
|
||||||
*
|
|
||||||
* n : number of bytes to skip
|
|
||||||
*/
|
|
||||||
void cio_skip(int n)
|
|
||||||
{
|
|
||||||
cio_bp += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read n bytes, copy to buffer
|
|
||||||
*
|
|
||||||
* n : number of bytes to transfer
|
|
||||||
*/
|
|
||||||
void cio_read_to_buf(unsigned char* src_buf, int n)/* Glenn adds */
|
|
||||||
{
|
|
||||||
if (cio_bp + n > cio_end)
|
|
||||||
longjmp(j2k_error, 1);
|
|
||||||
memcpy(cio_bp, src_buf, n);
|
|
||||||
cio_bp += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write n bytes, copy from buffer
|
|
||||||
*
|
|
||||||
* n : number of bytes to transfer
|
|
||||||
*/
|
|
||||||
void cio_write_from_buf(unsigned char* dest_buf, int n)/* Glenn adds */
|
|
||||||
{
|
|
||||||
if (cio_bp + n > cio_end)
|
|
||||||
longjmp(j2k_error, 1);
|
|
||||||
memcpy(dest_buf, cio_bp, n);
|
|
||||||
cio_bp += n;
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 __CIO_H
|
|
||||||
#define __CIO_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of bytes written.
|
|
||||||
*
|
|
||||||
* returns number of bytes written
|
|
||||||
*/
|
|
||||||
int cio_numbytes();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get position in byte stream.
|
|
||||||
*
|
|
||||||
* return position in bytes
|
|
||||||
*/
|
|
||||||
int cio_tell();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set position in byte stream.
|
|
||||||
*
|
|
||||||
* pos : position, in number of bytes, from the beginning of the stream
|
|
||||||
*/
|
|
||||||
void cio_seek(int pos);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of bytes left before the end of the stream.
|
|
||||||
*
|
|
||||||
* Returns the number of bytes before the end of the stream
|
|
||||||
*/
|
|
||||||
int cio_numbytesleft();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get pointer to the current position in the stream.
|
|
||||||
*
|
|
||||||
* return : pointer to the position
|
|
||||||
*/
|
|
||||||
unsigned char *cio_getbp();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize byte IO
|
|
||||||
*
|
|
||||||
* bp : destination/source stream
|
|
||||||
* len : length of the stream
|
|
||||||
*/
|
|
||||||
void cio_init(unsigned char *bp, int len);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write some bytes.
|
|
||||||
*
|
|
||||||
* v : value to write
|
|
||||||
* n : number of bytes to write
|
|
||||||
*/
|
|
||||||
void cio_write(unsigned int v, int n);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read some bytes.
|
|
||||||
*
|
|
||||||
* n : number of bytes to read
|
|
||||||
*
|
|
||||||
* return : value of the n bytes read
|
|
||||||
*/
|
|
||||||
unsigned int cio_read(int n);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip some bytes.
|
|
||||||
*
|
|
||||||
* n : number of bytes to skip
|
|
||||||
*/
|
|
||||||
void cio_skip(int n);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read n bytes, copy to buffer
|
|
||||||
*/
|
|
||||||
void cio_read_to_buf(unsigned char* src_buf, int n);/* Glenn Pearson adds */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write n bytes, copy from buffer
|
|
||||||
*/
|
|
||||||
void cio_write_from_buf(unsigned char* dest_buf, int n);/* Glenn Pearson adds */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,540 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2004, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* Copyright (c) 2005, Reiner Wahler
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE:
|
|
||||||
* This is a modified version of the openjpeg dwt.c file.
|
|
||||||
* Average speed improvement compared to the original file (measured on
|
|
||||||
* my own machine, a P4 running at 3.0 GHz):
|
|
||||||
* 5x3 wavelets about 2 times faster
|
|
||||||
* 9x7 wavelets about 3 times faster
|
|
||||||
* for both, encoding and decoding.
|
|
||||||
*
|
|
||||||
* The better performance is caused by doing the 1-dimensional DWT
|
|
||||||
* within a temporary buffer where the data can be accessed sequential
|
|
||||||
* for both directions, horizontal and vertical. The 2d vertical DWT was
|
|
||||||
* the major bottleneck in the former version.
|
|
||||||
*
|
|
||||||
* I have also removed the "Add Patrick" part because it is not longer
|
|
||||||
* needed.
|
|
||||||
*
|
|
||||||
* 6/6/2005
|
|
||||||
* -Ive (aka Reiner Wahler)
|
|
||||||
* mail: ive@lilysoft.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "dwt.h"
|
|
||||||
#include "int.h"
|
|
||||||
#include "fix.h"
|
|
||||||
#include "tcd.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define S(i) a[(i)*2]
|
|
||||||
#define D(i) a[(1+(i)*2)]
|
|
||||||
#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
|
|
||||||
#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
|
|
||||||
/* new */
|
|
||||||
#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
|
|
||||||
#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This table contains the norms of the 5-3 wavelets for different bands. */
|
|
||||||
/* </summary> */
|
|
||||||
double dwt_norms[4][10] = {
|
|
||||||
{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
|
|
||||||
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
|
|
||||||
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
|
|
||||||
{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This table contains the norms of the 9-7 wavelets for different bands. */
|
|
||||||
/* </summary> */
|
|
||||||
double dwt_norms_real[4][10] = {
|
|
||||||
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
|
|
||||||
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
|
|
||||||
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
|
|
||||||
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward lazy transform (horizontal). */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
|
|
||||||
int i;
|
|
||||||
for (i=0; i<sn; i++) b[i]=a[2*i+cas];
|
|
||||||
for (i=0; i<dn; i++) b[sn+i]=a[(2*i+1-cas)];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward lazy transform (vertical). */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
|
|
||||||
int i;
|
|
||||||
for (i=0; i<sn; i++) b[i*x]=a[2*i+cas];
|
|
||||||
for (i=0; i<dn; i++) b[(sn+i)*x]=a[(2*i+1-cas)];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse lazy transform (horizontal). */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
|
|
||||||
int i;
|
|
||||||
/* for (i=0; i<sn; i++) b[2*i+cas]=a[i];*/
|
|
||||||
/* for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)];*/
|
|
||||||
int* ai;
|
|
||||||
int* bi;
|
|
||||||
ai=a;
|
|
||||||
bi=b+cas;
|
|
||||||
for (i=0; i<sn; i++) {
|
|
||||||
*bi = *ai; bi+=2; ai++;
|
|
||||||
}
|
|
||||||
ai=a+sn;
|
|
||||||
bi=b+1-cas;
|
|
||||||
for (i=0; i<dn; i++) {
|
|
||||||
*bi = *ai; bi+=2; ai++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse lazy transform (vertical). */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
|
|
||||||
int i;
|
|
||||||
/* for (i=0; i<sn; i++) b[2*i+cas]=a[i*x];*/
|
|
||||||
/* for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)*x];*/
|
|
||||||
int* ai;
|
|
||||||
int* bi;
|
|
||||||
ai=a;
|
|
||||||
bi=b+cas;
|
|
||||||
for (i=0; i<sn; i++) {
|
|
||||||
*bi = *ai; bi+=2; ai+=x;
|
|
||||||
}
|
|
||||||
ai=a+(sn*x);
|
|
||||||
bi=b+1-cas;
|
|
||||||
for (i=0; i<dn; i++) {
|
|
||||||
*bi = *ai; bi+=2; ai+=x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward 5-3 wavelet tranform in 1-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_encode_1(int *a, int dn, int sn, int cas)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!cas) {
|
|
||||||
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
|
|
||||||
for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
|
|
||||||
S(0) *= 2;
|
|
||||||
else {
|
|
||||||
for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
|
|
||||||
for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse 5-3 wavelet tranform in 1-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_decode_1(int *a, int dn, int sn, int cas)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!cas) {
|
|
||||||
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
|
|
||||||
for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
|
|
||||||
S(0) /= 2;
|
|
||||||
else {
|
|
||||||
for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
|
|
||||||
for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward 5-3 wavelet tranform in 2-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_encode(tcd_tilecomp_t * tilec)
|
|
||||||
{
|
|
||||||
int i, j, k;
|
|
||||||
int* a;
|
|
||||||
int* aj;
|
|
||||||
int* bj;
|
|
||||||
int w, l;
|
|
||||||
|
|
||||||
w = tilec->x1-tilec->x0;
|
|
||||||
l = tilec->numresolutions-1;
|
|
||||||
a = tilec->data;
|
|
||||||
|
|
||||||
for (i = 0; i < l; i++) {
|
|
||||||
int rw; /* width of the resolution level computed */
|
|
||||||
int rh; /* heigth of the resolution level computed */
|
|
||||||
int rw1; /* width of the resolution level once lower than computed one */
|
|
||||||
int rh1; /* height of the resolution level once lower than computed one */
|
|
||||||
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int dn, sn;
|
|
||||||
|
|
||||||
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
|
|
||||||
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
|
|
||||||
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
|
|
||||||
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
|
|
||||||
|
|
||||||
cas_row = tilec->resolutions[l - i].x0 % 2;
|
|
||||||
cas_col = tilec->resolutions[l - i].y0 % 2;
|
|
||||||
|
|
||||||
|
|
||||||
sn = rh1;
|
|
||||||
dn = rh - rh1;
|
|
||||||
bj=(int*)malloc(rh*sizeof(int));
|
|
||||||
for (j=0; j<rw; j++) {
|
|
||||||
aj=a+j;
|
|
||||||
for (k=0; k<rh; k++) bj[k]=aj[k*w];
|
|
||||||
dwt_encode_1(bj, dn, sn, cas_col);
|
|
||||||
dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
|
|
||||||
sn = rw1;
|
|
||||||
dn = rw - rw1;
|
|
||||||
bj=(int*)malloc(rw*sizeof(int));
|
|
||||||
for (j=0; j<rh; j++) {
|
|
||||||
aj=a+j*w;
|
|
||||||
for (k=0; k<rw; k++) bj[k]=aj[k];
|
|
||||||
dwt_encode_1(bj, dn, sn, cas_row);
|
|
||||||
dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse 5-3 wavelet tranform in 2-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_decode(tcd_tilecomp_t * tilec, int stop)
|
|
||||||
{
|
|
||||||
int i, j, k;
|
|
||||||
int* a;
|
|
||||||
int* aj;
|
|
||||||
int* bj;
|
|
||||||
int w, l;
|
|
||||||
|
|
||||||
w = tilec->x1-tilec->x0;
|
|
||||||
l = tilec->numresolutions-1;
|
|
||||||
a = tilec->data;
|
|
||||||
|
|
||||||
for (i = l - 1; i >= stop; i--) {
|
|
||||||
int rw; /* width of the resolution level computed */
|
|
||||||
int rh; /* heigth of the resolution level computed */
|
|
||||||
int rw1; /* width of the resolution level once lower than computed one */
|
|
||||||
int rh1; /* height of the resolution level once lower than computed one */
|
|
||||||
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int dn, sn;
|
|
||||||
|
|
||||||
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
|
|
||||||
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
|
|
||||||
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
|
|
||||||
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
|
|
||||||
|
|
||||||
cas_row = tilec->resolutions[l - i].x0 % 2;
|
|
||||||
cas_col = tilec->resolutions[l - i].y0 % 2;
|
|
||||||
|
|
||||||
sn = rw1;
|
|
||||||
dn = rw - rw1;
|
|
||||||
bj=(int*)malloc(rw*sizeof(int));
|
|
||||||
for (j = 0; j < rh; j++) {
|
|
||||||
aj = a+j*w;
|
|
||||||
dwt_interleave_h(aj, bj, dn, sn, cas_row);
|
|
||||||
dwt_decode_1(bj, dn, sn, cas_row);
|
|
||||||
for (k = 0; k < rw; k++) aj[k] = bj[k];
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
|
|
||||||
sn = rh1;
|
|
||||||
dn = rh - rh1;
|
|
||||||
bj=(int*)malloc(rh*sizeof(int));
|
|
||||||
for (j = 0; j < rw; j++) {
|
|
||||||
aj = a+j;
|
|
||||||
dwt_interleave_v(aj, bj, dn, sn, w, cas_col);
|
|
||||||
dwt_decode_1(bj, dn, sn, cas_col);
|
|
||||||
for (k = 0; k < rh; k++) aj[k * w] = bj[k];
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get gain of 5-3 wavelet transform. */
|
|
||||||
/* </summary> */
|
|
||||||
int dwt_getgain(int orient)
|
|
||||||
{
|
|
||||||
if (orient == 0)
|
|
||||||
return 0;
|
|
||||||
if (orient == 1 || orient == 2)
|
|
||||||
return 1;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get norm of 5-3 wavelet. */
|
|
||||||
/* </summary> */
|
|
||||||
double dwt_getnorm(int level, int orient)
|
|
||||||
{
|
|
||||||
return dwt_norms[orient][level];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward 9-7 wavelet transform in 1-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_encode_1_real(int *a, int dn, int sn, int cas)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (!cas) {
|
|
||||||
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) = fix_mul(D(i), 5038); /*5038 */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) = fix_mul(S(i), 6659); /*6660 */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((sn > 0) || (dn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) = fix_mul(S(i), 5038); /*5038 */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) = fix_mul(D(i), 6659); /*6660 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse 9-7 wavelet transform in 1-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_decode_1_real(int *a, int dn, int sn, int cas)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (!cas) {
|
|
||||||
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) = fix_mul(S(i), 10078); /* 10076 */
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) = fix_mul(D(i), 13318); /* 13320 */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) -= fix_mul(D_(i - 1) + D_(i), 3633);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) -= fix_mul(S_(i) + S_(i + 1), 7233);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
S(i) += fix_mul(D_(i - 1) + D_(i), 434);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
D(i) += fix_mul(S_(i) + S_(i + 1), 12994); /* 12993 */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((sn > 0) || (dn > 1)) { /* NEW : CASE ONE ELEMENT */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) = fix_mul(D(i), 10078); /* 10076 */
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) = fix_mul(S(i), 13318); /* 13320 */
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) -= fix_mul(SS_(i) + SS_(i + 1), 3633);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) -= fix_mul(DD_(i) + DD_(i - 1), 7233);
|
|
||||||
for (i = 0; i < sn; i++)
|
|
||||||
D(i) += fix_mul(SS_(i) + SS_(i + 1), 434);
|
|
||||||
for (i = 0; i < dn; i++)
|
|
||||||
S(i) += fix_mul(DD_(i) + DD_(i - 1), 12994); /* 12993 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Forward 9-7 wavelet transform in 2-D. */
|
|
||||||
/* </summary> */
|
|
||||||
|
|
||||||
void dwt_encode_real(tcd_tilecomp_t * tilec)
|
|
||||||
{
|
|
||||||
int i, j, k;
|
|
||||||
int* a;
|
|
||||||
int* aj;
|
|
||||||
int* bj;
|
|
||||||
int w, l;
|
|
||||||
|
|
||||||
w = tilec->x1-tilec->x0;
|
|
||||||
l = tilec->numresolutions-1;
|
|
||||||
a = tilec->data;
|
|
||||||
|
|
||||||
for (i = 0; i < l; i++) {
|
|
||||||
int rw; /* width of the resolution level computed */
|
|
||||||
int rh; /* heigth of the resolution level computed */
|
|
||||||
int rw1; /* width of the resolution level once lower than computed one */
|
|
||||||
int rh1; /* height of the resolution level once lower than computed one */
|
|
||||||
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int dn, sn;
|
|
||||||
|
|
||||||
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
|
|
||||||
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
|
|
||||||
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
|
|
||||||
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
|
|
||||||
|
|
||||||
cas_row = tilec->resolutions[l - i].x0 % 2;
|
|
||||||
cas_col = tilec->resolutions[l - i].y0 % 2;
|
|
||||||
|
|
||||||
sn = rh1;
|
|
||||||
dn = rh - rh1;
|
|
||||||
bj=(int*)malloc(rh*sizeof(int));
|
|
||||||
for (j = 0; j < rw; j++) {
|
|
||||||
aj = a + j;
|
|
||||||
for (k = 0; k < rh; k++) bj[k] = aj[k*w];
|
|
||||||
dwt_encode_1_real(bj, dn, sn, cas_col);
|
|
||||||
dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
|
|
||||||
sn = rw1;
|
|
||||||
dn = rw - rw1;
|
|
||||||
bj=(int*)malloc(rw*sizeof(int));
|
|
||||||
for (j = 0; j < rh; j++) {
|
|
||||||
aj = a + j * w;
|
|
||||||
for (k = 0; k < rw; k++) bj[k] = aj[k];
|
|
||||||
dwt_encode_1_real(bj, dn, sn, cas_row);
|
|
||||||
dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse 9-7 wavelet transform in 2-D. */
|
|
||||||
/* </summary> */
|
|
||||||
void dwt_decode_real(tcd_tilecomp_t * tilec, int stop)
|
|
||||||
{
|
|
||||||
|
|
||||||
int i, j, k;
|
|
||||||
int* a;
|
|
||||||
int* aj;
|
|
||||||
int* bj;
|
|
||||||
int w, l;
|
|
||||||
|
|
||||||
w = tilec->x1-tilec->x0;
|
|
||||||
l = tilec->numresolutions-1;
|
|
||||||
a = tilec->data;
|
|
||||||
|
|
||||||
for (i = l-1; i >= stop; i--) {
|
|
||||||
int rw; /* width of the resolution level computed */
|
|
||||||
int rh; /* heigth of the resolution level computed */
|
|
||||||
int rw1; /* width of the resolution level once lower than computed one */
|
|
||||||
int rh1; /* height of the resolution level once lower than computed one */
|
|
||||||
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
int dn, sn;
|
|
||||||
|
|
||||||
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
|
|
||||||
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
|
|
||||||
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
|
|
||||||
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
|
|
||||||
|
|
||||||
cas_col = tilec->resolutions[l - i].x0 % 2; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
cas_row = tilec->resolutions[l - i].y0 % 2; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
|
|
||||||
|
|
||||||
sn = rw1;
|
|
||||||
dn = rw-rw1;
|
|
||||||
bj = (int*)malloc(rw * sizeof(int));
|
|
||||||
for (j = 0; j < rh; j++) {
|
|
||||||
aj = a+j*w;
|
|
||||||
dwt_interleave_h(aj, bj, dn, sn, cas_col);
|
|
||||||
dwt_decode_1_real(bj, dn, sn, cas_col);
|
|
||||||
for (k = 0; k < rw; k++) aj[k] = bj[k];
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
|
|
||||||
sn = rh1;
|
|
||||||
dn = rh-rh1;
|
|
||||||
bj = (int*)malloc(rh * sizeof(int));
|
|
||||||
for (j=0; j<rw; j++) {
|
|
||||||
aj = a+j;
|
|
||||||
dwt_interleave_v(aj, bj, dn, sn, w, cas_row);
|
|
||||||
dwt_decode_1_real(bj, dn, sn, cas_row);
|
|
||||||
for (k = 0; k < rh; k++) aj[k * w] = bj[k];
|
|
||||||
}
|
|
||||||
free(bj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get gain of 9-7 wavelet transform. */
|
|
||||||
/* </summary> */
|
|
||||||
int dwt_getgain_real(int orient)
|
|
||||||
{
|
|
||||||
(void)orient;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get norm of 9-7 wavelet. */
|
|
||||||
/* </summary> */
|
|
||||||
double dwt_getnorm_real(int level, int orient)
|
|
||||||
{
|
|
||||||
return dwt_norms_real[orient][level];
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tcd.h"
|
|
||||||
|
|
||||||
#ifndef __DWT_H
|
|
||||||
#define __DWT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apply a reversible DWT transform to a component of an image
|
|
||||||
* tilec : tile component information (present tile)
|
|
||||||
*/
|
|
||||||
/* void dwt_encode(int* a, int w, int h, int l); */
|
|
||||||
void dwt_encode(tcd_tilecomp_t * tilec);
|
|
||||||
/*
|
|
||||||
* Apply a reversible inverse DWT transform to a component of an image
|
|
||||||
* tilec : tile component information (present tile)
|
|
||||||
*/
|
|
||||||
void dwt_decode(tcd_tilecomp_t * tilec, int stop);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the gain of a subband for the reversible DWT
|
|
||||||
* orient: number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
|
|
||||||
*/
|
|
||||||
int dwt_getgain(int orient);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the norm of a wavelet function of a subband at a specified level for the reversible DWT
|
|
||||||
* level: level of the wavelet function
|
|
||||||
* orient: band of the wavelet function
|
|
||||||
*/
|
|
||||||
double dwt_getnorm(int level, int orient);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apply an irreversible DWT transform to a component of an image
|
|
||||||
*/
|
|
||||||
void dwt_encode_real(tcd_tilecomp_t * tilec);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apply an irreversible inverse DWT transform to a component of an image
|
|
||||||
*/
|
|
||||||
void dwt_decode_real(tcd_tilecomp_t * tilec, int stop);
|
|
||||||
/*
|
|
||||||
* Get the gain of a subband for the irreversible DWT
|
|
||||||
* orient: number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
|
|
||||||
*/
|
|
||||||
int dwt_getgain_real(int orient);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the norm of a wavelet function of a subband at a specified level for the irreversible DWT
|
|
||||||
* level: level of the wavelet function
|
|
||||||
* orient: band of the wavelet function
|
|
||||||
*/
|
|
||||||
double dwt_getnorm_real(int level, int orient);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
1602
libopenjpeg/j2k.c
1602
libopenjpeg/j2k.c
File diff suppressed because it is too large
Load Diff
@@ -1,241 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define VERSION "0.0.8"
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined (OPENJPEGDLL)
|
|
||||||
#ifdef gdcmopenjpeg_EXPORTS /*LIBJ2K_EXPORTS*/
|
|
||||||
#define LIBJ2K_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define LIBJ2K_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef OPENJPEGSTATIC
|
|
||||||
#define LIBJ2K_API extern
|
|
||||||
#else
|
|
||||||
#define LIBJ2K_API
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __J2K_H
|
|
||||||
#define __J2K_H
|
|
||||||
|
|
||||||
#define J2K_MAXRLVLS 33 /* Number of maximum resolution level authorized */
|
|
||||||
#define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) /* Number of maximum sub-band linked to number of resolution level */
|
|
||||||
#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
|
|
||||||
|
|
||||||
#define J2K_CP_CSTY_PRT 0x01
|
|
||||||
#define J2K_CP_CSTY_SOP 0x02
|
|
||||||
#define J2K_CP_CSTY_EPH 0x04
|
|
||||||
#define J2K_CCP_CSTY_PRT 0x01
|
|
||||||
#define J2K_CCP_CBLKSTY_LAZY 0x01
|
|
||||||
#define J2K_CCP_CBLKSTY_RESET 0x02
|
|
||||||
#define J2K_CCP_CBLKSTY_TERMALL 0x04
|
|
||||||
#define J2K_CCP_CBLKSTY_VSC 0x08
|
|
||||||
#define J2K_CCP_CBLKSTY_PTERM 0x10
|
|
||||||
#define J2K_CCP_CBLKSTY_SEGSYM 0x20
|
|
||||||
#define J2K_CCP_QNTSTY_NOQNT 0
|
|
||||||
#define J2K_CCP_QNTSTY_SIQNT 1
|
|
||||||
#define J2K_CCP_QNTSTY_SEQNT 2
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int dx, dy; /* XRsiz, YRsiz */
|
|
||||||
int w, h; /* width and height of data */
|
|
||||||
int x0, y0; /* offset of the component compare to the whole image */
|
|
||||||
int prec; /* precision */
|
|
||||||
int bpp; /* deapth of image in bits */
|
|
||||||
int sgnd; /* signed */
|
|
||||||
int resno_decoded; /* number of decoded resolution */
|
|
||||||
int factor; /* number of division by 2 of the out image compare to the original size of image */
|
|
||||||
int *data; /* image-component data */
|
|
||||||
} j2k_comp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0; /* XOsiz, YOsiz */
|
|
||||||
int x1, y1; /* Xsiz, Ysiz */
|
|
||||||
int numcomps; /* number of components */
|
|
||||||
int color_space; /* sRGB, Greyscale or YUV */
|
|
||||||
j2k_comp_t *comps; /* image-components */
|
|
||||||
} j2k_image_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int expn; /* exponent */
|
|
||||||
int mant; /* mantissa */
|
|
||||||
} j2k_stepsize_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int csty; /* coding style */
|
|
||||||
int numresolutions; /* number of resolutions */
|
|
||||||
int cblkw; /* width of code-blocks */
|
|
||||||
int cblkh; /* height of code-blocks */
|
|
||||||
int cblksty; /* code-block coding style */
|
|
||||||
int qmfbid; /* discrete wavelet transform identifier */
|
|
||||||
int qntsty; /* quantisation style */
|
|
||||||
j2k_stepsize_t stepsizes[J2K_MAXBANDS]; /* stepsizes used for quantization */
|
|
||||||
int numgbits; /* number of guard bits */
|
|
||||||
int roishift; /* Region Of Interest shift */
|
|
||||||
int prcw[J2K_MAXRLVLS]; /* Precinct width */
|
|
||||||
int prch[J2K_MAXRLVLS]; /* Precinct height */
|
|
||||||
} j2k_tccp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int resno0, compno0;
|
|
||||||
int layno1, resno1, compno1;
|
|
||||||
int prg;
|
|
||||||
int tile;
|
|
||||||
char progorder[4];
|
|
||||||
} j2k_poc_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int first; /* 1 : first part-tile of a tile */
|
|
||||||
int csty; /* coding style */
|
|
||||||
int prg; /* progression order */
|
|
||||||
int numlayers; /* number of layers */
|
|
||||||
int mct; /* multi-component transform identifier */
|
|
||||||
int rates[100]; /* rates of layers */
|
|
||||||
int numpocs; /* number of progression order changes */
|
|
||||||
int POC; /* Precise if a POC marker has been used O:NO, 1:YES */
|
|
||||||
j2k_poc_t pocs[32]; /* progression order changes */
|
|
||||||
unsigned char *ppt_data; /* packet header store there for futur use in t2_decode_packet */
|
|
||||||
unsigned char *ppt_data_first; /* pointer remaining on the first byte of the first header if ppt is used */
|
|
||||||
int ppt; /* If ppt == 1 --> there was a PPT marker for the present tile */
|
|
||||||
int ppt_store; /* Use in case of multiple marker PPT (number of info already store) */
|
|
||||||
int ppt_len; /* ppmbug1 */
|
|
||||||
float distoratio[100]; /* add fixed_quality */
|
|
||||||
j2k_tccp_t *tccps; /* tile-component coding parameters */
|
|
||||||
} j2k_tcp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int intermed_file; /* 1: Store each encoded tile one by one in the output file (for mega-Images)*/
|
|
||||||
int decod_format; /* 0: PGX, 1: PxM, 2: BMP */
|
|
||||||
int cod_format; /* 0: J2K, 1: JP2, 2: JPT */
|
|
||||||
int disto_alloc; /* Allocation by rate/distortion */
|
|
||||||
int fixed_alloc; /* Allocation by fixed layer */
|
|
||||||
int fixed_quality; /* add fixed_quality */
|
|
||||||
int reduce; /* if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
|
|
||||||
int layer; /* if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
|
|
||||||
int index_on; /* 0 = no index || 1 = index */
|
|
||||||
int tx0, ty0; /* XTOsiz, YTOsiz */
|
|
||||||
int tdx, tdy; /* XTsiz, YTsiz */
|
|
||||||
char *comment; /* comment for coding */
|
|
||||||
int tw, th; /* number of tiles in width and heigth */
|
|
||||||
int *tileno; /* ID number of the tiles present in the codestream */
|
|
||||||
int tileno_size; /* size of the vector tileno */
|
|
||||||
unsigned char *ppm_data; /* packet header store there for futur use in t2_decode_packet */
|
|
||||||
unsigned char *ppm_data_first; /* pointer remaining on the first byte of the first header if ppm is used */
|
|
||||||
int ppm; /* If ppm == 1 --> there was a PPM marker for the present tile */
|
|
||||||
int ppm_store; /* Use in case of multiple marker PPM (number of info already store) */
|
|
||||||
int ppm_previous; /* Use in case of multiple marker PPM (case on non-finished previous info) */
|
|
||||||
int ppm_len; /* ppmbug1 */
|
|
||||||
j2k_tcp_t *tcps; /* tile coding parameters */
|
|
||||||
int *matrice; /* Fixed layer */
|
|
||||||
} j2k_cp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int start_pos, end_pos; /* start and end position */
|
|
||||||
double disto; /* ADD for Marcela */
|
|
||||||
} info_packet; /* Index struct */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double *thresh; /* value of thresh for each layer by tile cfr. Marcela */
|
|
||||||
int num_tile; /* Number of Tile */
|
|
||||||
int start_pos; /* Start position */
|
|
||||||
int end_header; /* End position of the header */
|
|
||||||
int end_pos; /* End position */
|
|
||||||
int pw[33], ph[33]; /* precinct number for each resolution level */
|
|
||||||
|
|
||||||
int pdx[33], pdy[33]; /* precinct size (in power of 2), in X and Y for each resolution level */
|
|
||||||
info_packet *packet; /* information concerning packets inside tile */
|
|
||||||
int nbpix; /* add fixed_quality */
|
|
||||||
double distotile; /* add fixed_quality */
|
|
||||||
} info_tile; /* index struct */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int index_on;
|
|
||||||
double D_max; /* ADD for Marcela */
|
|
||||||
int num; /* numero of packet */
|
|
||||||
int index_write; /* writing the packet inthe index with t2_encode_packets */
|
|
||||||
int Im_w, Im_h; /* Image width and Height */
|
|
||||||
int Prog; /* progression order */
|
|
||||||
int Tile_x, Tile_y; /* Tile size in x and y */
|
|
||||||
int Tile_Ox, Tile_Oy;
|
|
||||||
int tw, th; /* Number of Tile in X and Y */
|
|
||||||
int Comp; /* Component numbers */
|
|
||||||
int Layer; /* number of layer */
|
|
||||||
int Decomposition; /* number of decomposition */
|
|
||||||
int Main_head_end; /* Main header position */
|
|
||||||
int codestream_size; /* codestream's size */
|
|
||||||
info_tile *tile; /* information concerning tiles inside image */
|
|
||||||
} info_image; /* index struct */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode an image into a JPEG-2000 codestream
|
|
||||||
* i: image to encode
|
|
||||||
* cp: coding parameters
|
|
||||||
* output: destination buffer or name of the output file when cp->intermed_file==1
|
|
||||||
* len: length of destination buffer
|
|
||||||
* index : index file name
|
|
||||||
*/
|
|
||||||
LIBJ2K_API int j2k_encode(j2k_image_t * i, j2k_cp_t * cp, char *output,
|
|
||||||
int len, char *index);
|
|
||||||
|
|
||||||
/* LIBJ2K_API int j2k_encode(j2k_image_t *i, j2k_cp_t *cp,unsigned char *dest, int len); */
|
|
||||||
/*
|
|
||||||
* Decode an image from a JPEG-2000 codestream
|
|
||||||
* src: source buffer
|
|
||||||
* len: length of source buffer
|
|
||||||
* i: decode image
|
|
||||||
* cp: coding parameters that were used to encode the image
|
|
||||||
*/
|
|
||||||
|
|
||||||
LIBJ2K_API int j2k_decode(unsigned char *src, int len, j2k_image_t * img,
|
|
||||||
j2k_cp_t * cp);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode an image form a JPT-stream (JPEG 2000, JPIP)
|
|
||||||
* src: source buffer
|
|
||||||
* len: length of source buffer
|
|
||||||
* i: decode image
|
|
||||||
* cp: coding parameters that were used to encode the image
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
|
||||||
j2k_cp_t * cp);
|
|
||||||
|
|
||||||
LIBJ2K_API void j2k_dec_release();/*antonin*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,529 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
|
||||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "j2k.h"
|
|
||||||
#include "jp2.h"
|
|
||||||
#include "cio.h"
|
|
||||||
|
|
||||||
#define JPIP_JPIP 0x6a706970
|
|
||||||
|
|
||||||
#define JP2_JP 0x6a502020
|
|
||||||
#define JP2_FTYP 0x66747970
|
|
||||||
#define JP2_JP2H 0x6a703268
|
|
||||||
#define JP2_IHDR 0x69686472
|
|
||||||
#define JP2_COLR 0x636f6c72
|
|
||||||
#define JP2_JP2C 0x6a703263
|
|
||||||
#define JP2_URL 0x75726c20
|
|
||||||
#define JP2_DBTL 0x6474626c
|
|
||||||
#define JP2_BPCC 0x62706363
|
|
||||||
#define JP2_JP2 0x6a703220
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Read box headers
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
int jp2_read_boxhdr(jp2_box_t * box)
|
|
||||||
{
|
|
||||||
box->init_pos = cio_tell();
|
|
||||||
box->length = cio_read(4);
|
|
||||||
box->type = cio_read(4);
|
|
||||||
if (box->length == 1) {
|
|
||||||
if (cio_read(4) != 0) {
|
|
||||||
fprintf(stderr, "Error: Cannot handle box sizes higher than 2^32\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
box->length = cio_read(4);
|
|
||||||
if (box->length == 0)
|
|
||||||
box->length = cio_numbytesleft() + 12;
|
|
||||||
} else if (box->length == 0) {
|
|
||||||
box->length = cio_numbytesleft() + 8;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Initialisation of a Standard JP2 structure
|
|
||||||
*/
|
|
||||||
|
|
||||||
int jp2_init_stdjp2(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
|
|
||||||
jp2_struct->comps =
|
|
||||||
(jp2_comps_t *) malloc(jp2_struct->numcomps * sizeof(jp2_comps_t));
|
|
||||||
|
|
||||||
jp2_struct->precedence = 0; /* PRECEDENCE*/
|
|
||||||
jp2_struct->approx = 0; /* APPROX*/
|
|
||||||
|
|
||||||
jp2_struct->brand = JP2_JP2; /* BR */
|
|
||||||
jp2_struct->minversion = 0; /* MinV */
|
|
||||||
jp2_struct->numcl = 1;
|
|
||||||
jp2_struct->cl = (unsigned int *) malloc(jp2_struct->numcl * sizeof(int));
|
|
||||||
jp2_struct->cl[0] = JP2_JP2; /* CL0 : JP2 */
|
|
||||||
|
|
||||||
jp2_struct->C = 7; /* C : Always 7*/
|
|
||||||
jp2_struct->UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
|
||||||
jp2_struct->IPR = 0; /* IPR, no intellectual property*/
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void jp2_write_url(char *Idx_file)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
char str[256];
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
sprintf(str, "%s", Idx_file);
|
|
||||||
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_URL, 4); /* DBTL*/
|
|
||||||
cio_write(0, 1); /* VERS*/
|
|
||||||
cio_write(0, 3); /* FLAG*/
|
|
||||||
|
|
||||||
for (i = 0; i < strlen(str); i++) {
|
|
||||||
cio_write(str[i], 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the IHDR box
|
|
||||||
*
|
|
||||||
* Image Header box
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int jp2_read_ihdr(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
if (JP2_IHDR != box.type) {
|
|
||||||
fprintf(stderr, "Error: Expected IHDR Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
jp2_struct->h = cio_read(4); /* HEIGHT*/
|
|
||||||
jp2_struct->w = cio_read(4); /* WIDTH*/
|
|
||||||
jp2_struct->numcomps = cio_read(2); /* NC*/
|
|
||||||
|
|
||||||
jp2_struct->bpc = cio_read(1); /* BPC*/
|
|
||||||
|
|
||||||
jp2_struct->C = cio_read(1); /* C */
|
|
||||||
jp2_struct->UnkC = cio_read(1); /* UnkC*/
|
|
||||||
jp2_struct->IPR = cio_read(1); /* IPR*/
|
|
||||||
|
|
||||||
if (cio_tell() - box.init_pos != box.length) {
|
|
||||||
fprintf(stderr, "Error with IHDR Box\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jp2_write_ihdr(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_IHDR, 4); /* IHDR*/
|
|
||||||
|
|
||||||
cio_write(jp2_struct->h, 4); /* HEIGHT*/
|
|
||||||
cio_write(jp2_struct->w, 4); /* WIDTH*/
|
|
||||||
cio_write(jp2_struct->numcomps, 2); /* NC*/
|
|
||||||
|
|
||||||
cio_write(jp2_struct->bpc, 1); /* BPC */
|
|
||||||
|
|
||||||
cio_write(jp2_struct->C, 1); /* C : Always 7*/
|
|
||||||
cio_write(jp2_struct->UnkC, 1); /* UnkC, colorspace unknow*/
|
|
||||||
cio_write(jp2_struct->IPR, 1); /* IPR, no intellectual property*/
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void jp2_write_bpcc(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_BPCC, 4); /* BPCC*/
|
|
||||||
|
|
||||||
for (i = 0; i < jp2_struct->numcomps; i++)
|
|
||||||
cio_write(jp2_struct->comps[i].bpcc, 1);
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int jp2_read_bpcc(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
if (JP2_BPCC != box.type) {
|
|
||||||
fprintf(stderr, "Error: Expected BPCC Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < jp2_struct->numcomps; i++)
|
|
||||||
jp2_struct->comps[i].bpcc = cio_read(1);
|
|
||||||
|
|
||||||
if (cio_tell() - box.init_pos != box.length) {
|
|
||||||
fprintf(stderr, "Error with BPCC Box\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jp2_write_colr(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_COLR, 4); /* COLR*/
|
|
||||||
|
|
||||||
cio_write(jp2_struct->meth, 1); /* METH*/
|
|
||||||
cio_write(jp2_struct->precedence, 1); /* PRECEDENCE*/
|
|
||||||
cio_write(jp2_struct->approx, 1); /* APPROX*/
|
|
||||||
|
|
||||||
if (jp2_struct->meth == 1)
|
|
||||||
cio_write(jp2_struct->enumcs, 4); /* EnumCS*/
|
|
||||||
else
|
|
||||||
cio_write(0, 1); /* PROFILE (??)*/
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
int jp2_read_colr(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
int skip_len;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
do {
|
|
||||||
if (JP2_COLR != box.type) {
|
|
||||||
cio_skip(box.length - 8);
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
}
|
|
||||||
} while (JP2_COLR != box.type);
|
|
||||||
|
|
||||||
jp2_struct->meth = cio_read(1); /* METH*/
|
|
||||||
jp2_struct->precedence = cio_read(1); /* PRECEDENCE*/
|
|
||||||
jp2_struct->approx = cio_read(1); /* APPROX*/
|
|
||||||
|
|
||||||
if (jp2_struct->meth == 1)
|
|
||||||
jp2_struct->enumcs = cio_read(4); /* EnumCS*/
|
|
||||||
else {
|
|
||||||
/* SKIP PROFILE */
|
|
||||||
skip_len = box.init_pos + box.length - cio_tell();
|
|
||||||
if (skip_len < 0) {
|
|
||||||
fprintf(stderr, "Error with JP2H box size\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cio_skip(box.init_pos + box.length - cio_tell());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cio_tell() - box.init_pos != box.length) {
|
|
||||||
fprintf(stderr, "Error with BPCC Box\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write the JP2H box
|
|
||||||
*
|
|
||||||
* JP2 Header box
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void jp2_write_jp2h(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);;
|
|
||||||
cio_write(JP2_JP2H, 4); /* JP2H */
|
|
||||||
|
|
||||||
jp2_write_ihdr(jp2_struct);
|
|
||||||
|
|
||||||
if (jp2_struct->bpc == 255)
|
|
||||||
jp2_write_bpcc(jp2_struct);
|
|
||||||
jp2_write_colr(jp2_struct);
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the JP2H box
|
|
||||||
*
|
|
||||||
* JP2 Header box
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int jp2_read_jp2h(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
int skip_len;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
do {
|
|
||||||
if (JP2_JP2H != box.type) {
|
|
||||||
if (box.type == JP2_JP2C) {
|
|
||||||
fprintf(stderr, "Error: Expected JP2H Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cio_skip(box.length - 8);
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
}
|
|
||||||
} while (JP2_JP2H != box.type);
|
|
||||||
|
|
||||||
if (jp2_read_ihdr(jp2_struct))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (jp2_struct->bpc == 255) {
|
|
||||||
if (jp2_read_bpcc(jp2_struct))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jp2_read_colr(jp2_struct))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
skip_len = box.init_pos + box.length - cio_tell();
|
|
||||||
if (skip_len < 0) {
|
|
||||||
fprintf(stderr, "Error with JP2H box size\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cio_skip(box.init_pos + box.length - cio_tell());
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write the FTYP box
|
|
||||||
*
|
|
||||||
* File type box
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void jp2_write_ftyp(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_FTYP, 4); /* FTYP */
|
|
||||||
|
|
||||||
cio_write(jp2_struct->brand, 4); /* BR */
|
|
||||||
cio_write(jp2_struct->minversion, 4); /* MinV */
|
|
||||||
|
|
||||||
for (i = 0; i < jp2_struct->numcl; i++)
|
|
||||||
cio_write(jp2_struct->cl[i], 4); /* CL */
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the FTYP box
|
|
||||||
*
|
|
||||||
* File type box
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int jp2_read_ftyp(jp2_struct_t * jp2_struct)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
|
|
||||||
if (JP2_FTYP != box.type) {
|
|
||||||
fprintf(stderr, "Error: Excpected FTYP Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
jp2_struct->brand = cio_read(4); /* BR */
|
|
||||||
jp2_struct->minversion = cio_read(4); /* MinV */
|
|
||||||
jp2_struct->numcl = (box.length - 16) / 4;
|
|
||||||
jp2_struct->cl =
|
|
||||||
(unsigned int *) malloc(jp2_struct->numcl * sizeof(unsigned int));
|
|
||||||
|
|
||||||
for (i = 0; i < (int) jp2_struct->numcl; i++)
|
|
||||||
jp2_struct->cl[i] = cio_read(4); /* CLi */
|
|
||||||
|
|
||||||
if (cio_tell() - box.init_pos != box.length) {
|
|
||||||
fprintf(stderr, "Error with FTYP Box\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int jp2_write_jp2c(int j2k_codestream_len, int *j2k_codestream_offset,
|
|
||||||
char *j2k_codestream)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_JP2C, 4); /* JP2C*/
|
|
||||||
|
|
||||||
*j2k_codestream_offset = cio_tell();
|
|
||||||
memcpy(cio_getbp(), j2k_codestream, j2k_codestream_len);
|
|
||||||
|
|
||||||
box.length = 8 + j2k_codestream_len;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
|
|
||||||
return box.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int jp2_read_jp2c(unsigned int *j2k_codestream_len,
|
|
||||||
unsigned int *j2k_codestream_offset)
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
do {
|
|
||||||
if (JP2_JP2C != box.type) {
|
|
||||||
cio_skip(box.length - 8);
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
}
|
|
||||||
} while (JP2_JP2C != box.type);
|
|
||||||
|
|
||||||
*j2k_codestream_offset = cio_tell();
|
|
||||||
*j2k_codestream_len = box.length - 8;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jp2_write_jp()
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
box.init_pos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_JP, 4); /* JP*/
|
|
||||||
cio_write(0x0d0a870a, 4);
|
|
||||||
|
|
||||||
box.length = cio_tell() - box.init_pos;
|
|
||||||
cio_seek(box.init_pos);
|
|
||||||
cio_write(box.length, 4); /* L */
|
|
||||||
cio_seek(box.init_pos + box.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the JP box
|
|
||||||
*
|
|
||||||
* JPEG 2000 signature
|
|
||||||
*
|
|
||||||
* return 1 if error else 0
|
|
||||||
*/
|
|
||||||
int jp2_read_jp()
|
|
||||||
{
|
|
||||||
jp2_box_t box;
|
|
||||||
|
|
||||||
jp2_read_boxhdr(&box);
|
|
||||||
if (JP2_JP != box.type) {
|
|
||||||
fprintf(stderr, "Error: Expected JP Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (0x0d0a870a != cio_read(4)) {
|
|
||||||
fprintf(stderr, "Error with JP Marker\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (cio_tell() - box.init_pos != box.length) {
|
|
||||||
fprintf(stderr, "Error with JP Box size\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int jp2_read_struct(unsigned char *src, jp2_struct_t * jp2_struct, int len)
|
|
||||||
{
|
|
||||||
cio_init(src, len);
|
|
||||||
|
|
||||||
if (jp2_read_jp())
|
|
||||||
return 1;
|
|
||||||
if (jp2_read_ftyp(jp2_struct))
|
|
||||||
return 1;
|
|
||||||
if (jp2_read_jp2h(jp2_struct))
|
|
||||||
return 1;
|
|
||||||
if (jp2_read_jp2c
|
|
||||||
(&jp2_struct->j2k_codestream_len,
|
|
||||||
&jp2_struct->j2k_codestream_offset))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int jp2_wrap_j2k(jp2_struct_t * jp2_struct, char *j2k_codestream,
|
|
||||||
char *output)
|
|
||||||
{
|
|
||||||
(void)output;
|
|
||||||
jp2_write_jp();
|
|
||||||
jp2_write_ftyp(jp2_struct);
|
|
||||||
jp2_write_jp2h(jp2_struct);
|
|
||||||
|
|
||||||
jp2_write_jp2c(jp2_struct->j2k_codestream_len,
|
|
||||||
&jp2_struct->j2k_codestream_offset, j2k_codestream);
|
|
||||||
|
|
||||||
return cio_tell();
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef __JP2_H
|
|
||||||
#define __JP2_H
|
|
||||||
|
|
||||||
#include "j2k.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int depth;
|
|
||||||
int sgnd;
|
|
||||||
int bpcc;
|
|
||||||
} jp2_comps_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int w;
|
|
||||||
unsigned int h;
|
|
||||||
unsigned int numcomps;
|
|
||||||
unsigned int bpc;
|
|
||||||
unsigned int C;
|
|
||||||
unsigned int UnkC;
|
|
||||||
unsigned int IPR;
|
|
||||||
unsigned int meth;
|
|
||||||
unsigned int approx;
|
|
||||||
unsigned int enumcs;
|
|
||||||
unsigned int precedence;
|
|
||||||
unsigned int brand;
|
|
||||||
unsigned int minversion;
|
|
||||||
unsigned int numcl;
|
|
||||||
unsigned int *cl;
|
|
||||||
jp2_comps_t *comps;
|
|
||||||
j2k_image_t *image;
|
|
||||||
unsigned int j2k_codestream_offset;
|
|
||||||
unsigned int j2k_codestream_len;
|
|
||||||
} jp2_struct_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int length;
|
|
||||||
int type;
|
|
||||||
int init_pos;
|
|
||||||
} jp2_box_t;
|
|
||||||
|
|
||||||
/* int jp2_init_stdjp2(jp2_struct_t * jp2_struct, j2k_image_t * img);
|
|
||||||
*
|
|
||||||
* Create a standard jp2_structure
|
|
||||||
* jp2_struct: the structure you are creating
|
|
||||||
* img: a j2k_image_t wich will help you to create the jp2_structure
|
|
||||||
*/
|
|
||||||
int jp2_init_stdjp2(jp2_struct_t * jp2_struct);
|
|
||||||
|
|
||||||
/* int jp2_write_jp2c(int j2k_len, int *j2k_codestream_offset, char *j2k_codestream)
|
|
||||||
*
|
|
||||||
* Write the jp2c codestream box
|
|
||||||
* j2k_len: the j2k codestream length
|
|
||||||
* j2k_codestream_offset: the function will return the j2k codestream offset
|
|
||||||
* j2k_codestream: the j2k codestream to include in jp2 file
|
|
||||||
*/
|
|
||||||
int jp2_write_jp2c(int j2k_len, int *j2k_codestream_offset, char *j2k_codestream);
|
|
||||||
|
|
||||||
/* int jp2_write_jp2h(jp2_struct_t * jp2_struct);
|
|
||||||
*
|
|
||||||
* Write the jp2h header box
|
|
||||||
* jp2_struct: the jp2 structure you are working with
|
|
||||||
*/
|
|
||||||
void jp2_write_jp2h(jp2_struct_t * jp2_struct);
|
|
||||||
|
|
||||||
/* int jp2_read_jp2h(jp2_struct_t * jp2_struct);
|
|
||||||
*
|
|
||||||
* Read the jp2h header box
|
|
||||||
* jp2_struct: the jp2 structure you are working with
|
|
||||||
*/
|
|
||||||
int jp2_read_jp2h(jp2_struct_t * jp2_struct);
|
|
||||||
|
|
||||||
/* int jp2_wrap_j2k(jp2_struct_t * jp2_struct, char *j2k_codestream,
|
|
||||||
int j2k_len, char *output)
|
|
||||||
*
|
|
||||||
* Wrap a J2K codestream in a JP2 file
|
|
||||||
* jp2_struct: the jp2 structure used to create jp2 boxes
|
|
||||||
* j2k_codestream: the j2k codestream to include in jp2 file
|
|
||||||
* output: pointer to jp2 codestream that will be created
|
|
||||||
*/
|
|
||||||
int jp2_wrap_j2k(jp2_struct_t * jp2_struct, char *j2k_codestream,
|
|
||||||
char *output);
|
|
||||||
|
|
||||||
|
|
||||||
/* int jp2_read_struct(unsigned char *src, jp2_struct_t * jp2_struct);
|
|
||||||
*
|
|
||||||
* Decode the structure of a JP2 file
|
|
||||||
* src: pointer to memory where compressed data is stored
|
|
||||||
* jp2_struct: the jp2 structure that will be created
|
|
||||||
* len: length of jp2 codestream
|
|
||||||
*/
|
|
||||||
int jp2_read_struct(unsigned char *src, jp2_struct_t * jp2_struct, int len);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004, Yannick Verschueren
|
|
||||||
* Copyright (c) 2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "jpt.h"
|
|
||||||
#include "j2k.h"
|
|
||||||
#include "cio.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the information contains in VBAS [JPP/JPT stream message header]
|
|
||||||
* Store information (7 bits) in value
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
unsigned int jpt_read_VBAS_info(unsigned int value)
|
|
||||||
{
|
|
||||||
unsigned char elmt;
|
|
||||||
|
|
||||||
elmt = cio_read(1);
|
|
||||||
while ((elmt >> 7) == 1) {
|
|
||||||
value = (value << 7);
|
|
||||||
value |= (elmt & 0x7f);
|
|
||||||
elmt = cio_read(1);
|
|
||||||
}
|
|
||||||
value = (value << 7);
|
|
||||||
value |= (elmt & 0x7f);
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the value of the message header structure
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void jpt_init_Msg_Header(jpt_msg_header_struct_t * header)
|
|
||||||
{
|
|
||||||
header->Id = 0; /* In-class Identifier */
|
|
||||||
header->last_byte = 0; /* Last byte information */
|
|
||||||
header->Class_Id = 0; /* Class Identifier */
|
|
||||||
header->CSn_Id = 0; /* CSn : index identifier */
|
|
||||||
header->Msg_offset = 0; /* Message offset */
|
|
||||||
header->Msg_length = 0; /* Message length */
|
|
||||||
header->Layer_nb = 0; /* Auxiliary for JPP case */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-initialize the value of the message header structure
|
|
||||||
*
|
|
||||||
* Only parameters always present in message header
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void jpt_reinit_Msg_Header(jpt_msg_header_struct_t * header)
|
|
||||||
{
|
|
||||||
header->Id = 0; /* In-class Identifier */
|
|
||||||
header->last_byte = 0; /* Last byte information */
|
|
||||||
header->Msg_offset = 0; /* Message offset */
|
|
||||||
header->Msg_length = 0; /* Message length */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the message header for a JPP/JPT - stream
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void jpt_read_Msg_Header(jpt_msg_header_struct_t * header)
|
|
||||||
{
|
|
||||||
unsigned char elmt, Class = 0, CSn = 0;
|
|
||||||
jpt_reinit_Msg_Header(header);
|
|
||||||
|
|
||||||
/* ------------- */
|
|
||||||
/* VBAS : Bin-ID */
|
|
||||||
/* ------------- */
|
|
||||||
elmt = cio_read(1);
|
|
||||||
|
|
||||||
/* See for Class and CSn */
|
|
||||||
switch ((elmt >> 5) & 0x03) {
|
|
||||||
case 0:
|
|
||||||
fprintf(stderr, "Forbidden value encounter in message header !!\n");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Class = 0;
|
|
||||||
CSn = 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Class = 1;
|
|
||||||
CSn = 0;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
Class = 1;
|
|
||||||
CSn = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
|
|
||||||
if (((elmt >> 4) & 0x01) == 1)
|
|
||||||
header->last_byte = 1;
|
|
||||||
|
|
||||||
/* In-class identifier */
|
|
||||||
header->Id |= (elmt & 0x0f);
|
|
||||||
if ((elmt >> 7) == 1)
|
|
||||||
header->Id = jpt_read_VBAS_info(header->Id);
|
|
||||||
|
|
||||||
/* ------------ */
|
|
||||||
/* VBAS : Class */
|
|
||||||
/* ------------ */
|
|
||||||
if (Class == 1) {
|
|
||||||
header->Class_Id = 0;
|
|
||||||
header->Class_Id = jpt_read_VBAS_info(header->Class_Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- */
|
|
||||||
/* VBAS : CSn */
|
|
||||||
/* ---------- */
|
|
||||||
if (CSn == 1) {
|
|
||||||
header->CSn_Id = 0;
|
|
||||||
header->CSn_Id = jpt_read_VBAS_info(header->CSn_Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------- */
|
|
||||||
/* VBAS : Msg_offset */
|
|
||||||
/* ----------------- */
|
|
||||||
header->Msg_offset = jpt_read_VBAS_info(header->Msg_offset);
|
|
||||||
|
|
||||||
/* ----------------- */
|
|
||||||
/* VBAS : Msg_length */
|
|
||||||
/* ----------------- */
|
|
||||||
header->Msg_length = jpt_read_VBAS_info(header->Msg_length);
|
|
||||||
|
|
||||||
/* ---------- */
|
|
||||||
/* VBAS : Aux */
|
|
||||||
/* ---------- */
|
|
||||||
if ((header->Class_Id & 0x01) == 1) {
|
|
||||||
header->Layer_nb = 0;
|
|
||||||
header->Layer_nb = jpt_read_VBAS_info(header->Layer_nb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 "mct.h"
|
|
||||||
#include "fix.h"
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This table contains the norms of the basis function of the reversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
double mct_norms[3] = { 1.732, .8292, .8292 };
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This table contains the norms of the basis function of the irreversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Foward reversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
void mct_encode(int *c0, int *c1, int *c2, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
int r, g, b, y, u, v;
|
|
||||||
r = c0[i];
|
|
||||||
g = c1[i];
|
|
||||||
b = c2[i];
|
|
||||||
y = (r + (g << 1) + b) >> 2;
|
|
||||||
u = b - g;
|
|
||||||
v = r - g;
|
|
||||||
c0[i] = y;
|
|
||||||
c1[i] = u;
|
|
||||||
c2[i] = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse reversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
void mct_decode(int *c0, int *c1, int *c2, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
int y, u, v, r, g, b;
|
|
||||||
y = c0[i];
|
|
||||||
u = c1[i];
|
|
||||||
v = c2[i];
|
|
||||||
g = y - ((u + v) >> 2);
|
|
||||||
r = v + g;
|
|
||||||
b = u + g;
|
|
||||||
c0[i] = r;
|
|
||||||
c1[i] = g;
|
|
||||||
c2[i] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get norm of basis function of reversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
double mct_getnorm(int compno)
|
|
||||||
{
|
|
||||||
return mct_norms[compno];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Foward irreversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
void mct_encode_real(int *c0, int *c1, int *c2, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
int r, g, b, y, u, v;
|
|
||||||
r = c0[i];
|
|
||||||
g = c1[i];
|
|
||||||
b = c2[i];
|
|
||||||
y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
|
|
||||||
u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
|
|
||||||
v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
|
|
||||||
c0[i] = y;
|
|
||||||
c1[i] = u;
|
|
||||||
c2[i] = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Inverse irreversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
void mct_decode_real(int *c0, int *c1, int *c2, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
int y, u, v, r, g, b;
|
|
||||||
y = c0[i];
|
|
||||||
u = c1[i];
|
|
||||||
v = c2[i];
|
|
||||||
r = y + fix_mul(v, 11485);
|
|
||||||
g = y - fix_mul(u, 2819) - fix_mul(v, 5850);
|
|
||||||
b = y + fix_mul(u, 14516);
|
|
||||||
c0[i] = r;
|
|
||||||
c1[i] = g;
|
|
||||||
c2[i] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Get norm of basis function of irreversible MCT. */
|
|
||||||
/* </summary> */
|
|
||||||
double mct_getnorm_real(int compno)
|
|
||||||
{
|
|
||||||
return mct_norms_real[compno];
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 __MCT_H
|
|
||||||
#define __MCT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apply a reversible multi-component transform to an image
|
|
||||||
* R: samples for red component
|
|
||||||
* G: samples for green component
|
|
||||||
* B: samples blue component
|
|
||||||
* n: number of samples for each component
|
|
||||||
*/
|
|
||||||
void mct_encode(int *R, int *G, int *B, int n);
|
|
||||||
/*
|
|
||||||
* Apply a reversible multi-component inverse transform to an image
|
|
||||||
* Y: samples for luminance component
|
|
||||||
* U: samples for red chrominance component
|
|
||||||
* V: samples for blue chrominance component
|
|
||||||
* n: number of samples for each component
|
|
||||||
*/
|
|
||||||
void mct_decode(int *V, int *U, int *Y, int n);
|
|
||||||
/*
|
|
||||||
* Get norm of the basis function used for the reversible multi-component transform
|
|
||||||
* compno: number of the component (0->Y, 1->U, 2->V)
|
|
||||||
*/
|
|
||||||
double mct_getnorm(int compno);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apply an irreversible multi-component transform to an image
|
|
||||||
* R: samples for red component
|
|
||||||
* G: samples for green component
|
|
||||||
* B: samples blue component
|
|
||||||
* n: number of samples for each component
|
|
||||||
*/
|
|
||||||
void mct_encode_real(int *c0, int *c1, int *c2, int n);
|
|
||||||
/*
|
|
||||||
* Apply an irreversible multi-component inverse transform to an image
|
|
||||||
* Y: samples for luminance component
|
|
||||||
* U: samples for red chrominance component
|
|
||||||
* V: samples for blue chrominance component
|
|
||||||
* n: number of samples for each component
|
|
||||||
*/
|
|
||||||
void mct_decode_real(int *c0, int *c1, int *c2, int n);
|
|
||||||
/*
|
|
||||||
* Get norm of the basis function used for the irreversible multi-component transform
|
|
||||||
* compno: number of the component (0->Y, 1->U, 2->V)
|
|
||||||
*/
|
|
||||||
double mct_getnorm_real(int compno);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,591 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mqc.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This struct defines the state of a context. */
|
|
||||||
/* </summary> */
|
|
||||||
typedef struct mqc_state_s {
|
|
||||||
unsigned int qeval; /* the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
|
|
||||||
int mps; /* the Most Probable Symbol (0 or 1) */
|
|
||||||
struct mqc_state_s *nmps; /* next state if the next encoded symbol is the MPS */
|
|
||||||
struct mqc_state_s *nlps; /* next state if the next encoded symbol is the LPS */
|
|
||||||
} mqc_state_t;
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* This array defines all the possible states for a context. */
|
|
||||||
/* </summary> */
|
|
||||||
mqc_state_t mqc_states[47 * 2] = {
|
|
||||||
{0x5601, 0, &mqc_states[2], &mqc_states[3]},
|
|
||||||
{0x5601, 1, &mqc_states[3], &mqc_states[2]},
|
|
||||||
{0x3401, 0, &mqc_states[4], &mqc_states[12]},
|
|
||||||
{0x3401, 1, &mqc_states[5], &mqc_states[13]},
|
|
||||||
{0x1801, 0, &mqc_states[6], &mqc_states[18]},
|
|
||||||
{0x1801, 1, &mqc_states[7], &mqc_states[19]},
|
|
||||||
{0x0ac1, 0, &mqc_states[8], &mqc_states[24]},
|
|
||||||
{0x0ac1, 1, &mqc_states[9], &mqc_states[25]},
|
|
||||||
{0x0521, 0, &mqc_states[10], &mqc_states[58]},
|
|
||||||
{0x0521, 1, &mqc_states[11], &mqc_states[59]},
|
|
||||||
{0x0221, 0, &mqc_states[76], &mqc_states[66]},
|
|
||||||
{0x0221, 1, &mqc_states[77], &mqc_states[67]},
|
|
||||||
{0x5601, 0, &mqc_states[14], &mqc_states[13]},
|
|
||||||
{0x5601, 1, &mqc_states[15], &mqc_states[12]},
|
|
||||||
{0x5401, 0, &mqc_states[16], &mqc_states[28]},
|
|
||||||
{0x5401, 1, &mqc_states[17], &mqc_states[29]},
|
|
||||||
{0x4801, 0, &mqc_states[18], &mqc_states[28]},
|
|
||||||
{0x4801, 1, &mqc_states[19], &mqc_states[29]},
|
|
||||||
{0x3801, 0, &mqc_states[20], &mqc_states[28]},
|
|
||||||
{0x3801, 1, &mqc_states[21], &mqc_states[29]},
|
|
||||||
{0x3001, 0, &mqc_states[22], &mqc_states[34]},
|
|
||||||
{0x3001, 1, &mqc_states[23], &mqc_states[35]},
|
|
||||||
{0x2401, 0, &mqc_states[24], &mqc_states[36]},
|
|
||||||
{0x2401, 1, &mqc_states[25], &mqc_states[37]},
|
|
||||||
{0x1c01, 0, &mqc_states[26], &mqc_states[40]},
|
|
||||||
{0x1c01, 1, &mqc_states[27], &mqc_states[41]},
|
|
||||||
{0x1601, 0, &mqc_states[58], &mqc_states[42]},
|
|
||||||
{0x1601, 1, &mqc_states[59], &mqc_states[43]},
|
|
||||||
{0x5601, 0, &mqc_states[30], &mqc_states[29]},
|
|
||||||
{0x5601, 1, &mqc_states[31], &mqc_states[28]},
|
|
||||||
{0x5401, 0, &mqc_states[32], &mqc_states[28]},
|
|
||||||
{0x5401, 1, &mqc_states[33], &mqc_states[29]},
|
|
||||||
{0x5101, 0, &mqc_states[34], &mqc_states[30]},
|
|
||||||
{0x5101, 1, &mqc_states[35], &mqc_states[31]},
|
|
||||||
{0x4801, 0, &mqc_states[36], &mqc_states[32]},
|
|
||||||
{0x4801, 1, &mqc_states[37], &mqc_states[33]},
|
|
||||||
{0x3801, 0, &mqc_states[38], &mqc_states[34]},
|
|
||||||
{0x3801, 1, &mqc_states[39], &mqc_states[35]},
|
|
||||||
{0x3401, 0, &mqc_states[40], &mqc_states[36]},
|
|
||||||
{0x3401, 1, &mqc_states[41], &mqc_states[37]},
|
|
||||||
{0x3001, 0, &mqc_states[42], &mqc_states[38]},
|
|
||||||
{0x3001, 1, &mqc_states[43], &mqc_states[39]},
|
|
||||||
{0x2801, 0, &mqc_states[44], &mqc_states[38]},
|
|
||||||
{0x2801, 1, &mqc_states[45], &mqc_states[39]},
|
|
||||||
{0x2401, 0, &mqc_states[46], &mqc_states[40]},
|
|
||||||
{0x2401, 1, &mqc_states[47], &mqc_states[41]},
|
|
||||||
{0x2201, 0, &mqc_states[48], &mqc_states[42]},
|
|
||||||
{0x2201, 1, &mqc_states[49], &mqc_states[43]},
|
|
||||||
{0x1c01, 0, &mqc_states[50], &mqc_states[44]},
|
|
||||||
{0x1c01, 1, &mqc_states[51], &mqc_states[45]},
|
|
||||||
{0x1801, 0, &mqc_states[52], &mqc_states[46]},
|
|
||||||
{0x1801, 1, &mqc_states[53], &mqc_states[47]},
|
|
||||||
{0x1601, 0, &mqc_states[54], &mqc_states[48]},
|
|
||||||
{0x1601, 1, &mqc_states[55], &mqc_states[49]},
|
|
||||||
{0x1401, 0, &mqc_states[56], &mqc_states[50]},
|
|
||||||
{0x1401, 1, &mqc_states[57], &mqc_states[51]},
|
|
||||||
{0x1201, 0, &mqc_states[58], &mqc_states[52]},
|
|
||||||
{0x1201, 1, &mqc_states[59], &mqc_states[53]},
|
|
||||||
{0x1101, 0, &mqc_states[60], &mqc_states[54]},
|
|
||||||
{0x1101, 1, &mqc_states[61], &mqc_states[55]},
|
|
||||||
{0x0ac1, 0, &mqc_states[62], &mqc_states[56]},
|
|
||||||
{0x0ac1, 1, &mqc_states[63], &mqc_states[57]},
|
|
||||||
{0x09c1, 0, &mqc_states[64], &mqc_states[58]},
|
|
||||||
{0x09c1, 1, &mqc_states[65], &mqc_states[59]},
|
|
||||||
{0x08a1, 0, &mqc_states[66], &mqc_states[60]},
|
|
||||||
{0x08a1, 1, &mqc_states[67], &mqc_states[61]},
|
|
||||||
{0x0521, 0, &mqc_states[68], &mqc_states[62]},
|
|
||||||
{0x0521, 1, &mqc_states[69], &mqc_states[63]},
|
|
||||||
{0x0441, 0, &mqc_states[70], &mqc_states[64]},
|
|
||||||
{0x0441, 1, &mqc_states[71], &mqc_states[65]},
|
|
||||||
{0x02a1, 0, &mqc_states[72], &mqc_states[66]},
|
|
||||||
{0x02a1, 1, &mqc_states[73], &mqc_states[67]},
|
|
||||||
{0x0221, 0, &mqc_states[74], &mqc_states[68]},
|
|
||||||
{0x0221, 1, &mqc_states[75], &mqc_states[69]},
|
|
||||||
{0x0141, 0, &mqc_states[76], &mqc_states[70]},
|
|
||||||
{0x0141, 1, &mqc_states[77], &mqc_states[71]},
|
|
||||||
{0x0111, 0, &mqc_states[78], &mqc_states[72]},
|
|
||||||
{0x0111, 1, &mqc_states[79], &mqc_states[73]},
|
|
||||||
{0x0085, 0, &mqc_states[80], &mqc_states[74]},
|
|
||||||
{0x0085, 1, &mqc_states[81], &mqc_states[75]},
|
|
||||||
{0x0049, 0, &mqc_states[82], &mqc_states[76]},
|
|
||||||
{0x0049, 1, &mqc_states[83], &mqc_states[77]},
|
|
||||||
{0x0025, 0, &mqc_states[84], &mqc_states[78]},
|
|
||||||
{0x0025, 1, &mqc_states[85], &mqc_states[79]},
|
|
||||||
{0x0015, 0, &mqc_states[86], &mqc_states[80]},
|
|
||||||
{0x0015, 1, &mqc_states[87], &mqc_states[81]},
|
|
||||||
{0x0009, 0, &mqc_states[88], &mqc_states[82]},
|
|
||||||
{0x0009, 1, &mqc_states[89], &mqc_states[83]},
|
|
||||||
{0x0005, 0, &mqc_states[90], &mqc_states[84]},
|
|
||||||
{0x0005, 1, &mqc_states[91], &mqc_states[85]},
|
|
||||||
{0x0001, 0, &mqc_states[90], &mqc_states[86]},
|
|
||||||
{0x0001, 1, &mqc_states[91], &mqc_states[87]},
|
|
||||||
{0x5601, 0, &mqc_states[92], &mqc_states[92]},
|
|
||||||
{0x5601, 1, &mqc_states[93], &mqc_states[93]},
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MQC_NUMCTXS 32
|
|
||||||
|
|
||||||
unsigned int mqc_c;
|
|
||||||
unsigned int mqc_a;
|
|
||||||
unsigned int mqc_ct;
|
|
||||||
unsigned char *mqc_bp;
|
|
||||||
unsigned char *mqc_start;
|
|
||||||
unsigned char *mqc_end;
|
|
||||||
mqc_state_t *mqc_ctxs[MQC_NUMCTXS];
|
|
||||||
mqc_state_t **mqc_curctx;
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Return the number of bytes already encoded. */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_numbytes()
|
|
||||||
{
|
|
||||||
return mqc_bp - mqc_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Output a byte, doing bit-stuffing if necessary. */
|
|
||||||
/* After a 0xff byte, the next byte must be smaller than 0x90 */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_byteout()
|
|
||||||
{
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c >> 20;
|
|
||||||
mqc_c &= 0xfffff;
|
|
||||||
mqc_ct = 7;
|
|
||||||
} else {
|
|
||||||
if ((mqc_c & 0x8000000) == 0) { /* ((mqc_c&0x8000000)==0) CHANGE */
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c >> 19;
|
|
||||||
mqc_c &= 0x7ffff;
|
|
||||||
mqc_ct = 8;
|
|
||||||
} else {
|
|
||||||
(*mqc_bp)++;
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
mqc_c &= 0x7ffffff;
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c >> 20;
|
|
||||||
mqc_c &= 0xfffff;
|
|
||||||
mqc_ct = 7;
|
|
||||||
} else {
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c >> 19;
|
|
||||||
mqc_c &= 0x7ffff;
|
|
||||||
mqc_ct = 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Renormalize mqc_a and mqc_c while encoding, so that mqc_a stays between 0x8000 and 0x10000 */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_renorme()
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
mqc_a <<= 1;
|
|
||||||
mqc_c <<= 1;
|
|
||||||
mqc_ct--;
|
|
||||||
if (mqc_ct == 0) {
|
|
||||||
mqc_byteout();
|
|
||||||
}
|
|
||||||
} while ((mqc_a & 0x8000) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Encode the most probable symbol. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_codemps()
|
|
||||||
{
|
|
||||||
mqc_a -= (*mqc_curctx)->qeval;
|
|
||||||
if ((mqc_a & 0x8000) == 0) {
|
|
||||||
if (mqc_a < (*mqc_curctx)->qeval) {
|
|
||||||
mqc_a = (*mqc_curctx)->qeval;
|
|
||||||
} else {
|
|
||||||
mqc_c += (*mqc_curctx)->qeval;
|
|
||||||
}
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nmps;
|
|
||||||
mqc_renorme();
|
|
||||||
} else {
|
|
||||||
mqc_c += (*mqc_curctx)->qeval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Encode the most least symbol. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_codelps()
|
|
||||||
{
|
|
||||||
mqc_a -= (*mqc_curctx)->qeval;
|
|
||||||
if (mqc_a < (*mqc_curctx)->qeval) {
|
|
||||||
mqc_c += (*mqc_curctx)->qeval;
|
|
||||||
} else {
|
|
||||||
mqc_a = (*mqc_curctx)->qeval;
|
|
||||||
}
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nlps;
|
|
||||||
mqc_renorme();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Initialize encoder. */
|
|
||||||
/* </summary> */
|
|
||||||
/* <param name="bp">Output buffer.</param> */
|
|
||||||
void mqc_init_enc(unsigned char *bp)
|
|
||||||
{
|
|
||||||
mqc_setcurctx(0);
|
|
||||||
mqc_a = 0x8000;
|
|
||||||
mqc_c = 0;
|
|
||||||
mqc_bp = bp - 1;
|
|
||||||
mqc_ct = 12;
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
mqc_ct = 13;
|
|
||||||
}
|
|
||||||
mqc_start = bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Set current context. */
|
|
||||||
/* </summary> */
|
|
||||||
/* <param name="ctxno">Context number.</param> */
|
|
||||||
void mqc_setcurctx(int ctxno)
|
|
||||||
{
|
|
||||||
mqc_curctx = &mqc_ctxs[ctxno];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Encode a symbol using the MQ-coder. */
|
|
||||||
/* </summary> */
|
|
||||||
/* <param name="d"> The symbol to be encoded (0 or 1).</param> */
|
|
||||||
void mqc_encode(int d)
|
|
||||||
{
|
|
||||||
if ((*mqc_curctx)->mps == d) {
|
|
||||||
mqc_codemps();
|
|
||||||
} else {
|
|
||||||
mqc_codelps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Fill mqc_c with 1's for flushing */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_setbits()
|
|
||||||
{
|
|
||||||
unsigned int tempc = mqc_c + mqc_a;
|
|
||||||
mqc_c |= 0xffff;
|
|
||||||
if (mqc_c >= tempc) {
|
|
||||||
mqc_c -= 0x8000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Flush encoded data. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_flush()
|
|
||||||
{
|
|
||||||
mqc_setbits();
|
|
||||||
mqc_c <<= mqc_ct;
|
|
||||||
mqc_byteout();
|
|
||||||
mqc_c <<= mqc_ct;
|
|
||||||
mqc_byteout();
|
|
||||||
|
|
||||||
if (*mqc_bp != 0xff) {
|
|
||||||
mqc_bp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* not fully implemented and tested !! */
|
|
||||||
/* BYPASS mode switch, initialization operation */
|
|
||||||
/* JPEG 2000 p 505 */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_bypass_init_enc()
|
|
||||||
{
|
|
||||||
mqc_c = 0;
|
|
||||||
mqc_ct = 8;
|
|
||||||
/*if (*mqc_bp == 0xff) {
|
|
||||||
mqc_ct = 7;
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* not fully implemented and tested !! */
|
|
||||||
/* BYPASS mode switch, coding operation */
|
|
||||||
/* JPEG 2000 p 505 */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_bypass_enc(int d)
|
|
||||||
{
|
|
||||||
mqc_ct--;
|
|
||||||
mqc_c = mqc_c + (d << mqc_ct);
|
|
||||||
if (mqc_ct == 0) {
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c;
|
|
||||||
mqc_ct = 8;
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
mqc_ct = 7;
|
|
||||||
}
|
|
||||||
mqc_c = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* not fully implemented and tested !! */
|
|
||||||
/* BYPASS mode switch, flush operation */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_bypass_flush_enc()
|
|
||||||
{
|
|
||||||
unsigned char bit_padding;
|
|
||||||
|
|
||||||
bit_padding = 0;
|
|
||||||
|
|
||||||
if (mqc_ct != 0) {
|
|
||||||
while (mqc_ct > 0) {
|
|
||||||
mqc_ct--;
|
|
||||||
mqc_c += bit_padding << mqc_ct;
|
|
||||||
bit_padding = (bit_padding + 1) & 0x01;
|
|
||||||
}
|
|
||||||
mqc_bp++;
|
|
||||||
*mqc_bp = mqc_c;
|
|
||||||
mqc_ct = 8;
|
|
||||||
mqc_c = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* RESET mode switch */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_reset_enc()
|
|
||||||
{
|
|
||||||
mqc_resetstates();
|
|
||||||
mqc_setstate(18, 0, 46);
|
|
||||||
mqc_setstate(0, 0, 3);
|
|
||||||
mqc_setstate(1, 0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* mode switch RESTART (TERMALL) */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_restart_enc()
|
|
||||||
{
|
|
||||||
int correction = 1;
|
|
||||||
|
|
||||||
/* <flush part> */
|
|
||||||
int n = 27 - 15 - mqc_ct;
|
|
||||||
mqc_c <<= mqc_ct;
|
|
||||||
while (n > 0) {
|
|
||||||
mqc_byteout();
|
|
||||||
n -= mqc_ct;
|
|
||||||
mqc_c <<= mqc_ct;
|
|
||||||
}
|
|
||||||
mqc_byteout();
|
|
||||||
|
|
||||||
return correction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* mode switch RESTART (TERMALL) reinitialisation */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_restart_init_enc()
|
|
||||||
{
|
|
||||||
/* <Re-init part> */
|
|
||||||
mqc_setcurctx(0);
|
|
||||||
mqc_a = 0x8000;
|
|
||||||
mqc_c = 0;
|
|
||||||
mqc_ct = 12;
|
|
||||||
mqc_bp--;
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
mqc_ct = 13;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* ERTERM mode switch */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_erterm_enc()
|
|
||||||
{
|
|
||||||
int k = 11 - mqc_ct + 1;
|
|
||||||
|
|
||||||
while (k > 0) {
|
|
||||||
mqc_c <<= mqc_ct;
|
|
||||||
mqc_ct = 0;
|
|
||||||
mqc_byteout();
|
|
||||||
k -= mqc_ct;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*mqc_bp != 0xff) {
|
|
||||||
mqc_byteout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* SEGMARK mode switch (SEGSYM) */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_segmark_enc()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
mqc_setcurctx(18);
|
|
||||||
|
|
||||||
for (i = 1; i < 5; i++) {
|
|
||||||
mqc_encode(i % 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_mpsexchange()
|
|
||||||
{
|
|
||||||
int d;
|
|
||||||
if (mqc_a < (*mqc_curctx)->qeval) {
|
|
||||||
d = 1 - (*mqc_curctx)->mps;
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nlps;
|
|
||||||
} else {
|
|
||||||
d = (*mqc_curctx)->mps;
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nmps;
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_lpsexchange()
|
|
||||||
{
|
|
||||||
int d;
|
|
||||||
if (mqc_a < (*mqc_curctx)->qeval) {
|
|
||||||
mqc_a = (*mqc_curctx)->qeval;
|
|
||||||
d = (*mqc_curctx)->mps;
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nmps;
|
|
||||||
} else {
|
|
||||||
mqc_a = (*mqc_curctx)->qeval;
|
|
||||||
d = 1 - (*mqc_curctx)->mps;
|
|
||||||
*mqc_curctx = (*mqc_curctx)->nlps;
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Input a byte. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_bytein()
|
|
||||||
{
|
|
||||||
if (mqc_bp != mqc_end) {
|
|
||||||
unsigned int c;
|
|
||||||
if (mqc_bp + 1 != mqc_end) {
|
|
||||||
c = *(mqc_bp + 1);
|
|
||||||
} else {
|
|
||||||
c = 0xff;
|
|
||||||
}
|
|
||||||
if (*mqc_bp == 0xff) {
|
|
||||||
if (c > 0x8f) {
|
|
||||||
mqc_c += 0xff00;
|
|
||||||
mqc_ct = 8;
|
|
||||||
} else {
|
|
||||||
mqc_bp++;
|
|
||||||
mqc_c += c << 9;
|
|
||||||
mqc_ct = 7;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc_bp++;
|
|
||||||
mqc_c += c << 8;
|
|
||||||
mqc_ct = 8;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc_c += 0xff00;
|
|
||||||
mqc_ct = 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Renormalize mqc_a and mqc_c while decoding. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_renormd()
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
if (mqc_ct == 0) {
|
|
||||||
mqc_bytein();
|
|
||||||
}
|
|
||||||
mqc_a <<= 1;
|
|
||||||
mqc_c <<= 1;
|
|
||||||
mqc_ct--;
|
|
||||||
} while (mqc_a < 0x8000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Initialize decoder. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_init_dec(unsigned char *bp, int len)
|
|
||||||
{
|
|
||||||
mqc_setcurctx(0);
|
|
||||||
mqc_start = bp;
|
|
||||||
mqc_end = bp + len;
|
|
||||||
mqc_bp = bp;
|
|
||||||
/*add antonin initbug1*/
|
|
||||||
if (len==0) mqc_c = 0xff << 16;
|
|
||||||
else mqc_c = *mqc_bp << 16;
|
|
||||||
/*dda*/
|
|
||||||
mqc_bytein();
|
|
||||||
mqc_c <<= 7;
|
|
||||||
mqc_ct -= 7;
|
|
||||||
mqc_a = 0x8000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Decode a symbol. */
|
|
||||||
/* </summary> */
|
|
||||||
int mqc_decode()
|
|
||||||
{
|
|
||||||
int d;
|
|
||||||
mqc_a -= (*mqc_curctx)->qeval;
|
|
||||||
if ((mqc_c >> 16) < (*mqc_curctx)->qeval) {
|
|
||||||
d = mqc_lpsexchange();
|
|
||||||
mqc_renormd();
|
|
||||||
} else {
|
|
||||||
mqc_c -= (*mqc_curctx)->qeval << 16;
|
|
||||||
if ((mqc_a & 0x8000) == 0) {
|
|
||||||
d = mqc_mpsexchange();
|
|
||||||
mqc_renormd();
|
|
||||||
} else {
|
|
||||||
d = (*mqc_curctx)->mps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Reset states of all contexts. */
|
|
||||||
/* </summary> */
|
|
||||||
void mqc_resetstates()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < MQC_NUMCTXS; i++) {
|
|
||||||
mqc_ctxs[i] = mqc_states;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Set the state for a context. */
|
|
||||||
/* </summary> */
|
|
||||||
/* <param name="ctxno">Context number</param> */
|
|
||||||
/* <param name="msb">Most significant bit</param> */
|
|
||||||
/* <param name="prob">Index to the probability of symbols</param> */
|
|
||||||
void mqc_setstate(int ctxno, int msb, int prob)
|
|
||||||
{
|
|
||||||
mqc_ctxs[ctxno] = &mqc_states[msb + (prob << 1)];
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __MQC_H
|
|
||||||
#define __MQC_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the number of bytes written/read since initialisation
|
|
||||||
*/
|
|
||||||
int mqc_numbytes();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reset the states of all the context of the coder/decoder
|
|
||||||
* (each context is set to a state where 0 and 1 are more or less equiprobable)
|
|
||||||
*/
|
|
||||||
void mqc_resetstates();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the state of a particular context
|
|
||||||
* ctxno: number that identifies the context
|
|
||||||
* msb: the MSB of the new state of the context
|
|
||||||
* prob: number that identifies the probability of the symbols for the new state of the context
|
|
||||||
*/
|
|
||||||
void mqc_setstate(int ctxno, int msb, int prob);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the encoder
|
|
||||||
* bp: pointer to the start of the buffer where the bytes will be written
|
|
||||||
*/
|
|
||||||
void mqc_init_enc(unsigned char *bp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the current context used for coding/decoding
|
|
||||||
* ctxno: number that identifies the context
|
|
||||||
*/
|
|
||||||
void mqc_setcurctx(int ctxno);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode a bit
|
|
||||||
* d: bit to encode (0 or 1)
|
|
||||||
*/
|
|
||||||
void mqc_encode(int d);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flush the encoder, so that all remaining data is written
|
|
||||||
*/
|
|
||||||
void mqc_flush();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BYPASS mode switch
|
|
||||||
*/
|
|
||||||
void mqc_bypass_init_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BYPASS mode switch
|
|
||||||
*/
|
|
||||||
void mqc_bypass_enc(int d);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BYPASS mode switch
|
|
||||||
*/
|
|
||||||
int mqc_bypass_flush_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RESET mode switch
|
|
||||||
*/
|
|
||||||
void mqc_reset_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RESTART mode switch (TERMALL)
|
|
||||||
*/
|
|
||||||
int mqc_restart_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RESTART mode switch (TERMALL)
|
|
||||||
*/
|
|
||||||
void mqc_restart_init_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ERTERM mode switch (PTERM)
|
|
||||||
*/
|
|
||||||
void mqc_erterm_enc();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SEGMARK mode switch (SEGSYM)
|
|
||||||
*/
|
|
||||||
void mqc_segmark_enc();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the decoder
|
|
||||||
* bp: pointer to the start of the buffer from which the bytes will be read
|
|
||||||
* len: length of the input buffer
|
|
||||||
*/
|
|
||||||
void mqc_init_dec(unsigned char *bp, int len);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode a bit (returns 0 or 1)
|
|
||||||
*/
|
|
||||||
int mqc_decode();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
557
libopenjpeg/pi.c
557
libopenjpeg/pi.c
@@ -1,557 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
|
||||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pi.h"
|
|
||||||
#include "int.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Create a packet iterator.
|
|
||||||
* </summary> */
|
|
||||||
pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno)
|
|
||||||
{
|
|
||||||
int p, q, i;
|
|
||||||
int compno, resno, pino;
|
|
||||||
int maxres = 0;
|
|
||||||
pi_iterator_t *pi;
|
|
||||||
j2k_tcp_t *tcp;
|
|
||||||
j2k_tccp_t *tccp;
|
|
||||||
|
|
||||||
tcp = &cp->tcps[tileno];
|
|
||||||
pi = (pi_iterator_t *) malloc((tcp->numpocs + 1) *
|
|
||||||
sizeof(pi_iterator_t));
|
|
||||||
|
|
||||||
for (pino = 0; pino < tcp->numpocs + 1; pino++) { /* change */
|
|
||||||
p = tileno % cp->tw;
|
|
||||||
q = tileno / cp->tw;
|
|
||||||
|
|
||||||
pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, img->x0);
|
|
||||||
pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, img->y0);
|
|
||||||
pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, img->x1);
|
|
||||||
pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, img->y1);
|
|
||||||
pi[pino].numcomps = img->numcomps;
|
|
||||||
pi[pino].comps =
|
|
||||||
(pi_comp_t *) malloc(img->numcomps * sizeof(pi_comp_t));
|
|
||||||
|
|
||||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
|
||||||
int tcx0, tcy0, tcx1, tcy1;
|
|
||||||
pi_comp_t *comp = &pi[pino].comps[compno];
|
|
||||||
tccp = &tcp->tccps[compno];
|
|
||||||
comp->dx = img->comps[compno].dx;
|
|
||||||
comp->dy = img->comps[compno].dy;
|
|
||||||
comp->numresolutions = tccp->numresolutions;
|
|
||||||
comp->resolutions =
|
|
||||||
(pi_resolution_t *) malloc(comp->numresolutions *
|
|
||||||
sizeof(pi_resolution_t));
|
|
||||||
tcx0 = int_ceildiv(pi->tx0, comp->dx);
|
|
||||||
tcy0 = int_ceildiv(pi->ty0, comp->dy);
|
|
||||||
tcx1 = int_ceildiv(pi->tx1, comp->dx);
|
|
||||||
tcy1 = int_ceildiv(pi->ty1, comp->dy);
|
|
||||||
if (comp->numresolutions > maxres) {
|
|
||||||
maxres = comp->numresolutions;
|
|
||||||
}
|
|
||||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
|
||||||
int levelno;
|
|
||||||
int rx0, ry0, rx1, ry1;
|
|
||||||
int px0, py0, px1, py1;
|
|
||||||
pi_resolution_t *res = &comp->resolutions[resno];
|
|
||||||
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
|
||||||
res->pdx = tccp->prcw[resno];
|
|
||||||
res->pdy = tccp->prch[resno];
|
|
||||||
} else {
|
|
||||||
res->pdx = 15;
|
|
||||||
res->pdy = 15;
|
|
||||||
}
|
|
||||||
levelno = comp->numresolutions - 1 - resno;
|
|
||||||
rx0 = int_ceildivpow2(tcx0, levelno);
|
|
||||||
ry0 = int_ceildivpow2(tcy0, levelno);
|
|
||||||
rx1 = int_ceildivpow2(tcx1, levelno);
|
|
||||||
ry1 = int_ceildivpow2(tcy1, levelno);
|
|
||||||
px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
|
|
||||||
py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
|
|
||||||
px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
|
|
||||||
py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
|
|
||||||
res->pw = (rx0==rx1)?0:((px1 - px0) >> res->pdx); /*Mod Antonin : sizebug1*/
|
|
||||||
res->ph = (ry0==ry1)?0:((py1 - py0) >> res->pdy); /*Mod Antonin : sizebug1*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tccp = &tcp->tccps[0];
|
|
||||||
pi[pino].step_p = 1;
|
|
||||||
pi[pino].step_c = 100 * pi[pino].step_p;
|
|
||||||
pi[pino].step_r = img->numcomps * pi[pino].step_c;
|
|
||||||
pi[pino].step_l = maxres * pi[pino].step_r;
|
|
||||||
|
|
||||||
if (pino == 0) {
|
|
||||||
pi[pino].include =
|
|
||||||
(short int *) malloc(img->numcomps * maxres *
|
|
||||||
tcp->numlayers * 100 * sizeof(short int));
|
|
||||||
for (i = 0; i < img->numcomps * maxres * tcp->numlayers * 100; i++)
|
|
||||||
pi[pino].include[i] = 0;
|
|
||||||
}
|
|
||||||
/* pi[pino].include=(short int*)calloc(img->numcomps*maxres*tcp->numlayers*1000,sizeof(short int)); */
|
|
||||||
else
|
|
||||||
pi[pino].include = pi[pino - 1].include;
|
|
||||||
|
|
||||||
if (tcp->POC == 0) {
|
|
||||||
pi[pino].first = 1;
|
|
||||||
pi[pino].poc.resno0 = 0;
|
|
||||||
pi[pino].poc.compno0 = 0;
|
|
||||||
pi[pino].poc.layno1 = tcp->numlayers;
|
|
||||||
pi[pino].poc.resno1 = maxres;
|
|
||||||
pi[pino].poc.compno1 = img->numcomps;
|
|
||||||
pi[pino].poc.prg = tcp->prg;
|
|
||||||
} else {
|
|
||||||
pi[pino].first = 1;
|
|
||||||
pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
|
|
||||||
pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
|
|
||||||
pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
|
|
||||||
pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
|
|
||||||
pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
|
|
||||||
pi[pino].poc.prg = tcp->pocs[pino].prg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet in layer-resolution-component-precinct order.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next_lrcp(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
pi_comp_t *comp;
|
|
||||||
pi_resolution_t *res;
|
|
||||||
|
|
||||||
if (!pi->first) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
goto skip;
|
|
||||||
} else {
|
|
||||||
pi->first = 0;
|
|
||||||
}
|
|
||||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
|
||||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
|
|
||||||
pi->resno++) {
|
|
||||||
for (pi->compno = pi->poc.compno0;
|
|
||||||
pi->compno < pi->poc.compno1; pi->compno++) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
if (pi->resno >= comp->numresolutions) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
|
|
||||||
if (!pi->
|
|
||||||
include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c + pi->precno * pi->step_p]) {
|
|
||||||
pi->include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
skip:;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet in resolution-layer-component-precinct order.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next_rlcp(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
pi_comp_t *comp;
|
|
||||||
pi_resolution_t *res;
|
|
||||||
if (!pi->first) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
goto skip;
|
|
||||||
} else {
|
|
||||||
pi->first = 0;
|
|
||||||
}
|
|
||||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
|
|
||||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
|
||||||
for (pi->compno = pi->poc.compno0;
|
|
||||||
pi->compno < pi->poc.compno1; pi->compno++) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
if (pi->resno >= comp->numresolutions) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
|
|
||||||
if (!pi->
|
|
||||||
include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c + pi->precno * pi->step_p]) {
|
|
||||||
pi->include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
skip:;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet in resolution-precinct-component-layer order.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next_rpcl(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
pi_comp_t *comp;
|
|
||||||
pi_resolution_t *res;
|
|
||||||
if (!pi->first) {
|
|
||||||
goto skip;
|
|
||||||
} else {
|
|
||||||
int compno, resno;
|
|
||||||
pi->first = 0;
|
|
||||||
pi->dx = 0;
|
|
||||||
pi->dy = 0;
|
|
||||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
|
||||||
comp = &pi->comps[compno];
|
|
||||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
|
||||||
int dx, dy;
|
|
||||||
res = &comp->resolutions[resno];
|
|
||||||
dx = comp->dx *
|
|
||||||
(1 << (res->pdx + comp->numresolutions - 1 - resno));
|
|
||||||
dy = comp->dy *
|
|
||||||
(1 << (res->pdy + comp->numresolutions - 1 - resno));
|
|
||||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
|
||||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
|
|
||||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
|
||||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
|
||||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
|
||||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
|
||||||
for (pi->compno = pi->poc.compno0;
|
|
||||||
pi->compno < pi->poc.compno1; pi->compno++) {
|
|
||||||
int levelno;
|
|
||||||
int trx0, try0;
|
|
||||||
int trx1, try1;/* Add antonin pcrl*/
|
|
||||||
int rpx, rpy;
|
|
||||||
int prci, prcj;
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
if (pi->resno >= comp->numresolutions) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
levelno = comp->numresolutions - 1 - pi->resno;
|
|
||||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
|
||||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
|
||||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
|
||||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
|
||||||
rpx = res->pdx + levelno;
|
|
||||||
rpy = res->pdy + levelno;
|
|
||||||
if (!
|
|
||||||
(pi->x % (comp->dx << rpx) == 0
|
|
||||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!
|
|
||||||
(pi->y % (comp->dy << rpy) == 0
|
|
||||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
if ((res->pw==0)||(res->pw==0)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
/*Add Antonin : pcrl*/
|
|
||||||
if ((trx0==trx1)||(try0==try1)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
prci =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->x, comp->dx << levelno),
|
|
||||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
|
||||||
prcj =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->y, comp->dy << levelno),
|
|
||||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
|
||||||
pi->precno = prci + prcj * res->pw;
|
|
||||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
|
||||||
if (!pi->
|
|
||||||
include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p]) {
|
|
||||||
pi->include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
skip:;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet in precinct-component-resolution-layer order.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next_pcrl(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
pi_comp_t *comp;
|
|
||||||
pi_resolution_t *res;
|
|
||||||
if (!pi->first) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
goto skip;
|
|
||||||
} else {
|
|
||||||
int compno, resno;
|
|
||||||
pi->first = 0;
|
|
||||||
pi->dx = 0;
|
|
||||||
pi->dy = 0;
|
|
||||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
|
||||||
comp = &pi->comps[compno];
|
|
||||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
|
||||||
int dx, dy;
|
|
||||||
res = &comp->resolutions[resno];
|
|
||||||
dx = comp->dx *
|
|
||||||
(1 << (res->pdx + comp->numresolutions - 1 - resno));
|
|
||||||
dy = comp->dy *
|
|
||||||
(1 << (res->pdy + comp->numresolutions - 1 - resno));
|
|
||||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
|
||||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
|
||||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
|
||||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
|
||||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
|
||||||
for (pi->compno = pi->poc.compno0;
|
|
||||||
pi->compno < pi->poc.compno1; pi->compno++) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
for (pi->resno = pi->poc.resno0;
|
|
||||||
pi->resno < int_min(pi->poc.resno1,
|
|
||||||
comp->numresolutions); pi->resno++) {
|
|
||||||
int levelno;
|
|
||||||
int trx0, try0;
|
|
||||||
int trx1, try1;/* Add antonin pcrl*/
|
|
||||||
int rpx, rpy;
|
|
||||||
int prci, prcj;
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
levelno = comp->numresolutions - 1 - pi->resno;
|
|
||||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
|
||||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
|
||||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
|
||||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
|
||||||
rpx = res->pdx + levelno;
|
|
||||||
rpy = res->pdy + levelno;
|
|
||||||
if (!
|
|
||||||
(pi->x % (comp->dx << rpx) == 0
|
|
||||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!
|
|
||||||
(pi->y % (comp->dy << rpy) == 0
|
|
||||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
if ((res->pw==0)||(res->pw==0)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
/*Add Antonin : pcrl*/
|
|
||||||
if ((trx0==trx1)||(try0==try1)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
prci =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->x, comp->dx << levelno),
|
|
||||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
|
||||||
prcj =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->y, comp->dy << levelno),
|
|
||||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
|
||||||
pi->precno = prci + prcj * res->pw;
|
|
||||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
|
||||||
if (!pi->
|
|
||||||
include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p]) {
|
|
||||||
pi->include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
skip:;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet in component-precinct-resolution-layer order.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next_cprl(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
pi_comp_t *comp;
|
|
||||||
pi_resolution_t *res;
|
|
||||||
if (!pi->first) {
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
goto skip;
|
|
||||||
} else {
|
|
||||||
pi->first = 0;
|
|
||||||
}
|
|
||||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
|
||||||
pi->compno++) {
|
|
||||||
int resno;
|
|
||||||
comp = &pi->comps[pi->compno];
|
|
||||||
pi->dx = 0;
|
|
||||||
pi->dy = 0;
|
|
||||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
|
||||||
int dx, dy;
|
|
||||||
res = &comp->resolutions[resno];
|
|
||||||
dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
|
|
||||||
dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
|
|
||||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
|
||||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
|
||||||
}
|
|
||||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
|
||||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
|
||||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
|
||||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
|
||||||
for (pi->resno = pi->poc.resno0;
|
|
||||||
pi->resno < int_min(pi->poc.resno1,
|
|
||||||
comp->numresolutions); pi->resno++) {
|
|
||||||
int levelno;
|
|
||||||
int trx0, try0;
|
|
||||||
int trx1, try1;/* Add antonin pcrl*/
|
|
||||||
int rpx, rpy;
|
|
||||||
int prci, prcj;
|
|
||||||
res = &comp->resolutions[pi->resno];
|
|
||||||
levelno = comp->numresolutions - 1 - pi->resno;
|
|
||||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
|
||||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
|
||||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
|
||||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
|
||||||
rpx = res->pdx + levelno;
|
|
||||||
rpy = res->pdy + levelno;
|
|
||||||
if (!
|
|
||||||
(pi->x % (comp->dx << rpx) == 0
|
|
||||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!
|
|
||||||
(pi->y % (comp->dy << rpy) == 0
|
|
||||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
if ((res->pw==0)||(res->pw==0)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
/*Add Antonin : pcrl*/
|
|
||||||
if ((trx0==trx1)||(try0==try1)) continue;
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
prci =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->x, comp->dx << levelno),
|
|
||||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
|
||||||
prcj =
|
|
||||||
int_floordivpow2(int_ceildiv
|
|
||||||
(pi->y, comp->dy << levelno),
|
|
||||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
|
||||||
pi->precno = prci + prcj * res->pw;
|
|
||||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
|
||||||
if (!pi->
|
|
||||||
include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p]) {
|
|
||||||
pi->include[pi->layno * pi->step_l +
|
|
||||||
pi->resno * pi->step_r +
|
|
||||||
pi->compno * pi->step_c +
|
|
||||||
pi->precno * pi->step_p] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
skip:;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary>
|
|
||||||
* Get next packet.
|
|
||||||
*
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* </summary> */
|
|
||||||
int pi_next(pi_iterator_t * pi)
|
|
||||||
{
|
|
||||||
switch (pi->poc.prg) {
|
|
||||||
case 0:
|
|
||||||
return pi_next_lrcp(pi);
|
|
||||||
case 1:
|
|
||||||
return pi_next_rlcp(pi);
|
|
||||||
case 2:
|
|
||||||
return pi_next_rpcl(pi);
|
|
||||||
case 3:
|
|
||||||
return pi_next_pcrl(pi);
|
|
||||||
case 4:
|
|
||||||
return pi_next_cprl(pi);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 __PI_H
|
|
||||||
#define __PI_H
|
|
||||||
|
|
||||||
#include "j2k.h"
|
|
||||||
#include "tcd.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int pdx, pdy;
|
|
||||||
int pw, ph;
|
|
||||||
} pi_resolution_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int dx, dy;
|
|
||||||
int numresolutions;
|
|
||||||
pi_resolution_t *resolutions;
|
|
||||||
} pi_comp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
short int *include; /* precise if the packet has been already used (usefull for progression order change) */
|
|
||||||
int step_l, step_r, step_c, step_p; /* different steps (layer, resolution, component, precinct) to localize the packet in the include vector */
|
|
||||||
int compno, resno, precno, layno; /* component, resolution, precinct and layer that indentify the packet */
|
|
||||||
int first; /* 0 if the first packet */
|
|
||||||
j2k_poc_t poc;
|
|
||||||
int numcomps;
|
|
||||||
pi_comp_t *comps;
|
|
||||||
int tx0, ty0, tx1, ty1;
|
|
||||||
int x, y, dx, dy;
|
|
||||||
} pi_iterator_t; /* packet iterator */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a packet iterator
|
|
||||||
* img: raw image for which the packets will be listed
|
|
||||||
* cp: coding paremeters
|
|
||||||
* tileno: number that identifies the tile for which to list the packets
|
|
||||||
* return value: returns a packet iterator that points to the first packet of the tile
|
|
||||||
*/
|
|
||||||
pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modify the packet iterator to point to the next packet
|
|
||||||
* pi: packet iterator to modify
|
|
||||||
* return value: returns 0 if pi pointed to the last packet or else returns 1
|
|
||||||
*/
|
|
||||||
int pi_next(pi_iterator_t * pi);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
1117
libopenjpeg/t1.c
1117
libopenjpeg/t1.c
File diff suppressed because it is too large
Load Diff
707
libopenjpeg/t2.c
707
libopenjpeg/t2.c
@@ -1,707 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2004, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "t2.h"
|
|
||||||
#include "tcd.h"
|
|
||||||
#include "bio.h"
|
|
||||||
#include "j2k.h"
|
|
||||||
#include "pi.h"
|
|
||||||
#include "tgt.h"
|
|
||||||
#include "int.h"
|
|
||||||
#include "cio.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define RESTART 0x04
|
|
||||||
|
|
||||||
extern jmp_buf j2k_error;
|
|
||||||
|
|
||||||
void t2_putcommacode(int n)
|
|
||||||
{
|
|
||||||
while (--n >= 0) {
|
|
||||||
bio_write(1, 1);
|
|
||||||
}
|
|
||||||
bio_write(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int t2_getcommacode()
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
for (n = 0; bio_read(1); n++) {
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Variable length code for signalling delta Zil (truncation point) */
|
|
||||||
/* <val> n : delta Zil */
|
|
||||||
/* <\summary> */
|
|
||||||
void t2_putnumpasses(int n)
|
|
||||||
{
|
|
||||||
if (n == 1) {
|
|
||||||
bio_write(0, 1);
|
|
||||||
} else if (n == 2) {
|
|
||||||
bio_write(2, 2);
|
|
||||||
} else if (n <= 5) {
|
|
||||||
bio_write(0xc | (n - 3), 4);
|
|
||||||
} else if (n <= 36) {
|
|
||||||
bio_write(0x1e0 | (n - 6), 9);
|
|
||||||
} else if (n <= 164) {
|
|
||||||
bio_write(0xff80 | (n - 37), 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int t2_getnumpasses()
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
if (!bio_read(1))
|
|
||||||
return 1;
|
|
||||||
if (!bio_read(1))
|
|
||||||
return 2;
|
|
||||||
if ((n = bio_read(2)) != 3)
|
|
||||||
return 3 + n;
|
|
||||||
if ((n = bio_read(5)) != 31)
|
|
||||||
return 6 + n;
|
|
||||||
return 37 + bio_read(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode a packet of a tile to a destination buffer
|
|
||||||
*
|
|
||||||
* Tile : the tile for which to write the packets
|
|
||||||
* tcp : the tile coding parameters
|
|
||||||
* compno : Identity of the packet --> component value
|
|
||||||
* resno : Identity of the packet --> resolution level value
|
|
||||||
* precno : Identity of the packet --> precinct value
|
|
||||||
* layno : Identity of the packet --> quality layer value
|
|
||||||
* dest : the destination buffer
|
|
||||||
* len : the length of the destination buffer
|
|
||||||
* info_IM : structure to create an index file
|
|
||||||
* tileno : number of the tile encoded
|
|
||||||
*/
|
|
||||||
int t2_encode_packet(tcd_tile_t * tile, j2k_tcp_t * tcp, int compno,
|
|
||||||
int resno, int precno, int layno, unsigned char *dest,
|
|
||||||
int len, info_image * info_IM, int tileno)
|
|
||||||
{
|
|
||||||
int bandno, cblkno;
|
|
||||||
unsigned char *sop = 0, *eph = 0;
|
|
||||||
tcd_tilecomp_t *tilec = &tile->comps[compno];
|
|
||||||
tcd_resolution_t *res = &tilec->resolutions[resno];
|
|
||||||
unsigned char *c = dest;
|
|
||||||
|
|
||||||
/* <SOP 0xff91> */
|
|
||||||
if (tcp->csty & J2K_CP_CSTY_SOP) {
|
|
||||||
sop = (unsigned char *) malloc(6 * sizeof(unsigned char));
|
|
||||||
sop[0] = 255;
|
|
||||||
sop[1] = 145;
|
|
||||||
sop[2] = 0;
|
|
||||||
sop[3] = 4;
|
|
||||||
sop[4] = (info_IM->num % 65536) / 256;
|
|
||||||
sop[5] = (info_IM->num % 65536) % 256;
|
|
||||||
memcpy(c, sop, 6);
|
|
||||||
free(sop);
|
|
||||||
c += 6;
|
|
||||||
}
|
|
||||||
/* </SOP> */
|
|
||||||
|
|
||||||
if (!layno) {
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
tgt_reset(prc->incltree);
|
|
||||||
tgt_reset(prc->imsbtree);
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
cblk->numpasses = 0;
|
|
||||||
tgt_setvalue(prc->imsbtree, cblkno, band->numbps - cblk->numbps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bio_init_enc(c, len);
|
|
||||||
bio_write(1, 1); /* Empty header bit */
|
|
||||||
|
|
||||||
/* Writing Packet header */
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
tcd_layer_t *layer = &cblk->layers[layno];
|
|
||||||
if (!cblk->numpasses && layer->numpasses) {
|
|
||||||
tgt_setvalue(prc->incltree, cblkno, layno);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
tcd_layer_t *layer = &cblk->layers[layno];
|
|
||||||
int increment = 0;
|
|
||||||
int nump = 0;
|
|
||||||
int len = 0, passno;
|
|
||||||
/* cblk inclusion bits */
|
|
||||||
if (!cblk->numpasses) {
|
|
||||||
tgt_encode(prc->incltree, cblkno, layno + 1);
|
|
||||||
} else {
|
|
||||||
bio_write(layer->numpasses != 0, 1);
|
|
||||||
}
|
|
||||||
/* if cblk not included, go to the next cblk */
|
|
||||||
if (!layer->numpasses) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* if first instance of cblk --> zero bit-planes information */
|
|
||||||
if (!cblk->numpasses) {
|
|
||||||
cblk->numlenbits = 3;
|
|
||||||
tgt_encode(prc->imsbtree, cblkno, 999);
|
|
||||||
}
|
|
||||||
/* number of coding passes included */
|
|
||||||
t2_putnumpasses(layer->numpasses);
|
|
||||||
|
|
||||||
/* computation of the increase of the length indicator and insertion in the header */
|
|
||||||
for (passno = cblk->numpasses;
|
|
||||||
passno < cblk->numpasses + layer->numpasses; passno++) {
|
|
||||||
tcd_pass_t *pass = &cblk->passes[passno];
|
|
||||||
nump++;
|
|
||||||
len += pass->len;
|
|
||||||
if (pass->term
|
|
||||||
|| passno == (cblk->numpasses + layer->numpasses) - 1) {
|
|
||||||
increment =
|
|
||||||
int_max(increment,
|
|
||||||
int_floorlog2(len) + 1 -
|
|
||||||
(cblk->numlenbits + int_floorlog2(nump)));
|
|
||||||
len = 0;
|
|
||||||
nump = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t2_putcommacode(increment);
|
|
||||||
/* computation of the new Length indicator */
|
|
||||||
cblk->numlenbits += increment;
|
|
||||||
/* insertion of the codeword segment length */
|
|
||||||
|
|
||||||
for (passno = cblk->numpasses;
|
|
||||||
passno < cblk->numpasses + layer->numpasses; passno++) {
|
|
||||||
tcd_pass_t *pass = &cblk->passes[passno];
|
|
||||||
nump++;
|
|
||||||
len += pass->len;
|
|
||||||
if (pass->term
|
|
||||||
|| passno == (cblk->numpasses + layer->numpasses) - 1) {
|
|
||||||
bio_write(len, cblk->numlenbits + int_floorlog2(nump));
|
|
||||||
len = 0;
|
|
||||||
nump = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bio_flush())
|
|
||||||
return -999; /* modified to eliminate longjmp !! */
|
|
||||||
|
|
||||||
c += bio_numbytes();
|
|
||||||
|
|
||||||
/* <EPH 0xff92> */
|
|
||||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
|
||||||
eph = (unsigned char *) malloc(2 * sizeof(unsigned char));
|
|
||||||
eph[0] = 255;
|
|
||||||
eph[1] = 146;
|
|
||||||
memcpy(c, eph, 2);
|
|
||||||
free(eph);
|
|
||||||
c += 2;
|
|
||||||
}
|
|
||||||
/* </EPH> */
|
|
||||||
|
|
||||||
/* Writing the packet body */
|
|
||||||
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
tcd_layer_t *layer = &cblk->layers[layno];
|
|
||||||
if (!layer->numpasses) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c + layer->len > dest + len) {
|
|
||||||
return -999;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(c, layer->data, layer->len);
|
|
||||||
cblk->numpasses += layer->numpasses;
|
|
||||||
c += layer->len;
|
|
||||||
/* ADD for index Cfr. Marcela --> delta disto by packet */
|
|
||||||
if (info_IM->index_write && info_IM->index_on) {
|
|
||||||
info_tile *info_TL = &info_IM->tile[tileno];
|
|
||||||
info_packet *info_PK = &info_TL->packet[info_IM->num];
|
|
||||||
info_PK->disto += layer->disto;
|
|
||||||
if (info_IM->D_max < info_PK->disto)
|
|
||||||
info_IM->D_max = info_PK->disto;
|
|
||||||
} /* </ADD> */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c - dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
void t2_init_seg(tcd_seg_t * seg, int cblksty, int first)
|
|
||||||
{
|
|
||||||
seg->numpasses = 0;
|
|
||||||
seg->len = 0;
|
|
||||||
if (cblksty & J2K_CCP_CBLKSTY_TERMALL)
|
|
||||||
seg->maxpasses = 1;
|
|
||||||
else if (cblksty & J2K_CCP_CBLKSTY_LAZY) {
|
|
||||||
if (first)
|
|
||||||
seg->maxpasses = 10;
|
|
||||||
else
|
|
||||||
seg->maxpasses = (((seg - 1)->maxpasses == 1)
|
|
||||||
|| ((seg - 1)->maxpasses == 10)) ? 2 : 1;
|
|
||||||
} else
|
|
||||||
seg->maxpasses = 109;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode a packet of a tile from a source buffer
|
|
||||||
*
|
|
||||||
* src : the source buffer
|
|
||||||
* len : the length of the source buffer
|
|
||||||
* tile : the tile for which to write the packets
|
|
||||||
* cp : the image coding parameters
|
|
||||||
* tcp : the tile coding parameters
|
|
||||||
* compno : Identity of the packet --> component value
|
|
||||||
* resno : Identity of the packet --> resolution level value
|
|
||||||
* precno : Identity of the packet --> precinct value
|
|
||||||
* layno : Identity of the packet --> quality layer value
|
|
||||||
*/
|
|
||||||
int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|
||||||
j2k_cp_t * cp, j2k_tcp_t * tcp, int compno, int resno,
|
|
||||||
int precno, int layno)
|
|
||||||
{
|
|
||||||
int bandno, cblkno;
|
|
||||||
tcd_tilecomp_t *tilec = &tile->comps[compno];
|
|
||||||
tcd_resolution_t *res = &tilec->resolutions[resno];
|
|
||||||
unsigned char *c = src;
|
|
||||||
|
|
||||||
unsigned char *hd = NULL;
|
|
||||||
int present;
|
|
||||||
|
|
||||||
if (layno == 0) {
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
|
|
||||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
|
||||||
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
|
|
||||||
tgt_reset(prc->incltree);
|
|
||||||
tgt_reset(prc->imsbtree);
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
cblk->numsegs = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* SOP markers*/
|
|
||||||
|
|
||||||
if (tcp->csty & J2K_CP_CSTY_SOP) {
|
|
||||||
|
|
||||||
if ((*c) != 0xff || (*(c + 1) != 0x91)) {
|
|
||||||
|
|
||||||
fprintf(stderr,"Warning : expected SOP marker\n");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
c += 6;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*TODO : check the Nsop value*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
|
|
||||||
This part deal with this caracteristic
|
|
||||||
step 1: Read packet header in the saved structure
|
|
||||||
step 2: Return to codestream for decoding */
|
|
||||||
|
|
||||||
|
|
||||||
if (cp->ppm == 1) { /* PPM */
|
|
||||||
hd = cp->ppm_data;
|
|
||||||
bio_init_dec(hd, cp->ppm_len); /*Mod Antonin : ppmbug1*/
|
|
||||||
} else if (tcp->ppt == 1) { /* PPT */
|
|
||||||
hd = tcp->ppt_data;
|
|
||||||
bio_init_dec(hd, tcp->ppt_len); /*Mod Antonin : ppmbug1*/
|
|
||||||
} else { /* Normal Case */
|
|
||||||
|
|
||||||
hd = c;
|
|
||||||
|
|
||||||
bio_init_dec(hd, src+len-hd);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
present = bio_read(1);
|
|
||||||
|
|
||||||
if (!present) {
|
|
||||||
bio_inalign();
|
|
||||||
|
|
||||||
hd += bio_numbytes();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EPH markers*/
|
|
||||||
|
|
||||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
|
||||||
|
|
||||||
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
|
|
||||||
|
|
||||||
printf("Error : expected EPH marker\n");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
hd += 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cp->ppm == 1) { /* PPM case */
|
|
||||||
|
|
||||||
cp->ppm_len+=cp->ppm_data-hd;
|
|
||||||
cp->ppm_data = hd;
|
|
||||||
return c - src;
|
|
||||||
}
|
|
||||||
if (tcp->ppt == 1) { /* PPT case */
|
|
||||||
|
|
||||||
tcp->ppt_len+=tcp->ppt_data-hd;
|
|
||||||
tcp->ppt_data = hd;
|
|
||||||
return c - src;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return hd - src;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
|
|
||||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
|
||||||
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
int included, increment, n;
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
tcd_seg_t *seg;
|
|
||||||
/* if cblk not yet included before --> inclusion tagtree */
|
|
||||||
if (!cblk->numsegs) {
|
|
||||||
included = tgt_decode(prc->incltree, cblkno, layno + 1);
|
|
||||||
/* else one bit */
|
|
||||||
} else {
|
|
||||||
included = bio_read(1);
|
|
||||||
}
|
|
||||||
/* if cblk not included */
|
|
||||||
if (!included) {
|
|
||||||
cblk->numnewpasses = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* if cblk not yet included --> zero-bitplane tagtree */
|
|
||||||
if (!cblk->numsegs) {
|
|
||||||
int i, numimsbs;
|
|
||||||
for (i = 0; !tgt_decode(prc->imsbtree, cblkno, i); i++) {
|
|
||||||
}
|
|
||||||
numimsbs = i - 1;
|
|
||||||
cblk->numbps = band->numbps - numimsbs;
|
|
||||||
cblk->numlenbits = 3;
|
|
||||||
}
|
|
||||||
/* number of coding passes */
|
|
||||||
cblk->numnewpasses = t2_getnumpasses();
|
|
||||||
increment = t2_getcommacode();
|
|
||||||
/* length indicator increment */
|
|
||||||
cblk->numlenbits += increment;
|
|
||||||
if (!cblk->numsegs) {
|
|
||||||
seg = &cblk->segs[0];
|
|
||||||
t2_init_seg(seg, tcp->tccps[compno].cblksty, 1);
|
|
||||||
} else {
|
|
||||||
seg = &cblk->segs[cblk->numsegs - 1];
|
|
||||||
if (seg->numpasses == seg->maxpasses) {
|
|
||||||
t2_init_seg(++seg, tcp->tccps[compno].cblksty, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n = cblk->numnewpasses;
|
|
||||||
|
|
||||||
do {
|
|
||||||
seg->numnewpasses = int_min(seg->maxpasses - seg->numpasses, n);
|
|
||||||
seg->newlen =
|
|
||||||
bio_read(cblk->numlenbits + int_floorlog2(seg->numnewpasses));
|
|
||||||
n -= seg->numnewpasses;
|
|
||||||
if (n > 0) {
|
|
||||||
t2_init_seg(++seg, tcp->tccps[compno].cblksty, 0);
|
|
||||||
}
|
|
||||||
} while (n > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bio_inalign())
|
|
||||||
return -999;
|
|
||||||
|
|
||||||
hd += bio_numbytes();
|
|
||||||
|
|
||||||
|
|
||||||
/* EPH markers*/
|
|
||||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
|
||||||
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
|
|
||||||
fprintf(stderr,"Error : expected EPH marker\n");
|
|
||||||
} else {
|
|
||||||
hd += 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cp->ppm==1) {
|
|
||||||
|
|
||||||
cp->ppm_len+=cp->ppm_data-hd;
|
|
||||||
|
|
||||||
cp->ppm_data = hd;
|
|
||||||
|
|
||||||
} else if (tcp->ppt == 1) {
|
|
||||||
|
|
||||||
tcp->ppt_len+=tcp->ppt_data-hd;
|
|
||||||
|
|
||||||
tcp->ppt_data = hd;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
c=hd;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
|
||||||
tcd_band_t *band = &res->bands[bandno];
|
|
||||||
tcd_precinct_t *prc = &band->precincts[precno];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*Add Antonin : sizebug1*/
|
|
||||||
|
|
||||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
|
||||||
|
|
||||||
/*ddA*/
|
|
||||||
|
|
||||||
|
|
||||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
|
||||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
|
||||||
tcd_seg_t *seg;
|
|
||||||
if (!cblk->numnewpasses)
|
|
||||||
continue;
|
|
||||||
if (!cblk->numsegs) {
|
|
||||||
seg = &cblk->segs[0];
|
|
||||||
|
|
||||||
cblk->numsegs++;
|
|
||||||
cblk->len = 0;
|
|
||||||
} else {
|
|
||||||
seg = &cblk->segs[cblk->numsegs - 1];
|
|
||||||
if (seg->numpasses == seg->maxpasses) {
|
|
||||||
seg++;
|
|
||||||
cblk->numsegs++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
if (c + seg->newlen > src + len) {
|
|
||||||
return -999;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(cblk->data + cblk->len, c, seg->newlen);
|
|
||||||
if (seg->numpasses == 0) {
|
|
||||||
seg->data = cblk->data + cblk->len;
|
|
||||||
}
|
|
||||||
c += seg->newlen;
|
|
||||||
cblk->len += seg->newlen;
|
|
||||||
seg->len += seg->newlen;
|
|
||||||
seg->numpasses += seg->numnewpasses;
|
|
||||||
cblk->numnewpasses -= seg->numnewpasses;
|
|
||||||
if (cblk->numnewpasses > 0) {
|
|
||||||
seg++;
|
|
||||||
cblk->numsegs++;
|
|
||||||
}
|
|
||||||
} while (cblk->numnewpasses > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return c - src;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode the packets of a tile to a destination buffer
|
|
||||||
*
|
|
||||||
* img : the source image
|
|
||||||
* cp : the image coding parameters
|
|
||||||
* tileno : number of the tile encoded
|
|
||||||
* tile : the tile for which to write the packets
|
|
||||||
* maxlayers : maximum number of layers
|
|
||||||
* dest : the destination buffer
|
|
||||||
* len : the length of the destination buffer
|
|
||||||
* info_IM : structure to create an index file
|
|
||||||
*/
|
|
||||||
int t2_encode_packets(j2k_image_t * img, j2k_cp_t * cp, int tileno,
|
|
||||||
tcd_tile_t * tile, int maxlayers,
|
|
||||||
unsigned char *dest, int len, info_image * info_IM)
|
|
||||||
{
|
|
||||||
unsigned char *c = dest;
|
|
||||||
int e = 0;
|
|
||||||
pi_iterator_t *pi;
|
|
||||||
int pino, compno;
|
|
||||||
|
|
||||||
pi = pi_create(img, cp, tileno);
|
|
||||||
|
|
||||||
for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
|
|
||||||
while (pi_next(&pi[pino])) {
|
|
||||||
if (pi[pino].layno < maxlayers) {
|
|
||||||
e = t2_encode_packet(tile, &cp->tcps[tileno],
|
|
||||||
pi[pino].compno, pi[pino].resno,
|
|
||||||
pi[pino].precno, pi[pino].layno, c,
|
|
||||||
dest + len - c, info_IM, tileno);
|
|
||||||
if (e == -999) {
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
c += e;
|
|
||||||
/* INDEX >> */
|
|
||||||
if (info_IM->index_write && info_IM->index_on) {
|
|
||||||
info_tile *info_TL = &info_IM->tile[tileno];
|
|
||||||
info_packet *info_PK = &info_TL->packet[info_IM->num];
|
|
||||||
if (!info_IM->num) {
|
|
||||||
info_PK->start_pos = info_TL->end_header + 1;
|
|
||||||
} else {
|
|
||||||
info_PK->start_pos =
|
|
||||||
info_TL->packet[info_IM->num - 1].end_pos + 1;
|
|
||||||
}
|
|
||||||
info_PK->end_pos = info_PK->start_pos + e - 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
/* << INDEX */
|
|
||||||
if ((info_IM->index_write
|
|
||||||
&& cp->tcps[tileno].csty & J2K_CP_CSTY_SOP)
|
|
||||||
|| (info_IM->index_write && info_IM->index_on)) {
|
|
||||||
info_IM->num++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FREE space memory taken by pi */
|
|
||||||
for (compno = 0; compno < pi[pino].numcomps; compno++) {
|
|
||||||
free(pi[pino].comps[compno].resolutions);
|
|
||||||
}
|
|
||||||
free(pi[pino].comps);
|
|
||||||
}
|
|
||||||
free(pi[0].include);
|
|
||||||
free(pi);
|
|
||||||
if (e == -999)
|
|
||||||
return e;
|
|
||||||
else
|
|
||||||
return c - dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode the packets of a tile from a source buffer
|
|
||||||
*
|
|
||||||
* src: the source buffer
|
|
||||||
* len: length of the source buffer
|
|
||||||
* img: destination image
|
|
||||||
* cp: image coding parameters
|
|
||||||
* tileno: number that identifies the tile for which to decode the packets
|
|
||||||
* tile: tile for which to decode the packets
|
|
||||||
*/
|
|
||||||
int t2_decode_packets(unsigned char *src, int len, j2k_image_t * img,
|
|
||||||
j2k_cp_t * cp, int tileno, tcd_tile_t * tile)
|
|
||||||
{
|
|
||||||
unsigned char *c = src;
|
|
||||||
pi_iterator_t *pi;
|
|
||||||
int pino, compno, e = 0;
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
pi = pi_create(img, cp, tileno);
|
|
||||||
|
|
||||||
for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
|
|
||||||
while (pi_next(&pi[pino])) {
|
|
||||||
|
|
||||||
if ((cp->layer==0) || (cp->layer>=((pi[pino].layno)+1))) {
|
|
||||||
e = t2_decode_packet(c, src + len - c, tile, cp,
|
|
||||||
&cp->tcps[tileno], pi[pino].compno,
|
|
||||||
pi[pino].resno, pi[pino].precno,
|
|
||||||
pi[pino].layno);
|
|
||||||
} else {
|
|
||||||
e = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* progression in resolution */
|
|
||||||
img->comps[pi[pino].compno].resno_decoded =
|
|
||||||
e > 0 ? int_max(pi[pino].resno,
|
|
||||||
img->comps[pi[pino].compno].
|
|
||||||
resno_decoded) : img->comps[pi[pino].
|
|
||||||
compno].resno_decoded;
|
|
||||||
n++;
|
|
||||||
|
|
||||||
if (e == -999) { /* ADD */
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
c += e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FREE space memory taken by pi */
|
|
||||||
for (compno = 0; compno < pi[pino].numcomps; compno++) {
|
|
||||||
free(pi[pino].comps[compno].resolutions);
|
|
||||||
}
|
|
||||||
free(pi[pino].comps);
|
|
||||||
}
|
|
||||||
free(pi[0].include);
|
|
||||||
free(pi);
|
|
||||||
|
|
||||||
if (e == -999)
|
|
||||||
return e;
|
|
||||||
else
|
|
||||||
return c - src;
|
|
||||||
}
|
|
||||||
1656
libopenjpeg/tcd.c
1656
libopenjpeg/tcd.c
File diff suppressed because it is too large
Load Diff
@@ -1,183 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __TCD_H
|
|
||||||
#define __TCD_H
|
|
||||||
|
|
||||||
#include "j2k.h"
|
|
||||||
#include "tgt.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int numpasses;
|
|
||||||
int len;
|
|
||||||
unsigned char *data;
|
|
||||||
int maxpasses;
|
|
||||||
int numnewpasses;
|
|
||||||
int newlen;
|
|
||||||
} tcd_seg_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int rate;
|
|
||||||
double distortiondec;
|
|
||||||
int term, len;
|
|
||||||
} tcd_pass_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int numpasses; /* Number of passes in the layer */
|
|
||||||
int len; /* len of information */
|
|
||||||
double disto; /* add for index (Cfr. Marcela) */
|
|
||||||
unsigned char *data; /* data */
|
|
||||||
} tcd_layer_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int numbps;
|
|
||||||
int numlenbits;
|
|
||||||
int len; /* length */
|
|
||||||
int numpasses; /* number of pass already done for the code-blocks */
|
|
||||||
int numnewpasses; /* number of pass added to the code-blocks */
|
|
||||||
int numsegs; /* number of segments */
|
|
||||||
tcd_seg_t segs[100]; /* segments informations */
|
|
||||||
unsigned char data[8192]; /* Data */
|
|
||||||
int numpassesinlayers; /* number of passes in the layer */
|
|
||||||
tcd_layer_t layers[100]; /* layer information */
|
|
||||||
int totalpasses; /* total number of passes */
|
|
||||||
tcd_pass_t passes[100]; /* information about the passes */
|
|
||||||
} tcd_cblk_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int cw, ch; /* number of precinct in width and heigth */
|
|
||||||
tcd_cblk_t *cblks; /* code-blocks informations */
|
|
||||||
tgt_tree_t *incltree; /* inclusion tree */
|
|
||||||
tgt_tree_t *imsbtree; /* IMSB tree */
|
|
||||||
} tcd_precinct_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int bandno;
|
|
||||||
tcd_precinct_t *precincts; /* precinct information */
|
|
||||||
int numbps;
|
|
||||||
float stepsize;
|
|
||||||
} tcd_band_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int pw, ph;
|
|
||||||
int numbands; /* number sub-band for the resolution level */
|
|
||||||
tcd_band_t bands[3]; /* subband information */
|
|
||||||
} tcd_resolution_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int numresolutions; /* number of resolutions level */
|
|
||||||
tcd_resolution_t *resolutions; /* resolutions information */
|
|
||||||
int *data; /* data of the component */
|
|
||||||
int nbpix; /* add fixed_quality */
|
|
||||||
} tcd_tilecomp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int x0, y0, x1, y1; /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
|
|
||||||
int numcomps; /* number of components in tile */
|
|
||||||
tcd_tilecomp_t *comps; /* Components information */
|
|
||||||
int nbpix; /* add fixed_quality */
|
|
||||||
double distotile; /* add fixed_quality */
|
|
||||||
double distolayer[100]; /* add fixed_quality */
|
|
||||||
} tcd_tile_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int tw, th; /* number of tiles in width and heigth */
|
|
||||||
tcd_tile_t *tiles; /* Tiles information */
|
|
||||||
} tcd_image_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the tile coder (reuses the memory allocated by tcd_malloc_encode)
|
|
||||||
* img: raw image
|
|
||||||
* cp: coding parameters
|
|
||||||
* curtileno : number that identifies the tile that will be encoded
|
|
||||||
*/
|
|
||||||
void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the tile coder (allocate the memory)
|
|
||||||
* img: raw image
|
|
||||||
* cp: coding parameters
|
|
||||||
* curtileno : number that identifies the tile that will be encoded
|
|
||||||
*/
|
|
||||||
void tcd_malloc_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the tile decoder
|
|
||||||
* img: raw image
|
|
||||||
* cp: coding parameters
|
|
||||||
*/
|
|
||||||
void tcd_init(j2k_image_t * img, j2k_cp_t * cp);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the memory allocated for encoding
|
|
||||||
* img: raw image
|
|
||||||
* cp: coding parameters
|
|
||||||
* curtileno : number that identifies the tile that will be encoded
|
|
||||||
*/
|
|
||||||
void tcd_free_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode a tile from the raw image into a buffer, format pnm, pgm or ppm
|
|
||||||
* tileno: number that identifies one of the tiles to be encoded
|
|
||||||
* dest: destination buffer
|
|
||||||
* len: length of destination buffer
|
|
||||||
* info_IM: creation of index file
|
|
||||||
*/
|
|
||||||
int tcd_encode_tile_pxm(int tileno, unsigned char *dest, int len,
|
|
||||||
info_image * info_IM);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode a tile from the raw image into a buffer, format pgx
|
|
||||||
* tileno: number that identifies one of the tiles to be encoded
|
|
||||||
* dest: destination buffer
|
|
||||||
* len: length of destination buffer
|
|
||||||
* info_IM: creation of index file
|
|
||||||
*/
|
|
||||||
int tcd_encode_tile_pgx(int tileno, unsigned char *dest, int len,
|
|
||||||
info_image * info_IM);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode a tile from a buffer into a raw image
|
|
||||||
* src: source buffer
|
|
||||||
* len: length of the source buffer
|
|
||||||
* tileno: number that identifies the tile that will be decoded
|
|
||||||
*/
|
|
||||||
int tcd_decode_tile(unsigned char *src, int len, int tileno);
|
|
||||||
|
|
||||||
void tcd_dec_release();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 "tgt.h"
|
|
||||||
#include "bio.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Reset tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
void tgt_reset(tgt_tree_t * tree)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
/* new */
|
|
||||||
if (!tree || tree == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < tree->numnodes; i++) {
|
|
||||||
tree->nodes[i].value = 999;
|
|
||||||
tree->nodes[i].low = 0;
|
|
||||||
tree->nodes[i].known = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Create tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
tgt_tree_t *tgt_create(int numleafsh, int numleafsv)
|
|
||||||
{
|
|
||||||
int nplh[32];
|
|
||||||
int nplv[32];
|
|
||||||
tgt_node_t *node;
|
|
||||||
tgt_node_t *parentnode;
|
|
||||||
tgt_node_t *parentnode0;
|
|
||||||
tgt_tree_t *tree;
|
|
||||||
int i, j, k;
|
|
||||||
int numlvls;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
tree = (tgt_tree_t *) malloc(sizeof(tgt_tree_t));
|
|
||||||
tree->numleafsh = numleafsh;
|
|
||||||
tree->numleafsv = numleafsv;
|
|
||||||
|
|
||||||
numlvls = 0;
|
|
||||||
nplh[0] = numleafsh;
|
|
||||||
nplv[0] = numleafsv;
|
|
||||||
tree->numnodes = 0;
|
|
||||||
do {
|
|
||||||
n = nplh[numlvls] * nplv[numlvls];
|
|
||||||
nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
|
|
||||||
nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
|
|
||||||
tree->numnodes += n;
|
|
||||||
++numlvls;
|
|
||||||
} while (n > 1);
|
|
||||||
|
|
||||||
/* ADD */
|
|
||||||
if (tree->numnodes == 0) {
|
|
||||||
free(tree);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tree->nodes = (tgt_node_t *) malloc(tree->numnodes * sizeof(tgt_node_t));
|
|
||||||
|
|
||||||
node = tree->nodes;
|
|
||||||
parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv];
|
|
||||||
parentnode0 = parentnode;
|
|
||||||
|
|
||||||
for (i = 0; i < numlvls - 1; ++i) {
|
|
||||||
for (j = 0; j < nplv[i]; ++j) {
|
|
||||||
k = nplh[i];
|
|
||||||
while (--k >= 0) {
|
|
||||||
node->parent = parentnode;
|
|
||||||
++node;
|
|
||||||
if (--k >= 0) {
|
|
||||||
node->parent = parentnode;
|
|
||||||
++node;
|
|
||||||
}
|
|
||||||
++parentnode;
|
|
||||||
}
|
|
||||||
if ((j & 1) || j == nplv[i] - 1) {
|
|
||||||
parentnode0 = parentnode;
|
|
||||||
} else {
|
|
||||||
parentnode = parentnode0;
|
|
||||||
parentnode0 += nplh[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node->parent = 0;
|
|
||||||
|
|
||||||
tgt_reset(tree);
|
|
||||||
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Destroy tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
void tgt_destroy(tgt_tree_t * t)
|
|
||||||
{
|
|
||||||
free(t->nodes);
|
|
||||||
free(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Set the value of a leaf of the tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
void tgt_setvalue(tgt_tree_t * tree, int leafno, int value)
|
|
||||||
{
|
|
||||||
tgt_node_t *node;
|
|
||||||
node = &tree->nodes[leafno];
|
|
||||||
while (node && node->value > value) {
|
|
||||||
node->value = value;
|
|
||||||
node = node->parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Encode the value of a leaf of the tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
void tgt_encode(tgt_tree_t * tree, int leafno, int threshold)
|
|
||||||
{
|
|
||||||
tgt_node_t *stk[31];
|
|
||||||
tgt_node_t **stkptr;
|
|
||||||
tgt_node_t *node;
|
|
||||||
int low;
|
|
||||||
|
|
||||||
stkptr = stk;
|
|
||||||
node = &tree->nodes[leafno];
|
|
||||||
while (node->parent) {
|
|
||||||
*stkptr++ = node;
|
|
||||||
node = node->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
low = 0;
|
|
||||||
for (;;) {
|
|
||||||
if (low > node->low) {
|
|
||||||
node->low = low;
|
|
||||||
} else {
|
|
||||||
low = node->low;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (low < threshold) {
|
|
||||||
if (low >= node->value) {
|
|
||||||
if (!node->known) {
|
|
||||||
bio_write(1, 1);
|
|
||||||
node->known = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bio_write(0, 1);
|
|
||||||
++low;
|
|
||||||
}
|
|
||||||
|
|
||||||
node->low = low;
|
|
||||||
if (stkptr == stk)
|
|
||||||
break;
|
|
||||||
node = *--stkptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* <summary> */
|
|
||||||
/* Decode the value of a leaf of the tag-tree. */
|
|
||||||
/* </summary> */
|
|
||||||
int tgt_decode(tgt_tree_t * tree, int leafno, int threshold)
|
|
||||||
{
|
|
||||||
tgt_node_t *stk[31];
|
|
||||||
tgt_node_t **stkptr;
|
|
||||||
tgt_node_t *node;
|
|
||||||
int low;
|
|
||||||
|
|
||||||
stkptr = stk;
|
|
||||||
node = &tree->nodes[leafno];
|
|
||||||
while (node->parent) {
|
|
||||||
*stkptr++ = node;
|
|
||||||
node = node->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
low = 0;
|
|
||||||
for (;;) {
|
|
||||||
if (low > node->low) {
|
|
||||||
node->low = low;
|
|
||||||
} else {
|
|
||||||
low = node->low;
|
|
||||||
}
|
|
||||||
while (low < threshold && low < node->value) {
|
|
||||||
if (bio_read(1)) {
|
|
||||||
node->value = low;
|
|
||||||
} else {
|
|
||||||
++low;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node->low = low;
|
|
||||||
if (stkptr == stk) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
node = *--stkptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (node->value < threshold) ? 1 : 0;
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
|
||||||
* 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 __TGT_H
|
|
||||||
#define __TGT_H
|
|
||||||
|
|
||||||
typedef struct tgt_node {
|
|
||||||
struct tgt_node *parent;
|
|
||||||
int value;
|
|
||||||
int low;
|
|
||||||
int known;
|
|
||||||
} tgt_node_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int numleafsh;
|
|
||||||
int numleafsv;
|
|
||||||
int numnodes;
|
|
||||||
tgt_node_t *nodes;
|
|
||||||
} tgt_tree_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reset a tag-tree (set all leaves to 0)
|
|
||||||
* tree: tag-tree to reset
|
|
||||||
*/
|
|
||||||
void tgt_reset(tgt_tree_t * tree);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a tag-tree
|
|
||||||
* numleafsh: width of the array of leafs of the tree
|
|
||||||
* numleafsv: height of the array of leafs of the tree
|
|
||||||
*/
|
|
||||||
tgt_tree_t *tgt_create(int numleafsh, int numleafsv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroy a tag-tree, liberating memory
|
|
||||||
* tree: tag-tree to destroy
|
|
||||||
*/
|
|
||||||
void tgt_destroy(tgt_tree_t * tree);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the value of a leaf of a tag-tree
|
|
||||||
* tree: tag-tree to modify
|
|
||||||
* leafno: number that identifies the leaf to modify
|
|
||||||
* value: new value of the leaf
|
|
||||||
*/
|
|
||||||
void tgt_setvalue(tgt_tree_t * tree, int leafno, int value);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode the value of a leaf of the tag-tree up to a given threshold
|
|
||||||
* leafno: number that identifies the leaf to encode
|
|
||||||
* threshold: threshold to use when encoding value of the leaf
|
|
||||||
*/
|
|
||||||
void tgt_encode(tgt_tree_t * tree, int leafno, int threshold);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode the value of a leaf of the tag-tree up to a given threshold
|
|
||||||
* leafno: number that identifies the leaf to decode
|
|
||||||
* threshold: threshold to use when decoding value of the leaf
|
|
||||||
*/
|
|
||||||
int tgt_decode(tgt_tree_t * tree, int leafno, int threshold);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="MJ2_Extractor" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=MJ2_Extractor - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "MJ2_Extractor.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "MJ2_Extractor.mak" CFG="MJ2_Extractor - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "MJ2_Extractor - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "MJ2_Extractor - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "MJ2_Extractor - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "MJ2_Extractor - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "MJ2_Extractor___Win32_Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "MJ2_Extractor___Win32_Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "MJ2_Extractor___Win32_Debug"
|
|
||||||
# PROP Intermediate_Dir "MJ2_Extractor___Win32_Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "MJ2_Extractor - Win32 Release"
|
|
||||||
# Name "MJ2_Extractor - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\extract_j2k_from_mj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="MJ2_Wrapper" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=MJ2_Wrapper - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "MJ2_Wrapper.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "MJ2_Wrapper.mak" CFG="MJ2_Wrapper - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "MJ2_Wrapper - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "MJ2_Wrapper - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "MJ2_Wrapper - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "MJ2_Wrapper - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "MJ2_Wrapper___Win32_Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "MJ2_Wrapper___Win32_Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "MJ2_Wrapper___Win32_Debug"
|
|
||||||
# PROP Intermediate_Dir "MJ2_Wrapper___Win32_Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "MJ2_Wrapper - Win32 Release"
|
|
||||||
# Name "MJ2_Wrapper - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\wrap_j2k_in_mj2.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
79
mj2/Makefile
79
mj2/Makefile
@@ -1,79 +0,0 @@
|
|||||||
#
|
|
||||||
# Valentin Mesaros (Octalis | DICE/UCL Belgium)
|
|
||||||
# 19 April 2005
|
|
||||||
#
|
|
||||||
# Makefile for mj2 source files (frames_to_mj2, mj2_to_frames, extract_j2k_from_mj2, wrap_j2k_in_mj2)
|
|
||||||
#
|
|
||||||
|
|
||||||
INCLUDES = -Imj2 \
|
|
||||||
-I../libopenjpeg
|
|
||||||
|
|
||||||
C_OPT = -Wall
|
|
||||||
CFLAGS = $(INCLUDES) $(C_OPT)
|
|
||||||
|
|
||||||
CC = gcc
|
|
||||||
|
|
||||||
OBJ_MJ2_DIR = obj
|
|
||||||
BIN_MJ2_DIR = bin
|
|
||||||
LIB_OPENJPEG_DIR = ../libopenjpeg/lib
|
|
||||||
LIB_OPENJPEG = $(LIB_OPENJPEG_DIR)/libopenjpeg.a
|
|
||||||
|
|
||||||
all: $(OBJ_MJ2_DIR) $(BIN_MJ2_DIR) \
|
|
||||||
$(BIN_MJ2_DIR)/frames_to_mj2 \
|
|
||||||
$(BIN_MJ2_DIR)/mj2_to_frames \
|
|
||||||
$(BIN_MJ2_DIR)/extract_j2k_from_mj2 \
|
|
||||||
$(BIN_MJ2_DIR)/wrap_j2k_in_mj2
|
|
||||||
|
|
||||||
|
|
||||||
$(OBJ_MJ2_DIR):
|
|
||||||
mkdir $(OBJ_MJ2_DIR)
|
|
||||||
|
|
||||||
$(BIN_MJ2_DIR):
|
|
||||||
mkdir $(BIN_MJ2_DIR)
|
|
||||||
|
|
||||||
$(OBJ_MJ2_DIR)/%.o:
|
|
||||||
$(CC) -c $(CFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
$(OBJ_MJ2_DIR)/frames_to_mj2.o: frames_to_mj2.c
|
|
||||||
$(OBJ_MJ2_DIR)/mj2_to_frames.o: mj2_to_frames.c
|
|
||||||
$(OBJ_MJ2_DIR)/mj2.o: mj2.c
|
|
||||||
$(OBJ_MJ2_DIR)/mj2_convert.o: mj2_convert.c
|
|
||||||
$(OBJ_MJ2_DIR)/extract_j2k_from_mj2.o: extract_j2k_from_mj2.c
|
|
||||||
$(OBJ_MJ2_DIR)/wrap_j2k_in_mj2.o: wrap_j2k_in_mj2.c
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MJ2_OBJS = $(addprefix $(OBJ_MJ2_DIR)/, mj2.o mj2_convert.o)
|
|
||||||
|
|
||||||
|
|
||||||
$(BIN_MJ2_DIR)/frames_to_mj2: $(OBJ_MJ2_DIR)/frames_to_mj2.o $(MJ2_OBJS) $(LIB_OPENJPEG)
|
|
||||||
$(CC) $(CFLAGS) \
|
|
||||||
-o $(BIN_MJ2_DIR)/frames_to_mj2 \
|
|
||||||
$(MJ2_OBJS) $(OBJ_MJ2_DIR)/frames_to_mj2.o \
|
|
||||||
$(LIB_OPENJPEG) \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
|
|
||||||
$(BIN_MJ2_DIR)/mj2_to_frames: $(OBJ_MJ2_DIR)/mj2_to_frames.o $(MJ2_OBJS) $(LIB_OPENJPEG)
|
|
||||||
$(CC) $(CFLAGS) \
|
|
||||||
-o $(BIN_MJ2_DIR)/mj2_to_frames \
|
|
||||||
$(MJ2_OBJS) $(OBJ_MJ2_DIR)/mj2_to_frames.o \
|
|
||||||
$(LIB_OPENJPEG) \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
|
|
||||||
$(BIN_MJ2_DIR)/extract_j2k_from_mj2: $(OBJ_MJ2_DIR)/extract_j2k_from_mj2.o $(MJ2_OBJS) $(LIB_OPENJPEG)
|
|
||||||
$(CC) $(CFLAGS) \
|
|
||||||
-o $(BIN_MJ2_DIR)/extract_j2k_from_mj2 \
|
|
||||||
$(MJ2_OBJS) $(OBJ_MJ2_DIR)/extract_j2k_from_mj2.o \
|
|
||||||
$(LIB_OPENJPEG) \
|
|
||||||
-lm
|
|
||||||
$(BIN_MJ2_DIR)/wrap_j2k_in_mj2: $(OBJ_MJ2_DIR)/wrap_j2k_in_mj2.o $(MJ2_OBJS) $(LIB_OPENJPEG)
|
|
||||||
$(CC) $(CFLAGS) \
|
|
||||||
-o $(BIN_MJ2_DIR)/wrap_j2k_in_mj2 \
|
|
||||||
$(MJ2_OBJS) $(OBJ_MJ2_DIR)/wrap_j2k_in_mj2.o \
|
|
||||||
$(LIB_OPENJPEG) \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BIN_MJ2_DIR)/* $(OBJ_MJ2_DIR)/*
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1987, 1993, 1994
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* last review : october 29th, 2002 */
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
|
||||||
optind = 1, /* index into parent argv vector */
|
|
||||||
optopt, /* character checked for validity */
|
|
||||||
optreset; /* reset getopt */
|
|
||||||
char *optarg; /* argument associated with option */
|
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
|
||||||
#define BADARG (int)':'
|
|
||||||
#define EMSG ""
|
|
||||||
|
|
||||||
/*
|
|
||||||
* getopt --
|
|
||||||
* Parse argc/argv argument vector.
|
|
||||||
*/
|
|
||||||
int getopt(nargc, nargv, ostr)
|
|
||||||
int nargc;
|
|
||||||
char *const *nargv;
|
|
||||||
const char *ostr;
|
|
||||||
{
|
|
||||||
# define __progname nargv[0]
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
|
||||||
char *oli; /* option letter list index */
|
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
|
||||||
optreset = 0;
|
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
|
||||||
++optind;
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} /* option letter okay? */
|
|
||||||
if ((optopt = (int) *place++) == (int) ':' ||
|
|
||||||
!(oli = strchr(ostr, optopt))) {
|
|
||||||
/*
|
|
||||||
* if the user didn't specify '-' as an option,
|
|
||||||
* assume it means -1.
|
|
||||||
*/
|
|
||||||
if (optopt == (int) '-')
|
|
||||||
return (-1);
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
if (opterr && *ostr != ':')
|
|
||||||
(void) fprintf(stderr,
|
|
||||||
"%s: illegal option -- %c\n", __progname, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
if (*++oli != ':') { /* don't need argument */
|
|
||||||
optarg = NULL;
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
} else { /* need an argument */
|
|
||||||
if (*place) /* no white space */
|
|
||||||
optarg = place;
|
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
|
||||||
place = EMSG;
|
|
||||||
if (*ostr == ':')
|
|
||||||
return (BADARG);
|
|
||||||
if (opterr)
|
|
||||||
(void) fprintf(stderr,
|
|
||||||
"%s: option requires an argument -- %c\n",
|
|
||||||
__progname, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
} else /* white space */
|
|
||||||
optarg = nargv[optind];
|
|
||||||
place = EMSG;
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
return (optopt); /* dump back option letter */
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
#include "mj2.h"
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h> // Must be included first
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
jmp_buf j2k_error;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
|
|
||||||
int tnum;
|
|
||||||
unsigned int snum;
|
|
||||||
mj2_movie_t movie;
|
|
||||||
mj2_tk_t *track;
|
|
||||||
mj2_sample_t *sample;
|
|
||||||
unsigned char* frame_codestream;
|
|
||||||
FILE *file, *outfile;
|
|
||||||
char outfilename[50];
|
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
printf("Bad syntax: Usage: MJ2_extractor mj2filename output_location\n");
|
|
||||||
printf("Example: MJ2_extractor foreman.mj2 output/foreman\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
|
||||||
|
|
||||||
if (!file) {
|
|
||||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mj2_read_struct(file, &movie)) // Creating the movie structure
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Decode first video track
|
|
||||||
tnum = 0;
|
|
||||||
while (movie.tk[tnum].track_type != 0)
|
|
||||||
tnum ++;
|
|
||||||
|
|
||||||
track = &movie.tk[tnum];
|
|
||||||
|
|
||||||
fprintf(stdout,"Extracting %d frames from file...\n",track->num_samples);
|
|
||||||
|
|
||||||
for (snum=0; snum < track->num_samples; snum++)
|
|
||||||
{
|
|
||||||
sample = &track->sample[snum];
|
|
||||||
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); // Skipping JP2C marker
|
|
||||||
fseek(file,sample->offset+8,SEEK_SET);
|
|
||||||
fread(frame_codestream,sample->sample_size-8,1, file); // Assuming that jp and ftyp markers size do
|
|
||||||
|
|
||||||
sprintf(outfilename,"%s_%d.j2k",argv[2],snum);
|
|
||||||
outfile = fopen(outfilename, "wb");
|
|
||||||
if (!outfile) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
|
||||||
fclose(outfile);
|
|
||||||
free(frame_codestream);
|
|
||||||
}
|
|
||||||
fclose(file);
|
|
||||||
fprintf(stdout, "%d frames correctly extracted\n", snum);
|
|
||||||
mj2_memory_free(&movie);
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,997 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003-2004, Fran<61>ois-Olivier Devaux
|
|
||||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <openjpeg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#ifndef DONT_HAVE_GETOPT
|
|
||||||
#include <getopt.h>
|
|
||||||
#else
|
|
||||||
#include "compat/getopt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mj2_convert.h"
|
|
||||||
|
|
||||||
#define MJ2_MDAT 0x6d646174
|
|
||||||
#define JP2_JP2C 0x6a703263
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h> // Must be included first
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
jmp_buf j2k_error;
|
|
||||||
|
|
||||||
void help_display()
|
|
||||||
{
|
|
||||||
fprintf(stdout,"HELP\n----\n\n");
|
|
||||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
fprintf(stdout,"List of parameters for the MJ2 encoder:\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"REMARKS:\n");
|
|
||||||
fprintf(stdout,"---------\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"COD and QCD never appear in the tile_header.\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"- This coder can encode a mega image, a test was made on a 24000x24000 pixels \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"color image. You need enough disk space memory (twice the original) to encode \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"the image,i.e. for a 1.5 GB image you need a minimum of 3GB of disk memory)\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"By default:\n");
|
|
||||||
fprintf(stdout,"------------\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout," * Lossless\n");
|
|
||||||
fprintf(stdout," * 1 tile\n");
|
|
||||||
fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
|
|
||||||
fprintf(stdout," * Size of code-block : 64 x 64\n");
|
|
||||||
fprintf(stdout," * Number of resolutions: 6\n");
|
|
||||||
fprintf(stdout," * No SOP marker in the codestream\n");
|
|
||||||
fprintf(stdout," * No EPH marker in the codestream\n");
|
|
||||||
fprintf(stdout," * No sub-sampling in x or y direction\n");
|
|
||||||
fprintf(stdout," * No mode switch activated\n");
|
|
||||||
fprintf(stdout," * Progression order: LRCP\n");
|
|
||||||
fprintf(stdout," * No index file\n");
|
|
||||||
fprintf(stdout," * No ROI upshifted\n");
|
|
||||||
fprintf(stdout," * No offset of the origin of the image\n");
|
|
||||||
fprintf(stdout," * No offset of the origin of the tiles\n");
|
|
||||||
fprintf(stdout," * Reversible DWT 5-3\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"Parameters:\n");
|
|
||||||
fprintf(stdout,"------------\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"Required Parameters (except with -h):\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-i : source file (-i source.yuv) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-o : destination file (-o dest.mj2) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"Optional Parameters:\n");
|
|
||||||
fprintf(stdout,"-h : display the help information \n");
|
|
||||||
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
|
|
||||||
fprintf(stdout," - The rate specified for each quality level is the desired \n");
|
|
||||||
fprintf(stdout," compression factor.\n");
|
|
||||||
fprintf(stdout," Example: -r 20,10,1 means quality 1: compress 20x, \n");
|
|
||||||
fprintf(stdout," quality 2: compress 10x and quality 3: compress lossless\n");
|
|
||||||
fprintf(stdout," (options -r and -q cannot be used together)\n ");
|
|
||||||
|
|
||||||
fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n ");
|
|
||||||
|
|
||||||
fprintf(stdout," (options -r and -q cannot be used together)\n ");
|
|
||||||
|
|
||||||
fprintf(stdout,"-n : number of resolutions (-n 3) \n");
|
|
||||||
fprintf(stdout,"-b : size of code block (-b 32,32) \n");
|
|
||||||
fprintf(stdout,"-c : size of precinct (-c 128,128) \n");
|
|
||||||
fprintf(stdout,"-t : size of tile (-t 512,512) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-s : subsampling factor (-s 2,2) [-s X,Y] \n");
|
|
||||||
fprintf(stdout," Remark: subsampling bigger than 2 can produce error\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-SOP : write SOP marker before each packet \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-EPH : write EPH marker after each header packet \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
|
|
||||||
fprintf
|
|
||||||
(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
|
|
||||||
fprintf
|
|
||||||
(stdout," Indicate multiple modes by adding their values. \n");
|
|
||||||
fprintf
|
|
||||||
(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
|
||||||
fprintf
|
|
||||||
(stdout," for component c=%%d [%%d = 0,1,2]\n");
|
|
||||||
fprintf
|
|
||||||
(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
|
|
||||||
fprintf
|
|
||||||
(stdout,"-T : offset of the origin of the tiles (-T 100,75) \n");
|
|
||||||
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
|
||||||
fprintf(stdout,"-W : image width, height and the dx and dy subsampling \n");
|
|
||||||
fprintf(stdout," of the Cb and Cr components for YUV files \n");
|
|
||||||
fprintf(stdout," (default is '352,288,2,2' for CIF format's 352x288 and 4:2:0)\n");
|
|
||||||
fprintf(stdout,"-F : video frame rate (set to 25 by default)\n");
|
|
||||||
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"IMPORTANT:\n");
|
|
||||||
fprintf(stdout,"-----------\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"The index file has the structure below:\n");
|
|
||||||
fprintf(stdout,"---------------------------------------\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"Image_height Image_width\n");
|
|
||||||
fprintf(stdout,"progression order\n");
|
|
||||||
fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
|
|
||||||
fprintf(stdout,"Components_nb\n");
|
|
||||||
fprintf(stdout,"Layers_nb\n");
|
|
||||||
fprintf(stdout,"decomposition_levels\n");
|
|
||||||
fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
|
|
||||||
fprintf(stdout," [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
|
|
||||||
fprintf(stdout,"Main_header_end_position\n");
|
|
||||||
fprintf(stdout,"Codestream_size\n");
|
|
||||||
fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
|
|
||||||
fprintf(stdout,"Tile_1 '' '' '' '' '' ''\n");
|
|
||||||
fprintf(stdout,"...\n");
|
|
||||||
fprintf(stdout,"Tile_Nt '' '' '' '' '' ''\n");
|
|
||||||
fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
|
|
||||||
fprintf(stdout,"...\n");
|
|
||||||
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
|
|
||||||
|
|
||||||
fprintf(stdout,"MaxDisto\n");
|
|
||||||
|
|
||||||
fprintf(stdout,"TotalDisto\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int give_progression(char progression[4])
|
|
||||||
{
|
|
||||||
if (progression[0] == 'L' && progression[1] == 'R'
|
|
||||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if (progression[0] == 'R' && progression[1] == 'L'
|
|
||||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
if (progression[0] == 'R' && progression[1] == 'P'
|
|
||||||
&& progression[2] == 'C' && progression[3] == 'L') {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
if (progression[0] == 'P' && progression[1] == 'C'
|
|
||||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
|
||||||
return 3;
|
|
||||||
} else {
|
|
||||||
if (progression[0] == 'C' && progression[1] == 'P'
|
|
||||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
|
||||||
return 4;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double dwt_norms_97[4][10] = {
|
|
||||||
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
|
|
||||||
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
|
|
||||||
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
|
|
||||||
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
|
|
||||||
};
|
|
||||||
|
|
||||||
int floorlog2(int a)
|
|
||||||
{
|
|
||||||
int l;
|
|
||||||
for (l = 0; a > 1; l++) {
|
|
||||||
a >>= 1;
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
void encode_stepsize(int stepsize, int numbps, int *expn, int *mant)
|
|
||||||
{
|
|
||||||
int p, n;
|
|
||||||
p = floorlog2(stepsize) - 13;
|
|
||||||
n = 11 - floorlog2(stepsize);
|
|
||||||
*mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
|
|
||||||
*expn = numbps - p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void calc_explicit_stepsizes(j2k_tccp_t * tccp, int prec)
|
|
||||||
{
|
|
||||||
int numbands, bandno;
|
|
||||||
numbands = 3 * tccp->numresolutions - 2;
|
|
||||||
for (bandno = 0; bandno < numbands; bandno++) {
|
|
||||||
double stepsize;
|
|
||||||
|
|
||||||
int resno, level, orient, gain;
|
|
||||||
resno = bandno == 0 ? 0 : (bandno - 1) / 3 + 1;
|
|
||||||
orient = bandno == 0 ? 0 : (bandno - 1) % 3 + 1;
|
|
||||||
level = tccp->numresolutions - 1 - resno;
|
|
||||||
gain =
|
|
||||||
tccp->qmfbid == 0 ? 0 : (orient ==
|
|
||||||
0 ? 0 : (orient == 1
|
|
||||||
|| orient == 2 ? 1 : 2));
|
|
||||||
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
|
|
||||||
stepsize = 1.0;
|
|
||||||
} else {
|
|
||||||
double norm = dwt_norms_97[orient][level];
|
|
||||||
stepsize = (1 << (gain + 1)) / norm;
|
|
||||||
}
|
|
||||||
encode_stepsize((int) floor(stepsize * 8192.0), prec + gain,
|
|
||||||
&tccp->stepsizes[bandno].expn,
|
|
||||||
&tccp->stepsizes[bandno].mant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int NumResolution, numD_min; /* NumResolution : number of resolution */
|
|
||||||
int Tile_arg; /* Tile_arg = 0 (not in argument) ou = 1 (in argument) */
|
|
||||||
int CSty; /* CSty : coding style */
|
|
||||||
int Prog_order; /* progression order (default LRCP) */
|
|
||||||
char progression[4];
|
|
||||||
int numpocs, numpocs_tile; /* Number of progression order change (POC) default 0 */
|
|
||||||
int prcw_init[J2K_MAXRLVLS]; /* Initialisation Precinct width */
|
|
||||||
int prch_init[J2K_MAXRLVLS]; /* Initialisation Precinct height */
|
|
||||||
//int prcw_init, prch_init; /* Initialisation precincts' size */
|
|
||||||
int cblockw_init, cblockh_init; /* Initialisation codeblocks' size */
|
|
||||||
int mode, value; /* Mode switch (cblk_style) */
|
|
||||||
int subsampling_dx, subsampling_dy; /* subsampling value for dx and dy */
|
|
||||||
int ROI_compno, ROI_shift; /* region of interrest */
|
|
||||||
int Dim[2]; /* portion of the image coded */
|
|
||||||
int TX0, TY0; /* tile off-set */
|
|
||||||
mj2_movie_t movie;
|
|
||||||
j2k_cp_t cp, cp_init; /* cp_init is used to initialise in multiple tiles */
|
|
||||||
j2k_tcp_t *tcp, *tcp_init; /* tcp_init is used to initialise in multiple tile */
|
|
||||||
j2k_poc_t POC[32]; /* POC : used in case of Progression order change */
|
|
||||||
j2k_poc_t *tcp_poc;
|
|
||||||
j2k_tccp_t *tccp;
|
|
||||||
int i, tileno, l, j;
|
|
||||||
char *infile = 0;
|
|
||||||
char *outfile = 0;
|
|
||||||
char *index = 0;
|
|
||||||
char *s, S1, S2, S3;
|
|
||||||
char *buf;
|
|
||||||
int ir = 0;
|
|
||||||
int res_spec = 0; /* For various precinct sizes specification */
|
|
||||||
char sep;
|
|
||||||
int w; /* Width of YUV file */
|
|
||||||
int h; /* Height of YUV file */
|
|
||||||
int CbCr_subsampling_dx; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
|
|
||||||
int CbCr_subsampling_dy; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
|
|
||||||
int frame_rate; /* Video Frame Rate */
|
|
||||||
int numcomps; /* In YUV files, numcomps always considered as 3 */
|
|
||||||
int prec; /* In YUV files, precision always considered as 8 */
|
|
||||||
int x1, y1, len, jp2c_initpos, m, k, pos;
|
|
||||||
long mdat_initpos, offset;
|
|
||||||
FILE *mj2file, *yuvfile;
|
|
||||||
unsigned int sampleno;
|
|
||||||
j2k_image_t img;
|
|
||||||
|
|
||||||
/* default value */
|
|
||||||
/* ------------- */
|
|
||||||
NumResolution = 6;
|
|
||||||
CSty = 0;
|
|
||||||
cblockw_init = 64;
|
|
||||||
cblockh_init = 64;
|
|
||||||
cp.tw = 1;
|
|
||||||
cp.th = 1;
|
|
||||||
cp.index_on = 0;
|
|
||||||
Prog_order = 0;
|
|
||||||
numpocs = 0;
|
|
||||||
mode = 0;
|
|
||||||
subsampling_dx = 1;
|
|
||||||
subsampling_dy = 1;
|
|
||||||
ROI_compno = -1; /* no ROI */
|
|
||||||
ROI_shift = 0;
|
|
||||||
Dim[0] = 0;
|
|
||||||
Dim[1] = 0;
|
|
||||||
TX0 = 0;
|
|
||||||
TY0 = 0;
|
|
||||||
cp.comment = NULL;
|
|
||||||
cp.disto_alloc = 0;
|
|
||||||
cp.fixed_alloc = 0;
|
|
||||||
cp.fixed_quality = 0; //add fixed_quality
|
|
||||||
w = 352; // CIF default value
|
|
||||||
h = 288; // CIF default value
|
|
||||||
CbCr_subsampling_dx = 2; // CIF default value
|
|
||||||
CbCr_subsampling_dy = 2; // CIF default value
|
|
||||||
frame_rate = 25;
|
|
||||||
|
|
||||||
|
|
||||||
Tile_arg = 0;
|
|
||||||
cp_init.tcps = (j2k_tcp_t *) malloc(sizeof(j2k_tcp_t)); /* initialisation if only one tile */
|
|
||||||
tcp_init = &cp_init.tcps[0];
|
|
||||||
tcp_init->numlayers = 0;
|
|
||||||
|
|
||||||
cp.intermed_file = 0; // Don't store each tile in a file during processing
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
int c = getopt(argc, argv,
|
|
||||||
"i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I:W:F:");
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
switch (c) {
|
|
||||||
case 'i': /* IN fill */
|
|
||||||
infile = optarg;
|
|
||||||
s = optarg;
|
|
||||||
while (*s) {
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
s--;
|
|
||||||
S3 = *s;
|
|
||||||
s--;
|
|
||||||
S2 = *s;
|
|
||||||
s--;
|
|
||||||
S1 = *s;
|
|
||||||
|
|
||||||
if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
|
|
||||||
|| (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
|
|
||||||
cp.decod_format = YUV_DFMT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf(stderr,
|
|
||||||
"!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
|
|
||||||
S1, S2, S3);
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'o': /* OUT fill */
|
|
||||||
outfile = optarg;
|
|
||||||
while (*outfile) {
|
|
||||||
outfile++;
|
|
||||||
}
|
|
||||||
outfile--;
|
|
||||||
S3 = *outfile;
|
|
||||||
outfile--;
|
|
||||||
S2 = *outfile;
|
|
||||||
outfile--;
|
|
||||||
S1 = *outfile;
|
|
||||||
|
|
||||||
outfile = optarg;
|
|
||||||
|
|
||||||
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|
|
||||||
|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
|
|
||||||
cp.cod_format = MJ2_CFMT;
|
|
||||||
else {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Unknown output format image *.%c%c%c [only *.mj2]!! \n",
|
|
||||||
S1, S2, S3);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'r': /* rates rates/distorsion */
|
|
||||||
s = optarg;
|
|
||||||
while (sscanf(s, "%d", &tcp_init->rates[tcp_init->numlayers])
|
|
||||||
== 1) {
|
|
||||||
tcp_init->numlayers++;
|
|
||||||
while (*s && *s != ',') {
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (!*s)
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
cp.disto_alloc = 1;
|
|
||||||
cp.matrice = NULL;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'q': /* add fixed_quality */
|
|
||||||
s = optarg;
|
|
||||||
while (sscanf
|
|
||||||
(s, "%f", &tcp_init->distoratio[tcp_init->numlayers]) == 1) {
|
|
||||||
tcp_init->numlayers++;
|
|
||||||
while (*s && *s != ',') {
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (!*s)
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
cp.fixed_quality = 1;
|
|
||||||
cp.matrice = NULL;
|
|
||||||
break;
|
|
||||||
/* dda */
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'f': /* mod fixed_quality (before : -q) */
|
|
||||||
s = optarg;
|
|
||||||
sscanf(s, "%d", &tcp_init->numlayers);
|
|
||||||
s++;
|
|
||||||
if (tcp_init->numlayers > 9)
|
|
||||||
s++;
|
|
||||||
cp.matrice =
|
|
||||||
(int *) malloc(tcp_init->numlayers * NumResolution * 3 *
|
|
||||||
sizeof(int));
|
|
||||||
s = s + 2;
|
|
||||||
for (i = 0; i < tcp_init->numlayers; i++) {
|
|
||||||
tcp_init->rates[i] = 1;
|
|
||||||
sscanf(s, "%d,", &cp.matrice[i * NumResolution * 3]);
|
|
||||||
s += 2;
|
|
||||||
if (cp.matrice[i * NumResolution * 3] > 9)
|
|
||||||
s++;
|
|
||||||
cp.matrice[i * NumResolution * 3 + 1] = 0;
|
|
||||||
cp.matrice[i * NumResolution * 3 + 2] = 0;
|
|
||||||
for (j = 1; j < NumResolution; j++) {
|
|
||||||
sscanf(s, "%d,%d,%d",
|
|
||||||
&cp.matrice[i * NumResolution * 3 + j * 3 + 0],
|
|
||||||
&cp.matrice[i * NumResolution * 3 + j * 3 + 1],
|
|
||||||
&cp.matrice[i * NumResolution * 3 + j * 3 + 2]);
|
|
||||||
s += 6;
|
|
||||||
if (cp.matrice[i * NumResolution * 3 + j * 3] > 9)
|
|
||||||
s++;
|
|
||||||
if (cp.matrice[i * NumResolution * 3 + j * 3 + 1] > 9)
|
|
||||||
s++;
|
|
||||||
if (cp.matrice[i * NumResolution * 3 + j * 3 + 2] > 9)
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (i < tcp_init->numlayers - 1)
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
cp.fixed_alloc = 1;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 't': /* tiles */
|
|
||||||
sscanf(optarg, "%d,%d", &cp.tdx, &cp.tdy);
|
|
||||||
Tile_arg = 1;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'n': /* resolution */
|
|
||||||
sscanf(optarg, "%d", &NumResolution);
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'c': /* precinct dimension */
|
|
||||||
s = optarg;
|
|
||||||
do {
|
|
||||||
sep = 0;
|
|
||||||
sscanf(s, "[%d,%d]%c", &prcw_init[res_spec],
|
|
||||||
&prch_init[res_spec], &sep);
|
|
||||||
CSty |= 0x01;
|
|
||||||
res_spec++;
|
|
||||||
s = strpbrk(s, "]") + 2;
|
|
||||||
} while (sep == ',');
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'b': /* code-block dimension */
|
|
||||||
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"!! Size of code_block error (option -b) !!\n\nRestriction :\n * width*height<=4096\n * 4<=width,height<= 1024\n\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'x': /* creation of index file */
|
|
||||||
index = optarg;
|
|
||||||
cp.index_on = 1;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'p': /* progression order */
|
|
||||||
s = optarg;
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
progression[i] = *s;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
Prog_order = give_progression(progression);
|
|
||||||
|
|
||||||
if (Prog_order == -1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 's': /* subsampling factor */
|
|
||||||
if (sscanf(optarg, "%d,%d", &subsampling_dx, &subsampling_dy)
|
|
||||||
!= 2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'd': /* coordonnate of the reference grid */
|
|
||||||
if (sscanf(optarg, "%d,%d", &Dim[0], &Dim[1]) != 2) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"-d 'coordonnate of the reference grid' argument error !! [-d x0,y0]\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'h': /* Display an help description */
|
|
||||||
help_display();
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
/* ----------------------------------------------------- */
|
|
||||||
case 'P': /* POC */
|
|
||||||
fprintf(stderr, "/----------------------------------\\\n");
|
|
||||||
fprintf(stderr, "| POC option not fully tested !! |\n");
|
|
||||||
fprintf(stderr, "\\----------------------------------/\n");
|
|
||||||
|
|
||||||
s = optarg;
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%s", &POC[numpocs].tile,
|
|
||||||
&POC[numpocs].resno0, &POC[numpocs].compno0,
|
|
||||||
&POC[numpocs].layno1, &POC[numpocs].resno1,
|
|
||||||
&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
|
|
||||||
POC[numpocs].prg = give_progression(POC[numpocs].progorder);
|
|
||||||
/* POC[numpocs].tile; */
|
|
||||||
numpocs++;
|
|
||||||
while (*s && *s != '/') {
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (!*s)
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'S': /* SOP marker */
|
|
||||||
CSty |= 0x02;
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'E': /* EPH marker */
|
|
||||||
CSty |= 0x04;
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'M': /* Mode switch pas tous au point !! */
|
|
||||||
if (sscanf(optarg, "%d", &value) == 1) {
|
|
||||||
for (i = 0; i <= 5; i++) {
|
|
||||||
int cache = value & (1 << i);
|
|
||||||
if (cache)
|
|
||||||
mode |= (1 << i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'R': /* ROI */
|
|
||||||
if (sscanf(optarg, "OI:c=%d,U=%d", &ROI_compno, &ROI_shift) != 2) {
|
|
||||||
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'T': /* Tile offset */
|
|
||||||
if (sscanf(optarg, "%d,%d", &TX0, &TY0) != 2) {
|
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'C': /* Add a comment */
|
|
||||||
cp.comment = optarg;
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'I': /* reversible or not */
|
|
||||||
ir = 1;
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'W': /* Width and Height and Cb and Cr subsampling in case of YUV format files */
|
|
||||||
if (sscanf
|
|
||||||
(optarg, "%d,%d,%d,%d", &w, &h, &CbCr_subsampling_dx,
|
|
||||||
&CbCr_subsampling_dy) != 4) {
|
|
||||||
fprintf(stderr, "-W argument error");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
case 'F': /* Video frame rate */
|
|
||||||
if (sscanf(optarg, "%d", &frame_rate) != 1) {
|
|
||||||
fprintf(stderr, "-F argument error");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
default:
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cp.tx0 = TX0;
|
|
||||||
cp.ty0 = TY0;
|
|
||||||
|
|
||||||
/* Error messages */
|
|
||||||
/* -------------- */
|
|
||||||
if (!infile || !outfile) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Correct usage: mj2_encoder -i yuv-file -o mj2-file (+ options)\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cp.disto_alloc || cp.fixed_alloc || cp.fixed_quality)
|
|
||||||
&& (!(cp.disto_alloc ^ cp.fixed_alloc ^ cp.fixed_quality))) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Error: options -r -q and -f can not be used together !!\n");
|
|
||||||
return 1;
|
|
||||||
} // mod fixed_quality
|
|
||||||
|
|
||||||
/* if no rate entered, lossless by default */
|
|
||||||
if (tcp_init->numlayers == 0) {
|
|
||||||
tcp_init->rates[tcp_init->numlayers] = 0; //MOD antonin : losslessbug
|
|
||||||
tcp_init->numlayers++;
|
|
||||||
cp.disto_alloc = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TX0 > Dim[0] || TY0 > Dim[1]) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
|
|
||||||
TX0, Dim[0], TY0, Dim[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < numpocs; i++) {
|
|
||||||
if (POC[i].prg == -1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
|
|
||||||
i + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* to respect profile - 0 */
|
|
||||||
/* ---------------------- */
|
|
||||||
numD_min = 0;
|
|
||||||
|
|
||||||
x1 = !Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
|
|
||||||
1) *
|
|
||||||
subsampling_dx + 1;
|
|
||||||
y1 = !Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
|
|
||||||
1) *
|
|
||||||
subsampling_dy + 1;
|
|
||||||
|
|
||||||
if (Tile_arg == 1) {
|
|
||||||
cp.tw = int_ceildiv(x1 - cp.tx0, cp.tdx);
|
|
||||||
cp.th = int_ceildiv(y1 - cp.ty0, cp.tdy);
|
|
||||||
} else {
|
|
||||||
cp.tdx = x1 - cp.tx0;
|
|
||||||
cp.tdy = y1 - cp.ty0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialization for PPM marker */
|
|
||||||
cp.ppm = 0;
|
|
||||||
cp.ppm_data = NULL;
|
|
||||||
cp.ppm_previous = 0;
|
|
||||||
cp.ppm_store = 0;
|
|
||||||
|
|
||||||
numcomps = 3; /* Because YUV files only have 3 components */
|
|
||||||
|
|
||||||
tcp_init->mct = 0; /* No component transform needed */
|
|
||||||
|
|
||||||
prec = 8; /* Because in YUV files, components have 8-bit depth */
|
|
||||||
|
|
||||||
/* Init the mutiple tiles */
|
|
||||||
/* ---------------------- */
|
|
||||||
cp.tcps = (j2k_tcp_t *) malloc(cp.tw * cp.th * sizeof(j2k_tcp_t));
|
|
||||||
|
|
||||||
for (tileno = 0; tileno < cp.tw * cp.th; tileno++) {
|
|
||||||
tcp = &cp.tcps[tileno];
|
|
||||||
tcp->numlayers = tcp_init->numlayers;
|
|
||||||
for (j = 0; j < tcp->numlayers; j++) {
|
|
||||||
if (cp.fixed_quality) // add fixed_quality
|
|
||||||
tcp->distoratio[j] = tcp_init->distoratio[j];
|
|
||||||
else
|
|
||||||
tcp->rates[j] = tcp_init->rates[j];
|
|
||||||
}
|
|
||||||
tcp->csty = CSty;
|
|
||||||
tcp->prg = Prog_order;
|
|
||||||
tcp->mct = tcp_init->mct;
|
|
||||||
tcp->ppt = 0;
|
|
||||||
tcp->ppt_data = NULL;
|
|
||||||
tcp->ppt_store = 0;
|
|
||||||
|
|
||||||
numpocs_tile = 0;
|
|
||||||
tcp->POC = 0;
|
|
||||||
if (numpocs) {
|
|
||||||
/* intialisation of POC */
|
|
||||||
tcp->POC = 1;
|
|
||||||
for (i = 0; i < numpocs; i++) {
|
|
||||||
if (tileno == POC[i].tile - 1 || POC[i].tile == -1) {
|
|
||||||
tcp_poc = &tcp->pocs[numpocs_tile];
|
|
||||||
tcp_poc->resno0 = POC[numpocs_tile].resno0;
|
|
||||||
tcp_poc->compno0 = POC[numpocs_tile].compno0;
|
|
||||||
tcp_poc->layno1 = POC[numpocs_tile].layno1;
|
|
||||||
tcp_poc->resno1 = POC[numpocs_tile].resno1;
|
|
||||||
tcp_poc->compno1 = POC[numpocs_tile].compno1;
|
|
||||||
tcp_poc->prg = POC[numpocs_tile].prg;
|
|
||||||
tcp_poc->tile = POC[numpocs_tile].tile;
|
|
||||||
numpocs_tile++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tcp->numpocs = numpocs_tile;
|
|
||||||
tcp->tccps = (j2k_tccp_t *) malloc(numcomps * sizeof(j2k_tccp_t));
|
|
||||||
|
|
||||||
for (i = 0; i < numcomps; i++) {
|
|
||||||
tccp = &tcp->tccps[i];
|
|
||||||
tccp->csty = CSty & 0x01; /* 0 => one precinct || 1 => custom precinct */
|
|
||||||
tccp->numresolutions = NumResolution;
|
|
||||||
tccp->cblkw = int_floorlog2(cblockw_init);
|
|
||||||
tccp->cblkh = int_floorlog2(cblockh_init);
|
|
||||||
tccp->cblksty = mode;
|
|
||||||
tccp->qmfbid = ir ? 0 : 1;
|
|
||||||
tccp->qntsty = ir ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
|
|
||||||
tccp->numgbits = 2;
|
|
||||||
if (i == ROI_compno)
|
|
||||||
tccp->roishift = ROI_shift;
|
|
||||||
else
|
|
||||||
tccp->roishift = 0;
|
|
||||||
if (CSty & J2K_CCP_CSTY_PRT) {
|
|
||||||
int p = 0;
|
|
||||||
for (j = tccp->numresolutions - 1; j >= 0; j--) {
|
|
||||||
if (p < res_spec) {
|
|
||||||
if (prcw_init[p] < 1)
|
|
||||||
tccp->prcw[j] = 1;
|
|
||||||
else
|
|
||||||
tccp->prcw[j] = int_floorlog2(prcw_init[p]);
|
|
||||||
|
|
||||||
if (prch_init[p] < 1)
|
|
||||||
tccp->prch[j] = 1;
|
|
||||||
else
|
|
||||||
tccp->prch[j] = int_floorlog2(prch_init[p]);
|
|
||||||
} else {
|
|
||||||
int size_prcw, size_prch;
|
|
||||||
size_prcw = prcw_init[res_spec - 1] >> (p - (res_spec - 1));
|
|
||||||
size_prch = prch_init[res_spec - 1] >> (p - (res_spec - 1));
|
|
||||||
if (size_prcw < 1)
|
|
||||||
tccp->prcw[j] = 1;
|
|
||||||
else
|
|
||||||
tccp->prcw[j] = int_floorlog2(size_prcw);
|
|
||||||
if (size_prch < 1)
|
|
||||||
tccp->prch[j] = 1;
|
|
||||||
else
|
|
||||||
tccp->prch[j] = int_floorlog2(size_prch);
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
/*printf("\nsize precinct pour level %d : %d,%d\n", j,
|
|
||||||
tccp->prcw[j], tccp->prch[j]); */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (j = 0; j < tccp->numresolutions; j++) {
|
|
||||||
tccp->prcw[j] = 15;
|
|
||||||
tccp->prch[j] = 15;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
calc_explicit_stepsizes(tccp, prec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mj2file = fopen(outfile, "wb");
|
|
||||||
|
|
||||||
if (!mj2file) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
movie.tk = (mj2_tk_t *) malloc(sizeof(mj2_tk_t));
|
|
||||||
movie.num_vtk = 1;
|
|
||||||
movie.num_stk = 0;
|
|
||||||
movie.num_htk = 0;
|
|
||||||
|
|
||||||
movie.tk[0].track_type = 0; // Video Track
|
|
||||||
movie.tk[0].track_ID = 1;
|
|
||||||
movie.tk[0].Dim[0] = Dim[0];
|
|
||||||
movie.tk[0].Dim[1] = Dim[1];
|
|
||||||
movie.tk[0].w = w;
|
|
||||||
movie.tk[0].h = h;
|
|
||||||
movie.tk[0].CbCr_subsampling_dx = CbCr_subsampling_dx;
|
|
||||||
movie.tk[0].CbCr_subsampling_dy = CbCr_subsampling_dy;
|
|
||||||
movie.tk[0].sample_rate = frame_rate;
|
|
||||||
movie.tk[0].jp2_struct.numcomps = 3; // NC
|
|
||||||
jp2_init_stdjp2(&movie.tk[0].jp2_struct);
|
|
||||||
|
|
||||||
movie.tk[0].jp2_struct.w = w;
|
|
||||||
movie.tk[0].jp2_struct.h = h;
|
|
||||||
movie.tk[0].jp2_struct.bpc = 7;
|
|
||||||
movie.tk[0].jp2_struct.meth = 1;
|
|
||||||
movie.tk[0].jp2_struct.enumcs = 18; // YUV
|
|
||||||
|
|
||||||
|
|
||||||
yuvfile = fopen(infile,"rb");
|
|
||||||
if (!yuvfile) {
|
|
||||||
fprintf(stderr, "failed to open %s for reading\n",infile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
movie.tk[0].num_samples = yuv_num_frames(&movie.tk[0],yuvfile);
|
|
||||||
if (!movie.tk[0].num_samples) {
|
|
||||||
fprintf(stderr,"Unable to count the number of frames in YUV input file\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// One sample per chunk
|
|
||||||
movie.tk[0].chunk = (mj2_chunk_t*) malloc(movie.tk[0].num_samples * sizeof(mj2_chunk_t));
|
|
||||||
movie.tk[0].sample = (mj2_sample_t*) malloc(movie.tk[0].num_samples * sizeof(mj2_sample_t));
|
|
||||||
|
|
||||||
if (mj2_init_stdmovie(&movie)) {
|
|
||||||
fprintf(stderr, "Error with movie initialization");
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Writing JP, FTYP and MDAT boxes
|
|
||||||
buf = (char*) malloc (300 * sizeof(char)); // Assuming that the JP and FTYP
|
|
||||||
// boxes won't be longer than 300 bytes
|
|
||||||
cio_init(buf , 300);
|
|
||||||
mj2_write_jp();
|
|
||||||
mj2_write_ftyp(&movie);
|
|
||||||
mdat_initpos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(MJ2_MDAT, 4);
|
|
||||||
fwrite(buf,cio_tell(),1,mj2file);
|
|
||||||
offset = cio_tell();
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
for (i = 0; i < movie.num_stk + movie.num_htk + movie.num_vtk; i++) {
|
|
||||||
if (movie.tk[i].track_type != 0) {
|
|
||||||
fprintf(stderr, "Unable to write sound or hint tracks\n");
|
|
||||||
} else {
|
|
||||||
//j2k_cp_t cp_init;
|
|
||||||
mj2_tk_t *tk;
|
|
||||||
|
|
||||||
tk = &movie.tk[i];
|
|
||||||
|
|
||||||
//tk->sample =
|
|
||||||
//(mj2_sample_t *) malloc(tk->num_samples * sizeof(mj2_sample_t));
|
|
||||||
tk->num_chunks = tk->num_samples;
|
|
||||||
//tk->chunk =
|
|
||||||
//(mj2_chunk_t *) malloc(tk->num_chunks * sizeof(mj2_chunk_t));
|
|
||||||
|
|
||||||
fprintf(stderr, "Video Track number %d\n", i + 1);
|
|
||||||
|
|
||||||
// Copy the first tile coding parameters (tcp) to cp_init
|
|
||||||
|
|
||||||
//cp_init.tcps =
|
|
||||||
//(j2k_tcp_t *) malloc(cp.tw * cp.th * sizeof(j2k_tcp_t));
|
|
||||||
for (tileno = 0; tileno < cp.tw * cp.th; tileno++) {
|
|
||||||
for (l = 0; l < cp.tcps[tileno].numlayers; l++) {
|
|
||||||
cp_init.tcps[tileno].rates[l] = cp.tcps[tileno].rates[l];
|
|
||||||
//tileno = cp.tcps[tileno].rates[l];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (sampleno = 0; sampleno < tk->num_samples; sampleno++) {
|
|
||||||
buf = (char *) malloc(cp.tdx * cp.tdy * cp.th * cp.tw * 2);
|
|
||||||
cio_init(buf, cp.tdx * cp.tdy * cp.th * cp.tw * 2);
|
|
||||||
|
|
||||||
fprintf(stderr, "Frame number %d/%d: ", sampleno + 1, tk->num_samples);
|
|
||||||
|
|
||||||
|
|
||||||
if (!yuvtoimage(yuvfile, tk, &img, sampleno, subsampling_dx, subsampling_dy)) {
|
|
||||||
fprintf(stderr, "Error with frame number %d in YUV file\n", sampleno);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
jp2c_initpos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(JP2_JP2C, 4); // JP2C
|
|
||||||
|
|
||||||
len = j2k_encode(&img, &cp, buf, cp.tdx * cp.tdy * 2, index);
|
|
||||||
if (len ==0) {
|
|
||||||
fprintf(stderr,"Unable to encode image");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cio_seek(jp2c_initpos);
|
|
||||||
cio_write(len+8,4);
|
|
||||||
|
|
||||||
for (m = 0; m < img.numcomps; m++) {
|
|
||||||
free(img.comps[m].data);
|
|
||||||
}
|
|
||||||
free(img.comps);
|
|
||||||
|
|
||||||
tk->sample[sampleno].sample_size = len+8;
|
|
||||||
|
|
||||||
tk->sample[sampleno].offset = offset;
|
|
||||||
tk->chunk[sampleno].offset = offset; // There is one sample per chunk
|
|
||||||
|
|
||||||
fwrite(buf, 1, len+8, mj2file);
|
|
||||||
|
|
||||||
offset += len+8;
|
|
||||||
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
// Copy the cp_init parameters to cp.tcps
|
|
||||||
|
|
||||||
for (tileno = 0; tileno < cp.tw * cp.th; tileno++) {
|
|
||||||
for (k = 0; k < cp.tcps[tileno].numlayers; k++) {
|
|
||||||
cp.tcps[tileno].rates[k] = cp_init.tcps[tileno].rates[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(mj2file, mdat_initpos, SEEK_SET);
|
|
||||||
|
|
||||||
buf = (char*) malloc(4*sizeof(char));
|
|
||||||
|
|
||||||
cio_init(buf, 4); // Init a cio to write box length variable in a little endian way
|
|
||||||
cio_write(offset - mdat_initpos, 4);
|
|
||||||
fwrite(buf, 4, 1, mj2file);
|
|
||||||
fseek(mj2file,0,SEEK_END);
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
// Writing MOOV box
|
|
||||||
i=1;
|
|
||||||
buf = (char*) malloc (10000 * sizeof(char));
|
|
||||||
cio_init(buf , i*10000);
|
|
||||||
if (setjmp(j2k_error)) {
|
|
||||||
i++;
|
|
||||||
realloc(buf,i*10000* sizeof(char));
|
|
||||||
pos = cio_tell();
|
|
||||||
cio_init(buf , i*10000);
|
|
||||||
cio_seek(pos);
|
|
||||||
}
|
|
||||||
mj2_write_moov(&movie);
|
|
||||||
fwrite(buf,cio_tell(),1,mj2file);
|
|
||||||
|
|
||||||
// Ending program
|
|
||||||
mj2_memory_free(&movie);
|
|
||||||
free(cp_init.tcps);
|
|
||||||
if (tcp_init->numlayers > 9)
|
|
||||||
free(cp.matrice);
|
|
||||||
for (tileno = 0; tileno < cp.tw * cp.th; tileno++)
|
|
||||||
free(cp.tcps[tileno].tccps);
|
|
||||||
free(cp.tcps);
|
|
||||||
fclose(mj2file);
|
|
||||||
free(buf);
|
|
||||||
remove("Compo0");
|
|
||||||
remove("Compo1");
|
|
||||||
remove("Compo2");
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="frames_to_mj2" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=frames_to_mj2 - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "frames_to_mj2.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "frames_to_mj2.mak" CFG="frames_to_mj2 - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "frames_to_mj2 - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "frames_to_mj2 - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "frames_to_mj2 - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "frames_to_mj2 - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "frames_to_mj2___Win32_Debug0"
|
|
||||||
# PROP BASE Intermediate_Dir "frames_to_mj2___Win32_Debug0"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "frames_to_mj2___Win32_Debug0"
|
|
||||||
# PROP Intermediate_Dir "frames_to_mj2___Win32_Debug0"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "frames_to_mj2 - Win32 Release"
|
|
||||||
# Name "frames_to_mj2 - Win32 Debug"
|
|
||||||
# Begin Group "MJ2"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "MJ2 Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "MJ2 Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\frames_to_mj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "OpenJPEG Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\openjpeg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
201
mj2/mj2.h
201
mj2/mj2.h
@@ -1,201 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003-2004, Fran<61>ois-Olivier Devaux
|
|
||||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <j2k.h>
|
|
||||||
#include <jp2.h>
|
|
||||||
|
|
||||||
#ifndef __MJ2_H
|
|
||||||
#define __MJ2_H
|
|
||||||
|
|
||||||
typedef struct { /* Time To Sample */
|
|
||||||
int sample_count;
|
|
||||||
int sample_delta;
|
|
||||||
} mj2_tts_t;
|
|
||||||
|
|
||||||
typedef struct { /* Chunk */
|
|
||||||
int num_samples;
|
|
||||||
int sample_descr_idx;
|
|
||||||
int offset;
|
|
||||||
} mj2_chunk_t;
|
|
||||||
|
|
||||||
typedef struct { /* Sample to chunk */
|
|
||||||
int first_chunk;
|
|
||||||
int samples_per_chunk;
|
|
||||||
int sample_descr_idx;
|
|
||||||
} mj2_sampletochunk_t;
|
|
||||||
|
|
||||||
typedef struct { /* Sample */
|
|
||||||
unsigned int sample_size;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int sample_delta;
|
|
||||||
} mj2_sample_t;
|
|
||||||
|
|
||||||
typedef struct { /* URL */
|
|
||||||
int location[4];
|
|
||||||
} mj2_url_t;
|
|
||||||
|
|
||||||
typedef struct { /* URN */
|
|
||||||
int name[2];
|
|
||||||
int location[4];
|
|
||||||
} mj2_urn_t;
|
|
||||||
|
|
||||||
typedef struct { /* Video Track Parameters */
|
|
||||||
int track_ID;
|
|
||||||
int track_type;
|
|
||||||
unsigned int creation_time;
|
|
||||||
unsigned int modification_time;
|
|
||||||
int duration;
|
|
||||||
int timescale;
|
|
||||||
int layer;
|
|
||||||
int volume;
|
|
||||||
int language;
|
|
||||||
int balance;
|
|
||||||
int maxPDUsize;
|
|
||||||
int avgPDUsize;
|
|
||||||
int maxbitrate;
|
|
||||||
int avgbitrate;
|
|
||||||
int slidingavgbitrate;
|
|
||||||
int graphicsmode;
|
|
||||||
int opcolor[3];
|
|
||||||
int num_url;
|
|
||||||
mj2_url_t *url;
|
|
||||||
int num_urn;
|
|
||||||
mj2_urn_t *urn;
|
|
||||||
int Dim[2];
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
int visual_w;
|
|
||||||
int visual_h;
|
|
||||||
int CbCr_subsampling_dx;
|
|
||||||
int CbCr_subsampling_dy;
|
|
||||||
// int subsampling_dx;
|
|
||||||
// int subsampling_dy;
|
|
||||||
int sample_rate;
|
|
||||||
int sample_description;
|
|
||||||
int horizresolution;
|
|
||||||
int vertresolution;
|
|
||||||
int compressorname[8];
|
|
||||||
int depth;
|
|
||||||
unsigned char fieldcount;
|
|
||||||
unsigned char fieldorder;
|
|
||||||
unsigned char or_fieldcount;
|
|
||||||
unsigned char or_fieldorder;
|
|
||||||
int num_br;
|
|
||||||
unsigned int *br;
|
|
||||||
unsigned char num_jp2x;
|
|
||||||
unsigned char *jp2xdata;
|
|
||||||
unsigned char hsub;
|
|
||||||
unsigned char vsub;
|
|
||||||
unsigned char hoff;
|
|
||||||
unsigned char voff;
|
|
||||||
int trans_matrix[9];
|
|
||||||
unsigned int num_samples; /* Number of samples */
|
|
||||||
int transorm;
|
|
||||||
int handler_type;
|
|
||||||
int name_size;
|
|
||||||
unsigned char same_sample_size;
|
|
||||||
int num_tts;
|
|
||||||
mj2_tts_t *tts; /* Time to sample */
|
|
||||||
unsigned int num_chunks;
|
|
||||||
mj2_chunk_t *chunk;
|
|
||||||
int num_samplestochunk;
|
|
||||||
mj2_sampletochunk_t *sampletochunk;
|
|
||||||
char *name;
|
|
||||||
jp2_struct_t jp2_struct;
|
|
||||||
mj2_sample_t *sample; /* Sample parameters */
|
|
||||||
} mj2_tk_t; /* Track Parameters */
|
|
||||||
|
|
||||||
typedef struct { /* Movie */
|
|
||||||
unsigned int brand;
|
|
||||||
unsigned int minversion;
|
|
||||||
int num_cl;
|
|
||||||
unsigned int *cl;
|
|
||||||
unsigned int creation_time;
|
|
||||||
unsigned int modification_time;
|
|
||||||
int timescale;
|
|
||||||
unsigned int duration;
|
|
||||||
int rate;
|
|
||||||
int num_vtk;
|
|
||||||
int num_stk;
|
|
||||||
int num_htk;
|
|
||||||
int volume;
|
|
||||||
int trans_matrix[9];
|
|
||||||
int next_tk_id;
|
|
||||||
mj2_tk_t *tk; /* Track Parameters */
|
|
||||||
} mj2_movie_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int length;
|
|
||||||
int type;
|
|
||||||
int init_pos;
|
|
||||||
} mj2_box_t;
|
|
||||||
|
|
||||||
void mj2_write_jp();
|
|
||||||
|
|
||||||
void mj2_write_ftyp(mj2_movie_t * movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use this function to initialize a standard movie with standard values
|
|
||||||
* It has one sample per chunk
|
|
||||||
*/
|
|
||||||
int mj2_init_stdmovie(mj2_movie_t * movie);
|
|
||||||
|
|
||||||
|
|
||||||
/* int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
|
|
||||||
*
|
|
||||||
* Encode a MJ2 movie from a yuv file
|
|
||||||
* movie: an existing mj2_movie structure (to create a standard one, use mj2_init_stdmovie
|
|
||||||
* cp: coding parameters of j2k images
|
|
||||||
* index: index file name
|
|
||||||
*/
|
|
||||||
int mj2_encode(mj2_movie_t * movie, j2k_cp_t * cp, char *index);
|
|
||||||
|
|
||||||
|
|
||||||
/* int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
|
|
||||||
* j2k_cp_t * cp, char *outfile);
|
|
||||||
*
|
|
||||||
* Decode a MJ2 movie to a yuv file
|
|
||||||
* src: pointer to memory where frames will be stored
|
|
||||||
* movie: a mj2_movie structure
|
|
||||||
* cp: coding parameters of j2k images
|
|
||||||
* outfile: yuv file name
|
|
||||||
*/
|
|
||||||
int mj2_decode(unsigned char *src, int len, mj2_movie_t * movie,
|
|
||||||
j2k_cp_t * cp, char *outfile);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free memory used to encode and decode mj2 files
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void mj2_memory_free(mj2_movie_t * movie);
|
|
||||||
|
|
||||||
int mj2_read_struct(FILE *file, mj2_movie_t * movie);
|
|
||||||
|
|
||||||
void mj2_write_moov(mj2_movie_t * movie);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,318 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#include "mj2.h"
|
|
||||||
#include <j2k.h>
|
|
||||||
#include <int.h>
|
|
||||||
|
|
||||||
/* ----------------------- */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* Count the number of frames */
|
|
||||||
/* in a YUV file */
|
|
||||||
/* */
|
|
||||||
/* ----------------------- */
|
|
||||||
|
|
||||||
int yuv_num_frames(mj2_tk_t * tk, FILE *f)
|
|
||||||
{
|
|
||||||
int numimages, frame_size;
|
|
||||||
long end_of_f;
|
|
||||||
|
|
||||||
frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
end_of_f = ftell(f); /* Calculate file size */
|
|
||||||
|
|
||||||
if (end_of_f < frame_size) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"YUV does not contains any frame of %d x %d size\n", tk->w,
|
|
||||||
tk->h);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
numimages = end_of_f / frame_size; /* Calculate number of images */
|
|
||||||
|
|
||||||
return numimages;
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// YUV to IMAGE
|
|
||||||
//
|
|
||||||
// -----------------------
|
|
||||||
|
|
||||||
int yuvtoimage(FILE *yuvfile, mj2_tk_t * tk, j2k_image_t * img,
|
|
||||||
int frame_num, int subsampling_dx, int subsampling_dy)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
int offset;
|
|
||||||
long end_of_f, position;
|
|
||||||
FILE *Compo;
|
|
||||||
|
|
||||||
offset =
|
|
||||||
(int) ((double) (frame_num * tk->w * tk->h) *
|
|
||||||
(1.0 +
|
|
||||||
1.0 * (double) 2 / (double) (tk->CbCr_subsampling_dx *
|
|
||||||
tk->CbCr_subsampling_dy)));
|
|
||||||
fseek(yuvfile, 0, SEEK_END);
|
|
||||||
end_of_f = ftell(yuvfile);
|
|
||||||
fseek(yuvfile, sizeof(unsigned char) * offset, SEEK_SET);
|
|
||||||
position = ftell(yuvfile);
|
|
||||||
if (position >= end_of_f) {
|
|
||||||
fprintf(stderr, "Cannot reach frame number %d in yuv file !!\n",
|
|
||||||
frame_num);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
img->x0 = tk->Dim[0];
|
|
||||||
img->y0 = tk->Dim[1];
|
|
||||||
img->x1 = !tk->Dim[0] ? (tk->w - 1) * subsampling_dx + 1 : tk->Dim[0] +
|
|
||||||
(tk->w - 1) * subsampling_dx + 1;
|
|
||||||
img->y1 = !tk->Dim[1] ? (tk->h - 1) * subsampling_dy + 1 : tk->Dim[1] +
|
|
||||||
(tk->h - 1) * subsampling_dy + 1;
|
|
||||||
img->numcomps = 3;
|
|
||||||
img->color_space = 3;
|
|
||||||
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
|
|
||||||
for (i = 0; i < img->numcomps; i++) {
|
|
||||||
img->comps[i].data = (int *) malloc(sizeof(int) * tk->w * tk->h);
|
|
||||||
img->comps[i].prec = 8;
|
|
||||||
img->comps[i].bpp = 8;
|
|
||||||
img->comps[i].sgnd = 0;
|
|
||||||
if (i == 0) {
|
|
||||||
img->comps[i].dx = subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy;
|
|
||||||
} else {
|
|
||||||
img->comps[i].dx = subsampling_dx * tk->CbCr_subsampling_dx;
|
|
||||||
img->comps[i].dy = subsampling_dy * tk->CbCr_subsampling_dy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Compo = fopen("Compo0", "wb");
|
|
||||||
if (!Compo) {
|
|
||||||
fprintf(stderr, "Failed to open Compo0 for writing !\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < (tk->w * tk->h / (img->comps[0].dx * img->comps[0].dy))
|
|
||||||
&& !feof(yuvfile); i++) {
|
|
||||||
unsigned char y;
|
|
||||||
j = fread(&y, 1, 1, yuvfile);
|
|
||||||
fwrite(&y, 1, 1, Compo);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(Compo);
|
|
||||||
|
|
||||||
Compo = fopen("Compo1", "wb");
|
|
||||||
if (!Compo) {
|
|
||||||
fprintf(stderr, "Failed to open Compo1 for writing !\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (tk->w * tk->h / (img->comps[1].dx * img->comps[1].dy))
|
|
||||||
&& !feof(yuvfile); i++) {
|
|
||||||
unsigned char cb;
|
|
||||||
j = fread(&cb, sizeof(unsigned char), 1, yuvfile);
|
|
||||||
fwrite(&cb, 1, 1, Compo);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(Compo);
|
|
||||||
|
|
||||||
Compo = fopen("Compo2", "wb");
|
|
||||||
if (!Compo) {
|
|
||||||
fprintf(stderr, "Failed to open Compo2 for writing !\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (tk->w * tk->h / (img->comps[2].dx * img->comps[2].dy))
|
|
||||||
&& !feof(yuvfile); i++) {
|
|
||||||
unsigned char cr;
|
|
||||||
j = fread(&cr, sizeof(unsigned char), 1, yuvfile);
|
|
||||||
fwrite(&cr, 1, 1, Compo);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(Compo);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// IMAGE to YUV
|
|
||||||
//
|
|
||||||
// -----------------------
|
|
||||||
|
|
||||||
|
|
||||||
int imagetoyuv(j2k_image_t * img, j2k_cp_t * cp, char *outfile)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (img->numcomps == 3) {
|
|
||||||
if (img->comps[0].dx != img->comps[1].dx / 2
|
|
||||||
|| img->comps[1].dx != img->comps[2].dx) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Error with the input image components size: cannot create yuv file)\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else if (!(img->numcomps == 1)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Error with the number of image components(must be one or three)\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(outfile, "a+b");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h); i++) {
|
|
||||||
unsigned char y;
|
|
||||||
y = img->comps[0].data[i];
|
|
||||||
fwrite(&y, 1, 1, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (img->numcomps == 3) {
|
|
||||||
for (i = 0; i < (img->comps[1].w * img->comps[1].h); i++) {
|
|
||||||
unsigned char cb;
|
|
||||||
cb = img->comps[1].data[i];
|
|
||||||
fwrite(&cb, 1, 1, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (img->comps[2].w * img->comps[2].h); i++) {
|
|
||||||
unsigned char cr;
|
|
||||||
cr = img->comps[2].data[i];
|
|
||||||
fwrite(&cr, 1, 1, f);
|
|
||||||
}
|
|
||||||
} else if (img->numcomps == 1) {
|
|
||||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
|
|
||||||
unsigned char cb = 125;
|
|
||||||
fwrite(&cb, 1, 1, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) {
|
|
||||||
unsigned char cr = 125;
|
|
||||||
fwrite(&cr, 1, 1, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// IMAGE to BMP
|
|
||||||
//
|
|
||||||
// -----------------------
|
|
||||||
|
|
||||||
int imagetobmp(j2k_image_t * img, j2k_cp_t * cp, char *outfile) {
|
|
||||||
int w,wr,h,hr,i,pad;
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
if (img->numcomps == 3 && img->comps[0].dx == img->comps[1].dx
|
|
||||||
&& img->comps[1].dx == img->comps[2].dx
|
|
||||||
&& img->comps[0].dy == img->comps[1].dy
|
|
||||||
&& img->comps[1].dy == img->comps[2].dy
|
|
||||||
&& img->comps[0].prec == img->comps[1].prec
|
|
||||||
&& img->comps[1].prec == img->comps[2].prec) {
|
|
||||||
/* -->> -->> -->> -->>
|
|
||||||
|
|
||||||
24 bits color
|
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
|
||||||
|
|
||||||
f = fopen(outfile, "wb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
w = img->comps[0].w;
|
|
||||||
wr = int_ceildivpow2(img->comps[0].w, img->comps[0].factor);
|
|
||||||
|
|
||||||
h = img->comps[0].h;
|
|
||||||
hr = int_ceildivpow2(img->comps[0].h, img->comps[0].factor);
|
|
||||||
|
|
||||||
fprintf(f, "BM");
|
|
||||||
|
|
||||||
/* FILE HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(f, "%c%c%c%c",
|
|
||||||
(unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
|
|
||||||
54) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
|
|
||||||
>> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
|
|
||||||
((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
|
||||||
|
|
||||||
/* INFO HEADER */
|
|
||||||
/* ------------- */
|
|
||||||
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
|
|
||||||
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
|
|
||||||
(unsigned char) ((wr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((wr) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
|
|
||||||
(unsigned char) ((hr) >> 8) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 16) & 0xff,
|
|
||||||
(unsigned char) ((hr) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
|
||||||
fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c",
|
|
||||||
(unsigned char) (3 * hr * wr +
|
|
||||||
3 * hr * (wr % 2)) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
8) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
16) & 0xff,
|
|
||||||
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
|
|
||||||
24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
|
|
||||||
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
|
|
||||||
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
|
||||||
|
|
||||||
for (i = 0; i < wr * hr; i++) {
|
|
||||||
unsigned char R, G, B;
|
|
||||||
/* a modifier */
|
|
||||||
// R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
// G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
// B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
|
||||||
B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
|
|
||||||
fprintf(f, "%c%c%c", B, G, R);
|
|
||||||
|
|
||||||
if ((i + 1) % wr == 0) {
|
|
||||||
for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */
|
|
||||||
fprintf(f, "%c", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
free(img->comps[1].data);
|
|
||||||
free(img->comps[2].data);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "mj2.h"
|
|
||||||
|
|
||||||
#ifndef __MJ2_CONVERT_H
|
|
||||||
#define __MJ2_CONVERT_H
|
|
||||||
|
|
||||||
int imagetoyuv(j2k_image_t * img, j2k_cp_t * cp, char *outfile);
|
|
||||||
|
|
||||||
int imagetobmp(j2k_image_t * img, j2k_cp_t * cp, char *outfile);
|
|
||||||
|
|
||||||
int yuvtoimage(FILE *yuvfile, mj2_tk_t * tk, j2k_image_t * img,
|
|
||||||
int frame_num, int subsampling_dx, int subsampling_dy);
|
|
||||||
|
|
||||||
int yuv_num_frames(mj2_tk_t * tk, FILE *f);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
#include "mj2.h"
|
|
||||||
#include "mj2_convert.h"
|
|
||||||
#include <openjpeg.h>
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h> // Must be included first
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
jmp_buf j2k_error;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
|
|
||||||
unsigned int tnum, snum;
|
|
||||||
mj2_movie_t movie;
|
|
||||||
mj2_tk_t *track;
|
|
||||||
mj2_sample_t *sample;
|
|
||||||
unsigned char* frame_codestream;
|
|
||||||
FILE *file, *outfile;
|
|
||||||
char outfilename[50];
|
|
||||||
j2k_image_t img;
|
|
||||||
j2k_cp_t cp;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
cp.layer=0;
|
|
||||||
cp.reduce=0;
|
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
printf("Bad syntax: Usage: MJ2_decoder inputfile.mj2 outputfile.yuv\n");
|
|
||||||
printf("Example: MJ2_decoder foreman.mj2 foreman.yuv\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
|
||||||
|
|
||||||
if (!file) {
|
|
||||||
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking output file
|
|
||||||
outfile = fopen(argv[2], "w");
|
|
||||||
if (!file) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fclose(outfile);
|
|
||||||
|
|
||||||
if (mj2_read_struct(file, &movie)) // Creating the movie structure
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
// Decode first video track
|
|
||||||
tnum = 0;
|
|
||||||
while (movie.tk[tnum].track_type != 0)
|
|
||||||
tnum ++;
|
|
||||||
|
|
||||||
track = &movie.tk[tnum];
|
|
||||||
|
|
||||||
// Output info on first video tracl
|
|
||||||
fprintf(stdout,"The first video track contains %d frames.\nWidth: %d, Height: %d \n\n",
|
|
||||||
track->num_samples, track->w, track->h);
|
|
||||||
|
|
||||||
for (snum=0; snum < track->num_samples; snum++)
|
|
||||||
{
|
|
||||||
fprintf(stdout,"Frame %d: ",snum+1);
|
|
||||||
sample = &track->sample[snum];
|
|
||||||
frame_codestream = (unsigned char*) malloc (sample->sample_size-8); // Skipping JP2C marker
|
|
||||||
fseek(file,sample->offset+8,SEEK_SET);
|
|
||||||
fread(frame_codestream,sample->sample_size-8,1, file); // Assuming that jp and ftyp markers size do
|
|
||||||
|
|
||||||
if (!j2k_decode(frame_codestream, sample->sample_size-8, &img, &cp)) // Decode J2K to image
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (((img.numcomps == 3) && (img.comps[0].dx == img.comps[1].dx / 2)
|
|
||||||
&& (img.comps[0].dx == img.comps[2].dx / 2 ) && (img.comps[0].dx == 1))
|
|
||||||
|| (img.numcomps == 1)) {
|
|
||||||
|
|
||||||
if (imagetoyuv(&img, &cp, argv[2])) // Convert image to YUV
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ((img.numcomps == 3) &&
|
|
||||||
(img.comps[0].dx == 1) && (img.comps[1].dx == 1)&&
|
|
||||||
(img.comps[2].dx == 1))// If YUV 4:4:4 input --> to bmp
|
|
||||||
{
|
|
||||||
fprintf(stdout,"The frames will be output in a bmp format (output_1.bmp, ...)\n");
|
|
||||||
sprintf(outfilename,"output_%d.bmp",snum);
|
|
||||||
if (imagetobmp(&img, &cp, outfilename)) // Convert image to YUV
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(stdout,"Image component dimensions are unknown. Unable to output image\n");
|
|
||||||
fprintf(stdout,"The frames will be output in a j2k file (output_1.j2k, ...)\n");
|
|
||||||
|
|
||||||
sprintf(outfilename,"output_%d.j2k",snum);
|
|
||||||
outfile = fopen(outfilename, "wb");
|
|
||||||
if (!outfile) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n",outfilename);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fwrite(frame_codestream,sample->sample_size-8,1,outfile);
|
|
||||||
fclose(outfile);
|
|
||||||
}
|
|
||||||
for (i=0; i<img.numcomps; i++)
|
|
||||||
free(img.comps[i].data);
|
|
||||||
j2k_dec_release();
|
|
||||||
free(frame_codestream);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
fprintf(stdout, "%d frame(s) correctly extracted\n", snum);
|
|
||||||
mj2_memory_free(&movie);
|
|
||||||
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,305 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="mj2_to_frames" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=mj2_to_frames - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "mj2_to_frames.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "mj2_to_frames.mak" CFG="mj2_to_frames - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "mj2_to_frames - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "mj2_to_frames - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_frames - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_frames - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "mj2_to_frames___Win32_Debug0"
|
|
||||||
# PROP BASE Intermediate_Dir "mj2_to_frames___Win32_Debug0"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "mj2_to_frames___Win32_Debug0"
|
|
||||||
# PROP Intermediate_Dir "mj2_to_frames___Win32_Debug0"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "mj2_to_frames - Win32 Release"
|
|
||||||
# Name "mj2_to_frames - Win32 Debug"
|
|
||||||
# Begin Group "MJ2"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "MJ2 Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "MJ2 Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.c
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_frames - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_frames - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /I "../libopenjpeg"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.c
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_frames - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_frames - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /I "../libopenjpeg"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.c
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_frames - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_frames - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /I "../libopenjpeg"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_to_frames.c
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_frames - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_frames - Win32 Debug"
|
|
||||||
|
|
||||||
# ADD CPP /I "../libopenjpeg"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "OpenJPEG Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ".h"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\openjpeg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ".c"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="mj2_to_metadata" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=mj2_to_metadata - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "mj2_to_metadata.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "mj2_to_metadata.mak" CFG="mj2_to_metadata - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "mj2_to_metadata - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "mj2_to_metadata - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "mj2_to_metadata - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "mj2_to_metadata - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "mj2_to_metadata___Win32_Debug0"
|
|
||||||
# PROP BASE Intermediate_Dir "mj2_to_metadata___Win32_Debug0"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "mj2_to_metadata___Win32_Debug0"
|
|
||||||
# PROP Intermediate_Dir "mj2_to_metadata___Win32_Debug0"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /FR /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "mj2_to_metadata - Win32 Release"
|
|
||||||
# Name "mj2_to_metadata - Win32 Debug"
|
|
||||||
# Begin Group "MJ2"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "MJ2 Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\meta_out.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "MJ2 Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\compat\getopt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\meta_out.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_convert.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\mj2_to_metadata.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Group "OpenJPEG Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ".h"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\openjpeg.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "OpenJPEG Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter ".c"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\bio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\cio.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\dwt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\fix.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\int.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\j2k.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jp2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\jpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mct.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\mqc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\pi.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\raw.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t1.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\t2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tcd.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\libopenjpeg\tgt.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,324 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="mj2_to_metadata"
|
|
||||||
ProjectGUID="{338C1241-ACB9-469F-98DF-3B9D79ADD1A0}"
|
|
||||||
SccProjectName=""
|
|
||||||
SccLocalPath="">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory=".\Release"
|
|
||||||
IntermediateDirectory=".\Release"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
InlineFunctionExpansion="1"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg"
|
|
||||||
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE,DONT_HAVE_GETOPT,NO_PACKETS_DECODING"
|
|
||||||
StringPooling="TRUE"
|
|
||||||
RuntimeLibrary="4"
|
|
||||||
EnableFunctionLevelLinking="TRUE"
|
|
||||||
UsePrecompiledHeader="2"
|
|
||||||
PrecompiledHeaderFile=".\Release/mj2_to_metadata.pch"
|
|
||||||
AssemblerListingLocation=".\Release/"
|
|
||||||
ObjectFile=".\Release/"
|
|
||||||
ProgramDataBaseFileName=".\Release/"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalOptions="/MACHINE:I386"
|
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
|
||||||
OutputFile=".\Release/mj2_to_metadata.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
ProgramDatabaseFile=".\Release/mj2_to_metadata.pdb"
|
|
||||||
SubSystem="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\Release/mj2_to_metadata.tlb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="2057"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory=".\mj2_to_metadata___Win32_Debug0"
|
|
||||||
IntermediateDirectory=".\mj2_to_metadata___Win32_Debug0"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="0"
|
|
||||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg"
|
|
||||||
PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE,DONT_HAVE_GETOPT,NO_PACKETS_DECODING"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="5"
|
|
||||||
UsePrecompiledHeader="2"
|
|
||||||
PrecompiledHeaderFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.pch"
|
|
||||||
AssemblerListingLocation=".\mj2_to_metadata___Win32_Debug0/"
|
|
||||||
ObjectFile=".\mj2_to_metadata___Win32_Debug0/"
|
|
||||||
ProgramDataBaseFileName=".\mj2_to_metadata___Win32_Debug0/"
|
|
||||||
WarningLevel="3"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
DebugInformationFormat="4"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalOptions="/MACHINE:I386"
|
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
|
||||||
OutputFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.exe"
|
|
||||||
LinkIncremental="2"
|
|
||||||
SuppressStartupBanner="TRUE"
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
ProgramDatabaseFile=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.pdb"
|
|
||||||
SubSystem="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
TypeLibraryName=".\mj2_to_metadata___Win32_Debug0/mj2_to_metadata.tlb"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="2057"
|
|
||||||
AdditionalIncludeDirectories=""
|
|
||||||
ResourceOutputFileName=""/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="MJ2"
|
|
||||||
Filter="">
|
|
||||||
<Filter
|
|
||||||
Name="MJ2 Header Files"
|
|
||||||
Filter="">
|
|
||||||
<File
|
|
||||||
RelativePath=".\compat\getopt.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="meta_out.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\mj2.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\mj2_convert.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="mj2_to_metadata.h">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="MJ2 Source Files"
|
|
||||||
Filter="">
|
|
||||||
<File
|
|
||||||
RelativePath=".\compat\getopt.c">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg;$(NoInherit)"
|
|
||||||
CompileAs="0"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="meta_out.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\mj2.c">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg;$(NoInherit)"
|
|
||||||
CompileAs="0"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\mj2_convert.c">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg;$(NoInherit)"
|
|
||||||
CompileAs="0"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\mj2_to_metadata.c">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../libopenjpeg;$(NoInherit)"
|
|
||||||
CompileAs="0"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="OpenJPEG"
|
|
||||||
Filter="">
|
|
||||||
<Filter
|
|
||||||
Name="OpenJPEG Header Files"
|
|
||||||
Filter=".h">
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\bio.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\cio.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\dwt.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\fix.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\int.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\j2k.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\jp2.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\jpt.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\mct.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\mqc.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\openjpeg.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\pi.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\raw.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\t1.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\t2.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\tcd.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\tgt.h">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="OpenJPEG Source Files"
|
|
||||||
Filter=".c">
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\bio.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\cio.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\dwt.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\fix.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\int.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\j2k.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\jp2.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\jpt.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\mct.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\mqc.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\pi.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\raw.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\t1.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\t2.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\tcd.c">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\libopenjpeg\tgt.c">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
<File
|
|
||||||
RelativePath="resource.h">
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "mj2.h"
|
|
||||||
#include <cio.h>
|
|
||||||
#include <j2k.h>
|
|
||||||
#include <int.h>
|
|
||||||
|
|
||||||
#define MJ2_MJ2 0x6d6a7032
|
|
||||||
#define MJ2_MJ2S 0x6d6a3273
|
|
||||||
#define JP2_JP2C 0x6a703263
|
|
||||||
#define MJ2_MDAT 0x6d646174
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h> // Must be included first
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
jmp_buf j2k_error;
|
|
||||||
|
|
||||||
void j2k_read_siz_marker(FILE *file, j2k_image_t *j2k_img)
|
|
||||||
{
|
|
||||||
int len,i;
|
|
||||||
char buf, buf2[2];
|
|
||||||
char *siz_buffer;
|
|
||||||
|
|
||||||
fseek(file, 0, SEEK_SET);
|
|
||||||
do {
|
|
||||||
fread(&buf,1,1, file);
|
|
||||||
if (buf==(char)0xff)
|
|
||||||
fread(&buf,1,1, file);
|
|
||||||
}
|
|
||||||
while (!(buf==(char)0x51));
|
|
||||||
|
|
||||||
fread(buf2,2,1,file); /* Lsiz */
|
|
||||||
len = ((buf2[0])<<8) + buf2[1];
|
|
||||||
|
|
||||||
siz_buffer = (char*) malloc(len * sizeof(char));
|
|
||||||
fread(siz_buffer,len, 1, file);
|
|
||||||
cio_init(siz_buffer,len);
|
|
||||||
|
|
||||||
cio_read(2); /* Rsiz (capabilities) */
|
|
||||||
j2k_img->x1 = cio_read(4); /* Xsiz */
|
|
||||||
j2k_img->y1 = cio_read(4); /* Ysiz */
|
|
||||||
j2k_img->x0 = cio_read(4); /* X0siz */
|
|
||||||
j2k_img->y0 = cio_read(4); /* Y0siz */
|
|
||||||
cio_skip(16); /* XTsiz, YTsiz, XT0siz, YT0siz */
|
|
||||||
|
|
||||||
j2k_img->numcomps = cio_read(2); /* Csiz */
|
|
||||||
j2k_img->comps =
|
|
||||||
(j2k_comp_t *) malloc(j2k_img->numcomps * sizeof(j2k_comp_t));
|
|
||||||
for (i = 0; i < j2k_img->numcomps; i++) {
|
|
||||||
int tmp;
|
|
||||||
tmp = cio_read(1); /* Ssiz_i */
|
|
||||||
j2k_img->comps[i].prec = (tmp & 0x7f) + 1;
|
|
||||||
j2k_img->comps[i].sgnd = tmp >> 7;
|
|
||||||
j2k_img->comps[i].dx = cio_read(1); /* XRsiz_i */
|
|
||||||
j2k_img->comps[i].dy = cio_read(1); /* YRsiz_i */
|
|
||||||
j2k_img->comps[i].resno_decoded = 0; /* number of resolution decoded */
|
|
||||||
j2k_img->comps[i].factor = 0; /* reducing factor by component */
|
|
||||||
}
|
|
||||||
free(siz_buffer);
|
|
||||||
fseek(file, 0, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setparams(mj2_movie_t *movie, j2k_image_t *img) {
|
|
||||||
int i, depth_0, depth, sign;
|
|
||||||
|
|
||||||
movie->tk[0].sample_rate = 25;
|
|
||||||
movie->tk[0].w = int_ceildiv(img->x1 - img->x0, img->comps[0].dx);
|
|
||||||
movie->tk[0].h = int_ceildiv(img->y1 - img->y0, img->comps[0].dy);
|
|
||||||
mj2_init_stdmovie(movie);
|
|
||||||
|
|
||||||
movie->tk[0].depth = img->comps[0].prec;
|
|
||||||
|
|
||||||
if (img->numcomps==3) {
|
|
||||||
if ((img->comps[0].dx == 1) && (img->comps[1].dx == 1) && (img->comps[1].dx == 1))
|
|
||||||
movie->tk[0].CbCr_subsampling_dx = 1;
|
|
||||||
else if ((img->comps[0].dx == 1) && (img->comps[1].dx == 2) && (img->comps[1].dx == 2))
|
|
||||||
movie->tk[0].CbCr_subsampling_dx = 2;
|
|
||||||
else
|
|
||||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
|
||||||
|
|
||||||
if ((img->comps[0].dy == 1) && (img->comps[1].dy == 1) && (img->comps[1].dy == 1))
|
|
||||||
movie->tk[0].CbCr_subsampling_dy = 1;
|
|
||||||
else if ((img->comps[0].dy == 1) && (img->comps[1].dy == 2) && (img->comps[1].dy == 2))
|
|
||||||
movie->tk[0].CbCr_subsampling_dy = 2;
|
|
||||||
else
|
|
||||||
fprintf(stderr,"Image component sizes are incoherent\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
movie->tk[0].sample_rate = 25;
|
|
||||||
|
|
||||||
movie->tk[0].jp2_struct.numcomps = img->numcomps; // NC
|
|
||||||
jp2_init_stdjp2(&movie->tk[0].jp2_struct);
|
|
||||||
|
|
||||||
movie->tk[0].jp2_struct.w = int_ceildiv(img->x1 - img->x0, img->comps[0].dx);
|
|
||||||
movie->tk[0].jp2_struct.h = int_ceildiv(img->y1 - img->y0, img->comps[0].dy);
|
|
||||||
|
|
||||||
depth_0 = img->comps[0].prec - 1;
|
|
||||||
sign = img->comps[0].sgnd;
|
|
||||||
movie->tk[0].jp2_struct.bpc = depth_0 + (sign << 7);
|
|
||||||
|
|
||||||
for (i = 1; i < img->numcomps; i++) {
|
|
||||||
depth = img->comps[i].prec - 1;
|
|
||||||
sign = img->comps[i].sgnd;
|
|
||||||
if (depth_0 != depth)
|
|
||||||
movie->tk[0].jp2_struct.bpc = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < img->numcomps; i++)
|
|
||||||
movie->tk[0].jp2_struct.comps[i].bpcc =
|
|
||||||
img->comps[i].prec - 1 + (img->comps[i].sgnd << 7);
|
|
||||||
|
|
||||||
if ((img->numcomps == 1 || img->numcomps == 3)
|
|
||||||
&& (movie->tk[0].jp2_struct.bpc != 255))
|
|
||||||
movie->tk[0].jp2_struct.meth = 1;
|
|
||||||
else
|
|
||||||
movie->tk[0].jp2_struct.meth = 2;
|
|
||||||
|
|
||||||
if (img->numcomps == 1)
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 17; // Grayscale
|
|
||||||
|
|
||||||
else if ((img->comps[0].dx == 1) && (img->comps[1].dx == 1) && (img->comps[1].dx == 1) &&
|
|
||||||
(img->comps[0].dy == 1) && (img->comps[1].dy == 1) && (img->comps[1].dy == 1))
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 16; // RGB
|
|
||||||
|
|
||||||
else if ((img->comps[0].dx == 1) && (img->comps[1].dx == 2) && (img->comps[1].dx == 2) &&
|
|
||||||
(img->comps[0].dy == 1) && (img->comps[1].dy == 2) && (img->comps[1].dy == 2))
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 18; // YUV
|
|
||||||
|
|
||||||
else
|
|
||||||
movie->tk[0].jp2_struct.enumcs = 0; // Unkown profile */
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
|
|
||||||
unsigned int snum;
|
|
||||||
mj2_movie_t movie;
|
|
||||||
mj2_sample_t *sample;
|
|
||||||
unsigned char* frame_codestream;
|
|
||||||
FILE *mj2file, *j2kfile;
|
|
||||||
char j2kfilename[50];
|
|
||||||
char *buf;
|
|
||||||
int offset, mdat_initpos;
|
|
||||||
j2k_image_t img;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
printf("Bad syntax: Usage: MJ2_Wrapper source_location mj2_filename\n");
|
|
||||||
printf("Example: MJ2_Wrapper input/input output.mj2\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mj2file = fopen(argv[2], "wb");
|
|
||||||
|
|
||||||
if (!mj2file) {
|
|
||||||
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialing the movie (parameters used in the JP and FTYP boxes
|
|
||||||
movie.num_htk = 0; // No hint tracks
|
|
||||||
movie.num_stk = 0; // No sound tracks
|
|
||||||
movie.num_vtk = 1; // One video track
|
|
||||||
movie.tk = (mj2_tk_t*) malloc (sizeof(mj2_tk_t)); //Memory allocation for the video track
|
|
||||||
movie.tk[0].sample = (mj2_sample_t*) malloc (sizeof(mj2_sample_t));
|
|
||||||
movie.tk[0].chunk = (mj2_chunk_t *) malloc(sizeof(mj2_chunk_t));
|
|
||||||
movie.tk[0].track_type = 0; // Video track
|
|
||||||
movie.tk[0].track_ID = 1; // Track ID = 1
|
|
||||||
movie.brand = MJ2_MJ2; // One brand: MJ2
|
|
||||||
movie.num_cl = 2; // Two compatible brands: MJ2 and MJ2S
|
|
||||||
movie.cl = (unsigned int *) malloc(movie.num_cl * sizeof(unsigned int));
|
|
||||||
movie.cl[0] = MJ2_MJ2;
|
|
||||||
movie.cl[1] = MJ2_MJ2S;
|
|
||||||
movie.minversion = 0; // Minimum version: 0
|
|
||||||
|
|
||||||
// Writing JP, FTYP and MDAT boxes
|
|
||||||
buf = (char*) malloc (300 * sizeof(char)); // Assuming that the JP and FTYP
|
|
||||||
// boxes won't be longer than 300 bytes
|
|
||||||
cio_init(buf , 300);
|
|
||||||
mj2_write_jp();
|
|
||||||
mj2_write_ftyp(&movie);
|
|
||||||
mdat_initpos = cio_tell();
|
|
||||||
cio_skip(4);
|
|
||||||
cio_write(MJ2_MDAT, 4);
|
|
||||||
fwrite(buf,cio_tell(),1,mj2file);
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
// Insert each j2k codestream in a JP2C box
|
|
||||||
snum=0;
|
|
||||||
offset = 0;
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
sample = &movie.tk[0].sample[snum];
|
|
||||||
sprintf(j2kfilename,"%s_%d.j2k",argv[1],snum);
|
|
||||||
j2kfile = fopen(j2kfilename, "rb");
|
|
||||||
if (!j2kfile) {
|
|
||||||
if (snum==0) { // Could not open a single codestream
|
|
||||||
fprintf(stderr, "failed to open %s for reading\n",j2kfilename);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else { // Tried to open a inexistant codestream
|
|
||||||
fprintf(stdout,"%d frames created\n",snum);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Calculating offset for samples and chunks
|
|
||||||
offset += cio_tell();
|
|
||||||
sample->offset = offset;
|
|
||||||
movie.tk[0].chunk[snum].offset = offset; // There will be one sample per chunk
|
|
||||||
|
|
||||||
// Calculating sample size
|
|
||||||
fseek(j2kfile,0,SEEK_END);
|
|
||||||
sample->sample_size = ftell(j2kfile) + 8; // Sample size is codestream + JP2C box header
|
|
||||||
fseek(j2kfile,0,SEEK_SET);
|
|
||||||
|
|
||||||
// Reading siz marker of j2k image for the first codestream
|
|
||||||
if (snum==0)
|
|
||||||
j2k_read_siz_marker(j2kfile, &img);
|
|
||||||
|
|
||||||
// Writing JP2C box header
|
|
||||||
frame_codestream = (unsigned char*) malloc (sample->sample_size+8);
|
|
||||||
cio_init(frame_codestream, sample->sample_size);
|
|
||||||
cio_write(sample->sample_size, 4); // Sample size
|
|
||||||
cio_write(JP2_JP2C, 4); // JP2C
|
|
||||||
|
|
||||||
// Writing codestream from J2K file to MJ2 file
|
|
||||||
fread(frame_codestream+8,sample->sample_size-8,1,j2kfile);
|
|
||||||
fwrite(frame_codestream,sample->sample_size,1,mj2file);
|
|
||||||
cio_skip(sample->sample_size-8);
|
|
||||||
|
|
||||||
// Ending loop
|
|
||||||
fclose(j2kfile);
|
|
||||||
snum++;
|
|
||||||
movie.tk[0].sample = realloc(movie.tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
|
|
||||||
movie.tk[0].chunk = realloc(movie.tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
|
|
||||||
free(frame_codestream);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Writing the MDAT box length in header
|
|
||||||
offset += cio_tell();
|
|
||||||
buf = (char*) malloc (4 * sizeof(char));
|
|
||||||
cio_init(buf,4);
|
|
||||||
cio_write(offset-mdat_initpos,4); // Write MDAT length in MDAT box header
|
|
||||||
fseek(mj2file,(long)mdat_initpos,SEEK_SET);
|
|
||||||
fwrite(buf,4,1,mj2file);
|
|
||||||
fseek(mj2file,0,SEEK_END);
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
// Setting movie parameters
|
|
||||||
movie.tk[0].num_samples=snum;
|
|
||||||
movie.tk[0].num_chunks=snum;
|
|
||||||
setparams(&movie, &img);
|
|
||||||
|
|
||||||
// Writing MOOV box
|
|
||||||
i=1;
|
|
||||||
buf = (char*) malloc (10000 * sizeof(char));
|
|
||||||
cio_init(buf , i*10000);
|
|
||||||
if (setjmp(j2k_error)) {
|
|
||||||
i++;
|
|
||||||
buf = realloc(buf,i*10000* sizeof(char));
|
|
||||||
cio_init(buf , i*10000);
|
|
||||||
}
|
|
||||||
mj2_write_moov(&movie);
|
|
||||||
fwrite(buf,cio_tell(),1,mj2file);
|
|
||||||
|
|
||||||
// Ending program
|
|
||||||
fclose(mj2file);
|
|
||||||
free(img.comps);
|
|
||||||
free(buf);
|
|
||||||
mj2_memory_free(&movie);
|
|
||||||
|
|
||||||
|
|
||||||
//MEMORY LEAK
|
|
||||||
#ifdef _DEBUG
|
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
#endif
|
|
||||||
//MEM
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
12
src/CMakeLists.txt
Normal file
12
src/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# 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()
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
#add_subdirectory(lib)
|
||||||
|
#add_subdirectory(bin)
|
||||||
21
src/bin/CMakeLists.txt
Normal file
21
src/bin/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# source code for openjpeg apps:
|
||||||
|
add_subdirectory(common)
|
||||||
|
# Part 1 & 2:
|
||||||
|
add_subdirectory(jp2)
|
||||||
|
|
||||||
|
# optionals components:
|
||||||
|
if(BUILD_JPWL)
|
||||||
|
add_subdirectory(jpwl)
|
||||||
|
endif()
|
||||||
|
if(BUILD_MJ2)
|
||||||
|
add_subdirectory(mj2)
|
||||||
|
endif()
|
||||||
|
if(BUILD_JPIP)
|
||||||
|
add_subdirectory(jpip)
|
||||||
|
endif()
|
||||||
|
if(BUILD_JP3D)
|
||||||
|
add_subdirectory(jp3d)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wx apps:
|
||||||
|
add_subdirectory(wx)
|
||||||
7
src/bin/common/CMakeLists.txt
Normal file
7
src/bin/common/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# opj_apps_config.h generation
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_apps_config.h.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/opj_apps_config.h
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
958
src/bin/common/color.c
Normal file
958
src/bin/common/color.c
Normal file
@@ -0,0 +1,958 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* 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 <assert.h>
|
||||||
|
|
||||||
|
#include "opj_apps_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS2
|
||||||
|
#include <lcms2.h>
|
||||||
|
#endif
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
#include <lcms.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPJ_USE_LEGACY
|
||||||
|
#define OPJ_CLRSPC_GRAY CLRSPC_GRAY
|
||||||
|
#define OPJ_CLRSPC_SRGB CLRSPC_SRGB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*--------------------------------------------------------
|
||||||
|
Matrix for 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;
|
||||||
|
size_t maxw, maxh, max, i;
|
||||||
|
int offset, upb;
|
||||||
|
|
||||||
|
upb = (int)img->comps[0].prec;
|
||||||
|
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||||
|
|
||||||
|
maxw = (size_t)img->comps[0].w; maxh = (size_t)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);
|
||||||
|
|
||||||
|
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||||
|
|
||||||
|
for(i = 0U; 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;
|
||||||
|
img->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
return;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
free(r);
|
||||||
|
free(g);
|
||||||
|
free(b);
|
||||||
|
}/* sycc444_to_rgb() */
|
||||||
|
|
||||||
|
static void sycc422_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
int *d0, *d1, *d2, *r, *g, *b;
|
||||||
|
const int *y, *cb, *cr;
|
||||||
|
size_t maxw, maxh, max, offx, loopmaxw;
|
||||||
|
int offset, upb;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
upb = (int)img->comps[0].prec;
|
||||||
|
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||||
|
|
||||||
|
maxw = (size_t)img->comps[0].w; maxh = (size_t)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);
|
||||||
|
|
||||||
|
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||||
|
|
||||||
|
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||||
|
offx = img->x0 & 1U;
|
||||||
|
loopmaxw = maxw - offx;
|
||||||
|
|
||||||
|
for(i=0U; i < maxh; ++i)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
if (offx > 0U) {
|
||||||
|
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j=0U; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if (j < loopmaxw) {
|
||||||
|
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 = img->comps[2].w = img->comps[0].w;
|
||||||
|
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||||
|
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||||
|
img->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
return;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
free(r);
|
||||||
|
free(g);
|
||||||
|
free(b);
|
||||||
|
}/* 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;
|
||||||
|
size_t maxw, maxh, max, offx, loopmaxw, offy, loopmaxh;
|
||||||
|
int offset, upb;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
upb = (int)img->comps[0].prec;
|
||||||
|
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||||
|
|
||||||
|
maxw = (size_t)img->comps[0].w; maxh = (size_t)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);
|
||||||
|
|
||||||
|
if (r == NULL || g == NULL || b == NULL) goto fails;
|
||||||
|
|
||||||
|
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||||
|
offx = img->x0 & 1U;
|
||||||
|
loopmaxw = maxw - offx;
|
||||||
|
/* if img->y0 is odd, then first line shall use Cb/Cr = 0 */
|
||||||
|
offy = img->y0 & 1U;
|
||||||
|
loopmaxh = maxh - offy;
|
||||||
|
|
||||||
|
if (offy > 0U) {
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
for(j=0; j < maxw; ++j)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0U; i < (loopmaxh & ~(size_t)1U); i += 2U)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
ny = y + maxw;
|
||||||
|
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||||
|
|
||||||
|
if (offx > 0U) {
|
||||||
|
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||||
|
++y; ++r; ++g; ++b;
|
||||||
|
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||||
|
++ny; ++nr; ++ng; ++nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j=0; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if(j < loopmaxw)
|
||||||
|
{
|
||||||
|
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; ++cb; ++cr;
|
||||||
|
}
|
||||||
|
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||||
|
}
|
||||||
|
if(i < loopmaxh)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
for(j=0U; j < (maxw & ~(size_t)1U); j += 2U)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if(j < maxw)
|
||||||
|
{
|
||||||
|
sycc_to_rgb(offset, upb, *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;
|
||||||
|
|
||||||
|
img->comps[1].w = img->comps[2].w = img->comps[0].w;
|
||||||
|
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||||
|
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||||
|
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||||
|
img->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
return;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
free(r);
|
||||||
|
free(g);
|
||||||
|
free(b);
|
||||||
|
}/* sycc420_to_rgb() */
|
||||||
|
|
||||||
|
void color_sycc_to_rgb(opj_image_t *img)
|
||||||
|
{
|
||||||
|
if(img->numcomps < 3)
|
||||||
|
{
|
||||||
|
img->color_space = OPJ_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;
|
||||||
|
}
|
||||||
|
}/* color_sycc_to_rgb() */
|
||||||
|
|
||||||
|
#if defined(OPJ_HAVE_LIBLCMS2) || defined(OPJ_HAVE_LIBLCMS1)
|
||||||
|
|
||||||
|
#ifdef OPJ_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 /* OPJ_HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
|
/*#define DEBUG_PROFILE*/
|
||||||
|
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;
|
||||||
|
int *r, *g, *b;
|
||||||
|
size_t nr_samples, i, max, max_w, max_h;
|
||||||
|
int prec, ok = 0;
|
||||||
|
OPJ_COLOR_SPACE new_space;
|
||||||
|
|
||||||
|
in_prof = cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||||
|
#ifdef DEBUG_PROFILE
|
||||||
|
FILE *icm = fopen("debug.icm","wb");
|
||||||
|
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||||
|
fclose(icm);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(in_prof == NULL) return;
|
||||||
|
|
||||||
|
in_space = cmsGetPCS(in_prof);
|
||||||
|
out_space = cmsGetColorSpace(in_prof);
|
||||||
|
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||||
|
|
||||||
|
|
||||||
|
max_w = image->comps[0].w;
|
||||||
|
max_h = image->comps[0].h;
|
||||||
|
prec = (int)image->comps[0].prec;
|
||||||
|
|
||||||
|
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||||
|
{
|
||||||
|
if( prec <= 8 )
|
||||||
|
{
|
||||||
|
in_type = TYPE_RGB_8;
|
||||||
|
out_type = TYPE_RGB_8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
in_type = TYPE_RGB_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
}
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
new_space = OPJ_CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_GRAY_8;
|
||||||
|
out_type = TYPE_RGB_8;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
new_space = OPJ_CLRSPC_SRGB;
|
||||||
|
}
|
||||||
|
else if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||||
|
{
|
||||||
|
in_type = TYPE_YCbCr_16;
|
||||||
|
out_type = TYPE_RGB_16;
|
||||||
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
|
new_space = OPJ_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
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(out_prof == NULL)
|
||||||
|
{
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
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
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
(void)prec;
|
||||||
|
(void)in_space;
|
||||||
|
#endif /* DEBUG_PROFILE */
|
||||||
|
|
||||||
|
transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
|
||||||
|
|
||||||
|
#ifdef OPJ_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
|
||||||
|
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image->numcomps > 2)/* RGB, RGBA */
|
||||||
|
{
|
||||||
|
if( prec <= 8 )
|
||||||
|
{
|
||||||
|
unsigned char *inbuf, *outbuf, *in, *out;
|
||||||
|
|
||||||
|
max = max_w * max_h;
|
||||||
|
nr_samples = (size_t)(max * 3U * sizeof(unsigned char));
|
||||||
|
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
|
||||||
|
if(inbuf == NULL || outbuf == NULL) goto fails0;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0U; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned char)*r++;
|
||||||
|
*in++ = (unsigned char)*g++;
|
||||||
|
*in++ = (unsigned char)*b++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0U; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++;
|
||||||
|
*g++ = (int)*out++;
|
||||||
|
*b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
ok = 1;
|
||||||
|
|
||||||
|
fails0:
|
||||||
|
free(inbuf);
|
||||||
|
free(outbuf);
|
||||||
|
}
|
||||||
|
else /* prec > 8 */
|
||||||
|
{
|
||||||
|
unsigned short *inbuf, *outbuf, *in, *out;
|
||||||
|
|
||||||
|
max = max_w * max_h;
|
||||||
|
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||||
|
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
|
||||||
|
if(inbuf == NULL || outbuf == NULL) goto fails1;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0U ; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned short)*r++;
|
||||||
|
*in++ = (unsigned short)*g++;
|
||||||
|
*in++ = (unsigned short)*b++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)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++;
|
||||||
|
}
|
||||||
|
ok = 1;
|
||||||
|
|
||||||
|
fails1:
|
||||||
|
free(inbuf);
|
||||||
|
free(outbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* image->numcomps <= 2 : GRAY, GRAYA */
|
||||||
|
{
|
||||||
|
if(prec <= 8)
|
||||||
|
{
|
||||||
|
unsigned char *in, *inbuf, *out, *outbuf;
|
||||||
|
opj_image_comp_t *new_comps;
|
||||||
|
|
||||||
|
max = max_w * max_h;
|
||||||
|
nr_samples = (size_t)(max * 3 * sizeof(unsigned char));
|
||||||
|
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||||
|
g = (int*)calloc((size_t)max, sizeof(int));
|
||||||
|
b = (int*)calloc((size_t)max, sizeof(int));
|
||||||
|
|
||||||
|
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails2;
|
||||||
|
|
||||||
|
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||||
|
|
||||||
|
if(new_comps == NULL) goto fails2;
|
||||||
|
|
||||||
|
image->comps = new_comps;
|
||||||
|
|
||||||
|
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 = g;
|
||||||
|
image->comps[2].data = b;
|
||||||
|
|
||||||
|
image->numcomps += 2;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
|
||||||
|
for(i = 0U; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned char)*r++;
|
||||||
|
}
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
g = image->comps[1].data;
|
||||||
|
b = image->comps[2].data;
|
||||||
|
|
||||||
|
for(i = 0U; i < max; ++i)
|
||||||
|
{
|
||||||
|
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||||
|
}
|
||||||
|
r = g = b = NULL;
|
||||||
|
ok = 1;
|
||||||
|
|
||||||
|
fails2:
|
||||||
|
free(inbuf);
|
||||||
|
free(outbuf);
|
||||||
|
free(g);
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
else /* prec > 8 */
|
||||||
|
{
|
||||||
|
unsigned short *in, *inbuf, *out, *outbuf;
|
||||||
|
opj_image_comp_t *new_comps;
|
||||||
|
|
||||||
|
max = max_w * max_h;
|
||||||
|
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||||
|
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||||
|
g = (int*)calloc((size_t)max, sizeof(int));
|
||||||
|
b = (int*)calloc((size_t)max, sizeof(int));
|
||||||
|
|
||||||
|
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails3;
|
||||||
|
|
||||||
|
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||||
|
|
||||||
|
if(new_comps == NULL) goto fails3;
|
||||||
|
|
||||||
|
image->comps = new_comps;
|
||||||
|
|
||||||
|
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 = g;
|
||||||
|
image->comps[2].data = b;
|
||||||
|
|
||||||
|
image->numcomps += 2;
|
||||||
|
|
||||||
|
r = image->comps[0].data;
|
||||||
|
|
||||||
|
for(i = 0U; i < max; ++i)
|
||||||
|
{
|
||||||
|
*in++ = (unsigned short)*r++;
|
||||||
|
}
|
||||||
|
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)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++;
|
||||||
|
}
|
||||||
|
r = g = b = NULL;
|
||||||
|
ok = 1;
|
||||||
|
|
||||||
|
fails3:
|
||||||
|
free(inbuf);
|
||||||
|
free(outbuf);
|
||||||
|
free(g);
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
}/* if(image->numcomps > 2) */
|
||||||
|
|
||||||
|
cmsDeleteTransform(transform);
|
||||||
|
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in_prof);
|
||||||
|
cmsCloseProfile(out_prof);
|
||||||
|
#endif
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
image->color_space = new_space;
|
||||||
|
}
|
||||||
|
}/* color_apply_icc_profile() */
|
||||||
|
|
||||||
|
void color_cielab_to_rgb(opj_image_t *image)
|
||||||
|
{
|
||||||
|
int *row;
|
||||||
|
int enumcs, numcomps;
|
||||||
|
OPJ_COLOR_SPACE new_space;
|
||||||
|
|
||||||
|
numcomps = (int)image->numcomps;
|
||||||
|
|
||||||
|
if(numcomps != 3)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
|
||||||
|
__FILE__,__LINE__,numcomps);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
row = (int*)image->icc_profile_buf;
|
||||||
|
enumcs = row[0];
|
||||||
|
|
||||||
|
if(enumcs == 14) /* CIELab */
|
||||||
|
{
|
||||||
|
int *L, *a, *b, *red, *green, *blue;
|
||||||
|
int *src0, *src1, *src2, *dst0, *dst1, *dst2;
|
||||||
|
double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2;
|
||||||
|
double minL, maxL, mina, maxa, minb, maxb;
|
||||||
|
unsigned int default_type;
|
||||||
|
unsigned int i, max;
|
||||||
|
cmsHPROFILE in, out;
|
||||||
|
cmsHTRANSFORM transform;
|
||||||
|
cmsUInt16Number RGB[3];
|
||||||
|
cmsCIELab Lab;
|
||||||
|
|
||||||
|
in = cmsCreateLab4Profile(NULL);
|
||||||
|
if(in == NULL){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out = cmsCreate_sRGBProfile();
|
||||||
|
if(out == NULL){
|
||||||
|
cmsCloseProfile(in);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
|
||||||
|
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS2
|
||||||
|
cmsCloseProfile(in);
|
||||||
|
cmsCloseProfile(out);
|
||||||
|
#endif
|
||||||
|
if(transform == NULL)
|
||||||
|
{
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in);
|
||||||
|
cmsCloseProfile(out);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new_space = OPJ_CLRSPC_SRGB;
|
||||||
|
|
||||||
|
prec0 = (double)image->comps[0].prec;
|
||||||
|
prec1 = (double)image->comps[1].prec;
|
||||||
|
prec2 = (double)image->comps[2].prec;
|
||||||
|
|
||||||
|
default_type = (unsigned int)row[1];
|
||||||
|
|
||||||
|
if(default_type == 0x44454600)/* DEF : default */
|
||||||
|
{
|
||||||
|
rl = 100; ra = 170; rb = 200;
|
||||||
|
ol = 0;
|
||||||
|
oa = pow(2, prec1 - 1);
|
||||||
|
ob = pow(2, prec2 - 2) + pow(2, prec2 - 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rl = row[2]; ra = row[4]; rb = row[6];
|
||||||
|
ol = row[3]; oa = row[5]; ob = row[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
L = src0 = image->comps[0].data;
|
||||||
|
a = src1 = image->comps[1].data;
|
||||||
|
b = src2 = image->comps[2].data;
|
||||||
|
|
||||||
|
max = image->comps[0].w * image->comps[0].h;
|
||||||
|
|
||||||
|
red = dst0 = (int*)malloc(max * sizeof(int));
|
||||||
|
green = dst1 = (int*)malloc(max * sizeof(int));
|
||||||
|
blue = dst2 = (int*)malloc(max * sizeof(int));
|
||||||
|
|
||||||
|
if(red == NULL || green == NULL || blue == NULL) goto fails;
|
||||||
|
|
||||||
|
minL = -(rl * ol)/(pow(2, prec0)-1);
|
||||||
|
maxL = minL + rl;
|
||||||
|
|
||||||
|
mina = -(ra * oa)/(pow(2, prec1)-1);
|
||||||
|
maxa = mina + ra;
|
||||||
|
|
||||||
|
minb = -(rb * ob)/(pow(2, prec2)-1);
|
||||||
|
maxb = minb + rb;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
Lab.L = minL + (double)(*L) * (maxL - minL)/(pow(2, prec0)-1); ++L;
|
||||||
|
Lab.a = mina + (double)(*a) * (maxa - mina)/(pow(2, prec1)-1); ++a;
|
||||||
|
Lab.b = minb + (double)(*b) * (maxb - minb)/(pow(2, prec2)-1); ++b;
|
||||||
|
|
||||||
|
cmsDoTransform(transform, &Lab, RGB, 1);
|
||||||
|
|
||||||
|
*red++ = RGB[0];
|
||||||
|
*green++ = RGB[1];
|
||||||
|
*blue++ = RGB[2];
|
||||||
|
}
|
||||||
|
cmsDeleteTransform(transform);
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in);
|
||||||
|
cmsCloseProfile(out);
|
||||||
|
#endif
|
||||||
|
free(src0); image->comps[0].data = dst0;
|
||||||
|
free(src1); image->comps[1].data = dst1;
|
||||||
|
free(src2); image->comps[2].data = dst2;
|
||||||
|
|
||||||
|
image->color_space = new_space;
|
||||||
|
image->comps[0].prec = 16;
|
||||||
|
image->comps[1].prec = 16;
|
||||||
|
image->comps[2].prec = 16;
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
fails:
|
||||||
|
cmsDeleteTransform(transform);
|
||||||
|
#ifdef OPJ_HAVE_LIBLCMS1
|
||||||
|
cmsCloseProfile(in);
|
||||||
|
cmsCloseProfile(out);
|
||||||
|
#endif
|
||||||
|
if(red) free(red);
|
||||||
|
if(green) free(green);
|
||||||
|
if(blue) free(blue);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs);
|
||||||
|
}/* color_cielab_to_rgb() */
|
||||||
|
|
||||||
|
#endif /* OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 */
|
||||||
|
|
||||||
|
void color_cmyk_to_rgb(opj_image_t *image)
|
||||||
|
{
|
||||||
|
float C, M, Y, K;
|
||||||
|
float sC, sM, sY, sK;
|
||||||
|
unsigned int w, h, max, i;
|
||||||
|
|
||||||
|
w = image->comps[0].w;
|
||||||
|
h = image->comps[0].h;
|
||||||
|
|
||||||
|
if(image->numcomps < 4) return;
|
||||||
|
|
||||||
|
max = w * h;
|
||||||
|
|
||||||
|
sC = 1.0F / (float)((1 << image->comps[0].prec) - 1);
|
||||||
|
sM = 1.0F / (float)((1 << image->comps[1].prec) - 1);
|
||||||
|
sY = 1.0F / (float)((1 << image->comps[2].prec) - 1);
|
||||||
|
sK = 1.0F / (float)((1 << image->comps[3].prec) - 1);
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
/* CMYK values from 0 to 1 */
|
||||||
|
C = (float)(image->comps[0].data[i]) * sC;
|
||||||
|
M = (float)(image->comps[1].data[i]) * sM;
|
||||||
|
Y = (float)(image->comps[2].data[i]) * sY;
|
||||||
|
K = (float)(image->comps[3].data[i]) * sK;
|
||||||
|
|
||||||
|
/* Invert all CMYK values */
|
||||||
|
C = 1.0F - C;
|
||||||
|
M = 1.0F - M;
|
||||||
|
Y = 1.0F - Y;
|
||||||
|
K = 1.0F - K;
|
||||||
|
|
||||||
|
/* CMYK -> RGB : RGB results from 0 to 255 */
|
||||||
|
image->comps[0].data[i] = (int)(255.0F * C * K); /* R */
|
||||||
|
image->comps[1].data[i] = (int)(255.0F * M * K); /* G */
|
||||||
|
image->comps[2].data[i] = (int)(255.0F * Y * K); /* B */
|
||||||
|
}
|
||||||
|
|
||||||
|
free(image->comps[3].data); image->comps[3].data = NULL;
|
||||||
|
image->comps[0].prec = 8;
|
||||||
|
image->comps[1].prec = 8;
|
||||||
|
image->comps[2].prec = 8;
|
||||||
|
image->numcomps -= 1;
|
||||||
|
image->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
|
||||||
|
for (i = 3; i < image->numcomps; ++i) {
|
||||||
|
memcpy(&(image->comps[i]), &(image->comps[i+1]), sizeof(image->comps[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}/* color_cmyk_to_rgb() */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This code has been adopted from sjpx_openjpeg.c of ghostscript
|
||||||
|
*/
|
||||||
|
void color_esycc_to_rgb(opj_image_t *image)
|
||||||
|
{
|
||||||
|
int y, cb, cr, sign1, sign2, val;
|
||||||
|
unsigned int w, h, max, i;
|
||||||
|
int flip_value = (1 << (image->comps[0].prec-1));
|
||||||
|
int max_value = (1 << image->comps[0].prec) - 1;
|
||||||
|
|
||||||
|
if (
|
||||||
|
(image->numcomps < 3)
|
||||||
|
|| (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx)
|
||||||
|
|| (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy)
|
||||||
|
) {
|
||||||
|
fprintf(stderr,"%s:%d:color_esycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = image->comps[0].w;
|
||||||
|
h = image->comps[0].h;
|
||||||
|
|
||||||
|
sign1 = (int)image->comps[1].sgnd;
|
||||||
|
sign2 = (int)image->comps[2].sgnd;
|
||||||
|
|
||||||
|
max = w * h;
|
||||||
|
|
||||||
|
for(i = 0; i < max; ++i)
|
||||||
|
{
|
||||||
|
|
||||||
|
y = image->comps[0].data[i]; cb = image->comps[1].data[i]; cr = image->comps[2].data[i];
|
||||||
|
|
||||||
|
if( !sign1) cb -= flip_value;
|
||||||
|
if( !sign2) cr -= flip_value;
|
||||||
|
|
||||||
|
val = (int)
|
||||||
|
((float)y - (float)0.0000368 * (float)cb
|
||||||
|
+ (float)1.40199 * (float)cr + (float)0.5);
|
||||||
|
|
||||||
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
|
image->comps[0].data[i] = val;
|
||||||
|
|
||||||
|
val = (int)
|
||||||
|
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
|
||||||
|
- (float)0.7141128 * (float)cr + (float)0.5);
|
||||||
|
|
||||||
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
|
image->comps[1].data[i] = val;
|
||||||
|
|
||||||
|
val = (int)
|
||||||
|
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
|
||||||
|
- (float)0.000008 *(float)cr + (float)0.5);
|
||||||
|
|
||||||
|
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||||
|
image->comps[2].data[i] = val;
|
||||||
|
}
|
||||||
|
image->color_space = OPJ_CLRSPC_SRGB;
|
||||||
|
|
||||||
|
}/* color_esycc_to_rgb() */
|
||||||
47
src/bin/common/color.h
Normal file
47
src/bin/common/color.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _OPJ_COLOR_H_
|
||||||
|
#define _OPJ_COLOR_H_
|
||||||
|
|
||||||
|
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||||
|
extern void color_apply_icc_profile(opj_image_t *image);
|
||||||
|
extern void color_cielab_to_rgb(opj_image_t *image);
|
||||||
|
|
||||||
|
extern void color_cmyk_to_rgb(opj_image_t *image);
|
||||||
|
extern void color_esycc_to_rgb(opj_image_t *image);
|
||||||
|
#endif /* _OPJ_COLOR_H_ */
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* 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,65 +35,21 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "j2k.h"
|
#ifndef _OPJ_FORMAT_DEFS_H_
|
||||||
|
#define _OPJ_FORMAT_DEFS_H_
|
||||||
|
|
||||||
#ifndef __INT_H
|
#define J2K_CFMT 0
|
||||||
#define __INT_H
|
#define JP2_CFMT 1
|
||||||
|
#define JPT_CFMT 2
|
||||||
|
|
||||||
/*
|
#define PXM_DFMT 10
|
||||||
* Get the minimum of two integers.
|
#define PGX_DFMT 11
|
||||||
*
|
#define BMP_DFMT 12
|
||||||
* returns a if a < b else b
|
#define YUV_DFMT 13
|
||||||
*/
|
#define TIF_DFMT 14
|
||||||
int int_min(int a, int b);
|
#define RAW_DFMT 15 /* MSB / Big Endian */
|
||||||
|
#define TGA_DFMT 16
|
||||||
|
#define PNG_DFMT 17
|
||||||
|
#define RAWL_DFMT 18 /* LSB / Little Endian */
|
||||||
|
|
||||||
/*
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||||
* Get the maximum of two integers.
|
|
||||||
*
|
|
||||||
* returns a if a > b else b
|
|
||||||
*/
|
|
||||||
int int_max(int a, int b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clamp an integer inside an interval.
|
|
||||||
*
|
|
||||||
* return a if (min < a < max)
|
|
||||||
* return max if (a > max)
|
|
||||||
* return min if (a < min)
|
|
||||||
*/
|
|
||||||
int int_clamp(int a, int min, int max);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get absolute value of integer.
|
|
||||||
*/
|
|
||||||
int int_abs(int a);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Divide an integer and round upwards.
|
|
||||||
*
|
|
||||||
* a divided by b
|
|
||||||
*/
|
|
||||||
int int_ceildiv(int a, int b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Divide an integer by a power of 2 and round upwards.
|
|
||||||
*
|
|
||||||
* a divided by 2^b
|
|
||||||
*/
|
|
||||||
LIBJ2K_API int int_ceildivpow2(int a, int b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Divide an integer by a power of 2 and round downwards.
|
|
||||||
*
|
|
||||||
* a divided by 2^b
|
|
||||||
*/
|
|
||||||
LIBJ2K_API int int_floordivpow2(int a, int b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get logarithm of an integer and round downwards.
|
|
||||||
*
|
|
||||||
* log2(a)
|
|
||||||
*/
|
|
||||||
int int_floorlog2(int a);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
15
src/bin/common/opj_apps_config.h.cmake.in
Normal file
15
src/bin/common/opj_apps_config.h.cmake.in
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "opj_config_private.h"
|
||||||
|
|
||||||
|
/* create opj_apps_config.h for CMake */
|
||||||
|
|
||||||
|
#cmakedefine OPJ_HAVE_LIBPNG @HAVE_LIBPNG@
|
||||||
|
#cmakedefine OPJ_HAVE_PNG_H @HAVE_PNG_H@
|
||||||
|
#cmakedefine OPJ_HAVE_LIBTIFF @HAVE_LIBTIFF@
|
||||||
|
#cmakedefine OPJ_HAVE_TIFF_H @HAVE_TIFF_H@
|
||||||
|
|
||||||
|
#cmakedefine OPJ_HAVE_LIBLCMS1
|
||||||
|
#cmakedefine OPJ_HAVE_LIBLCMS2
|
||||||
|
#cmakedefine OPJ_HAVE_LCMS1_H
|
||||||
|
#cmakedefine OPJ_HAVE_LCMS2_H
|
||||||
|
|
||||||
|
|
||||||
255
src/bin/common/opj_getopt.c
Normal file
255
src/bin/common/opj_getopt.c
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 3-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
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 opj_reset_options_reading(void) {
|
||||||
|
opj_opterr = 1;
|
||||||
|
opj_optind = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||||
|
# define __progname nargv[0]
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
const char *oli = NULL; /* option letter list index */
|
||||||
|
|
||||||
|
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||||
|
opj_optreset = 0;
|
||||||
|
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
||||||
|
place = EMSG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (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;
|
||||||
|
const 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*/
|
||||||
29
src/bin/common/opj_getopt.h
Normal file
29
src/bin/common/opj_getopt.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
typedef struct opj_option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
}opj_option_t;
|
||||||
|
|
||||||
|
#define NO_ARG 0
|
||||||
|
#define REQ_ARG 1
|
||||||
|
#define OPT_ARG 2
|
||||||
|
|
||||||
|
extern int opj_opterr;
|
||||||
|
extern int opj_optind;
|
||||||
|
extern int opj_optopt;
|
||||||
|
extern int opj_optreset;
|
||||||
|
extern char *opj_optarg;
|
||||||
|
|
||||||
|
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const opj_option_t *longopts, int totlen);
|
||||||
|
extern void opj_reset_options_reading(void);
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
||||||
72
src/bin/common/opj_string.h
Normal file
72
src/bin/common/opj_string.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, Matthieu Darbois
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OPJ_STRING_H
|
||||||
|
#define OPJ_STRING_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* strnlen is not standard, strlen_s is C11... */
|
||||||
|
/* keep in mind there still is a buffer read overflow possible */
|
||||||
|
static size_t opj_strnlen_s(const char *src, size_t max_len)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (src == NULL) {
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
for (len = 0U; (*src != '\0') && (len < max_len); src++, len++);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* should be equivalent to C11 function except for the handler */
|
||||||
|
/* keep in mind there still is a buffer read overflow possible */
|
||||||
|
static int opj_strcpy_s(char* dst, size_t dst_size, const char* src)
|
||||||
|
{
|
||||||
|
size_t src_len = 0U;
|
||||||
|
if ((dst == NULL) || (dst_size == 0U)) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
if (src == NULL) {
|
||||||
|
dst[0] = '\0';
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
src_len = opj_strnlen_s(src, dst_size);
|
||||||
|
if (src_len >= dst_size) {
|
||||||
|
return ERANGE;
|
||||||
|
}
|
||||||
|
memcpy(dst, src, src_len);
|
||||||
|
dst[src_len] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* OPJ_STRING_H */
|
||||||
82
src/bin/jp2/CMakeLists.txt
Normal file
82
src/bin/jp2/CMakeLists.txt
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
set(common_SRCS
|
||||||
|
convert.c
|
||||||
|
convert.h
|
||||||
|
convertbmp.c
|
||||||
|
index.c
|
||||||
|
index.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/color.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
|
||||||
|
)
|
||||||
|
|
||||||
|
if(OPJ_HAVE_LIBTIFF)
|
||||||
|
list(APPEND common_SRCS converttif.c)
|
||||||
|
endif()
|
||||||
|
if(OPJ_HAVE_LIBPNG)
|
||||||
|
list(APPEND common_SRCS convertpng.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
||||||
|
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DOPJ_EXPORTS)
|
||||||
|
else()
|
||||||
|
add_definitions(-DOPJ_STATIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
foreach(exe opj_decompress opj_compress opj_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()
|
||||||
|
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(${exe} m)
|
||||||
|
endif()
|
||||||
|
# Install exe
|
||||||
|
install(TARGETS ${exe}
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
if(OPJ_USE_DSYMUTIL)
|
||||||
|
add_custom_command(TARGET ${exe} POST_BUILD
|
||||||
|
COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
|
||||||
|
COMMENT "dsymutil $<TARGET_FILE:${exe}>"
|
||||||
|
DEPENDS ${exe})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(BUILD_DOC)
|
||||||
|
# Install man pages
|
||||||
|
install(
|
||||||
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_decompress.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||||
|
#
|
||||||
|
endif()
|
||||||
2276
src/bin/jp2/convert.c
Normal file
2276
src/bin/jp2/convert.c
Normal file
File diff suppressed because it is too large
Load Diff
119
src/bin/jp2/convert.h
Normal file
119
src/bin/jp2/convert.h
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* 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 component encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_comp_cparameters {
|
||||||
|
/** subsampling in X direction */
|
||||||
|
int dx;
|
||||||
|
/** subsampling in Y direction */
|
||||||
|
int dy;
|
||||||
|
/*@}*/
|
||||||
|
} raw_comp_cparameters_t;
|
||||||
|
|
||||||
|
/**@name RAW image encoding parameters */
|
||||||
|
/*@{*/
|
||||||
|
typedef struct raw_cparameters {
|
||||||
|
/** width of the raw image */
|
||||||
|
int rawWidth;
|
||||||
|
/** height of the raw image */
|
||||||
|
int rawHeight;
|
||||||
|
/** number of components of the raw image */
|
||||||
|
int rawComp;
|
||||||
|
/** bit depth of the raw image */
|
||||||
|
int rawBitDepth;
|
||||||
|
/** signed/unsigned raw image */
|
||||||
|
OPJ_BOOL rawSigned;
|
||||||
|
/** raw components parameters */
|
||||||
|
raw_comp_cparameters_t *rawComps;
|
||||||
|
/*@}*/
|
||||||
|
} raw_cparameters_t;
|
||||||
|
|
||||||
|
/* Component precision clipping */
|
||||||
|
void clip_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||||
|
/* Component precision scaling */
|
||||||
|
void scale_component(opj_image_comp_t* component, OPJ_UINT32 precision);
|
||||||
|
|
||||||
|
/* planar / interleaved conversions */
|
||||||
|
typedef void (* convert_32s_CXPX)(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length);
|
||||||
|
extern const convert_32s_CXPX convert_32s_CXPX_LUT[5];
|
||||||
|
typedef void (* convert_32s_PXCX)(OPJ_INT32 const* const* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length, OPJ_INT32 adjust);
|
||||||
|
extern const convert_32s_PXCX convert_32s_PXCX_LUT[5];
|
||||||
|
/* bit depth conversions */
|
||||||
|
typedef void (* convert_XXx32s_C1R)(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length);
|
||||||
|
extern const convert_XXx32s_C1R convert_XXu32s_C1R_LUT[9]; /* up to 8bpp */
|
||||||
|
typedef void (* convert_32sXXx_C1R)(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length);
|
||||||
|
extern const convert_32sXXx_C1R convert_32sXXu_C1R_LUT[9]; /* up to 8bpp */
|
||||||
|
|
||||||
|
|
||||||
|
/* TGA conversion */
|
||||||
|
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
|
int imagetotga(opj_image_t * image, const char *outfile);
|
||||||
|
|
||||||
|
/* 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, int force_split);
|
||||||
|
|
||||||
|
/* RAW conversion */
|
||||||
|
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||||
|
int imagetorawl(opj_image_t * image, const char *outfile);
|
||||||
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
|
||||||
|
opj_image_t* rawltoimage(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 */
|
||||||
|
|
||||||
978
src/bin/jp2/convertbmp.c
Normal file
978
src/bin/jp2/convertbmp.c
Normal file
@@ -0,0 +1,978 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "opj_apps_config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
OPJ_UINT16 bfType; /* 'BM' for Bitmap (19776) */
|
||||||
|
OPJ_UINT32 bfSize; /* Size of the file */
|
||||||
|
OPJ_UINT16 bfReserved1; /* Reserved : 0 */
|
||||||
|
OPJ_UINT16 bfReserved2; /* Reserved : 0 */
|
||||||
|
OPJ_UINT32 bfOffBits; /* Offset */
|
||||||
|
} OPJ_BITMAPFILEHEADER;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
OPJ_UINT32 biSize; /* Size of the structure in bytes */
|
||||||
|
OPJ_UINT32 biWidth; /* Width of the image in pixels */
|
||||||
|
OPJ_UINT32 biHeight; /* Heigth of the image in pixels */
|
||||||
|
OPJ_UINT16 biPlanes; /* 1 */
|
||||||
|
OPJ_UINT16 biBitCount; /* Number of color bits by pixels */
|
||||||
|
OPJ_UINT32 biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
|
||||||
|
OPJ_UINT32 biSizeImage; /* Size of the image in bytes */
|
||||||
|
OPJ_UINT32 biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
|
||||||
|
OPJ_UINT32 biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
|
||||||
|
OPJ_UINT32 biClrUsed; /* Number of color used in the image (0: ALL) */
|
||||||
|
OPJ_UINT32 biClrImportant; /* Number of important color (0: ALL) */
|
||||||
|
OPJ_UINT32 biRedMask; /* Red channel bit mask */
|
||||||
|
OPJ_UINT32 biGreenMask; /* Green channel bit mask */
|
||||||
|
OPJ_UINT32 biBlueMask; /* Blue channel bit mask */
|
||||||
|
OPJ_UINT32 biAlphaMask; /* Alpha channel bit mask */
|
||||||
|
OPJ_UINT32 biColorSpaceType; /* Color space type */
|
||||||
|
OPJ_UINT8 biColorSpaceEP[36]; /* Color space end points */
|
||||||
|
OPJ_UINT32 biRedGamma; /* Red channel gamma */
|
||||||
|
OPJ_UINT32 biGreenGamma; /* Green channel gamma */
|
||||||
|
OPJ_UINT32 biBlueGamma; /* Blue channel gamma */
|
||||||
|
OPJ_UINT32 biIntent; /* Intent */
|
||||||
|
OPJ_UINT32 biIccProfileData; /* ICC profile data */
|
||||||
|
OPJ_UINT32 biIccProfileSize; /* ICC profile size */
|
||||||
|
OPJ_UINT32 biReserved; /* Reserved */
|
||||||
|
} OPJ_BITMAPINFOHEADER;
|
||||||
|
|
||||||
|
static void opj_applyLUT8u_8u32s_C1R(
|
||||||
|
OPJ_UINT8 const* pSrc, OPJ_INT32 srcStride,
|
||||||
|
OPJ_INT32* pDst, OPJ_INT32 dstStride,
|
||||||
|
OPJ_UINT8 const* pLUT,
|
||||||
|
OPJ_UINT32 width, OPJ_UINT32 height)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 y;
|
||||||
|
|
||||||
|
for (y = height; y != 0U; --y) {
|
||||||
|
OPJ_UINT32 x;
|
||||||
|
|
||||||
|
for(x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
pDst[x] = (OPJ_INT32)pLUT[pSrc[x]];
|
||||||
|
}
|
||||||
|
pSrc += srcStride;
|
||||||
|
pDst += dstStride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void opj_applyLUT8u_8u32s_C1P3R(
|
||||||
|
OPJ_UINT8 const* pSrc, OPJ_INT32 srcStride,
|
||||||
|
OPJ_INT32* const* pDst, OPJ_INT32 const* pDstStride,
|
||||||
|
OPJ_UINT8 const* const* pLUT,
|
||||||
|
OPJ_UINT32 width, OPJ_UINT32 height)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 y;
|
||||||
|
OPJ_INT32* pR = pDst[0];
|
||||||
|
OPJ_INT32* pG = pDst[1];
|
||||||
|
OPJ_INT32* pB = pDst[2];
|
||||||
|
OPJ_UINT8 const* pLUT_R = pLUT[0];
|
||||||
|
OPJ_UINT8 const* pLUT_G = pLUT[1];
|
||||||
|
OPJ_UINT8 const* pLUT_B = pLUT[2];
|
||||||
|
|
||||||
|
for (y = height; y != 0U; --y) {
|
||||||
|
OPJ_UINT32 x;
|
||||||
|
|
||||||
|
for(x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
OPJ_UINT8 idx = pSrc[x];
|
||||||
|
pR[x] = (OPJ_INT32)pLUT_R[idx];
|
||||||
|
pG[x] = (OPJ_INT32)pLUT_G[idx];
|
||||||
|
pB[x] = (OPJ_INT32)pLUT_B[idx];
|
||||||
|
}
|
||||||
|
pSrc += srcStride;
|
||||||
|
pR += pDstStride[0];
|
||||||
|
pG += pDstStride[1];
|
||||||
|
pB += pDstStride[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bmp24toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
OPJ_UINT32 width, height;
|
||||||
|
OPJ_UINT32 x, y;
|
||||||
|
const OPJ_UINT8 *pSrc = NULL;
|
||||||
|
|
||||||
|
width = image->comps[0].w;
|
||||||
|
height = image->comps[0].h;
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
pSrc = pData + (height - 1U) * stride;
|
||||||
|
for(y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for(x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
image->comps[0].data[index] = (OPJ_INT32)pSrc[3*x+2]; /* R */
|
||||||
|
image->comps[1].data[index] = (OPJ_INT32)pSrc[3*x+1]; /* G */
|
||||||
|
image->comps[2].data[index] = (OPJ_INT32)pSrc[3*x+0]; /* B */
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
pSrc -= stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bmp_mask_get_shift_and_prec(OPJ_UINT32 mask, OPJ_UINT32* shift, OPJ_UINT32* prec)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 l_shift, l_prec;
|
||||||
|
|
||||||
|
l_shift = l_prec = 0U;
|
||||||
|
|
||||||
|
if (mask != 0U) {
|
||||||
|
while ((mask & 1U) == 0U) {
|
||||||
|
mask >>= 1;
|
||||||
|
l_shift++;
|
||||||
|
}
|
||||||
|
while (mask & 1U) {
|
||||||
|
mask >>= 1;
|
||||||
|
l_prec++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*shift = l_shift; *prec = l_prec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT32 redMask, OPJ_UINT32 greenMask, OPJ_UINT32 blueMask, OPJ_UINT32 alphaMask)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
OPJ_UINT32 width, height;
|
||||||
|
OPJ_UINT32 x, y;
|
||||||
|
const OPJ_UINT8 *pSrc = NULL;
|
||||||
|
OPJ_BOOL hasAlpha;
|
||||||
|
OPJ_UINT32 redShift, redPrec;
|
||||||
|
OPJ_UINT32 greenShift, greenPrec;
|
||||||
|
OPJ_UINT32 blueShift, bluePrec;
|
||||||
|
OPJ_UINT32 alphaShift, alphaPrec;
|
||||||
|
|
||||||
|
width = image->comps[0].w;
|
||||||
|
height = image->comps[0].h;
|
||||||
|
|
||||||
|
hasAlpha = image->numcomps > 3U;
|
||||||
|
|
||||||
|
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||||
|
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||||
|
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||||
|
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||||
|
|
||||||
|
image->comps[0].bpp = redPrec;
|
||||||
|
image->comps[0].prec = redPrec;
|
||||||
|
image->comps[1].bpp = greenPrec;
|
||||||
|
image->comps[1].prec = greenPrec;
|
||||||
|
image->comps[2].bpp = bluePrec;
|
||||||
|
image->comps[2].prec = bluePrec;
|
||||||
|
if (hasAlpha) {
|
||||||
|
image->comps[3].bpp = alphaPrec;
|
||||||
|
image->comps[3].prec = alphaPrec;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
pSrc = pData + (height - 1U) * stride;
|
||||||
|
for(y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for(x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 value = 0U;
|
||||||
|
|
||||||
|
value |= ((OPJ_UINT32)pSrc[4*x+0]) << 0;
|
||||||
|
value |= ((OPJ_UINT32)pSrc[4*x+1]) << 8;
|
||||||
|
value |= ((OPJ_UINT32)pSrc[4*x+2]) << 16;
|
||||||
|
value |= ((OPJ_UINT32)pSrc[4*x+3]) << 24;
|
||||||
|
|
||||||
|
image->comps[0].data[index] = (OPJ_INT32)((value & redMask) >> redShift); /* R */
|
||||||
|
image->comps[1].data[index] = (OPJ_INT32)((value & greenMask) >> greenShift); /* G */
|
||||||
|
image->comps[2].data[index] = (OPJ_INT32)((value & blueMask) >> blueShift); /* B */
|
||||||
|
if (hasAlpha) {
|
||||||
|
image->comps[3].data[index] = (OPJ_INT32)((value & alphaMask) >> alphaShift); /* A */
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
pSrc -= stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bmpmask16toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT32 redMask, OPJ_UINT32 greenMask, OPJ_UINT32 blueMask, OPJ_UINT32 alphaMask)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
OPJ_UINT32 width, height;
|
||||||
|
OPJ_UINT32 x, y;
|
||||||
|
const OPJ_UINT8 *pSrc = NULL;
|
||||||
|
OPJ_BOOL hasAlpha;
|
||||||
|
OPJ_UINT32 redShift, redPrec;
|
||||||
|
OPJ_UINT32 greenShift, greenPrec;
|
||||||
|
OPJ_UINT32 blueShift, bluePrec;
|
||||||
|
OPJ_UINT32 alphaShift, alphaPrec;
|
||||||
|
|
||||||
|
width = image->comps[0].w;
|
||||||
|
height = image->comps[0].h;
|
||||||
|
|
||||||
|
hasAlpha = image->numcomps > 3U;
|
||||||
|
|
||||||
|
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||||
|
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||||
|
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||||
|
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||||
|
|
||||||
|
image->comps[0].bpp = redPrec;
|
||||||
|
image->comps[0].prec = redPrec;
|
||||||
|
image->comps[1].bpp = greenPrec;
|
||||||
|
image->comps[1].prec = greenPrec;
|
||||||
|
image->comps[2].bpp = bluePrec;
|
||||||
|
image->comps[2].prec = bluePrec;
|
||||||
|
if (hasAlpha) {
|
||||||
|
image->comps[3].bpp = alphaPrec;
|
||||||
|
image->comps[3].prec = alphaPrec;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
pSrc = pData + (height - 1U) * stride;
|
||||||
|
for(y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for(x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 value = 0U;
|
||||||
|
|
||||||
|
value |= ((OPJ_UINT32)pSrc[2*x+0]) << 0;
|
||||||
|
value |= ((OPJ_UINT32)pSrc[2*x+1]) << 8;
|
||||||
|
|
||||||
|
image->comps[0].data[index] = (OPJ_INT32)((value & redMask) >> redShift); /* R */
|
||||||
|
image->comps[1].data[index] = (OPJ_INT32)((value & greenMask) >> greenShift); /* G */
|
||||||
|
image->comps[2].data[index] = (OPJ_INT32)((value & blueMask) >> blueShift); /* B */
|
||||||
|
if (hasAlpha) {
|
||||||
|
image->comps[3].data[index] = (OPJ_INT32)((value & alphaMask) >> alphaShift); /* A */
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
pSrc -= stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static opj_image_t* bmp8toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_image_t* image, OPJ_UINT8 const* const* pLUT)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 width, height;
|
||||||
|
const OPJ_UINT8 *pSrc = NULL;
|
||||||
|
|
||||||
|
width = image->comps[0].w;
|
||||||
|
height = image->comps[0].h;
|
||||||
|
|
||||||
|
pSrc = pData + (height - 1U) * stride;
|
||||||
|
if (image->numcomps == 1U) {
|
||||||
|
opj_applyLUT8u_8u32s_C1R(pSrc, -(OPJ_INT32)stride, image->comps[0].data, (OPJ_INT32)width, pLUT[0], width, height);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OPJ_INT32* pDst[3];
|
||||||
|
OPJ_INT32 pDstStride[3];
|
||||||
|
|
||||||
|
pDst[0] = image->comps[0].data; pDst[1] = image->comps[1].data; pDst[2] = image->comps[2].data;
|
||||||
|
pDstStride[0] = (OPJ_INT32)width; pDstStride[1] = (OPJ_INT32)width; pDstStride[2] = (OPJ_INT32)width;
|
||||||
|
opj_applyLUT8u_8u32s_C1P3R(pSrc, -(OPJ_INT32)stride, pDst, pDstStride, pLUT, width, height);
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OPJ_BOOL bmp_read_file_header(FILE* IN, OPJ_BITMAPFILEHEADER* header)
|
||||||
|
{
|
||||||
|
header->bfType = (OPJ_UINT16)getc(IN);
|
||||||
|
header->bfType |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||||
|
|
||||||
|
if (header->bfType != 19778) {
|
||||||
|
fprintf(stderr,"Error, not a BMP file!\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FILE HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
header->bfSize = (OPJ_UINT32)getc(IN);
|
||||||
|
header->bfSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->bfSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->bfSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->bfReserved1 = (OPJ_UINT16)getc(IN);
|
||||||
|
header->bfReserved1 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||||
|
|
||||||
|
header->bfReserved2 = (OPJ_UINT16)getc(IN);
|
||||||
|
header->bfReserved2 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||||
|
|
||||||
|
header->bfOffBits = (OPJ_UINT32)getc(IN);
|
||||||
|
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->bfOffBits |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
|
||||||
|
{
|
||||||
|
memset(header, 0, sizeof(*header));
|
||||||
|
/* INFO HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
header->biSize = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
switch (header->biSize) {
|
||||||
|
case 12U: /* BITMAPCOREHEADER */
|
||||||
|
case 40U: /* BITMAPINFOHEADER */
|
||||||
|
case 52U: /* BITMAPV2INFOHEADER */
|
||||||
|
case 56U: /* BITMAPV3INFOHEADER */
|
||||||
|
case 108U: /* BITMAPV4HEADER */
|
||||||
|
case 124U: /* BITMAPV5HEADER */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
header->biWidth = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biWidth |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biWidth |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biWidth |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biHeight = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biHeight |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biHeight |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biHeight |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biPlanes = (OPJ_UINT16)getc(IN);
|
||||||
|
header->biPlanes |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||||
|
|
||||||
|
header->biBitCount = (OPJ_UINT16)getc(IN);
|
||||||
|
header->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
|
||||||
|
|
||||||
|
if(header->biSize >= 40U) {
|
||||||
|
header->biCompression = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biCompression |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biCompression |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biCompression |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biSizeImage = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biSizeImage |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biXpelsPerMeter = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biYpelsPerMeter = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biClrUsed = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biClrUsed |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biClrImportant = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biClrImportant |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(header->biSize >= 56U) {
|
||||||
|
header->biRedMask = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biRedMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biRedMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biRedMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biGreenMask = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biGreenMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biBlueMask = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biBlueMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biAlphaMask = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(header->biSize >= 108U) {
|
||||||
|
header->biColorSpaceType = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {
|
||||||
|
fprintf(stderr,"Error, can't read BMP header\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
header->biRedGamma = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biRedGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biGreenGamma = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biBlueGamma = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(header->biSize >= 124U) {
|
||||||
|
header->biIntent = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biIntent |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biIntent |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biIntent |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biIccProfileData = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biIccProfileSize = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
|
||||||
|
header->biReserved = (OPJ_UINT32)getc(IN);
|
||||||
|
header->biReserved |= (OPJ_UINT32)getc(IN) << 8;
|
||||||
|
header->biReserved |= (OPJ_UINT32)getc(IN) << 16;
|
||||||
|
header->biReserved |= (OPJ_UINT32)getc(IN) << 24;
|
||||||
|
}
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OPJ_BOOL bmp_read_raw_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||||
|
{
|
||||||
|
OPJ_ARG_NOT_USED(width);
|
||||||
|
|
||||||
|
if ( fread(pData, sizeof(OPJ_UINT8), stride * height, IN) != (stride * height) )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OPJ_BOOL bmp_read_rle8_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 x, y;
|
||||||
|
OPJ_UINT8 *pix;
|
||||||
|
const OPJ_UINT8 *beyond;
|
||||||
|
|
||||||
|
beyond = pData + stride * height;
|
||||||
|
pix = pData;
|
||||||
|
|
||||||
|
x = y = 0U;
|
||||||
|
while (y < height)
|
||||||
|
{
|
||||||
|
int c = getc(IN);
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
int j;
|
||||||
|
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||||
|
|
||||||
|
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||||
|
*pix = c1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c = getc(IN);
|
||||||
|
if (c == 0x00) { /* EOL */
|
||||||
|
x = 0;
|
||||||
|
++y;
|
||||||
|
pix = pData + y * stride + x;
|
||||||
|
}
|
||||||
|
else if (c == 0x01) { /* EOP */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (c == 0x02) { /* MOVE by dxdy */
|
||||||
|
c = getc(IN);
|
||||||
|
x += (OPJ_UINT32)c;
|
||||||
|
c = getc(IN);
|
||||||
|
y += (OPJ_UINT32)c;
|
||||||
|
pix = pData + y * stride + x;
|
||||||
|
}
|
||||||
|
else /* 03 .. 255 */
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++)
|
||||||
|
{
|
||||||
|
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||||
|
*pix = c1;
|
||||||
|
}
|
||||||
|
if ((OPJ_UINT32)c & 1U) { /* skip padding byte */
|
||||||
|
getc(IN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/* while() */
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 x, y;
|
||||||
|
OPJ_UINT8 *pix;
|
||||||
|
const OPJ_UINT8 *beyond;
|
||||||
|
|
||||||
|
beyond = pData + stride * height;
|
||||||
|
pix = pData;
|
||||||
|
x = y = 0U;
|
||||||
|
while(y < height)
|
||||||
|
{
|
||||||
|
int c = getc(IN);
|
||||||
|
if(c == EOF) break;
|
||||||
|
|
||||||
|
if(c) {/* encoded mode */
|
||||||
|
int j;
|
||||||
|
OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
|
||||||
|
|
||||||
|
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||||
|
*pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { /* absolute mode */
|
||||||
|
c = getc(IN);
|
||||||
|
if(c == EOF) break;
|
||||||
|
|
||||||
|
if(c == 0x00) { /* EOL */
|
||||||
|
x = 0; y++; pix = pData + y * stride;
|
||||||
|
}
|
||||||
|
else if(c == 0x01) { /* EOP */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(c == 0x02) { /* MOVE by dxdy */
|
||||||
|
c = getc(IN); x += (OPJ_UINT32)c;
|
||||||
|
c = getc(IN); y += (OPJ_UINT32)c;
|
||||||
|
pix = pData + y * stride + x;
|
||||||
|
}
|
||||||
|
else { /* 03 .. 255 : absolute mode */
|
||||||
|
int j;
|
||||||
|
OPJ_UINT8 c1 = 0U;
|
||||||
|
|
||||||
|
for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
|
||||||
|
if((j&1) == 0) {
|
||||||
|
c1 = (OPJ_UINT8)getc(IN);
|
||||||
|
}
|
||||||
|
*pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||||
|
}
|
||||||
|
if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */
|
||||||
|
getc(IN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* while(y < height) */
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
||||||
|
{
|
||||||
|
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
||||||
|
OPJ_UINT8 lut_R[256], lut_G[256], lut_B[256];
|
||||||
|
OPJ_UINT8 const* pLUT[3];
|
||||||
|
opj_image_t * image = NULL;
|
||||||
|
FILE *IN;
|
||||||
|
OPJ_BITMAPFILEHEADER File_h;
|
||||||
|
OPJ_BITMAPINFOHEADER Info_h;
|
||||||
|
OPJ_UINT32 i, palette_len, numcmpts = 1U;
|
||||||
|
OPJ_BOOL l_result = OPJ_FALSE;
|
||||||
|
OPJ_UINT8* pData = NULL;
|
||||||
|
OPJ_UINT32 stride;
|
||||||
|
|
||||||
|
pLUT[0] = lut_R; pLUT[1] = lut_G; pLUT[2] = lut_B;
|
||||||
|
|
||||||
|
IN = fopen(filename, "rb");
|
||||||
|
if (!IN)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to open %s for reading !!\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bmp_read_file_header(IN, &File_h)) {
|
||||||
|
fclose(IN);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!bmp_read_info_header(IN, &Info_h)) {
|
||||||
|
fclose(IN);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load palette */
|
||||||
|
if (Info_h.biBitCount <= 8U)
|
||||||
|
{
|
||||||
|
memset(&lut_R[0], 0, sizeof(lut_R));
|
||||||
|
memset(&lut_G[0], 0, sizeof(lut_G));
|
||||||
|
memset(&lut_B[0], 0, sizeof(lut_B));
|
||||||
|
|
||||||
|
palette_len = Info_h.biClrUsed;
|
||||||
|
if((palette_len == 0U) && (Info_h.biBitCount <= 8U)) {
|
||||||
|
palette_len = (1U << Info_h.biBitCount);
|
||||||
|
}
|
||||||
|
if (palette_len > 256U) {
|
||||||
|
palette_len = 256U;
|
||||||
|
}
|
||||||
|
if (palette_len > 0U) {
|
||||||
|
OPJ_UINT8 has_color = 0U;
|
||||||
|
for (i = 0U; i < palette_len; i++) {
|
||||||
|
lut_B[i] = (OPJ_UINT8)getc(IN);
|
||||||
|
lut_G[i] = (OPJ_UINT8)getc(IN);
|
||||||
|
lut_R[i] = (OPJ_UINT8)getc(IN);
|
||||||
|
(void)getc(IN); /* padding */
|
||||||
|
has_color |= (lut_B[i] ^ lut_G[i]) | (lut_G[i] ^ lut_R[i]);
|
||||||
|
}
|
||||||
|
if(has_color) {
|
||||||
|
numcmpts = 3U;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
numcmpts = 3U;
|
||||||
|
if ((Info_h.biCompression == 3) && (Info_h.biAlphaMask != 0U)) {
|
||||||
|
numcmpts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stride = ((Info_h.biWidth * Info_h.biBitCount + 31U) / 32U) * 4U; /* rows are aligned on 32bits */
|
||||||
|
if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /* RLE 4 gets decoded as 8 bits data for now... */
|
||||||
|
stride = ((Info_h.biWidth * 8U + 31U) / 32U) * 4U;
|
||||||
|
}
|
||||||
|
pData = (OPJ_UINT8 *) calloc(1, stride * Info_h.biHeight * sizeof(OPJ_UINT8));
|
||||||
|
if (pData == NULL) {
|
||||||
|
fclose(IN);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Place the cursor at the beginning of the image information */
|
||||||
|
fseek(IN, 0, SEEK_SET);
|
||||||
|
fseek(IN, (long)File_h.bfOffBits, SEEK_SET);
|
||||||
|
|
||||||
|
switch (Info_h.biCompression) {
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
/* read raw data */
|
||||||
|
l_result = bmp_read_raw_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* read rle8 data */
|
||||||
|
l_result = bmp_read_rle8_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* read rle4 data */
|
||||||
|
l_result = bmp_read_rle4_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unsupported BMP compression\n");
|
||||||
|
l_result = OPJ_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!l_result) {
|
||||||
|
free(pData);
|
||||||
|
fclose(IN);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create the image */
|
||||||
|
memset(&cmptparm[0], 0, sizeof(cmptparm));
|
||||||
|
for(i = 0; i < 4U; i++)
|
||||||
|
{
|
||||||
|
cmptparm[i].prec = 8;
|
||||||
|
cmptparm[i].bpp = 8;
|
||||||
|
cmptparm[i].sgnd = 0;
|
||||||
|
cmptparm[i].dx = (OPJ_UINT32)parameters->subsampling_dx;
|
||||||
|
cmptparm[i].dy = (OPJ_UINT32)parameters->subsampling_dy;
|
||||||
|
cmptparm[i].w = Info_h.biWidth;
|
||||||
|
cmptparm[i].h = Info_h.biHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? OPJ_CLRSPC_GRAY : OPJ_CLRSPC_SRGB);
|
||||||
|
if(!image) {
|
||||||
|
fclose(IN);
|
||||||
|
free(pData);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (numcmpts == 4U) {
|
||||||
|
image->comps[3].alpha = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set image offset and reference grid */
|
||||||
|
image->x0 = (OPJ_UINT32)parameters->image_offset_x0;
|
||||||
|
image->y0 = (OPJ_UINT32)parameters->image_offset_y0;
|
||||||
|
image->x1 = image->x0 + (Info_h.biWidth - 1U) * (OPJ_UINT32)parameters->subsampling_dx + 1U;
|
||||||
|
image->y1 = image->y0 + (Info_h.biHeight - 1U) * (OPJ_UINT32)parameters->subsampling_dy + 1U;
|
||||||
|
|
||||||
|
/* Read the data */
|
||||||
|
if (Info_h.biBitCount == 24 && Info_h.biCompression == 0) { /*RGB */
|
||||||
|
bmp24toimage(pData, stride, image);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
|
||||||
|
bmp8toimage(pData, stride, image, pLUT);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
|
||||||
|
bmp8toimage(pData, stride, image, pLUT);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
|
||||||
|
bmp8toimage(pData, stride, image, pLUT); /* RLE 4 gets decoded as 8 bits data for now */
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
|
||||||
|
bmpmask32toimage(pData, stride, image, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, 0x00000000U);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
|
||||||
|
bmpmask32toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
|
||||||
|
bmpmask16toimage(pData, stride, image, 0x7C00U, 0x03E0U, 0x001FU, 0x0000U);
|
||||||
|
}
|
||||||
|
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
|
||||||
|
if ((Info_h.biRedMask == 0U) && (Info_h.biGreenMask == 0U) && (Info_h.biBlueMask == 0U)) {
|
||||||
|
Info_h.biRedMask = 0xF800U;
|
||||||
|
Info_h.biGreenMask = 0x07E0U;
|
||||||
|
Info_h.biBlueMask = 0x001FU;
|
||||||
|
}
|
||||||
|
bmpmask16toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
opj_image_destroy(image);
|
||||||
|
image = NULL;
|
||||||
|
fprintf(stderr, "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
|
||||||
|
}
|
||||||
|
free(pData);
|
||||||
|
fclose(IN);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
int imagetobmp(opj_image_t * image, const char *outfile) {
|
||||||
|
int w, h;
|
||||||
|
int i, pad;
|
||||||
|
FILE *fdest = NULL;
|
||||||
|
int adjustR, adjustG, adjustB;
|
||||||
|
|
||||||
|
if (image->comps[0].prec < 8) {
|
||||||
|
fprintf(stderr, "Unsupported number of components: %d\n", image->comps[0].prec);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
|
||||||
|
&& image->comps[1].dx == image->comps[2].dx
|
||||||
|
&& image->comps[0].dy == image->comps[1].dy
|
||||||
|
&& image->comps[1].dy == image->comps[2].dy
|
||||||
|
&& image->comps[0].prec == image->comps[1].prec
|
||||||
|
&& image->comps[1].prec == image->comps[2].prec) {
|
||||||
|
|
||||||
|
/* -->> -->> -->> -->>
|
||||||
|
24 bits color
|
||||||
|
<<-- <<-- <<-- <<-- */
|
||||||
|
|
||||||
|
fdest = fopen(outfile, "wb");
|
||||||
|
if (!fdest) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = (int)image->comps[0].w;
|
||||||
|
h = (int)image->comps[0].h;
|
||||||
|
|
||||||
|
fprintf(fdest, "BM");
|
||||||
|
|
||||||
|
/* FILE HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
fprintf(fdest, "%c%c%c%c",
|
||||||
|
(OPJ_UINT8) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
||||||
|
|
||||||
|
/* INFO HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((w) & 0xff),
|
||||||
|
(OPJ_UINT8) ((w) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((w) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((w) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((h) & 0xff),
|
||||||
|
(OPJ_UINT8) ((h) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (3 * h * w + 3 * h * (w % 2)) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
|
||||||
|
if (image->comps[0].prec > 8) {
|
||||||
|
adjustR = (int)image->comps[0].prec - 8;
|
||||||
|
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
adjustR = 0;
|
||||||
|
if (image->comps[1].prec > 8) {
|
||||||
|
adjustG = (int)image->comps[1].prec - 8;
|
||||||
|
printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
adjustG = 0;
|
||||||
|
if (image->comps[2].prec > 8) {
|
||||||
|
adjustB = (int)image->comps[2].prec - 8;
|
||||||
|
printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
adjustB = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < w * h; i++) {
|
||||||
|
OPJ_UINT8 rc, gc, bc;
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||||
|
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||||
|
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||||
|
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||||
|
rc = (OPJ_UINT8)r;
|
||||||
|
|
||||||
|
g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||||
|
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||||
|
g = ((g >> adjustG)+((g >> (adjustG-1))%2));
|
||||||
|
if(g > 255) g = 255; else if(g < 0) g = 0;
|
||||||
|
gc = (OPJ_UINT8)g;
|
||||||
|
|
||||||
|
b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||||
|
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
|
||||||
|
b = ((b >> adjustB)+((b >> (adjustB-1))%2));
|
||||||
|
if(b > 255) b = 255; else if(b < 0) b = 0;
|
||||||
|
bc = (OPJ_UINT8)b;
|
||||||
|
|
||||||
|
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||||
|
|
||||||
|
if ((i + 1) % w == 0) {
|
||||||
|
for (pad = ((3 * w) % 4) ? (4 - (3 * w) % 4) : 0; pad > 0; pad--) /* ADD */
|
||||||
|
fprintf(fdest, "%c", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fdest);
|
||||||
|
} else { /* Gray-scale */
|
||||||
|
|
||||||
|
/* -->> -->> -->> -->>
|
||||||
|
8 bits non code (Gray scale)
|
||||||
|
<<-- <<-- <<-- <<-- */
|
||||||
|
|
||||||
|
fdest = fopen(outfile, "wb");
|
||||||
|
if (!fdest) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
w = (int)image->comps[0].w;
|
||||||
|
h = (int)image->comps[0].h;
|
||||||
|
|
||||||
|
fprintf(fdest, "BM");
|
||||||
|
|
||||||
|
/* FILE HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff,
|
||||||
|
((54 + 1024) >> 16) & 0xff,
|
||||||
|
((54 + 1024) >> 24) & 0xff);
|
||||||
|
|
||||||
|
/* INFO HEADER */
|
||||||
|
/* ------------- */
|
||||||
|
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((w) & 0xff),
|
||||||
|
(OPJ_UINT8) ((w) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((w) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((w) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) ((h) & 0xff),
|
||||||
|
(OPJ_UINT8) ((h) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (OPJ_UINT8) (h * w + h * (w % 2)) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 8) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 16) & 0xff,
|
||||||
|
(OPJ_UINT8) ((h * w + h * (w % 2)) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||||
|
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||||
|
|
||||||
|
if (image->comps[0].prec > 8) {
|
||||||
|
adjustR = (int)image->comps[0].prec - 8;
|
||||||
|
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||||
|
}else
|
||||||
|
adjustR = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
fprintf(fdest, "%c%c%c%c", i, i, i, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < w * h; i++) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||||
|
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||||
|
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||||
|
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||||
|
|
||||||
|
fprintf(fdest, "%c", (OPJ_UINT8)r);
|
||||||
|
|
||||||
|
if ((i + 1) % w == 0) {
|
||||||
|
for (pad = (w % 4) ? (4 - w % 4) : 0; pad > 0; pad--) /* ADD */
|
||||||
|
fprintf(fdest, "%c", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fdest);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
500
src/bin/jp2/convertpng.c
Normal file
500
src/bin/jp2/convertpng.c
Normal file
@@ -0,0 +1,500 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* Copyright (c) 2015, Matthieu Darbois
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "opj_apps_config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "convert.h"
|
||||||
|
|
||||||
|
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||||
|
#define MAGIC_SIZE 8
|
||||||
|
/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
|
||||||
|
|
||||||
|
|
||||||
|
static void convert_16u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T i;
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
OPJ_INT32 val0 = *pSrc++;
|
||||||
|
OPJ_INT32 val1 = *pSrc++;
|
||||||
|
pDst[i] = val0 << 8 | val1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||||
|
{
|
||||||
|
png_structp png = NULL;
|
||||||
|
png_infop info = NULL;
|
||||||
|
double gamma;
|
||||||
|
int bit_depth, interlace_type,compression_type, filter_type;
|
||||||
|
OPJ_UINT32 i;
|
||||||
|
png_uint_32 width, height = 0U;
|
||||||
|
int color_type;
|
||||||
|
FILE *reader = NULL;
|
||||||
|
OPJ_BYTE** rows = NULL;
|
||||||
|
OPJ_INT32* row32s = NULL;
|
||||||
|
/* j2k: */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
opj_image_cmptparm_t cmptparm[4];
|
||||||
|
OPJ_UINT32 nr_comp;
|
||||||
|
OPJ_BYTE sigbuf[8];
|
||||||
|
convert_XXx32s_C1R cvtXXTo32s = NULL;
|
||||||
|
convert_32s_CXPX cvtCxToPx = NULL;
|
||||||
|
OPJ_INT32* planes[4];
|
||||||
|
|
||||||
|
if((reader = fopen(read_idf, "rb")) == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|
||||||
|
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL)) == NULL)
|
||||||
|
goto fin;
|
||||||
|
if((info = png_create_info_struct(png)) == NULL)
|
||||||
|
goto fin;
|
||||||
|
|
||||||
|
if(setjmp(png_jmpbuf(png)))
|
||||||
|
goto fin;
|
||||||
|
|
||||||
|
png_init_io(png, reader);
|
||||||
|
png_set_sig_bytes(png, MAGIC_SIZE);
|
||||||
|
|
||||||
|
png_read_info(png, info);
|
||||||
|
|
||||||
|
if(png_get_IHDR(png, info, &width, &height,
|
||||||
|
&bit_depth, &color_type, &interlace_type,
|
||||||
|
&compression_type, &filter_type) == 0)
|
||||||
|
goto fin;
|
||||||
|
|
||||||
|
/* png_set_expand():
|
||||||
|
* expand paletted images to RGB, expand grayscale images of
|
||||||
|
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||||
|
* to alpha channels.
|
||||||
|
*/
|
||||||
|
if(color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||||
|
png_set_expand(png);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(png_get_valid(png, info, PNG_INFO_tRNS)) {
|
||||||
|
png_set_expand(png);
|
||||||
|
}
|
||||||
|
/* We might wan't to expand background */
|
||||||
|
/*
|
||||||
|
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
|
||||||
|
png_color_16p bgnd;
|
||||||
|
png_get_bKGD(png, info, &bgnd);
|
||||||
|
png_set_background(png, bgnd, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( !png_get_gAMA(png, info, &gamma))
|
||||||
|
gamma = 1.0;
|
||||||
|
|
||||||
|
/* we're not displaying but converting, screen gamma == 1.0 */
|
||||||
|
png_set_gamma(png, 1.0, gamma);
|
||||||
|
|
||||||
|
png_read_update_info(png, info);
|
||||||
|
|
||||||
|
color_type = png_get_color_type(png, info);
|
||||||
|
|
||||||
|
switch (color_type) {
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
nr_comp = 1;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
|
nr_comp = 2;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
nr_comp = 3;
|
||||||
|
break;
|
||||||
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
|
nr_comp = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"pngtoimage: colortype %d is not supported\n", color_type);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
cvtCxToPx = convert_32s_CXPX_LUT[nr_comp];
|
||||||
|
bit_depth = png_get_bit_depth(png, info);
|
||||||
|
|
||||||
|
switch (bit_depth) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 8:
|
||||||
|
cvtXXTo32s = convert_XXu32s_C1R_LUT[bit_depth];
|
||||||
|
break;
|
||||||
|
case 16: /* 16 bpp is specific to PNG */
|
||||||
|
cvtXXTo32s = convert_16u32s_C1R;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"pngtoimage: bit depth %d is not supported\n", bit_depth);
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rows = (OPJ_BYTE**)calloc(height+1, sizeof(OPJ_BYTE*));
|
||||||
|
if(rows == NULL){
|
||||||
|
fprintf(stderr, "pngtoimage: memory out\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
for(i = 0; i < height; ++i){
|
||||||
|
rows[i] = (OPJ_BYTE*)malloc(png_get_rowbytes(png,info));
|
||||||
|
if(rows[i] == NULL){
|
||||||
|
fprintf(stderr,"pngtoimage: memory out\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
png_read_image(png, rows);
|
||||||
|
|
||||||
|
/* Create image */
|
||||||
|
memset(cmptparm, 0, sizeof(cmptparm));
|
||||||
|
for(i = 0; i < nr_comp; ++i)
|
||||||
|
{
|
||||||
|
cmptparm[i].prec = (OPJ_UINT32)bit_depth;
|
||||||
|
/* bits_per_pixel: 8 or 16 */
|
||||||
|
cmptparm[i].bpp = (OPJ_UINT32)bit_depth;
|
||||||
|
cmptparm[i].sgnd = 0;
|
||||||
|
cmptparm[i].dx = (OPJ_UINT32)params->subsampling_dx;
|
||||||
|
cmptparm[i].dy = (OPJ_UINT32)params->subsampling_dy;
|
||||||
|
cmptparm[i].w = (OPJ_UINT32)width;
|
||||||
|
cmptparm[i].h = (OPJ_UINT32)height;
|
||||||
|
}
|
||||||
|
|
||||||
|
image = opj_image_create(nr_comp, &cmptparm[0], (nr_comp > 2U) ? OPJ_CLRSPC_SRGB : OPJ_CLRSPC_GRAY);
|
||||||
|
if(image == NULL) goto fin;
|
||||||
|
image->x0 = (OPJ_UINT32)params->image_offset_x0;
|
||||||
|
image->y0 = (OPJ_UINT32)params->image_offset_y0;
|
||||||
|
image->x1 = (OPJ_UINT32)(image->x0 + (width - 1) * (OPJ_UINT32)params->subsampling_dx + 1 + image->x0);
|
||||||
|
image->y1 = (OPJ_UINT32)(image->y0 + (height - 1) * (OPJ_UINT32)params->subsampling_dy + 1 + image->y0);
|
||||||
|
|
||||||
|
row32s = (OPJ_INT32 *)malloc((size_t)width * nr_comp * sizeof(OPJ_INT32));
|
||||||
|
if(row32s == NULL) goto fin;
|
||||||
|
|
||||||
|
/* Set alpha channel */
|
||||||
|
image->comps[nr_comp-1U].alpha = 1U - (nr_comp & 1U);
|
||||||
|
|
||||||
|
for(i = 0; i < nr_comp; i++)
|
||||||
|
{
|
||||||
|
planes[i] = image->comps[i].data;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < height; ++i)
|
||||||
|
{
|
||||||
|
cvtXXTo32s(rows[i], row32s, (OPJ_SIZE_T)width * nr_comp);
|
||||||
|
cvtCxToPx(row32s, planes, width);
|
||||||
|
planes[0] += width;
|
||||||
|
planes[1] += width;
|
||||||
|
planes[2] += width;
|
||||||
|
planes[3] += width;
|
||||||
|
}
|
||||||
|
fin:
|
||||||
|
if(rows)
|
||||||
|
{
|
||||||
|
for(i = 0; i < height; ++i)
|
||||||
|
if(rows[i]) free(rows[i]);
|
||||||
|
free(rows);
|
||||||
|
}
|
||||||
|
if (row32s) {
|
||||||
|
free(row32s);
|
||||||
|
}
|
||||||
|
if(png)
|
||||||
|
png_destroy_read_struct(&png, &info, NULL);
|
||||||
|
|
||||||
|
fclose(reader);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
|
||||||
|
}/* pngtoimage() */
|
||||||
|
|
||||||
|
|
||||||
|
static void convert_32s16u_C1R(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T i;
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
OPJ_UINT32 val = (OPJ_UINT32)pSrc[i];
|
||||||
|
*pDst++ = (OPJ_BYTE)(val >> 8);
|
||||||
|
*pDst++ = (OPJ_BYTE)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int imagetopng(opj_image_t * image, const char *write_idf)
|
||||||
|
{
|
||||||
|
FILE * volatile writer = NULL;
|
||||||
|
png_structp png = NULL;
|
||||||
|
png_infop info = NULL;
|
||||||
|
png_bytep volatile row_buf = NULL;
|
||||||
|
int nr_comp, color_type;
|
||||||
|
volatile int prec;
|
||||||
|
png_color_8 sig_bit;
|
||||||
|
OPJ_INT32 const* planes[4];
|
||||||
|
int i;
|
||||||
|
OPJ_INT32* volatile buffer32s = NULL;
|
||||||
|
|
||||||
|
volatile int fails = 1;
|
||||||
|
|
||||||
|
memset(&sig_bit, 0, sizeof(sig_bit));
|
||||||
|
prec = (int)image->comps[0].prec;
|
||||||
|
planes[0] = image->comps[0].data;
|
||||||
|
nr_comp = (int)image->numcomps;
|
||||||
|
|
||||||
|
if (nr_comp > 4) {
|
||||||
|
nr_comp = 4;
|
||||||
|
}
|
||||||
|
for (i = 1; i < nr_comp; ++i) {
|
||||||
|
if (image->comps[0].dx != image->comps[i].dx) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].dy != image->comps[i].dy) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].prec != image->comps[i].prec) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
planes[i] = image->comps[i].data;
|
||||||
|
}
|
||||||
|
if (i != nr_comp) {
|
||||||
|
fprintf(stderr,"imagetopng: All components shall have the same subsampling, same bit depth, same sign.\n");
|
||||||
|
fprintf(stderr,"\tAborting\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||||
|
}
|
||||||
|
if(prec > 8 && prec < 16)
|
||||||
|
{
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), 16);
|
||||||
|
}
|
||||||
|
prec = 16;
|
||||||
|
}
|
||||||
|
else if(prec < 8 && nr_comp > 1)/* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||||
|
{
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), 8);
|
||||||
|
}
|
||||||
|
prec = 8;
|
||||||
|
} else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1)==1))) { /* GRAY with non native precision */
|
||||||
|
if ((prec == 5) || (prec == 6)) {
|
||||||
|
prec = 8;
|
||||||
|
} else {
|
||||||
|
prec++;
|
||||||
|
}
|
||||||
|
for (i = 0; i < nr_comp; ++i) {
|
||||||
|
scale_component(&(image->comps[i]), (OPJ_UINT32)prec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"imagetopng: can not create %s\n\twrong bit_depth %d\n", write_idf, prec);
|
||||||
|
return fails;
|
||||||
|
}
|
||||||
|
|
||||||
|
writer = fopen(write_idf, "wb");
|
||||||
|
|
||||||
|
if(writer == NULL) return fails;
|
||||||
|
|
||||||
|
/* Create and initialize the png_struct with the desired error handler
|
||||||
|
* functions. If you want to use the default stderr and longjump method,
|
||||||
|
* you can supply NULL for the last three parameters. We also check that
|
||||||
|
* the library version is compatible with the one used at compile time,
|
||||||
|
* in case we are using dynamically linked libraries. REQUIRED.
|
||||||
|
*/
|
||||||
|
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
|
||||||
|
|
||||||
|
if(png == NULL) goto fin;
|
||||||
|
|
||||||
|
/* Allocate/initialize the image information data. REQUIRED
|
||||||
|
*/
|
||||||
|
info = png_create_info_struct(png);
|
||||||
|
|
||||||
|
if(info == NULL) goto fin;
|
||||||
|
|
||||||
|
/* Set error handling. REQUIRED if you are not supplying your own
|
||||||
|
* error handling functions in the png_create_write_struct() call.
|
||||||
|
*/
|
||||||
|
if(setjmp(png_jmpbuf(png))) goto fin;
|
||||||
|
|
||||||
|
/* I/O initialization functions is REQUIRED
|
||||||
|
*/
|
||||||
|
png_init_io(png, writer);
|
||||||
|
|
||||||
|
/* Set the image information here. Width and height are up to 2^31,
|
||||||
|
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||||
|
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||||
|
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||||
|
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||||
|
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||||
|
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||||
|
* REQUIRED
|
||||||
|
*
|
||||||
|
* ERRORS:
|
||||||
|
*
|
||||||
|
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||||
|
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
|
if(nr_comp >= 3) /* RGB(A) */
|
||||||
|
{
|
||||||
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
|
||||||
|
}
|
||||||
|
else /* GRAY(A) */
|
||||||
|
{
|
||||||
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
sig_bit.gray = (png_byte)prec;
|
||||||
|
}
|
||||||
|
if((nr_comp & 1) == 0) /* ALPHA */
|
||||||
|
{
|
||||||
|
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||||
|
sig_bit.alpha = (png_byte)prec;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_set_IHDR(png, info, image->comps[0].w, image->comps[0].h, prec, color_type,
|
||||||
|
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
|
png_set_sBIT(png, info, &sig_bit);
|
||||||
|
/* png_set_gamma(png, 2.2, 1./2.2); */
|
||||||
|
/* png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); */
|
||||||
|
png_write_info(png, info);
|
||||||
|
|
||||||
|
/* setup conversion */
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T rowStride;
|
||||||
|
png_size_t png_row_size;
|
||||||
|
|
||||||
|
png_row_size = png_get_rowbytes(png, info);
|
||||||
|
rowStride = ((OPJ_SIZE_T)image->comps[0].w * (OPJ_SIZE_T)nr_comp * (OPJ_SIZE_T)prec + 7U) / 8U;
|
||||||
|
if (rowStride != (OPJ_SIZE_T)png_row_size) {
|
||||||
|
fprintf(stderr, "Invalid PNG row size\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
row_buf = (png_bytep)malloc(png_row_size);
|
||||||
|
if (row_buf == NULL) {
|
||||||
|
fprintf(stderr, "Can't allocate memory for PNG row\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
buffer32s = (OPJ_INT32*)malloc((OPJ_SIZE_T)image->comps[0].w * (OPJ_SIZE_T)nr_comp * sizeof(OPJ_INT32));
|
||||||
|
if (buffer32s == NULL) {
|
||||||
|
fprintf(stderr, "Can't allocate memory for interleaved 32s row\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert */
|
||||||
|
{
|
||||||
|
OPJ_SIZE_T width= image->comps[0].w;
|
||||||
|
OPJ_UINT32 y;
|
||||||
|
convert_32s_PXCX cvtPxToCx = convert_32s_PXCX_LUT[nr_comp];
|
||||||
|
convert_32sXXx_C1R cvt32sToPack = NULL;
|
||||||
|
OPJ_INT32 adjust = image->comps[0].sgnd ? 1 << (prec - 1) : 0;
|
||||||
|
png_bytep row_buf_cpy = row_buf;
|
||||||
|
OPJ_INT32* buffer32s_cpy = buffer32s;
|
||||||
|
|
||||||
|
switch (prec) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
case 8:
|
||||||
|
cvt32sToPack = convert_32sXXu_C1R_LUT[prec];
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
cvt32sToPack = convert_32s16u_C1R;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* never here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(y = 0; y < image->comps[0].h; ++y)
|
||||||
|
{
|
||||||
|
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
|
||||||
|
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (OPJ_SIZE_T)nr_comp);
|
||||||
|
png_write_row(png, row_buf_cpy);
|
||||||
|
planes[0] += width;
|
||||||
|
planes[1] += width;
|
||||||
|
planes[2] += width;
|
||||||
|
planes[3] += width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_write_end(png, info);
|
||||||
|
|
||||||
|
fails = 0;
|
||||||
|
|
||||||
|
fin:
|
||||||
|
if(png) {
|
||||||
|
png_destroy_write_struct(&png, &info);
|
||||||
|
}
|
||||||
|
if(row_buf) {
|
||||||
|
free(row_buf);
|
||||||
|
}
|
||||||
|
if(buffer32s) {
|
||||||
|
free(buffer32s);
|
||||||
|
}
|
||||||
|
fclose(writer);
|
||||||
|
|
||||||
|
if(fails) (void)remove(write_idf); /* ignore return value */
|
||||||
|
|
||||||
|
return fails;
|
||||||
|
}/* imagetopng() */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user