Compare commits
856 Commits
v1.7.0
...
SunshineRe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69e0738096 | ||
|
|
0b31537bfe | ||
|
|
776a977824 | ||
|
|
5cf091b8b2 | ||
|
|
bea4bc6a1a | ||
|
|
9596514c79 | ||
|
|
5ada2d4b6f | ||
|
|
dd15b9234f | ||
|
|
d03d145be4 | ||
|
|
1083d7e0ef | ||
|
|
cdaa4b4e99 | ||
|
|
295fcb53b0 | ||
|
|
389c35e08e | ||
|
|
003aa6a4eb | ||
|
|
f9d205b869 | ||
|
|
e08afcb963 | ||
|
|
3750123e43 | ||
|
|
b20f39d09f | ||
|
|
7eda762c28 | ||
|
|
0460769eea | ||
|
|
d3939c785d | ||
|
|
184882e916 | ||
|
|
6c9df4574c | ||
|
|
034c83f996 | ||
|
|
2b582b169b | ||
|
|
38f59e640c | ||
|
|
af1e7b346e | ||
|
|
7a2f572eaa | ||
|
|
5fe0820e13 | ||
|
|
28a4101d4d | ||
|
|
cc22edcce3 | ||
|
|
2424d2a082 | ||
|
|
b1ccb70277 | ||
|
|
c641cc6394 | ||
|
|
9a6568f5e8 | ||
|
|
3627b33eec | ||
|
|
702eb95b84 | ||
|
|
03f191f47d | ||
|
|
813a4b0200 | ||
|
|
c24950b261 | ||
|
|
806abb1985 | ||
|
|
a4591a5eaa | ||
|
|
018737eb15 | ||
|
|
3e5bd4e13b | ||
|
|
98ec8b9910 | ||
|
|
d2a966f363 | ||
|
|
8a7cc9259c | ||
|
|
382fc710e5 | ||
|
|
be4229867a | ||
|
|
6b05022530 | ||
|
|
08a3828cc9 | ||
|
|
d5efedf51b | ||
|
|
8394a96fa8 | ||
|
|
4f7e869509 | ||
|
|
7aac61859f | ||
|
|
3ba967bdc1 | ||
|
|
9fb4e677a6 | ||
|
|
1ffb5aa6fe | ||
|
|
0100cd2f36 | ||
|
|
d6b486524c | ||
|
|
f80394fc02 | ||
|
|
e750c598be | ||
|
|
26191dd274 | ||
|
|
12171f6cd9 | ||
|
|
457276fa5d | ||
|
|
7ba21ac4fd | ||
|
|
e2b011590d | ||
|
|
ef6f411b70 | ||
|
|
2c48161595 | ||
|
|
ca3e0d2ba9 | ||
|
|
922e234fe9 | ||
|
|
b9cfd2fae5 | ||
|
|
ce3511f7ea | ||
|
|
a8e1bd1538 | ||
|
|
0876c8c2bf | ||
|
|
0554ecae5c | ||
|
|
cfbc8a23f7 | ||
|
|
8b19f82c0b | ||
|
|
794dbacea3 | ||
|
|
3a4b6cf6b6 | ||
|
|
c0c9c51e43 | ||
|
|
e17405d80a | ||
|
|
5e6ed2dc9f | ||
|
|
adebc36bc7 | ||
|
|
165bebda3e | ||
|
|
0f54e5fe46 | ||
|
|
aab195a6eb | ||
|
|
2400d146ce | ||
|
|
9a9b5ce61e | ||
|
|
6b473c6edc | ||
|
|
9d8f31a0cb | ||
|
|
5947769812 | ||
|
|
52673f5249 | ||
|
|
f44de434c2 | ||
|
|
cbb27a5661 | ||
|
|
48eaccc612 | ||
|
|
5499136677 | ||
|
|
57b66a9be9 | ||
|
|
746f419e80 | ||
|
|
5d1a138c5c | ||
|
|
e781870da3 | ||
|
|
e3f30fece9 | ||
|
|
7b2536eb0d | ||
|
|
299382b907 | ||
|
|
fce64f8f12 | ||
|
|
f8bf11d574 | ||
|
|
fdfe0cae87 | ||
|
|
66664660d7 | ||
|
|
760ac98ab6 | ||
|
|
2bd5d88dbf | ||
|
|
5f78a36899 | ||
|
|
b897b9427f | ||
|
|
c33b1004d1 | ||
|
|
19e8977fff | ||
|
|
c097d650dc | ||
|
|
b7af32bee3 | ||
|
|
d2422b03be | ||
|
|
97d2085735 | ||
|
|
e307df79a1 | ||
|
|
324fe06a06 | ||
|
|
fe15371047 | ||
|
|
fbb7196100 | ||
|
|
8c9a9c9d12 | ||
|
|
6f8ea87c46 | ||
|
|
3d84157325 | ||
|
|
9abf8ddf91 | ||
|
|
f289d5d9e7 | ||
|
|
821c03a389 | ||
|
|
c37a473287 | ||
|
|
3eebedc4c3 | ||
|
|
5eb99b7d2f | ||
|
|
3534706a59 | ||
|
|
717a8a5cdb | ||
|
|
586d8fdf21 | ||
|
|
f4016c2e1c | ||
|
|
2bb08d7638 | ||
|
|
155cc56632 | ||
|
|
4a4032f3b8 | ||
|
|
cd5aa8f074 | ||
|
|
c2b26f6c15 | ||
|
|
f25ca2ac80 | ||
|
|
303c74f4c9 | ||
|
|
59d4d833f1 | ||
|
|
562acd6e2c | ||
|
|
c3d76669ca | ||
|
|
14d8d14832 | ||
|
|
cdc04ba413 | ||
|
|
ab91525e7a | ||
|
|
0a4b3487ea | ||
|
|
0061055e73 | ||
|
|
a16c4015ba | ||
|
|
0173c29630 | ||
|
|
26a734a538 | ||
|
|
04e7dc1270 | ||
|
|
1cdc11dae2 | ||
|
|
1cb75c4471 | ||
|
|
b6efc9f583 | ||
|
|
01868e46fe | ||
|
|
313cce23db | ||
|
|
9aca1f41f3 | ||
|
|
81c7445744 | ||
|
|
d54daa19a0 | ||
|
|
0c58a42b08 | ||
|
|
68cbf31c8b | ||
|
|
d518222340 | ||
|
|
7a35a43bd4 | ||
|
|
cb52e82a60 | ||
|
|
1a43bc8abf | ||
|
|
e88c39b090 | ||
|
|
a1f5e6ba43 | ||
|
|
d0a0aa7a65 | ||
|
|
8cf956e669 | ||
|
|
3bbb23b1bc | ||
|
|
a582b5996c | ||
|
|
4cd10c34e2 | ||
|
|
3ec1dbf51c | ||
|
|
71deb8925e | ||
|
|
abb562d1ab | ||
|
|
a495a6bfbc | ||
|
|
e86b17be2d | ||
|
|
e62f805bcd | ||
|
|
6f8ae718d1 | ||
|
|
1dcfa9e0ee | ||
|
|
7f0664ff82 | ||
|
|
03b3e60e23 | ||
|
|
72bde5234a | ||
|
|
1e1f5e8193 | ||
|
|
6c01b6da9b | ||
|
|
756aac1f9a | ||
|
|
c0ac428179 | ||
|
|
7549b471c3 | ||
|
|
0b265320a9 | ||
|
|
6033a76870 | ||
|
|
3708d55ef9 | ||
|
|
9996cf6157 | ||
|
|
3e78b7c262 | ||
|
|
65e012c540 | ||
|
|
2a88f7d7c4 | ||
|
|
dca9501de7 | ||
|
|
8ed6b549ee | ||
|
|
1a741b97d2 | ||
|
|
33809f56c5 | ||
|
|
67ee544231 | ||
|
|
94f61ce307 | ||
|
|
b57f7cdc79 | ||
|
|
c901a7136f | ||
|
|
243db9a3a8 | ||
|
|
a5ef61ac82 | ||
|
|
9e272aeef0 | ||
|
|
5c45979783 | ||
|
|
02f214d8a7 | ||
|
|
daac25c343 | ||
|
|
768f1b5710 | ||
|
|
5b4b9fd169 | ||
|
|
7dea357f4c | ||
|
|
9ef10b1663 | ||
|
|
d2004e88f9 | ||
|
|
ef27cc54dd | ||
|
|
19390eaec3 | ||
|
|
dff6171605 | ||
|
|
4fe84efafd | ||
|
|
ed4997168b | ||
|
|
b92de9beb5 | ||
|
|
7f50b2ba7b | ||
|
|
c35bc71334 | ||
|
|
413a8111c0 | ||
|
|
5be31898f1 | ||
|
|
44faf3e169 | ||
|
|
937a60c8f9 | ||
|
|
f7626699da | ||
|
|
ad97c72821 | ||
|
|
b7ce7b7dab | ||
|
|
b73f4dd8e4 | ||
|
|
a4bf92dae4 | ||
|
|
1e745ba48b | ||
|
|
f8273e977e | ||
|
|
605843b527 | ||
|
|
71d2bd83aa | ||
|
|
a12704c6a3 | ||
|
|
43271f290e | ||
|
|
7533b475be | ||
|
|
1b89e5c973 | ||
|
|
8ba127d4c5 | ||
|
|
bb8ea493d6 | ||
|
|
02cffa9a71 | ||
|
|
76fc30e460 | ||
|
|
e8ec81bf04 | ||
|
|
9fba54ad5d | ||
|
|
ccd98c3c3d | ||
|
|
2539e41e59 | ||
|
|
83312fbb74 | ||
|
|
6134162f1c | ||
|
|
fb713226a0 | ||
|
|
3ac46f5fa7 | ||
|
|
d5c507ca6b | ||
|
|
858bb15a6b | ||
|
|
faee255730 | ||
|
|
eb5b1312bb | ||
|
|
5445b4f97a | ||
|
|
02ead94848 | ||
|
|
6a4f76a219 | ||
|
|
1252b0bde2 | ||
|
|
a40fbf0da1 | ||
|
|
468f52a4f6 | ||
|
|
3f1fb9a66e | ||
|
|
c181891549 | ||
|
|
f84f4aa058 | ||
|
|
5d5c3e2a48 | ||
|
|
5b8b88e05a | ||
|
|
0287e21c01 | ||
|
|
7d2f2bd610 | ||
|
|
d56393b134 | ||
|
|
1f7ed035d3 | ||
|
|
8430328043 | ||
|
|
f311852e9b | ||
|
|
ac0a32e690 | ||
|
|
88482a2431 | ||
|
|
efbd339dc8 | ||
|
|
ff28ce8d65 | ||
|
|
cb33470673 | ||
|
|
e6389d62dc | ||
|
|
2766f17cb9 | ||
|
|
70c36716c9 | ||
|
|
48702b1ed9 | ||
|
|
16216b2ed0 | ||
|
|
3e22553d7e | ||
|
|
4744839a08 | ||
|
|
cb0c13a1a1 | ||
|
|
f0497a2721 | ||
|
|
77d018dbc8 | ||
|
|
4be8b50360 | ||
|
|
2581935b36 | ||
|
|
a7cf09883e | ||
|
|
1254a7bbe2 | ||
|
|
fb5ec1d1f5 | ||
|
|
5bcb350d89 | ||
|
|
81bc6b49f8 | ||
|
|
9019a1eb23 | ||
|
|
f3780998ed | ||
|
|
27090c541f | ||
|
|
ef73469700 | ||
|
|
2d12a82a54 | ||
|
|
c5d9dc4732 | ||
|
|
84ec70e707 | ||
|
|
b7f5d7e415 | ||
|
|
8df7a52cf7 | ||
|
|
9bb9292a41 | ||
|
|
438c499718 | ||
|
|
ff81d9461a | ||
|
|
f4f85aa1fd | ||
|
|
56f2f0b727 | ||
|
|
19f325aa09 | ||
|
|
1d5a63c180 | ||
|
|
d7da5153f3 | ||
|
|
c67f010302 | ||
|
|
90a10b3508 | ||
|
|
a09f7d274f | ||
|
|
daa9466b7a | ||
|
|
efb252206b | ||
|
|
ffb847bbc0 | ||
|
|
44b2392a10 | ||
|
|
855540b5c5 | ||
|
|
a7b9b0da42 | ||
|
|
5f8eac9dc8 | ||
|
|
b0ea103c61 | ||
|
|
65781e6080 | ||
|
|
fc0149cdbc | ||
|
|
3946c076fe | ||
|
|
b5b6d3f85c | ||
|
|
10f09dc15d | ||
|
|
f50d23a0d4 | ||
|
|
cb9f972d13 | ||
|
|
53fd33604d | ||
|
|
c8e3935648 | ||
|
|
8f9c8ee293 | ||
|
|
767fe92de5 | ||
|
|
435b9cd1bb | ||
|
|
afc7c2b449 | ||
|
|
e0a7c7e935 | ||
|
|
b0415370f8 | ||
|
|
b7ff2fe3e3 | ||
|
|
7978f5ebfe | ||
|
|
b663110288 | ||
|
|
3ef9e3bc69 | ||
|
|
a032bd28ad | ||
|
|
834a524a67 | ||
|
|
e3460bea09 | ||
|
|
31041f2ade | ||
|
|
3320272673 | ||
|
|
131959e388 | ||
|
|
d23835a6c2 | ||
|
|
e17632e0d5 | ||
|
|
d57a3b101b | ||
|
|
c2289c047b | ||
|
|
4ade726a07 | ||
|
|
856a45a775 | ||
|
|
f64ccbab7e | ||
|
|
8a44c8fce1 | ||
|
|
2a70dde016 | ||
|
|
f1a5fb6b62 | ||
|
|
04bb15a108 | ||
|
|
9b358a1b39 | ||
|
|
86ad4aabf3 | ||
|
|
36c097744c | ||
|
|
e7cd445491 | ||
|
|
9b66d74382 | ||
|
|
e3752aefed | ||
|
|
d8ff809092 | ||
|
|
a8f5bf8baf | ||
|
|
3a3605b812 | ||
|
|
f1c635d103 | ||
|
|
15cce79040 | ||
|
|
fef681be7c | ||
|
|
e379a5a03e | ||
|
|
f2b4911f60 | ||
|
|
ff93de6e61 | ||
|
|
29adc28d80 | ||
|
|
118937aa99 | ||
|
|
6ec4c65f04 | ||
|
|
fefb40bda2 | ||
|
|
c5938f7d31 | ||
|
|
e748b74c67 | ||
|
|
a957d58939 | ||
|
|
37a9a52544 | ||
|
|
566d70a6d1 | ||
|
|
7b7157f491 | ||
|
|
ea8791697e | ||
|
|
dd9f7bba5d | ||
|
|
8051cd4194 | ||
|
|
b4a7fa1ad9 | ||
|
|
e460bd9a69 | ||
|
|
5a3082275e | ||
|
|
bdf20355b6 | ||
|
|
21ea923520 | ||
|
|
484fff444f | ||
|
|
f63d0abbc1 | ||
|
|
5a05898ec4 | ||
|
|
b9ee7cc30a | ||
|
|
03ee96cdff | ||
|
|
be2598bc4c | ||
|
|
01f5fe6eb1 | ||
|
|
32f9cbb11d | ||
|
|
67e99c799c | ||
|
|
da5284c6b8 | ||
|
|
c2fa79347e | ||
|
|
953a7ff066 | ||
|
|
84cabd6a1e | ||
|
|
e1a6b7e249 | ||
|
|
72b342912e | ||
|
|
07f52c463e | ||
|
|
064f0216b4 | ||
|
|
70a4d113b3 | ||
|
|
2001d6b6ec | ||
|
|
b278cbb32e | ||
|
|
7ec9af8200 | ||
|
|
71b0c35653 | ||
|
|
4032df3115 | ||
|
|
6eadc29ca0 | ||
|
|
c6f7a39d22 | ||
|
|
73099edae3 | ||
|
|
f53646764c | ||
|
|
7b42fea0f5 | ||
|
|
df1e9732d0 | ||
|
|
822ba4432f | ||
|
|
8e6c6acf18 | ||
|
|
83b13f6a3f | ||
|
|
aceb3f3425 | ||
|
|
37f2ec2f9f | ||
|
|
4d1e822de7 | ||
|
|
b8276fd8e3 | ||
|
|
d319ebc0a8 | ||
|
|
5f32d9347d | ||
|
|
ba136fe42d | ||
|
|
e4090b1475 | ||
|
|
b7d2ecbf1a | ||
|
|
f77f846c8d | ||
|
|
23b34aeb92 | ||
|
|
59c887129d | ||
|
|
bd7cd9245a | ||
|
|
53c7cf116c | ||
|
|
95b7842e31 | ||
|
|
0b953ccc40 | ||
|
|
41c4eabcaa | ||
|
|
0a33a3a71a | ||
|
|
d6b470cd07 | ||
|
|
d1cb627582 | ||
|
|
1d99158562 | ||
|
|
05c32c7a62 | ||
|
|
ea4d32b4ad | ||
|
|
bb9e260793 | ||
|
|
536cb6febd | ||
|
|
258fe8bad0 | ||
|
|
74772a1f61 | ||
|
|
bdaa5f20a1 | ||
|
|
19293601b3 | ||
|
|
f2bcfa5275 | ||
|
|
6265027222 | ||
|
|
36ff4dcd11 | ||
|
|
35a53ef1d7 | ||
|
|
507c5eb7ca | ||
|
|
169670a58b | ||
|
|
fbb5dced97 | ||
|
|
aa54a386f3 | ||
|
|
6b8c58e3b5 | ||
|
|
67f4797e09 | ||
|
|
7335ae548c | ||
|
|
0b1a5bc3c1 | ||
|
|
e9c54bb5e4 | ||
|
|
4294038271 | ||
|
|
408eab13f0 | ||
|
|
ee0bd9ee76 | ||
|
|
263a25fb87 | ||
|
|
fa10ce28d2 | ||
|
|
039f665af1 | ||
|
|
304fa05094 | ||
|
|
89ad14b82f | ||
|
|
73785af730 | ||
|
|
d2c3e50a3f | ||
|
|
2fbe7ab6ce | ||
|
|
164799e4c4 | ||
|
|
4f57269518 | ||
|
|
92c9311a4c | ||
|
|
ca6fd89700 | ||
|
|
80b100f135 | ||
|
|
8e12f11089 | ||
|
|
f4324e8890 | ||
|
|
fda34fea46 | ||
|
|
0770150455 | ||
|
|
d79a8fc87b | ||
|
|
8e1bbfe938 | ||
|
|
3469d65f95 | ||
|
|
486536f92d | ||
|
|
70717cb6c8 | ||
|
|
94ebcdeb6b | ||
|
|
152238e67f | ||
|
|
eef51e0bd0 | ||
|
|
91df8446b0 | ||
|
|
ffb55f482a | ||
|
|
b2c5a84964 | ||
|
|
0be43cf1c2 | ||
|
|
f5923860fa | ||
|
|
adc2921f38 | ||
|
|
ca630a106e | ||
|
|
cbbc42d564 | ||
|
|
0054e6a378 | ||
|
|
76e30150b9 | ||
|
|
cd197a3807 | ||
|
|
b9673df961 | ||
|
|
37c8ea54eb | ||
|
|
e616b40c6f | ||
|
|
26109ca8f9 | ||
|
|
46e57d4f1c | ||
|
|
7743843a27 | ||
|
|
c84e145557 | ||
|
|
e767392b44 | ||
|
|
457177905d | ||
|
|
de74443d76 | ||
|
|
f3e7340118 | ||
|
|
efe3dd77fa | ||
|
|
7c690b9de1 | ||
|
|
5ce8770dc3 | ||
|
|
e9ddd6b8f8 | ||
|
|
f94f458922 | ||
|
|
89ef06fd3f | ||
|
|
ccd135b2a6 | ||
|
|
80eb0851d9 | ||
|
|
b84f470fca | ||
|
|
5caeccc007 | ||
|
|
96a4e16a4b | ||
|
|
477c657f60 | ||
|
|
68ad5411c9 | ||
|
|
cc50e620c0 | ||
|
|
8646abb18b | ||
|
|
2fbf6b732e | ||
|
|
93416e40a4 | ||
|
|
d2210414bc | ||
|
|
e6e9a21597 | ||
|
|
e14be5c8c2 | ||
|
|
f9b3561ca8 | ||
|
|
95083e846b | ||
|
|
ce415fb65c | ||
|
|
f479ea4bcf | ||
|
|
1a6c00ca8b | ||
|
|
58033d3cbc | ||
|
|
4c23ab029a | ||
|
|
0846f8a963 | ||
|
|
65a1aae629 | ||
|
|
caef97ad36 | ||
|
|
761439cc8d | ||
|
|
b847c53395 | ||
|
|
aca3e8f6c4 | ||
|
|
7122a7c174 | ||
|
|
769a7b89d2 | ||
|
|
d2b13f515d | ||
|
|
ef601d3345 | ||
|
|
d9e5601e10 | ||
|
|
c385133c84 | ||
|
|
b91a670c05 | ||
|
|
c90c8e0f4b | ||
|
|
0a8cd6d03d | ||
|
|
af89351432 | ||
|
|
fb81754880 | ||
|
|
dc5bfc1c41 | ||
|
|
98c740f204 | ||
|
|
255742db26 | ||
|
|
af4ceb0658 | ||
|
|
08d72b12ab | ||
|
|
5fb4badb7c | ||
|
|
4650636e5a | ||
|
|
2c65da3397 | ||
|
|
abc1d185b7 | ||
|
|
124eba4371 | ||
|
|
a673496ed3 | ||
|
|
af2a49afa7 | ||
|
|
b151796e0e | ||
|
|
828b2c9bc0 | ||
|
|
be8b838334 | ||
|
|
73fedf453c | ||
|
|
e03de192c8 | ||
|
|
725cdc2d69 | ||
|
|
048c57cf0c | ||
|
|
12dcbfbc79 | ||
|
|
32be05fa6c | ||
|
|
ae62b67554 | ||
|
|
29908533cd | ||
|
|
9c4f22d85b | ||
|
|
7f64668e55 | ||
|
|
0208942b84 | ||
|
|
783e86990c | ||
|
|
cdefc0e384 | ||
|
|
1c9f996248 | ||
|
|
c9715c5b0b | ||
|
|
dd47123bde | ||
|
|
594dc64a43 | ||
|
|
1b69994ffa | ||
|
|
3de21156b5 | ||
|
|
ce2c6ab49e | ||
|
|
d19c5a4a4a | ||
|
|
8945fe4857 | ||
|
|
464919072d | ||
|
|
f8c2087d74 | ||
|
|
7adc0e24ab | ||
|
|
ba65f29a72 | ||
|
|
76eef6fe59 | ||
|
|
1d1947c51a | ||
|
|
af4ac8fb5f | ||
|
|
adaf5cd69c | ||
|
|
516f5a40d0 | ||
|
|
3b7887a041 | ||
|
|
fe38f59bbb | ||
|
|
cd93aba002 | ||
|
|
2bcabce1d6 | ||
|
|
6ed9a62501 | ||
|
|
b987c025db | ||
|
|
27d8d100c5 | ||
|
|
701230b49c | ||
|
|
726d8248c5 | ||
|
|
07a2c5a81d | ||
|
|
081ae32d35 | ||
|
|
a7f02b3964 | ||
|
|
e116548b50 | ||
|
|
3190814265 | ||
|
|
eeea2b4de4 | ||
|
|
21f6174846 | ||
|
|
ed4c6b7c92 | ||
|
|
89be317a00 | ||
|
|
1ad4597d7a | ||
|
|
c65b659538 | ||
|
|
3c23163a29 | ||
|
|
c3900ee4f3 | ||
|
|
9c5da9e42c | ||
|
|
efa970c6a5 | ||
|
|
179f04739d | ||
|
|
b2f513caae | ||
|
|
9c1e74b0c0 | ||
|
|
e53af58d4a | ||
|
|
d9cb2ce6c7 | ||
|
|
a967f2b037 | ||
|
|
db5a7578c9 | ||
|
|
15086833a3 | ||
|
|
785729abdf | ||
|
|
32f407340f | ||
|
|
2830b35aa6 | ||
|
|
fb38f6adea | ||
|
|
a1e714dce7 | ||
|
|
3710ea903e | ||
|
|
72a9b6b7fe | ||
|
|
0d3fab40e5 | ||
|
|
3a30f1dc71 | ||
|
|
95abf3dca3 | ||
|
|
4e4d554ea4 | ||
|
|
9642780bb8 | ||
|
|
73bc656e63 | ||
|
|
b8b235df09 | ||
|
|
7b23aece00 | ||
|
|
531af998fb | ||
|
|
c7bdaf6632 | ||
|
|
92c7792e95 | ||
|
|
c9e0a6c533 | ||
|
|
6331267df6 | ||
|
|
1e81966b89 | ||
|
|
b785b9d219 | ||
|
|
85da7163a7 | ||
|
|
f3f8bee83b | ||
|
|
8802d5033f | ||
|
|
3d39564605 | ||
|
|
7843f51110 | ||
|
|
8bfdc98ef4 | ||
|
|
6673c89791 | ||
|
|
a8a30ae3b9 | ||
|
|
15af410e6f | ||
|
|
9e5cbf330f | ||
|
|
2fa9334090 | ||
|
|
fcdf5d377e | ||
|
|
756a284048 | ||
|
|
32e2b584b9 | ||
|
|
add52b4d57 | ||
|
|
a4d2cb3d12 | ||
|
|
72fbb3f63e | ||
|
|
c62290accb | ||
|
|
8ad40c5d66 | ||
|
|
cd5a721c23 | ||
|
|
643844c01d | ||
|
|
1a3c9ac5ef | ||
|
|
c84f080fc8 | ||
|
|
5fcdbfdd9e | ||
|
|
77dca2ddb2 | ||
|
|
d8fc691625 | ||
|
|
96fa4af939 | ||
|
|
2334793554 | ||
|
|
20e445b4be | ||
|
|
051263117d | ||
|
|
085db93fc8 | ||
|
|
8fe6925414 | ||
|
|
57ad7e62d2 | ||
|
|
6736e91ce0 | ||
|
|
4cbdb7897d | ||
|
|
d57d0ceb0d | ||
|
|
03608103b8 | ||
|
|
9c58d42a3c | ||
|
|
675d171104 | ||
|
|
bf3e605d3b | ||
|
|
a56ad597d4 | ||
|
|
cc5ffafd7c | ||
|
|
b101bb0001 | ||
|
|
405af67f45 | ||
|
|
f772cbee51 | ||
|
|
72d93b8723 | ||
|
|
7f78870295 | ||
|
|
706b9c55c2 | ||
|
|
48ae0d003d | ||
|
|
51c5933b76 | ||
|
|
0204d09a89 | ||
|
|
465c6b9ed6 | ||
|
|
39847c4688 | ||
|
|
7721c6e3da | ||
|
|
648ed00ce2 | ||
|
|
87c9358813 | ||
|
|
64b968b262 | ||
|
|
c0fbf4bf55 | ||
|
|
900e533b4b | ||
|
|
01818582cf | ||
|
|
9a0620f140 | ||
|
|
0216925e05 | ||
|
|
32b24a98ca | ||
|
|
93d7a4938a | ||
|
|
56265b78ec | ||
|
|
6ee76aa6f7 | ||
|
|
32d6aefe00 | ||
|
|
84795863e5 | ||
|
|
9deb3e433c | ||
|
|
92a5b14347 | ||
|
|
891a330955 | ||
|
|
3cee90fe8b | ||
|
|
2bb58bac2e | ||
|
|
9dc1897b35 | ||
|
|
7a7da24df5 | ||
|
|
46f7250f08 | ||
|
|
58bfe23e5a | ||
|
|
ccb914ea83 | ||
|
|
10fe67f4a6 | ||
|
|
a34247ebf4 | ||
|
|
53e96b02c0 | ||
|
|
7c022d6061 | ||
|
|
14e5b46687 | ||
|
|
0243c61ea1 | ||
|
|
d73d4e9d48 | ||
|
|
3d60d9e3c5 | ||
|
|
329b708aaf | ||
|
|
59e0367dd4 | ||
|
|
56c85813ee | ||
|
|
a6bb2604f6 | ||
|
|
b2c71c099f | ||
|
|
102eca7d65 | ||
|
|
55a1d54b8e | ||
|
|
0c313807ff | ||
|
|
d5e685aaf2 | ||
|
|
214fc0419d | ||
|
|
1e24b889dd | ||
|
|
08dd79fafd | ||
|
|
988e2c3fdf | ||
|
|
92dc20850d | ||
|
|
fa9c366076 | ||
|
|
08ab36a5d9 | ||
|
|
c1c04b489c | ||
|
|
0caa321fe5 | ||
|
|
3acaf773b8 | ||
|
|
5080746fa0 | ||
|
|
66c95af093 | ||
|
|
9241816a71 | ||
|
|
07e1f0e802 | ||
|
|
340f8f1f17 | ||
|
|
0316b7ff9a | ||
|
|
7416d2aaf1 | ||
|
|
cb61342e58 | ||
|
|
d99de40b2b | ||
|
|
533675416c | ||
|
|
8baceee06c | ||
|
|
f7bf5c33bc | ||
|
|
f8445030c7 | ||
|
|
1d60131df7 | ||
|
|
539b6410fa | ||
|
|
75f067d5c9 | ||
|
|
518e9b7513 | ||
|
|
0314bb4d38 | ||
|
|
ddfe004204 | ||
|
|
07375e7a39 | ||
|
|
44b69f3d3e | ||
|
|
bca4cf8584 | ||
|
|
4f3f503953 | ||
|
|
1df635a164 | ||
|
|
f3ae5789be | ||
|
|
cf7cd21474 | ||
|
|
0f8fbcfcc1 | ||
|
|
a1f9109392 | ||
|
|
c648be6410 | ||
|
|
6fa0b668ba | ||
|
|
1925b24512 | ||
|
|
1101b4075a | ||
|
|
edb144bd1d | ||
|
|
bcefad1a97 | ||
|
|
0419f8bee9 | ||
|
|
a67fe755cd | ||
|
|
f012f664d2 | ||
|
|
744563a150 | ||
|
|
389074d1e9 | ||
|
|
93778eccbb | ||
|
|
f46d8e8a10 | ||
|
|
f5bfab139c | ||
|
|
df20f918ba | ||
|
|
b8fc1f634e | ||
|
|
ae9dadb5d8 | ||
|
|
d31c062693 | ||
|
|
544928a039 | ||
|
|
14276b3cf8 | ||
|
|
07e7eeedd1 | ||
|
|
125a10bb44 | ||
|
|
9b8e5c8719 | ||
|
|
a803507d67 | ||
|
|
cb5efad026 | ||
|
|
26922a1578 | ||
|
|
90493b6571 | ||
|
|
2dee921cd5 | ||
|
|
433c7c3f99 | ||
|
|
fef461fd13 | ||
|
|
1f56645b69 | ||
|
|
69ca6cd5b2 | ||
|
|
8805e3fb27 | ||
|
|
64d8397ea5 | ||
|
|
4d4496fc4d | ||
|
|
af67342969 | ||
|
|
d9cbd52ea8 | ||
|
|
8b25d44bcf | ||
|
|
3d6733bed8 | ||
|
|
c3f3db518b | ||
|
|
385ec62e53 | ||
|
|
881524831f | ||
|
|
376be8b990 | ||
|
|
96ddbf2a8b | ||
|
|
c2ee420917 | ||
|
|
74a1ba0d1e | ||
|
|
0dc05a39e6 | ||
|
|
72fe406f64 | ||
|
|
90ac174260 | ||
|
|
b555e02220 | ||
|
|
507c94c24c | ||
|
|
2699fa8cf9 | ||
|
|
513002416c | ||
|
|
22530cd77e | ||
|
|
81521b98fd | ||
|
|
73c2feee97 | ||
|
|
d4212d390d | ||
|
|
2b8a55f396 | ||
|
|
f253da09ec | ||
|
|
e232abdab2 | ||
|
|
fae40e0bdf |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,6 +11,7 @@
|
||||
/bin-release
|
||||
/indra/viewer-*
|
||||
/indra/newview/vivox-runtime/
|
||||
/indra/newview/dbghelp.dll
|
||||
/libraries/
|
||||
/lib/
|
||||
*.pyc
|
||||
@@ -22,3 +23,4 @@
|
||||
/LICENSES/
|
||||
/edited-files.txt
|
||||
qtcreator-build/
|
||||
/.pc
|
||||
|
||||
114
LICENSES/FLOSS-exception.txt
Normal file
114
LICENSES/FLOSS-exception.txt
Normal file
@@ -0,0 +1,114 @@
|
||||
Linden Research, Inc. ("Linden Lab") Viewer FLOSS License Exception v0.5
|
||||
|
||||
The Linden Lab Exception for Free/Libre and Open Source Software-only
|
||||
Applications Using Linden Lab Viewer Software (the "FLOSS Exception").
|
||||
|
||||
Exception Intent
|
||||
|
||||
Linden Lab is releasing the source code for certain software that
|
||||
enables users to view or otherwise access the Second Life virtual
|
||||
world environment (the "Viewer Software"), under version 2 of the GNU
|
||||
General Public License (the "GPL"). The creation or distribution of
|
||||
works based on the Program (as defined under the GPL) of the Viewer
|
||||
Software may require the use of certain Free/Libre and Open Source
|
||||
Software ("FLOSS") works that are subject to license agreements not
|
||||
compatible with re-licensing under the GPL. Because we want to allow
|
||||
the Viewer Software to be distributed with these FLOSS works, this
|
||||
FLOSS Exception following exception applies subject to the terms and
|
||||
conditions below.
|
||||
|
||||
Legal Terms and Conditions
|
||||
|
||||
As a special exception to the terms and conditions of version 2.0 of
|
||||
the GPL:
|
||||
|
||||
You are free to distribute a work based on the Program that is formed
|
||||
entirely from the Viewer Software (and any modifications thereof) and
|
||||
one or more works that are independent and separate works not derived
|
||||
from the Viewer Software, and are licensed under one or more of the
|
||||
licenses listed below in section 1 (each, a "FLOSS Work") , as long
|
||||
as:
|
||||
|
||||
A. You obey the GPL in all respects for the Viewer Software and any
|
||||
work based on the Program, except for the FLOSS Works, for which
|
||||
you must comply with B below,
|
||||
|
||||
B. all FLOSS Works,
|
||||
|
||||
i. are distributed subject to one of the FLOSS licenses
|
||||
listed below, and
|
||||
|
||||
ii. the object code or executable form of the FLOSS Works are
|
||||
accompanied by the complete corresponding
|
||||
machine-readable source code for those FLOSS Works on the
|
||||
same medium and under the same FLOSS license as the
|
||||
corresponding object code or executable forms thereof,
|
||||
and
|
||||
|
||||
C. any works that are aggregated with the Viewer Software or a work
|
||||
based on the Program on a volume of a storage or distribution
|
||||
medium in accordance with the GPL, and are not licensed under
|
||||
the FLOSS licenses listed below, are independent and separate
|
||||
works in themselves which are not derivatives of either the
|
||||
Viewer Software, a work based on the Program or a FLOSS Work.
|
||||
|
||||
If the above conditions are not met, then the Viewer Software may only
|
||||
be copied, modified, distributed or used under the terms and
|
||||
conditions of the GPL or another valid licensing option from Linden
|
||||
Lab.
|
||||
|
||||
1. FLOSS License List
|
||||
|
||||
License name Version(s)/Copyright Date
|
||||
Academic Free License 2.0
|
||||
Apache Software License 1.0/1.1/2.0
|
||||
Apple Public Source License 2.0
|
||||
Artistic license From Perl 5.8.0
|
||||
BSD license "July 22 1999"
|
||||
Common Development and
|
||||
Distribution License (CDDL) 1.0
|
||||
Common Public License 1.0
|
||||
GNU Library or "Lesser" General
|
||||
Public License (LGPL) 2.0/2.1
|
||||
Jabber Open Source License 1.0
|
||||
MIT License (As listed in file MIT-License.txt) -
|
||||
Mozilla Public License (MPL) 1.0/1.1
|
||||
Open Software License 2.0
|
||||
OpenSSL license (with
|
||||
original SSLeay license) "2003" ("1998")
|
||||
PHP License 3.0
|
||||
Python license (CNRI Python License) -
|
||||
Python Software Foundation License 2.1.1
|
||||
Sleepycat License "1999"
|
||||
W3C License "2001"
|
||||
X11 License "2001"
|
||||
Zlib/libpng License -
|
||||
Zope Public License 2.0
|
||||
|
||||
Due to the many variants of some of the above licenses, we require
|
||||
that any variant of the above licenses be identical in substance to
|
||||
the form approved by the Open Source Initiative and follow the 2003
|
||||
version of the Free Software Foundation's Free Software Definition
|
||||
(http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of the
|
||||
Open Source Definition by the Open Source Initiative
|
||||
(http://www.opensource.org/docs/definition.php).
|
||||
|
||||
2. Definitions
|
||||
|
||||
Terms used, but not defined, herein shall have the meaning provided in
|
||||
the GPL.
|
||||
|
||||
3. Applicability
|
||||
|
||||
This FLOSS Exception applies to all Viewer Software files that contain
|
||||
a notice placed by Linden Lab saying that the Viewer Software may be
|
||||
distributed under the terms of this FLOSS Exception. If you create or
|
||||
distribute a work which is a work based on the Program for the Viewer
|
||||
Software and any other work licensed under the GPL, then this FLOSS
|
||||
Exception is not available for that work; thus, you must remove the
|
||||
FLOSS Exception notice from that work and comply with the GPL in all
|
||||
respects, including by retaining all GPL notices. You may choose to
|
||||
redistribute a copy of the Viewer Software exclusively under the terms
|
||||
of the GPL by removing the FLOSS Exception notice from that copy of
|
||||
the Viewer Software, provided that the copy has never been modified by
|
||||
you or any third party.
|
||||
339
LICENSES/GPL-license.txt
Normal file
339
LICENSES/GPL-license.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
36
LICENSES/LLQTWEBKIT_LICENSE.txt
Normal file
36
LICENSES/LLQTWEBKIT_LICENSE.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
Source code
|
||||
========
|
||||
The license for the source code in this distribution should be clearly
|
||||
marked on each source file. Unless otherwise specified, the source
|
||||
code in this distribution ("Source Code") is provided by Linden Lab to
|
||||
you under the terms of the GNU General Public License, version 2.0
|
||||
("GPL"), unless you have obtained a separate licensing agreement
|
||||
("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
the GPL can be found in GPL-license.txt in this distribution, or
|
||||
online at http://secondlifegrid.net/technology-programs/license-virtual-world/viewerlicensing/gplv2
|
||||
|
||||
There are special exceptions to the terms and conditions of the GPL as
|
||||
it is applied to this Source Code. View the full text of the exception
|
||||
in the file FLOSS-exception.txt in this software distribution, or
|
||||
online at http://secondlifegrid.net/technology-programs/license-virtual-world/viewerlicensing/flossexception
|
||||
|
||||
By copying, modifying or distributing this software, you acknowledge
|
||||
that you have read and understood your obligations described above,
|
||||
and agree to abide by those obligations.
|
||||
|
||||
ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
COMPLETENESS OR PERFORMANCE.
|
||||
|
||||
Logos and trademarks
|
||||
==============
|
||||
|
||||
"Second Life" and "Linden Lab" are registered trademarks of Linden
|
||||
Research, Inc. Other trademarks include (but are not limited to): the
|
||||
names Linden and Linden Research, as well as the Linden Lab Hexagon
|
||||
Design and the Second Life Hand Design logos.
|
||||
|
||||
Use of logos and trademarks are subject to the Linden Lab trademark
|
||||
policy, available at:
|
||||
|
||||
http://secondlife.com/corporate/trademark/
|
||||
27
README
27
README
@@ -9,15 +9,30 @@
|
||||
Sin-gu-la-ri-ty (noun) - a distinctive feature, a uniqueness; a point at which
|
||||
continuity breaks up; a point in history at which machine becomes smarter than
|
||||
humanity and/or fuses with it indivisively; or simply a cool sounding word with
|
||||
my initials in it :)
|
||||
the initials S.G. in it :)
|
||||
|
||||
Singularity Viewer is a Second Life protocol compatible client application. It
|
||||
can be used to access Second LIfe service as well as a number of other such as
|
||||
those based upon OpenSim plattform. It is directly based upon source code of
|
||||
Ascent Viewer by Balseraph Software Group, which is in turn based upon source
|
||||
code released by Linden Lab, with contributions from various sources.
|
||||
Singularity Viewer is a SecondLife(tm) protocol compatible client application.
|
||||
It can be used to access SecondLife services as well as a number of others such
|
||||
as those based upon the OpenSim platform.
|
||||
|
||||
Singulariy is maintained by a small group of volunteers who can be contacted
|
||||
both, in-world (SingularityViewer group) as well on IRC (#SingularityViewer
|
||||
@ FreeNode). Bug requests and features requests can be submitted through our
|
||||
Issue Tracker (http://code.google.com/p/singularity-viewer/issues/list or from
|
||||
the viewer menu: Help --> Bug Reporting --> Singularity Issue Tracker...)
|
||||
|
||||
|
||||
As this Readme grows out of date, please refer to
|
||||
|
||||
http://www.singularityviewer.org/about
|
||||
|
||||
|
||||
00000000011111111112222222222333333333344444444445555555555666666666677777777778
|
||||
12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
History
|
||||
|
||||
The Singularity viewer was started by Siana Gearz in November 2010 by forking it
|
||||
from the Ascent Viewer, by Balseraph Software Group, which in turn was based upon
|
||||
source code modified from the snowglobe source code released by Linden Lab.
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ Celierra Darling
|
||||
VWR-6975
|
||||
Cron Stardust
|
||||
VWR-10579
|
||||
STORM-1919
|
||||
Cypren Christenson
|
||||
SNOW-129
|
||||
SNOW-140
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<key>OpenCircuit</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>template</string>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>false</boolean>
|
||||
</map>
|
||||
@@ -370,6 +370,14 @@
|
||||
</map>
|
||||
|
||||
<!-- Server to client -->
|
||||
<key>DisplayNameUpdate</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>ParcelVoiceInfo</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
@@ -419,6 +427,22 @@
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>SetDisplayNameReply</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>SimConsoleResponse</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>DirLandReply</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
@@ -515,8 +539,24 @@
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<!-- UDPDeprecated Messages -->
|
||||
|
||||
<key>NavMeshStatusUpdate</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>AgentStateUpdate</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<!-- UDPDeprecated Messages -->
|
||||
<key>ScriptRunningReply</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
@@ -569,26 +609,9 @@
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<!-- Server to client -->
|
||||
<key>DisplayNameUpdate</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>SetDisplayNameReply</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
</map>
|
||||
<key>capBans</key>
|
||||
|
||||
@@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
|
||||
cmake_policy(SET CMP0003 OLD)
|
||||
|
||||
set(ROOT_PROJECT_NAME "Singularity" CACHE STRING
|
||||
"The root project/makefile/solution name. Defaults to SecondLife.")
|
||||
"The root project/makefile/solution name. Defaults to Singularity.")
|
||||
project(${ROOT_PROJECT_NAME})
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
@@ -46,8 +46,9 @@ endif(NOT STANDALONE)
|
||||
add_custom_target(prepare DEPENDS ${prepare_depends})
|
||||
|
||||
add_subdirectory(cmake)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}cwdebug)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}aistatemachine)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llaudio)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llappearance)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llcharacter)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llcommon)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llimage)
|
||||
@@ -62,11 +63,15 @@ add_subdirectory(${LIBS_OPEN_PREFIX}llvfs)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llwindow)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llxml)
|
||||
|
||||
if(STANDALONE)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llqtwebkit)
|
||||
endif(STANDALONE)
|
||||
|
||||
if (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
|
||||
add_subdirectory(${LIBS_CLOSED_PREFIX}llkdu)
|
||||
endif (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
|
||||
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
|
||||
#add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
|
||||
|
||||
if (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
|
||||
add_subdirectory(${LIBS_CLOSED_PREFIX}copy_win_scripts)
|
||||
@@ -77,7 +82,6 @@ if (VIEWER)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llui)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llxuixml)
|
||||
|
||||
# viewer plugins directory
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}plugins)
|
||||
|
||||
39
indra/aistatemachine/CMakeLists.txt
Normal file
39
indra/aistatemachine/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
project(aistatemachine)
|
||||
|
||||
include(00-Common)
|
||||
include(LLCommon)
|
||||
include(LLMessage)
|
||||
include(LLMath)
|
||||
include(LLXML)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
include_directories(
|
||||
${LLCOMMON_INCLUDE_DIRS}
|
||||
${LLMESSAGE_INCLUDE_DIRS}
|
||||
${LLMATH_INCLUDE_DIRS}
|
||||
${LLXML_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(aistatemachine_SOURCE_FILES
|
||||
aistatemachine.cpp
|
||||
aitimer.cpp
|
||||
)
|
||||
|
||||
set(aistatemachine_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
aistatemachine.h
|
||||
aitimer.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${aistatemachine_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
list(APPEND aistatemachine_SOURCE_FILES ${aistatemachine_HEADER_FILES})
|
||||
|
||||
add_library (aistatemachine ${aistatemachine_SOURCE_FILES})
|
||||
add_dependencies(aistatemachine prepare)
|
||||
|
||||
628
indra/aistatemachine/aistatemachine.cpp
Normal file
628
indra/aistatemachine/aistatemachine.cpp
Normal file
@@ -0,0 +1,628 @@
|
||||
/**
|
||||
* @file aistatemachine.cpp
|
||||
* @brief Implementation of AIStateMachine
|
||||
*
|
||||
* Copyright (c) 2010, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 01/03/2010
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "llcontrol.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "aithreadsafe.h"
|
||||
#include "aistatemachine.h"
|
||||
|
||||
// Local variables.
|
||||
namespace {
|
||||
struct QueueElementComp;
|
||||
|
||||
class QueueElement {
|
||||
private:
|
||||
AIStateMachine* mStateMachine;
|
||||
U64 mRuntime;
|
||||
|
||||
public:
|
||||
QueueElement(AIStateMachine* statemachine) : mStateMachine(statemachine), mRuntime(0) { }
|
||||
friend bool operator==(QueueElement const& e1, QueueElement const& e2) { return e1.mStateMachine == e2.mStateMachine; }
|
||||
friend struct QueueElementComp;
|
||||
|
||||
AIStateMachine& statemachine(void) const { return *mStateMachine; }
|
||||
void add(U64 count) { mRuntime += count; }
|
||||
};
|
||||
|
||||
struct QueueElementComp {
|
||||
bool operator()(QueueElement const& e1, QueueElement const& e2) const { return e1.mRuntime < e2.mRuntime; }
|
||||
};
|
||||
|
||||
typedef std::vector<QueueElement> active_statemachines_type;
|
||||
active_statemachines_type active_statemachines;
|
||||
}
|
||||
|
||||
// static
|
||||
U64 AIStateMachine::sMaxCount;
|
||||
AIThreadSafeDC<AIStateMachine::csme_type> AIStateMachine::sContinuedStateMachinesAndMainloopEnabled;
|
||||
|
||||
// static
|
||||
void AIStateMachine::setMaxCount(F32 StateMachineMaxTime)
|
||||
{
|
||||
llassert(is_main_thread());
|
||||
Dout(dc::statemachine, "(Re)calculating AIStateMachine::sMaxCount");
|
||||
sMaxCount = calc_clock_frequency() * StateMachineMaxTime / 1000;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
|
||||
void AIStateMachine::run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent, bool on_abort_signal_parent)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::run(" << (void*)parent << ", " << (parent ? parent->state_str(new_parent_state) : "NA") << ", " << abort_parent << ") [" << (void*)this << "]");
|
||||
// Must be the first time we're being run, or we must be called from a callback function.
|
||||
llassert(!mParent || mState == bs_callback);
|
||||
llassert(!mCallback || mState == bs_callback);
|
||||
// Can only be run when in this state.
|
||||
llassert(mState == bs_initialize || mState == bs_callback);
|
||||
|
||||
// Allow NULL to be passed as parent to signal that we want to reuse the old one.
|
||||
if (parent)
|
||||
{
|
||||
mParent = parent;
|
||||
// In that case remove any old callback!
|
||||
if (mCallback)
|
||||
{
|
||||
delete mCallback;
|
||||
mCallback = NULL;
|
||||
}
|
||||
|
||||
mNewParentState = new_parent_state;
|
||||
mAbortParent = abort_parent;
|
||||
mOnAbortSignalParent = on_abort_signal_parent;
|
||||
}
|
||||
|
||||
// If abort_parent is requested then a parent must be provided.
|
||||
llassert(!abort_parent || mParent);
|
||||
// If a parent is provided, it must be running.
|
||||
llassert(!mParent || mParent->mState == bs_run);
|
||||
|
||||
// Mark that run() has been called, in case we're being called from a callback function.
|
||||
mState = bs_initialize;
|
||||
|
||||
// Set mIdle to false and add statemachine to continued_statemachines.
|
||||
mSetStateLock.lock();
|
||||
locked_cont();
|
||||
}
|
||||
|
||||
void AIStateMachine::run(callback_type::signal_type::slot_type const& slot)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::run(<slot>) [" << (void*)this << "]");
|
||||
// Must be the first time we're being run, or we must be called from a callback function.
|
||||
llassert(!mParent || mState == bs_callback);
|
||||
llassert(!mCallback || mState == bs_callback);
|
||||
// Can only be run when in this state.
|
||||
llassert(mState == bs_initialize || mState == bs_callback);
|
||||
|
||||
// Clean up any old callbacks.
|
||||
mParent = NULL;
|
||||
if (mCallback)
|
||||
{
|
||||
delete mCallback;
|
||||
mCallback = NULL;
|
||||
}
|
||||
|
||||
mCallback = new callback_type(slot);
|
||||
|
||||
// Mark that run() has been called, in case we're being called from a callback function.
|
||||
mState = bs_initialize;
|
||||
|
||||
// Set mIdle to false and add statemachine to continued_statemachines.
|
||||
mSetStateLock.lock();
|
||||
locked_cont();
|
||||
}
|
||||
|
||||
void AIStateMachine::idle(void)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::idle() [" << (void*)this << "]");
|
||||
llassert(is_main_thread());
|
||||
llassert(!mIdle);
|
||||
mIdle = true;
|
||||
mSleep = 0;
|
||||
#ifdef SHOW_ASSERT
|
||||
mCalledThreadUnsafeIdle = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AIStateMachine::idle(state_type current_run_state)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::idle(" << state_str(current_run_state) << ") [" << (void*)this << "]");
|
||||
llassert(is_main_thread());
|
||||
llassert(!mIdle);
|
||||
mSetStateLock.lock();
|
||||
// Only go idle if the run state is (still) what we expect it to be.
|
||||
// Otherwise assume that another thread called set_state() and continue running.
|
||||
if (current_run_state == mRunState)
|
||||
{
|
||||
mIdle = true;
|
||||
mSleep = 0;
|
||||
}
|
||||
mSetStateLock.unlock();
|
||||
}
|
||||
|
||||
// About thread safeness:
|
||||
//
|
||||
// The main thread initializes a statemachine and calls run, so a statemachine
|
||||
// runs in the main thread. However, it is allowed that a state calls idle()
|
||||
// and then allows one or more other threads to call cont() upon some
|
||||
// event (only once, of course, as idle() has to be called before cont()
|
||||
// can be called again-- and a non-main thread is not allowed to call idle()).
|
||||
// Instead of cont() one may also call set_state().
|
||||
// Of course, this may give rise to a race condition; if that happens then
|
||||
// the thread that calls cont() (set_state()) first is serviced, and the other
|
||||
// thread(s) are ignored, as if they never called cont().
|
||||
void AIStateMachine::locked_cont(void)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::locked_cont() [" << (void*)this << "]");
|
||||
llassert(mIdle);
|
||||
// Atomic test mActive and change mIdle.
|
||||
mIdleActive.lock();
|
||||
#ifdef SHOW_ASSERT
|
||||
mContThread.reset();
|
||||
#endif
|
||||
mIdle = false;
|
||||
bool not_active = mActive == as_idle;
|
||||
mIdleActive.unlock();
|
||||
// mActive is only changed in AIStateMachine::mainloop, by the main-thread, and
|
||||
// here, possibly by any thread. However, after setting mIdle to false above, it
|
||||
// is impossible for any thread to come here, until after the main-thread called
|
||||
// idle(). So, if this is the main thread then that certainly isn't going to
|
||||
// happen until we left this function, while if this is another thread and the
|
||||
// state machine is already running in the main thread then not_active is false
|
||||
// and we're already at the end of this function.
|
||||
// If not_active is true then main-thread is not running this statemachine.
|
||||
// It might call cont() (or set_state()) but never locked_cont(), and will never
|
||||
// start actually running until we are done here and release the lock on
|
||||
// sContinuedStateMachinesAndMainloopEnabled again. It is therefore safe
|
||||
// to release mSetStateLock here, with as advantage that if we're not the main-
|
||||
// thread and not_active is true, then the main-thread won't block when it has
|
||||
// a timer running that times out and calls set_state().
|
||||
mSetStateLock.unlock();
|
||||
if (not_active)
|
||||
{
|
||||
AIWriteAccess<csme_type> csme_w(sContinuedStateMachinesAndMainloopEnabled);
|
||||
// See above: it is not possible that mActive was changed since not_active
|
||||
// was set to true above.
|
||||
llassert_always(mActive == as_idle);
|
||||
Dout(dc::statemachine, "Adding " << (void*)this << " to continued_statemachines");
|
||||
csme_w->continued_statemachines.push_back(this);
|
||||
if (!csme_w->mainloop_enabled)
|
||||
{
|
||||
Dout(dc::statemachine, "Activating AIStateMachine::mainloop.");
|
||||
csme_w->mainloop_enabled = true;
|
||||
}
|
||||
mActive = as_queued;
|
||||
llassert_always(!mIdle); // It should never happen that the main thread calls idle(), while another thread calls cont() concurrently.
|
||||
}
|
||||
}
|
||||
|
||||
void AIStateMachine::set_state(state_type state)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::set_state(" << state_str(state) << ") [" << (void*)this << "]");
|
||||
|
||||
// Stop race condition of multiple threads calling cont() or set_state() here.
|
||||
mSetStateLock.lock();
|
||||
|
||||
// Do not call set_state() unless running.
|
||||
llassert(mState == bs_run || !is_main_thread());
|
||||
|
||||
// If this function is called from another thread than the main thread, then we have to ignore
|
||||
// it if we're not idle and the state is less than the current state. The main thread must
|
||||
// be able to change the state to anything (also smaller values). Note that that only can work
|
||||
// if the main thread itself at all times cancels thread callbacks that call set_state()
|
||||
// before calling idle() again!
|
||||
//
|
||||
// Thus: main thead calls idle(), and tells one or more threads to do callbacks on events,
|
||||
// which (might) call set_state(). If the main thread calls set_state first (currently only
|
||||
// possible as a result of the use of a timer) it will set mIdle to false (here) then cancel
|
||||
// the call backs from the other threads and only then call idle() again.
|
||||
// Thus if you want other threads get here while mIdle is false to be ignored then the
|
||||
// main thread should use a large value for the new run state.
|
||||
//
|
||||
// If a non-main thread calls set_state first, then the state is changed but the main thread
|
||||
// can still override it if it calls set_state before handling the new state; in the latter
|
||||
// case it would still be as if the call from the non-main thread was ignored.
|
||||
//
|
||||
// Concurrent calls from non-main threads however, always result in the largest state
|
||||
// to prevail.
|
||||
|
||||
// If the state machine is already running, and we are not the main-thread and the new
|
||||
// state is less than the current state, ignore it.
|
||||
// Also, if abort() or finish() was called, then we should just ignore it.
|
||||
if (mState != bs_run ||
|
||||
(!mIdle && state <= mRunState && !AIThreadID::in_main_thread()))
|
||||
{
|
||||
#ifdef SHOW_ASSERT
|
||||
// It's a bit weird if the same thread does two calls on a row where the second call
|
||||
// has a smaller value: warn about that.
|
||||
if (mState == bs_run && mContThread.equals_current_thread())
|
||||
{
|
||||
llwarns << "Ignoring call to set_state(" << state_str(state) <<
|
||||
") by non-main thread before main-thread could react on previous call, "
|
||||
"because new state is smaller than old state (" << state_str(mRunState) << ")." << llendl;
|
||||
}
|
||||
#endif
|
||||
mSetStateLock.unlock();
|
||||
return; // Ignore.
|
||||
}
|
||||
|
||||
// Do not call idle() when set_state is called from another thread; use idle(state_type) instead.
|
||||
llassert(!mCalledThreadUnsafeIdle || is_main_thread());
|
||||
|
||||
// Change mRunState to the requested value.
|
||||
if (mRunState != state)
|
||||
{
|
||||
mRunState = state;
|
||||
Dout(dc::statemachine, "mRunState set to " << state_str(mRunState));
|
||||
}
|
||||
|
||||
// Continue the state machine if appropriate.
|
||||
if (mIdle)
|
||||
locked_cont(); // This unlocks mSetStateLock.
|
||||
else
|
||||
mSetStateLock.unlock();
|
||||
|
||||
// If we get here then mIdle is false, so only mRunState can still be changed but we won't
|
||||
// call locked_cont() anymore. When the main thread finally picks up on the state change,
|
||||
// it will cancel any possible callbacks from other threads and process the largest state
|
||||
// that this function was called with in the meantime.
|
||||
}
|
||||
|
||||
void AIStateMachine::abort(void)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::abort() [" << (void*)this << "]");
|
||||
// It's possible that abort() is called before calling AIStateMachine::multiplex.
|
||||
// In that case the statemachine wasn't initialized yet and we should just kill() it.
|
||||
if (LL_UNLIKELY(mState == bs_initialize))
|
||||
{
|
||||
// It's ok to use the thread-unsafe idle() here, because if the statemachine
|
||||
// wasn't started yet, then other threads won't call set_state() on it.
|
||||
if (!mIdle)
|
||||
idle();
|
||||
// run() calls locked_cont() after which the top of the mainloop adds this
|
||||
// state machine to active_statemachines. Therefore, if the following fails
|
||||
// then either the same statemachine called run() immediately followed by abort(),
|
||||
// which is not allowed; or there were two active statemachines running,
|
||||
// the first created a new statemachine and called run() on it, and then
|
||||
// the other (before reaching the top of the mainloop) called abort() on
|
||||
// that freshly created statemachine. Obviously, this is highly unlikely,
|
||||
// but if that is the case then here we bump the statemachine into
|
||||
// continued_statemachines to prevent kill() to delete this statemachine:
|
||||
// the caller of abort() does not expect that.
|
||||
if (LL_UNLIKELY(mActive == as_idle))
|
||||
{
|
||||
mSetStateLock.lock();
|
||||
locked_cont();
|
||||
idle();
|
||||
}
|
||||
kill();
|
||||
}
|
||||
else
|
||||
{
|
||||
llassert(mState == bs_run);
|
||||
mSetStateLock.lock();
|
||||
mState = bs_abort; // Causes additional calls to set_state to be ignored.
|
||||
mSetStateLock.unlock();
|
||||
abort_impl();
|
||||
mAborted = true;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
void AIStateMachine::finish(void)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::finish() [" << (void*)this << "]");
|
||||
mSetStateLock.lock();
|
||||
llassert(mState == bs_run || mState == bs_abort);
|
||||
// It is possible that mIdle is true when abort or finish was called from
|
||||
// outside multiplex_impl. However, that only may be done by the main thread.
|
||||
llassert(!mIdle || is_main_thread());
|
||||
if (!mIdle)
|
||||
idle(); // After calling this, we don't want other threads to call set_state() anymore.
|
||||
mState = bs_finish; // Causes additional calls to set_state to be ignored.
|
||||
mSetStateLock.unlock();
|
||||
finish_impl();
|
||||
// Did finish_impl call kill()? Then that is only the default. Remember it.
|
||||
bool default_delete = (mState == bs_killed);
|
||||
mState = bs_finish;
|
||||
if (mParent)
|
||||
{
|
||||
// It is possible that the parent is not running when the parent is in fact aborting and called
|
||||
// abort on this object from it's abort_impl function. It that case we don't want to recursively
|
||||
// call abort again (or change it's state).
|
||||
if (mParent->running())
|
||||
{
|
||||
if (mAborted && mAbortParent)
|
||||
{
|
||||
mParent->abort();
|
||||
mParent = NULL;
|
||||
}
|
||||
else if (!mAborted || mOnAbortSignalParent)
|
||||
{
|
||||
mParent->set_state(mNewParentState);
|
||||
}
|
||||
}
|
||||
}
|
||||
// After this (bool)*this evaluates to true and we can call the callback, which then is allowed to call run().
|
||||
mState = bs_callback;
|
||||
if (mCallback)
|
||||
{
|
||||
// This can/may call kill() that sets mState to bs_kill and in which case the whole AIStateMachine
|
||||
// will be deleted from the mainloop, or it may call run() that sets mState is set to bs_initialize
|
||||
// and might change or reuse mCallback or mParent.
|
||||
mCallback->callback(!mAborted);
|
||||
if (mState != bs_initialize)
|
||||
{
|
||||
delete mCallback;
|
||||
mCallback = NULL;
|
||||
mParent = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not restarted by callback. Allow run() to be called later on.
|
||||
mParent = NULL;
|
||||
}
|
||||
// Fix the final state.
|
||||
if (mState == bs_callback)
|
||||
mState = default_delete ? bs_killed : bs_initialize;
|
||||
if (mState == bs_killed && mActive == as_idle)
|
||||
{
|
||||
// Bump the statemachine onto the active statemachine list, or else it won't be deleted.
|
||||
mSetStateLock.lock();
|
||||
locked_cont();
|
||||
idle();
|
||||
}
|
||||
}
|
||||
|
||||
void AIStateMachine::kill(void)
|
||||
{
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::kill() [" << (void*)this << "]");
|
||||
// Should only be called from finish() (or when not running (bs_initialize)).
|
||||
// However, also allow multiple calls to kill() on a row (bs_killed) (which effectively don't do anything).
|
||||
llassert(mIdle && (mState == bs_callback || mState == bs_finish || mState == bs_initialize || mState == bs_killed));
|
||||
base_state_type prev_state = mState;
|
||||
mState = bs_killed;
|
||||
if (prev_state == bs_initialize && mActive == as_idle)
|
||||
{
|
||||
// We're not running (ie being deleted by a parent statemachine), delete it immediately.
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
// Return stringified 'state'.
|
||||
char const* AIStateMachine::state_str(state_type state)
|
||||
{
|
||||
if (state >= min_state && state < max_state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
AI_CASE_RETURN(bs_initialize);
|
||||
AI_CASE_RETURN(bs_run);
|
||||
AI_CASE_RETURN(bs_abort);
|
||||
AI_CASE_RETURN(bs_finish);
|
||||
AI_CASE_RETURN(bs_callback);
|
||||
AI_CASE_RETURN(bs_killed);
|
||||
}
|
||||
}
|
||||
return state_str_impl(state);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Private methods
|
||||
//
|
||||
|
||||
void AIStateMachine::multiplex(U64 current_time)
|
||||
{
|
||||
// Return immediately when this state machine is sleeping.
|
||||
// A negative value of mSleep means we're counting frames,
|
||||
// a positive value means we're waiting till a certain
|
||||
// amount of time has passed.
|
||||
if (mSleep != 0)
|
||||
{
|
||||
if (mSleep < 0)
|
||||
{
|
||||
if (++mSleep)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current_time < (U64)mSleep)
|
||||
return;
|
||||
mSleep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DoutEntering(dc::statemachine, "AIStateMachine::multiplex() [" << (void*)this << "] [with state: " << state_str(mState == bs_run ? mRunState : mState) << "]");
|
||||
llassert(mState == bs_initialize || mState == bs_run);
|
||||
|
||||
// Real state machine starts here.
|
||||
if (mState == bs_initialize)
|
||||
{
|
||||
mAborted = false;
|
||||
mState = bs_run;
|
||||
initialize_impl();
|
||||
if (mAborted || mState != bs_run)
|
||||
return;
|
||||
}
|
||||
multiplex_impl();
|
||||
}
|
||||
|
||||
//static
|
||||
void AIStateMachine::add_continued_statemachines(AIReadAccess<csme_type>& csme_r)
|
||||
{
|
||||
bool nonempty = false;
|
||||
for (continued_statemachines_type::const_iterator iter = csme_r->continued_statemachines.begin(); iter != csme_r->continued_statemachines.end(); ++iter)
|
||||
{
|
||||
nonempty = true;
|
||||
active_statemachines.push_back(QueueElement(*iter));
|
||||
Dout(dc::statemachine, "Adding " << (void*)*iter << " to active_statemachines");
|
||||
(*iter)->mActive = as_active;
|
||||
}
|
||||
if (nonempty)
|
||||
AIWriteAccess<csme_type>(csme_r)->continued_statemachines.clear();
|
||||
}
|
||||
|
||||
// static
|
||||
void AIStateMachine::dowork(void)
|
||||
{
|
||||
llassert(!active_statemachines.empty());
|
||||
// Run one or more state machines.
|
||||
U64 total_clocks = 0;
|
||||
for (active_statemachines_type::iterator iter = active_statemachines.begin(); iter != active_statemachines.end(); ++iter)
|
||||
{
|
||||
AIStateMachine& statemachine(iter->statemachine());
|
||||
if (!statemachine.mIdle)
|
||||
{
|
||||
U64 start = get_clock_count();
|
||||
// This might call idle() and then pass the statemachine to another thread who then may call cont().
|
||||
// Hence, after this isn't not sure what mIdle is, and it can change from true to false at any moment,
|
||||
// if it is true after this function returns.
|
||||
statemachine.multiplex(start);
|
||||
U64 delta = get_clock_count() - start;
|
||||
iter->add(delta);
|
||||
total_clocks += delta;
|
||||
if (total_clocks >= sMaxCount)
|
||||
{
|
||||
#ifndef LL_RELEASE_FOR_DOWNLOAD
|
||||
llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / calc_clock_frequency()) << " ms." << llendl;
|
||||
#endif
|
||||
std::sort(active_statemachines.begin(), active_statemachines.end(), QueueElementComp());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove idle state machines from the loop.
|
||||
active_statemachines_type::iterator iter = active_statemachines.begin();
|
||||
while (iter != active_statemachines.end())
|
||||
{
|
||||
AIStateMachine& statemachine(iter->statemachine());
|
||||
// Atomic test mIdle and change mActive.
|
||||
bool locked = statemachine.mIdleActive.tryLock();
|
||||
// If the lock failed, then another thread is in the middle of calling cont(),
|
||||
// thus mIdle will end up false. So, there is no reason to block here; just
|
||||
// treat mIdle as false already.
|
||||
if (locked && statemachine.mIdle)
|
||||
{
|
||||
// Without the lock, it would be possible that another thread called cont() right here,
|
||||
// changing mIdle to false again but NOT adding the statemachine to continued_statemachines,
|
||||
// thinking it is in active_statemachines (and it is), while immediately below it is
|
||||
// erased from active_statemachines.
|
||||
statemachine.mActive = as_idle;
|
||||
// Now, calling cont() is ok -- as that will cause the statemachine to be added to
|
||||
// continued_statemachines, so it's fine in that case-- even necessary-- to remove it from
|
||||
// active_statemachines regardless, and we can release the lock here.
|
||||
statemachine.mIdleActive.unlock();
|
||||
Dout(dc::statemachine, "Erasing " << (void*)&statemachine << " from active_statemachines");
|
||||
iter = active_statemachines.erase(iter);
|
||||
if (statemachine.mState == bs_killed)
|
||||
{
|
||||
Dout(dc::statemachine, "Deleting " << (void*)&statemachine);
|
||||
delete &statemachine;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (locked)
|
||||
{
|
||||
statemachine.mIdleActive.unlock();
|
||||
}
|
||||
llassert(statemachine.mActive == as_active); // It should not be possible that another thread called cont() and changed this when we are we are not idle.
|
||||
llassert(statemachine.mState == bs_run || statemachine.mState == bs_initialize);
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
if (active_statemachines.empty())
|
||||
{
|
||||
// If this was the last state machine, remove mainloop from the IdleCallbacks.
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled, true);
|
||||
if (csme_r->continued_statemachines.empty() && csme_r->mainloop_enabled)
|
||||
{
|
||||
Dout(dc::statemachine, "Deactivating AIStateMachine::mainloop: no active state machines left.");
|
||||
AIWriteAccess<csme_type>(csme_r)->mainloop_enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void AIStateMachine::flush(void)
|
||||
{
|
||||
DoutEntering(dc::curl, "AIStateMachine::flush(void)");
|
||||
{
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
|
||||
add_continued_statemachines(csme_r);
|
||||
}
|
||||
// Abort all state machines.
|
||||
for (active_statemachines_type::iterator iter = active_statemachines.begin(); iter != active_statemachines.end(); ++iter)
|
||||
{
|
||||
AIStateMachine& statemachine(iter->statemachine());
|
||||
if (statemachine.abortable())
|
||||
{
|
||||
// We can't safely call abort() here for non-running (run() was called, but they weren't initialized yet) statemachines,
|
||||
// because that might call kill() which in some cases is undesirable (ie, when it is owned by a partent that will
|
||||
// also call abort() on it when it is aborted itself).
|
||||
if (statemachine.running())
|
||||
statemachine.abort();
|
||||
else
|
||||
statemachine.idle(); // Stop the statemachine from starting, in the next loop with batch == 0.
|
||||
}
|
||||
}
|
||||
for (int batch = 0;; ++batch)
|
||||
{
|
||||
// Run mainloop until all state machines are idle (batch == 0) or deleted (batch == 1).
|
||||
for(;;)
|
||||
{
|
||||
{
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
|
||||
if (!csme_r->mainloop_enabled)
|
||||
break;
|
||||
}
|
||||
mainloop();
|
||||
}
|
||||
if (batch == 1)
|
||||
break;
|
||||
{
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
|
||||
add_continued_statemachines(csme_r);
|
||||
}
|
||||
}
|
||||
// At this point all statemachines should be idle.
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
|
||||
llinfos << "Current number of continued statemachines: " << csme_r->continued_statemachines.size() << llendl;
|
||||
llinfos << "Current number of active statemachines: " << active_statemachines.size() << llendl;
|
||||
llassert(csme_r->continued_statemachines.empty() && active_statemachines.empty());
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
#define AISTATEMACHINE_H
|
||||
|
||||
#include "aithreadsafe.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "lltimer.h"
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
//!
|
||||
@@ -192,6 +192,15 @@ class AIStateMachine {
|
||||
as_active // State machine is on active_statemachines list.
|
||||
};
|
||||
|
||||
//! Type of continued_statemachines.
|
||||
typedef std::vector<AIStateMachine*> continued_statemachines_type;
|
||||
//! Type of sContinuedStateMachinesAndMainloopEnabled.
|
||||
struct csme_type
|
||||
{
|
||||
continued_statemachines_type continued_statemachines;
|
||||
bool mainloop_enabled;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef U32 state_type; //!< The type of mRunState
|
||||
|
||||
@@ -207,12 +216,17 @@ class AIStateMachine {
|
||||
active_type mActive; //!< Whether statemachine is idle, queued to be added to the active list, or already on the active list.
|
||||
S64 mSleep; //!< Non-zero while the state machine is sleeping.
|
||||
LLMutex mIdleActive; //!< Used for atomic operations on the pair mIdle / mActive.
|
||||
#ifdef SHOW_ASSERT
|
||||
AIThreadID mContThread; //!< Thread that last called locked_cont().
|
||||
bool mCalledThreadUnsafeIdle; //!< Set to true when idle() is called.
|
||||
#endif
|
||||
|
||||
// Callback facilities.
|
||||
// From within an other state machine:
|
||||
AIStateMachine* mParent; //!< The parent object that started this state machine, or NULL if there isn't any.
|
||||
state_type mNewParentState; //!< The state at which the parent should continue upon a successful finish.
|
||||
bool mAbortParent; //!< If true, abort parent on abort(). Otherwise continue as normal.
|
||||
bool mOnAbortSignalParent; //!< If true and mAbortParent is false, change state of parent even on abort.
|
||||
// From outside a state machine:
|
||||
struct callback_type {
|
||||
typedef boost::signals2::signal<void (bool)> signal_type;
|
||||
@@ -225,40 +239,60 @@ class AIStateMachine {
|
||||
};
|
||||
callback_type* mCallback; //!< Pointer to signal/connection, or NULL when not connected.
|
||||
|
||||
static AIThreadSafeSimpleDC<U64> sMaxCount; //!< Number of cpu clocks below which we start a new state machine within the same frame.
|
||||
static U64 sMaxCount; //!< Number of cpu clocks below which we start a new state machine within the same frame.
|
||||
static AIThreadSafeDC<csme_type> sContinuedStateMachinesAndMainloopEnabled; //!< Read/write locked variable pair.
|
||||
|
||||
protected:
|
||||
LLMutex mSetStateLock; //!< For critical areas in set_state() and locked_cont().
|
||||
|
||||
//! State of the derived class. Only valid if mState == bs_run. Call set_state to change.
|
||||
state_type mRunState;
|
||||
volatile state_type mRunState;
|
||||
|
||||
public:
|
||||
//! Create a non-running state machine.
|
||||
AIStateMachine(void) : mState(bs_initialize), mIdle(true), mAborted(true), mActive(as_idle), mSleep(0), mParent(NULL), mCallback(NULL) { updateSettings(); }
|
||||
AIStateMachine(void) : mState(bs_initialize), mIdle(true), mAborted(true), mActive(as_idle), mSleep(0), mParent(NULL), mCallback(NULL)
|
||||
#ifdef SHOW_ASSERT
|
||||
, mContThread(AIThreadID::none), mCalledThreadUnsafeIdle(false)
|
||||
#endif
|
||||
{ }
|
||||
|
||||
protected:
|
||||
//! The user should call 'kill()', not delete a AIStateMachine (derived) directly.
|
||||
virtual ~AIStateMachine() { llassert(mState == bs_killed && mActive == as_idle); }
|
||||
virtual ~AIStateMachine() { llassert((mState == bs_killed && mActive == as_idle) || mState == bs_initialize); }
|
||||
|
||||
public:
|
||||
//! Halt the state machine until cont() is called.
|
||||
//! Halt the state machine until cont() is called (not thread-safe).
|
||||
void idle(void);
|
||||
|
||||
//! Halt the state machine until cont() is called, provided it is still in 'cur_run_state'.
|
||||
void idle(state_type current_run_state);
|
||||
|
||||
//! Temporarily halt the state machine.
|
||||
void yield_frame(unsigned int frames) { mSleep = -(S64)frames; }
|
||||
|
||||
//! Temporarily halt the state machine.
|
||||
void yield_ms(unsigned int ms) { mSleep = LLFastTimer::getCPUClockCount64() + LLFastTimer::countsPerSecond() * ms / 1000; }
|
||||
void yield_ms(unsigned int ms) { mSleep = get_clock_count() + calc_clock_frequency() * ms / 1000; }
|
||||
|
||||
//! Continue running after calling idle.
|
||||
void cont(void);
|
||||
void cont(void)
|
||||
{
|
||||
mSetStateLock.lock();
|
||||
// Ignore calls to cont() if the statemachine isn't idle. See comments in set_state().
|
||||
// Calling cont() twice or after calling set_state(), without first calling idle(), is an error.
|
||||
if (mState != bs_run || !mIdle) { llassert(mState != bs_run || !mContThread.equals_current_thread()); mSetStateLock.unlock(); return; }
|
||||
locked_cont();
|
||||
}
|
||||
private:
|
||||
void locked_cont(void);
|
||||
|
||||
public:
|
||||
//---------------------------------------
|
||||
// Changing the state.
|
||||
|
||||
//! Change state to <code>bs_run</code>. May only be called after creation or after returning from finish().
|
||||
// If <code>parent</code> is non-NULL, change the parent state machine's state to <code>new_parent_state</code>
|
||||
// upon finish, or in the case of an abort and when <code>abort_parent</code> is true, call parent->abort() instead.
|
||||
void run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent = true);
|
||||
void run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent = true, bool on_abort_signal_parent = true);
|
||||
|
||||
//! Change state to 'bs_run'. May only be called after creation or after returning from finish().
|
||||
// Does not cause a callback.
|
||||
@@ -315,7 +349,7 @@ class AIStateMachine {
|
||||
// Other.
|
||||
|
||||
//! Called whenever the StateMachineMaxTime setting is changed.
|
||||
static void updateSettings(void);
|
||||
static void setMaxCount(F32 StateMachineMaxTime);
|
||||
|
||||
//---------------------------------------
|
||||
// Accessors.
|
||||
@@ -326,11 +360,14 @@ class AIStateMachine {
|
||||
//! Return true if the derived class is running (also when we are idle).
|
||||
bool running(void) const { return mState == bs_run; }
|
||||
|
||||
//! Return true if it's safe to call abort.
|
||||
bool abortable(void) const { return mState == bs_run || mState == bs_initialize; }
|
||||
|
||||
//! Return true if the derived class is running but idle.
|
||||
bool waiting(void) const { return mState == bs_run && mIdle; }
|
||||
|
||||
// Use some safebool idiom (http://www.artima.com/cppsource/safebool.html) rather than operator bool.
|
||||
typedef state_type AIStateMachine::* const bool_type;
|
||||
typedef volatile state_type AIStateMachine::* const bool_type;
|
||||
//! Return true if state machine successfully finished.
|
||||
operator bool_type() const { return ((mState == bs_initialize || mState == bs_callback) && !mAborted) ? &AIStateMachine::mRunState : 0; }
|
||||
|
||||
@@ -338,9 +375,27 @@ class AIStateMachine {
|
||||
char const* state_str(state_type state);
|
||||
|
||||
private:
|
||||
static void mainloop(void*);
|
||||
static void add_continued_statemachines(AIReadAccess<csme_type>& csme_r);
|
||||
static void dowork(void);
|
||||
void multiplex(U64 current_time);
|
||||
|
||||
public:
|
||||
//! Call this once per frame to give the statemachines CPU cycles.
|
||||
static void mainloop(void)
|
||||
{
|
||||
{
|
||||
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled, true);
|
||||
if (!csme_r->mainloop_enabled)
|
||||
return;
|
||||
if (!csme_r->continued_statemachines.empty())
|
||||
add_continued_statemachines(csme_r);
|
||||
}
|
||||
dowork();
|
||||
}
|
||||
|
||||
//! Abort all running state machines and then run mainloop until all state machines are idle (called when application is exiting).
|
||||
static void flush(void);
|
||||
|
||||
protected:
|
||||
//---------------------------------------
|
||||
// Derived class implementations.
|
||||
@@ -70,7 +70,6 @@ class AITimer : public AIStateMachine {
|
||||
* @brief Set the interval after which the timer should expire.
|
||||
*
|
||||
* @param interval Amount of time in seconds before the timer will expire.
|
||||
* @param True if the timer should be deleted after it expires; false means it will keep firing at regular intervals.
|
||||
*
|
||||
* Call abort() at any time to stop the timer (and delete the AITimer object).
|
||||
*/
|
||||
@@ -41,7 +41,9 @@ if (WINDOWS)
|
||||
"${CMAKE_C_FLAGS_RELEASE} ${LL_C_FLAGS} /O2 /Zi /MD /MP /arch:SSE2 /fp:fast"
|
||||
CACHE STRING "C compiler release options" FORCE)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LARGEADDRESSAWARE")
|
||||
if(NOT CMAKE_EXE_LINKER_FLAGS_RELEASE MATCHES LARGEADDRESSAWARE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LARGEADDRESSAWARE")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "")
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "")
|
||||
@@ -68,8 +70,7 @@ if (WINDOWS)
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C++ compiler release options" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C compiler release options" FORCE)
|
||||
"${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "C compiler release options" FORCE)
|
||||
add_definitions(
|
||||
/Zc:wchar_t-
|
||||
)
|
||||
@@ -130,7 +131,6 @@ if (LINUX)
|
||||
add_definitions(-DLL_IGNORE_SIGCHLD)
|
||||
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
|
||||
find_program(GXX g++)
|
||||
mark_as_advanced(GXX)
|
||||
|
||||
@@ -183,9 +183,6 @@ if (LINUX)
|
||||
|
||||
# End of hacks.
|
||||
|
||||
#GCC Specific
|
||||
add_definitions(-DCC_GCC)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
|
||||
if (NOT STANDALONE)
|
||||
@@ -194,10 +191,10 @@ if (LINUX)
|
||||
endif (NOT STANDALONE)
|
||||
if (${ARCH} STREQUAL "x86_64")
|
||||
add_definitions(-DLINUX64=1 -pipe)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffast-math -funroll-loops")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -ffast-math -funroll-loops")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math")
|
||||
else (${ARCH} STREQUAL "x86_64")
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -march=pentium4")
|
||||
@@ -217,7 +214,6 @@ if (LINUX)
|
||||
mark_as_advanced(CLANGXX)
|
||||
|
||||
add_definitions(
|
||||
-DCC_CLANG
|
||||
-D_FORTIFY_SOURCE=2
|
||||
)
|
||||
|
||||
@@ -237,12 +233,10 @@ if (LINUX)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "icc*" AND ${CMAKE_CXX_COMPILER} MATCHES "icpc*")
|
||||
|
||||
find_program(ICC icc)
|
||||
mark_as_advanced(ICC)
|
||||
|
||||
add_definitions(
|
||||
-DCC_ICC
|
||||
-D_FORTIFY_SOURCE=2
|
||||
)
|
||||
|
||||
@@ -276,14 +270,23 @@ if (DARWIN)
|
||||
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
|
||||
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
|
||||
# NOTE: it's critical that the optimization flag is put in front.
|
||||
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
|
||||
# NOTE: it's critical that the optimization flag is put in front.
|
||||
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
|
||||
# NOTE: it's critical that the optimization flag is put in front.
|
||||
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3")
|
||||
endif()
|
||||
endif (DARWIN)
|
||||
|
||||
|
||||
@@ -325,7 +328,7 @@ else (STANDALONE)
|
||||
glib-2.0
|
||||
gstreamer-0.10
|
||||
gtk-2.0
|
||||
llfreetype2
|
||||
freetype2
|
||||
pango-1.0
|
||||
)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(AISTATEMACHINE_INCLUDE_DIRS statemachine)
|
||||
set(AISTATEMACHINE_LIBRARIES statemachine)
|
||||
set(AISTATEMACHINE_INCLUDE_DIRS ${LIBS_OPEN_DIR}/aistatemachine)
|
||||
set(AISTATEMACHINE_LIBRARIES aistatemachine)
|
||||
|
||||
@@ -33,8 +33,8 @@ else (STANDALONE)
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib
|
||||
)
|
||||
set(APRUTIL_LIBRARIES
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.dylib
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.dylib
|
||||
)
|
||||
set(APRICONV_LIBRARIES iconv)
|
||||
else (WINDOWS)
|
||||
|
||||
@@ -40,3 +40,11 @@ link_directories(
|
||||
${VORBISFILE_LIBRARY_DIRS}
|
||||
${OGG_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(LLAUDIO_VORBIS_LIBRARIES
|
||||
${VORBISENC_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES}
|
||||
${VORBIS_LIBRARIES}
|
||||
${OGG_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
@@ -7,10 +7,8 @@ set(Boost_FIND_REQUIRED ON)
|
||||
if (STANDALONE)
|
||||
include(FindBoost)
|
||||
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
find_package(Boost 1.40.0 COMPONENTS date_time filesystem program_options regex system thread wave)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(boost)
|
||||
set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
@@ -18,36 +16,36 @@ else (STANDALONE)
|
||||
if (WINDOWS)
|
||||
set(BOOST_VERSION 1_45)
|
||||
|
||||
# SNOW-788
|
||||
# 00-Common.cmake alreay sets MSVC_SUFFIX to be correct for the VS we are using eg VC71, VC80, VC90 etc
|
||||
# The precompiled boost libs for VC71 use a different suffix to VS80 and VS90
|
||||
# This code should ensure the cmake rules are valid for any VS being used in future as long as the approprate
|
||||
# boost libs are avaiable - RC.
|
||||
|
||||
if (MSVC71)
|
||||
set(BOOST_OPTIM_SUFFIX mt-s)
|
||||
set(BOOST_DEBUG_SUFFIX mt-sgd)
|
||||
else (MSVC71)
|
||||
set(BOOST_OPTIM_SUFFIX mt)
|
||||
set(BOOST_DEBUG_SUFFIX mt-gd)
|
||||
endif (MSVC71)
|
||||
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY
|
||||
# SNOW-788
|
||||
# 00-Common.cmake alreay sets MSVC_SUFFIX to be correct for the VS we are using eg VC71, VC80, VC90 etc
|
||||
# The precompiled boost libs for VC71 use a different suffix to VS80 and VS90
|
||||
# This code should ensure the cmake rules are valid for any VS being used in future as long as the approprate
|
||||
# boost libs are avaiable - RC.
|
||||
|
||||
if (MSVC71)
|
||||
set(BOOST_OPTIM_SUFFIX mt-s)
|
||||
set(BOOST_DEBUG_SUFFIX mt-sgd)
|
||||
else (MSVC71)
|
||||
set(BOOST_OPTIM_SUFFIX mt)
|
||||
set(BOOST_DEBUG_SUFFIX mt-gd)
|
||||
endif (MSVC71)
|
||||
|
||||
set(Boost_PROGRAM_OPTIONS_LIBRARY
|
||||
optimized libboost_program_options-vc${MSVC_SUFFIX}-${BOOST_OPTIM_SUFFIX}-${BOOST_VERSION}
|
||||
debug libboost_program_options-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION})
|
||||
set(BOOST_REGEX_LIBRARY
|
||||
set(Boost_REGEX_LIBRARY
|
||||
optimized libboost_regex-vc${MSVC_SUFFIX}-${BOOST_OPTIM_SUFFIX}-${BOOST_VERSION}
|
||||
debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION})
|
||||
|
||||
|
||||
elseif (DARWIN)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
set(Boost_FILESYSTEM_LIBRARY boost_filesystem)
|
||||
set(Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options)
|
||||
set(Boost_REGEX_LIBRARY boost_regex)
|
||||
set(Boost_SYSTEM_LIBRARY boost_system)
|
||||
elseif (LINUX)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
set(Boost_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(Boost_REGEX_LIBRARY boost_regex-mt)
|
||||
set(Boost_SYSTEM_LIBRARY boost_system-mt)
|
||||
endif (WINDOWS)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -41,6 +41,7 @@ set(cmake_SOURCE_FILES
|
||||
Hunspell.cmake
|
||||
JPEG.cmake
|
||||
LLAddBuildTest.cmake
|
||||
LLAppearance.cmake
|
||||
LLAudio.cmake
|
||||
LLCharacter.cmake
|
||||
LLCommon.cmake
|
||||
@@ -54,13 +55,14 @@ set(cmake_SOURCE_FILES
|
||||
LLMessage.cmake
|
||||
LLPlugin.cmake
|
||||
LLPrimitive.cmake
|
||||
LLQtWebkit.cmake
|
||||
LLRender.cmake
|
||||
LLScene.cmake
|
||||
LLUI.cmake
|
||||
LLVFS.cmake
|
||||
LLWindow.cmake
|
||||
LLXML.cmake
|
||||
LScript.cmake
|
||||
# LScript.cmake
|
||||
Linking.cmake
|
||||
NDOF.cmake
|
||||
OPENAL.cmake
|
||||
@@ -70,6 +72,7 @@ set(cmake_SOURCE_FILES
|
||||
PNG.cmake
|
||||
Python.cmake
|
||||
Prebuilt.cmake
|
||||
Qt4.cmake
|
||||
RunBuildTest.cmake
|
||||
TemplateCheck.cmake
|
||||
Tut.cmake
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
set(CURL_FIND_QUIETLY ON)
|
||||
set(CURL_FIND_QUIETLY OFF)
|
||||
set(CURL_FIND_REQUIRED ON)
|
||||
|
||||
if (STANDALONE)
|
||||
@@ -14,6 +14,9 @@ else (STANDALONE)
|
||||
optimized libcurl)
|
||||
else (WINDOWS)
|
||||
set(CURL_LIBRARIES curl)
|
||||
if(LINUX AND WORD_SIZE EQUAL 64)
|
||||
list(APPEND CURL_LIBRARIES idn)
|
||||
endif(LINUX AND WORD_SIZE EQUAL 64)
|
||||
endif (WINDOWS)
|
||||
set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
set(CWDEBUG_LIBRARIES cwdebug)
|
||||
include_directories (${CMAKE_SOURCE_DIR}/cwdebug)
|
||||
|
||||
set(cwdebug_SOURCE_FILES
|
||||
${CMAKE_SOURCE_DIR}/cwdebug/debug.cc
|
||||
)
|
||||
|
||||
set(cwdebug_HEADER_FILES
|
||||
${CMAKE_SOURCE_DIR}/cwdebug/cwdebug.h
|
||||
${CMAKE_SOURCE_DIR}/cwdebug/sys.h
|
||||
${CMAKE_SOURCE_DIR}/cwdebug/debug.h
|
||||
${CMAKE_SOURCE_DIR}/cwdebug/debug_ostream_operators.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${cwdebug_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
list(APPEND cwdebug_SOURCE_FILES ${cwdebug_HEADER_FILES})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ if(INSTALL_PROPRIETARY)
|
||||
endif(INSTALL_PROPRIETARY)
|
||||
|
||||
find_library(FMODEX_LIBRARY
|
||||
NAMES fmodex fmodex_vc fmodexL_vc
|
||||
NAMES fmodex fmodexL fmodex_vc fmodexL_vc
|
||||
PATHS
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}
|
||||
@@ -18,7 +18,7 @@ if (NOT FMODEX_LIBRARY)
|
||||
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
|
||||
if (FMODEX_SDK_DIR)
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex fmodex_vc fmodexL_vc
|
||||
fmodex_vc fmodexL_vc fmodex fmodexL fmodex64 fmodexL64
|
||||
PATHS
|
||||
${FMODEX_SDK_DIR}/api/lib
|
||||
${FMODEX_SDK_DIR}/api
|
||||
@@ -26,26 +26,25 @@ if (NOT FMODEX_LIBRARY)
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
|
||||
endif(FMODEX_SDK_DIR)
|
||||
if(WINDOWS AND NOT FMODEX_LIBRARY)
|
||||
set(FMODEX_PROG_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows")
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex_vc fmodexL_vc
|
||||
set(FMODEX_PROG_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows")
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex_vc fmodexL_vc
|
||||
PATHS
|
||||
${FMODEX_PROG_DIR}/api/lib
|
||||
${FMODEX_PROG_DIR}/api
|
||||
${FMODEX_PROG_DIR}
|
||||
${FMODEX_PROG_DIR}/api
|
||||
${FMODEX_PROG_DIR}
|
||||
)
|
||||
if(FMODEX_LIBRARY)
|
||||
message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}")
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR})
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE)
|
||||
endif(FMODEX_LIBRARY)
|
||||
if(FMODEX_LIBRARY)
|
||||
message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}")
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR})
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE)
|
||||
endif(FMODEX_LIBRARY)
|
||||
endif(WINDOWS AND NOT FMODEX_LIBRARY)
|
||||
endif (NOT FMODEX_LIBRARY)
|
||||
|
||||
find_path(FMODEX_INCLUDE_DIR fmod.h
|
||||
find_path(FMODEX_INCLUDE_DIR fmod.hpp
|
||||
${LIBS_PREBUILT_DIR}/include/fmodex
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex
|
||||
${FMODEX_SDK_DIR}/api/inc
|
||||
@@ -53,6 +52,11 @@ find_path(FMODEX_INCLUDE_DIR fmod.h
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
if(DARWIN)
|
||||
set(FMODEX_ORIG_LIBRARY "${FMODEX_LIBRARY}")
|
||||
set(FMODEX_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/libfmodex.dylib")
|
||||
endif(DARWIN)
|
||||
|
||||
if (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
|
||||
set(FMODEX ON CACHE BOOL "Use closed source FMOD Ex sound library.")
|
||||
else (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
|
||||
|
||||
@@ -5,7 +5,7 @@ FIND_PATH(HUNSPELL_INCLUDE_DIR hunspell.hxx
|
||||
/usr/include
|
||||
)
|
||||
|
||||
SET(HUNSPELL_NAMES ${HUNSPELL_NAMES} hunspell hunspell-1.2)
|
||||
SET(HUNSPELL_NAMES ${HUNSPELL_NAMES} hunspell hunspell-1.2 hunspell-1.3)
|
||||
FIND_LIBRARY(HUNSPELL_LIBRARY
|
||||
NAMES ${HUNSPELL_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
# - Find JSONCpp
|
||||
# Find the JSONCpp includes and library
|
||||
# This module defines
|
||||
# JSONCPP_INCLUDE_DIR, where to find json.h, etc.
|
||||
# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
|
||||
# JSONCPP_FOUND, If false, do not try to use jsoncpp.
|
||||
# also defined, but not for general use are
|
||||
# JSONCPP_LIBRARY, where to find the jsoncpp library.
|
||||
# JSONCPP_FOUND, System has libjsoncpp.
|
||||
# JSONCPP_INCLUDE_DIRS - The libjsoncpp include directories.
|
||||
# JSONCPP_LIBRARIES - The libraries needed to use libjsoncpp.
|
||||
# JSONCPP_DEFINITIONS - Compiler switches required for using libjsoncpp.
|
||||
|
||||
FIND_PATH(JSONCPP_INCLUDE_DIR json/json.h
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
PKG_CHECK_MODULES(PC_JSONCPP jsoncpp)
|
||||
SET(JSONCPP_DEFINITIONS ${PC_JSONCPP_CFLAGS_OTHER})
|
||||
|
||||
FIND_PATH(JSONCPP_INCLUDE_DIR json/reader.h
|
||||
HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES jsoncpp)
|
||||
|
||||
# Get the GCC compiler version
|
||||
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
|
||||
@@ -22,39 +24,16 @@ EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
|
||||
)
|
||||
|
||||
# Try to find a library that was compiled with the same compiler version as we currently use.
|
||||
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so)
|
||||
IF (STANDALONE)
|
||||
# On standalone, assume that the system installed library was compiled with the used compiler.
|
||||
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson.so)
|
||||
ENDIF (STANDALONE)
|
||||
FIND_LIBRARY(JSONCPP_LIBRARY
|
||||
NAMES ${JSONCPP_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so
|
||||
HINTS ${PC_JSONCPP_LIBDIR} ${PC_JSONCPP_LIBRARY_DIRS}
|
||||
PATHS /usr/lib /usr/local/lib)
|
||||
|
||||
IF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
|
||||
SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
|
||||
SET(JSONCPP_FOUND "YES")
|
||||
ELSE (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
|
||||
SET(JSONCPP_FOUND "NO")
|
||||
ENDIF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
|
||||
SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
|
||||
SET(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JSONCPP DEFAULT_MSG
|
||||
JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
|
||||
|
||||
IF (JSONCPP_FOUND)
|
||||
IF (NOT JSONCPP_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found JSONCpp: ${JSONCPP_LIBRARIES}")
|
||||
ENDIF (NOT JSONCPP_FIND_QUIETLY)
|
||||
ELSE (JSONCPP_FOUND)
|
||||
IF (JSONCPP_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find JSONCpp library")
|
||||
ENDIF (JSONCPP_FIND_REQUIRED)
|
||||
ENDIF (JSONCPP_FOUND)
|
||||
|
||||
# Deprecated declarations.
|
||||
SET (NATIVE_JSONCPP_INCLUDE_PATH ${JSONCPP_INCLUDE_DIR} )
|
||||
GET_FILENAME_COMPONENT (NATIVE_JSONCPP_LIB_PATH ${JSONCPP_LIBRARY} PATH)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
JSONCPP_LIBRARY
|
||||
JSONCPP_INCLUDE_DIR
|
||||
)
|
||||
MARK_AS_ADVANCED(JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if(WORD_SIZE EQUAL 64)
|
||||
set(DISABLE_TCMALLOC TRUE)
|
||||
endif(WORD_SIZE EQUAL 64)
|
||||
|
||||
if (STANDALONE)
|
||||
include(FindGooglePerfTools)
|
||||
else (STANDALONE)
|
||||
if (LINUX OR WINDOWS)
|
||||
if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
use_prebuilt_binary(gperftools)
|
||||
endif (LINUX OR WINDOWS)
|
||||
if (WINDOWS)
|
||||
endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
if (WINDOWS AND NOT DISABLE_TCMALLOC)
|
||||
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
|
||||
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")
|
||||
endif (WINDOWS)
|
||||
endif (WINDOWS AND NOT DISABLE_TCMALLOC)
|
||||
if (LINUX)
|
||||
if(USE_GOOGLE_PERFTOOLS)
|
||||
set(TCMALLOC_LIBRARIES tcmalloc)
|
||||
|
||||
@@ -6,7 +6,7 @@ if (STANDALONE)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(hunspell)
|
||||
|
||||
set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/hunspell)
|
||||
set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/hunspell)
|
||||
|
||||
if (LINUX OR DARWIN)
|
||||
set(HUNSPELL_LIBRARY hunspell-1.3)
|
||||
|
||||
@@ -13,8 +13,8 @@ else (STANDALONE)
|
||||
set(JPEG_LIBRARIES jpeg)
|
||||
elseif (DARWIN)
|
||||
set(JPEG_LIBRARIES
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/liblljpeg.a
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/liblljpeg.a
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libjpeg.a
|
||||
)
|
||||
elseif (WINDOWS)
|
||||
set(JPEG_LIBRARIES jpeglib)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
include(Prebuilt)
|
||||
|
||||
set(JSONCPP_FIND_QUIETLY ON)
|
||||
set(JSONCPP_FIND_QUIETLY OFF)
|
||||
set(JSONCPP_FIND_REQUIRED ON)
|
||||
|
||||
if (STANDALONE)
|
||||
@@ -14,7 +14,7 @@ else (STANDALONE)
|
||||
debug json_vc${MSVC_SUFFIX}d
|
||||
optimized json_vc${MSVC_SUFFIX})
|
||||
elseif (DARWIN)
|
||||
set(JSONCPP_LIBRARIES json_mac-universal-gcc_libmt)
|
||||
set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt)
|
||||
elseif (LINUX)
|
||||
set(JSONCPP_LIBRARIES jsoncpp)
|
||||
endif (WINDOWS)
|
||||
|
||||
11
indra/cmake/LLAppearance.cmake
Normal file
11
indra/cmake/LLAppearance.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Variables)
|
||||
|
||||
set(LLAPPEARANCE_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llappearance
|
||||
)
|
||||
|
||||
set(LLAPPEARANCE_LIBRARIES llappearance)
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@ include(CARes)
|
||||
include(CURL)
|
||||
include(OpenSSL)
|
||||
include(XmlRpcEpi)
|
||||
include(AIStateMachine)
|
||||
|
||||
set(LLMESSAGE_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llmessage
|
||||
${CARES_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIRS}
|
||||
${AISTATEMACHINE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(LLMESSAGE_LIBRARIES llmessage)
|
||||
set(LLMESSAGE_LIBRARIES llmessage aistatemachine)
|
||||
|
||||
11
indra/cmake/LLQtWebkit.cmake
Normal file
11
indra/cmake/LLQtWebkit.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
if (STANDALONE)
|
||||
set(LLQTWEBKIT_INCLUDE_DIR
|
||||
${LIBS_OPEN_DIR}/llqtwebkit
|
||||
)
|
||||
|
||||
set(LLQTWEBKIT_LIBRARY
|
||||
llqtwebkit
|
||||
)
|
||||
endif (STANDALONE)
|
||||
@@ -8,5 +8,5 @@ set(LLVFS_INCLUDE_DIRS
|
||||
|
||||
set(LLVFS_LIBRARIES
|
||||
llvfs
|
||||
${BOOST_REGEX_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
)
|
||||
|
||||
@@ -18,7 +18,11 @@ else (STANDALONE)
|
||||
use_prebuilt_binary(SDL)
|
||||
set (SDL_FOUND TRUE)
|
||||
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR})
|
||||
set (SDL_LIBRARY SDL directfb fusion direct)
|
||||
if(WORD_SIZE EQUAL 64)
|
||||
set (SDL_LIBRARY SDL)
|
||||
else(WORD_SIZE EQUAL 64)
|
||||
set (SDL_LIBRARY SDL directfb fusion direct)
|
||||
endif(WORD_SIZE EQUAL 64)
|
||||
endif (LINUX)
|
||||
endif (STANDALONE)
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(LLXUIXML_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llxuixml
|
||||
)
|
||||
|
||||
set(LLXUIXML_LIBRARIES llxuixml)
|
||||
@@ -10,9 +10,9 @@ if (NOT STANDALONE)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS})
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS})
|
||||
elseif (DARWIN)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release)
|
||||
set(ARCH_PREBUILT_DIRS ${ARCH_PREBUILT_DIRS_RELEASE})
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS_RELEASE})
|
||||
set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug)
|
||||
endif (WINDOWS)
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ else (STANDALONE)
|
||||
set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
if (LINUX)
|
||||
if (LINUX OR DARWIN)
|
||||
set(CRYPTO_LIBRARIES crypto)
|
||||
elseif (DARWIN)
|
||||
set(CRYPTO_LIBRARIES llcrypto)
|
||||
endif (LINUX)
|
||||
endif (LINUX OR DARWIN)
|
||||
|
||||
@@ -15,5 +15,5 @@ else (STANDALONE)
|
||||
else(LINUX)
|
||||
set(PNG_LIBRARIES png15)
|
||||
endif()
|
||||
set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/libpng15)
|
||||
set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/)
|
||||
endif (STANDALONE)
|
||||
|
||||
12
indra/cmake/Qt4.cmake
Normal file
12
indra/cmake/Qt4.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
set(Qt4_FIND_REQUIRED ON)
|
||||
|
||||
include(FindQt4)
|
||||
|
||||
find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtNetwork QtOpenGL QtWebKit REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
endif (STANDALONE)
|
||||
4
indra/cmake/StateMachine.cmake
Normal file
4
indra/cmake/StateMachine.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(STATEMACHINE_INCLUDE_DIRS statemachine)
|
||||
set(STATEMACHINE_LIBRARIES statemachine)
|
||||
@@ -30,6 +30,7 @@ set(LIBS_SERVER_DIR ${CMAKE_SOURCE_DIR}/${LIBS_SERVER_PREFIX})
|
||||
set(SCRIPTS_DIR ${CMAKE_SOURCE_DIR}/${SCRIPTS_PREFIX})
|
||||
set(SERVER_DIR ${CMAKE_SOURCE_DIR}/${SERVER_PREFIX})
|
||||
set(VIEWER_DIR ${CMAKE_SOURCE_DIR}/${VIEWER_PREFIX})
|
||||
set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)")
|
||||
set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable for build timing runs to reduce variation)")
|
||||
set(VISTA_ICON OFF CACHE BOOL "Allow vista icon with pre 2008 Visual Studio IDEs. (Assumes replacement old rcdll.dll with new rcdll.dll from win sdk 7.0 or later)")
|
||||
|
||||
@@ -76,37 +77,36 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(DARWIN 1)
|
||||
|
||||
#SDK Compiler and Deployment targets for XCode
|
||||
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
|
||||
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
if(${CMAKE_GENERATOR} MATCHES Xcode)
|
||||
#SDK Compiler and Deployment targets for XCode
|
||||
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
|
||||
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
|
||||
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
|
||||
endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
else()
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
|
||||
endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
endif(${CMAKE_GENERATOR} MATCHES Xcode)
|
||||
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
|
||||
## We currently support only 32-bit i386 builds, so use these:
|
||||
set(CMAKE_OSX_ARCHITECTURES i386)
|
||||
set(ARCH i386)
|
||||
set(WORD_SIZE 32)
|
||||
|
||||
# NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
|
||||
# -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
|
||||
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64
|
||||
if (NOT CMAKE_OSX_ARCHITECTURES)
|
||||
set(CMAKE_OSX_ARCHITECTURES i386)
|
||||
endif (NOT CMAKE_OSX_ARCHITECTURES)
|
||||
|
||||
if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
|
||||
set(ARCH universal)
|
||||
else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
|
||||
set(ARCH ppc)
|
||||
else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
|
||||
set(ARCH i386)
|
||||
endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
|
||||
endif (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
|
||||
## But if you want to compile for mixed 32/64 bit, try these:
|
||||
# set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
|
||||
# set(ARCH universal)
|
||||
# set(WORD_SIZE 64)
|
||||
|
||||
## Finally, set up the build output directories
|
||||
set(LL_ARCH ${ARCH}_darwin)
|
||||
set(LL_ARCH_DIR universal-darwin)
|
||||
set(WORD_SIZE 32)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
|
||||
|
||||
@@ -19,8 +19,3 @@ else (NOT STANDALONE)
|
||||
endif(LINUX AND ${ARCH} STREQUAL "x86_64")
|
||||
set(STANDALONE ON)
|
||||
endif(NOT STANDALONE)
|
||||
|
||||
if (WINDOWS)
|
||||
use_prebuilt_binary(dbghelp)
|
||||
endif (WINDOWS)
|
||||
|
||||
|
||||
@@ -1,31 +1,10 @@
|
||||
# -*- cmake -*-
|
||||
include(Linking)
|
||||
include(Prebuilt)
|
||||
include(LLQtWebkit)
|
||||
include(Qt4)
|
||||
|
||||
if (STANDALONE)
|
||||
# The minimal version, 4.4.3, is rather arbitrary: it's the version in Debian/Lenny.
|
||||
find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtNetwork QtOpenGL QtWebKit REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
set(QTDIR $ENV{QTDIR})
|
||||
if (QTDIR AND NOT "${QT_BINARY_DIR}" STREQUAL "${QTDIR}/bin")
|
||||
message(FATAL_ERROR "\"${QT_BINARY_DIR}\" is unequal \"${QTDIR}/bin\"; "
|
||||
"Qt is found by looking for qmake in your PATH. "
|
||||
"Please set your PATH such that 'qmake' is found in \$QTDIR/bin, "
|
||||
"or unset QTDIR if the found Qt is correct.")
|
||||
endif (QTDIR AND NOT "${QT_BINARY_DIR}" STREQUAL "${QTDIR}/bin")
|
||||
find_package(LLQtWebkit REQUIRED QUIET)
|
||||
# Add the plugins.
|
||||
set(QT_PLUGIN_LIBRARIES)
|
||||
foreach(qlibname qgif qjpeg)
|
||||
find_library(QT_PLUGIN_${qlibname} ${qlibname} PATHS ${QT_PLUGINS_DIR}/imageformats NO_DEFAULT_PATH)
|
||||
if (QT_PLUGIN_${qlibname})
|
||||
list(APPEND QT_PLUGIN_LIBRARIES ${QT_PLUGIN_${qlibname}})
|
||||
else (QT_PLUGIN_${qtlibname})
|
||||
message(FATAL_ERROR "Could not find the Qt plugin ${qlibname} in \"${QT_PLUGINS_DIR}/imageformats\"!")
|
||||
endif (QT_PLUGIN_${qlibname})
|
||||
endforeach(qlibname)
|
||||
# qjpeg depends on libjpeg
|
||||
list(APPEND QT_PLUGIN_LIBRARIES jpeg)
|
||||
set(WEBKITLIBPLUGIN OFF CACHE BOOL
|
||||
"WEBKITLIBPLUGIN support for the llplugin/llmedia test apps.")
|
||||
else (STANDALONE)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
project(cwdebug)
|
||||
|
||||
include(00-Common)
|
||||
include(LLCommon)
|
||||
include(LLMath)
|
||||
include(LLMessage)
|
||||
include(LLVFS)
|
||||
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set(cwdebug_SOURCE_FILES
|
||||
debug.cc
|
||||
)
|
||||
|
||||
set(cwdebug_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
cwdebug.h
|
||||
sys.h
|
||||
debug.h
|
||||
debug_ostream_operators.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${cwdebug_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
if(NOT WORD_SIZE EQUAL 32)
|
||||
if(WINDOWS)
|
||||
add_definitions(/FIXED:NO)
|
||||
else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
|
||||
add_definitions(-fPIC)
|
||||
endif(WINDOWS)
|
||||
endif (NOT WORD_SIZE EQUAL 32)
|
||||
|
||||
list(APPEND cwdebug_SOURCE_FILES ${cwdebug_HEADER_FILES})
|
||||
|
||||
add_library (cwdebug ${cwdebug_SOURCE_FILES})
|
||||
@@ -49,6 +49,8 @@
|
||||
namespace debug {
|
||||
|
||||
#if CWDEBUG_LOCATION
|
||||
ll_thread_local size_t BackTrace::S_number;
|
||||
|
||||
void BackTrace::dump_backtrace(void) const
|
||||
{
|
||||
for (int frame = 0; frame < frames(); ++frame)
|
||||
@@ -67,6 +69,67 @@ void BackTrace::dump_backtrace(void) const
|
||||
Dout(dc::finish, mangled_function_name);
|
||||
}
|
||||
}
|
||||
|
||||
void BackTraces::store_trace(size_t trace)
|
||||
{
|
||||
mBackTraces.push_back(trace);
|
||||
}
|
||||
|
||||
void BackTraces::remove_trace(size_t trace)
|
||||
{
|
||||
trace_container_type::iterator iter = mBackTraces.begin();
|
||||
while (iter != mBackTraces.end())
|
||||
{
|
||||
if (*iter == trace)
|
||||
{
|
||||
*iter = mBackTraces.back();
|
||||
mBackTraces.pop_back();
|
||||
return;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
DoutFatal(dc::core, "Trace doesn't exist!");
|
||||
}
|
||||
|
||||
void BackTraces::dump(void) const
|
||||
{
|
||||
Dout(dc::backtrace|continued_cf, "Dump for (BackTraces*)" << (void*)this << " (" << mBackTraces.size() << " backtraces): ");
|
||||
for (trace_container_type::const_iterator iter = mBackTraces.begin(); iter != mBackTraces.end(); ++iter)
|
||||
{
|
||||
Dout(dc::continued|nonewline_cf, *iter << ' ');
|
||||
}
|
||||
Dout(dc::finish, "");
|
||||
}
|
||||
|
||||
BackTraceTracker::BackTraceTracker(BackTraces* back_traces) : mBackTraces(back_traces)
|
||||
{
|
||||
BACKTRACE;
|
||||
mTrace = BackTrace::S_number;
|
||||
mBackTraces->store_trace(mTrace);
|
||||
}
|
||||
|
||||
BackTraceTracker::~BackTraceTracker()
|
||||
{
|
||||
mBackTraces->remove_trace(mTrace);
|
||||
}
|
||||
|
||||
BackTraceTracker::BackTraceTracker(BackTraceTracker const& orig) : mBackTraces(orig.mBackTraces)
|
||||
{
|
||||
BACKTRACE;
|
||||
mTrace = BackTrace::S_number;
|
||||
mBackTraces->store_trace(mTrace);
|
||||
}
|
||||
|
||||
BackTraceTracker& BackTraceTracker::operator=(BackTraceTracker const& orig)
|
||||
{
|
||||
mBackTraces->remove_trace(mTrace);
|
||||
mBackTraces = orig.mBackTraces;
|
||||
BACKTRACE;
|
||||
mTrace = BackTrace::S_number;
|
||||
mBackTraces->store_trace(mTrace);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // CWDEBUG_LOCATION
|
||||
|
||||
#if CWDEBUG_ALLOC && CWDEBUG_LOCATION
|
||||
@@ -173,6 +236,8 @@ void stop_recording_backtraces(void)
|
||||
channel_ct backtrace DDCN("BACKTRACE"); //!< This debug channel is used for backtraces.
|
||||
channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used for output related to class AIStateMachine.
|
||||
channel_ct caps DDCN("CAPS"); //!< This debug channel is used for output related to Capabilities.
|
||||
channel_ct curl DDCN("CURL"); //!< This debug channel is used for output related to Curl.
|
||||
channel_ct curlio DDCN("CURLIO"); //!< This debug channel is used to print debug output of libcurl.
|
||||
|
||||
} // namespace dc
|
||||
} // namespace DEBUGCHANNELS
|
||||
@@ -411,4 +476,94 @@ void cwdebug_backtrace(int n)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CWDEBUG
|
||||
#elif defined(DEBUG_CURLIO)
|
||||
|
||||
#include "debug.h"
|
||||
#include "aithreadid.h"
|
||||
|
||||
namespace debug
|
||||
{
|
||||
|
||||
namespace libcwd { libcwd_do_type const libcw_do; }
|
||||
|
||||
ll_thread_local int Indent::S_indentation;
|
||||
|
||||
Indent::Indent(int indent) : M_indent(indent)
|
||||
{
|
||||
S_indentation += M_indent;
|
||||
}
|
||||
|
||||
Indent::~Indent()
|
||||
{
|
||||
S_indentation -= M_indent;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, Indent::print_nt)
|
||||
{
|
||||
if (Indent::S_indentation)
|
||||
os << std::string(Indent::S_indentation, ' ');
|
||||
return os;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CURLIO
|
||||
std::ostream& operator<<(std::ostream& os, print_thread_id_t)
|
||||
{
|
||||
if (!AIThreadID::in_main_thread_inline())
|
||||
{
|
||||
os << std::hex << (size_t)AIThreadID::getCurrentThread_inline() << std::dec << ' ';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, libcwd::buf2str const& b2s)
|
||||
{
|
||||
static char const c2s_tab[7] = { 'a', 'b', 't', 'n', 'v', 'f', 'r' };
|
||||
size_t size = b2s.mSize;
|
||||
for (char const* p1 = b2s.mBuf; size > 0; --size, ++p1)
|
||||
{
|
||||
char c =*p1;
|
||||
if ((c > 31 && c != 92 && c != 127) || (unsigned char)c > 159)
|
||||
os.put(c);
|
||||
else
|
||||
{
|
||||
os.put('\\');
|
||||
if (c > 6 && c < 14)
|
||||
{
|
||||
os.put(c2s_tab[c - 7]);
|
||||
return os;
|
||||
}
|
||||
else if (c == 27)
|
||||
{
|
||||
os.put('e');
|
||||
return os;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
os.put('\\');
|
||||
return os;
|
||||
}
|
||||
std::ostream::char_type old_fill = os.fill('0');
|
||||
std::ios_base::fmtflags old_flgs = os.flags();
|
||||
os.width(3);
|
||||
os << std::oct << (int)((unsigned char)c);
|
||||
os.setf(old_flgs);
|
||||
os.fill(old_fill);
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
namespace dc
|
||||
{
|
||||
|
||||
fake_channel const warning(1, "WARNING ");
|
||||
fake_channel const curl(1, "CURL ");
|
||||
fake_channel const curlio(1, "CURLIO ");
|
||||
fake_channel const statemachine(1, "STATEMACHINE");
|
||||
fake_channel const notice(1, "NOTICE ");
|
||||
|
||||
} // namespace dc
|
||||
} // namespace debug
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,94 @@
|
||||
|
||||
#ifndef CWDEBUG
|
||||
|
||||
#ifdef DEBUG_CURLIO
|
||||
|
||||
// If CWDEBUG is not defined, but DEBUG_CURLIO is, then replace
|
||||
// some of the cwd macro's with something that generates viewer
|
||||
// specific debug output. Note that this generates a LOT of
|
||||
// output and should not normally be defined.
|
||||
|
||||
#include <string>
|
||||
#include "llpreprocessor.h"
|
||||
|
||||
namespace debug {
|
||||
namespace libcwd {
|
||||
|
||||
struct buf2str {
|
||||
buf2str(char const* buf, int size) : mBuf(buf), mSize(size) { }
|
||||
char const* mBuf;
|
||||
int mSize;
|
||||
};
|
||||
|
||||
struct libcwd_do_type {
|
||||
void on() const { }
|
||||
};
|
||||
extern LL_COMMON_API libcwd_do_type const libcw_do;
|
||||
|
||||
} // namespace libcwd
|
||||
|
||||
enum print_thread_id_t { print_thread_id };
|
||||
inline void init() { }
|
||||
struct Indent {
|
||||
int M_indent;
|
||||
static ll_thread_local int S_indentation;
|
||||
enum LL_COMMON_API print_nt { print };
|
||||
LL_COMMON_API Indent(int indent);
|
||||
LL_COMMON_API ~Indent();
|
||||
};
|
||||
|
||||
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, libcwd::buf2str const& b2s);
|
||||
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, Indent::print_nt);
|
||||
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, print_thread_id_t);
|
||||
|
||||
namespace dc {
|
||||
|
||||
struct fake_channel {
|
||||
int mOn;
|
||||
char const* mLabel;
|
||||
fake_channel(int on, char const* label) : mOn(on), mLabel(label) { }
|
||||
fake_channel(void) : mOn(0) { }
|
||||
bool is_on() const { return !!mOn; }
|
||||
bool is_off() const { return !mOn; }
|
||||
void on() const { }
|
||||
void off() const { }
|
||||
};
|
||||
extern LL_COMMON_API fake_channel const warning;
|
||||
extern LL_COMMON_API fake_channel const curl;
|
||||
extern LL_COMMON_API fake_channel const curlio;
|
||||
extern LL_COMMON_API fake_channel const statemachine;
|
||||
extern LL_COMMON_API fake_channel const notice;
|
||||
|
||||
} // namespace dc
|
||||
} // namespace debug
|
||||
|
||||
#define LIBCWD_DEBUG_CHANNELS debug
|
||||
#define LibcwDoutScopeBegin(a, b, c) do { using namespace debug; using namespace debug::libcwd; llinfos_nf << print_thread_id << (c).mLabel << ": " << Indent::print;
|
||||
#define LibcwDoutStream llcont
|
||||
#define LibcwDoutScopeEnd llcont << llendl; } while(0)
|
||||
|
||||
#define Debug(x) do { using namespace debug; using namespace debug::libcwd; x; } while(0)
|
||||
#define Dout(a, b) do { using namespace debug; using namespace debug::libcwd; if ((a).mOn) { llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << b << llendl; } } while(0)
|
||||
#define DoutEntering(a, b) \
|
||||
int __slviewer_debug_indentation = 2; \
|
||||
{ \
|
||||
using namespace debug; \
|
||||
using namespace debug::libcwd; \
|
||||
if ((a).mOn) \
|
||||
llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << "Entering " << b << llendl; \
|
||||
else \
|
||||
__slviewer_debug_indentation = 0; \
|
||||
} \
|
||||
debug::Indent __slviewer_debug_indent(__slviewer_debug_indentation);
|
||||
|
||||
#else // !DEBUG_CURLIO
|
||||
|
||||
#define Debug(x)
|
||||
#define Dout(a, b)
|
||||
#define DoutEntering(a, b)
|
||||
|
||||
#endif // !DEBUG_CURLIO
|
||||
|
||||
#ifndef DOXYGEN // No need to document this. See http://libcwd.sourceforge.net/ for more info.
|
||||
|
||||
#include <iostream>
|
||||
@@ -36,9 +124,6 @@
|
||||
#define AllocTag2(p, desc)
|
||||
#define AllocTag_dynamic_description(p, x)
|
||||
#define AllocTag(p, x)
|
||||
#define Debug(x)
|
||||
#define Dout(a, b)
|
||||
#define DoutEntering(a, b)
|
||||
#define DoutFatal(a, b) LibcwDoutFatal(::std, , a, b)
|
||||
#define ForAllDebugChannels(STATEMENT)
|
||||
#define ForAllDebugObjects(STATEMENT)
|
||||
@@ -88,7 +173,9 @@
|
||||
#include <boost/shared_array.hpp>
|
||||
#if CWDEBUG_LOCATION
|
||||
#include <execinfo.h> // Needed for 'backtrace'.
|
||||
#include "llpreprocessor.h"
|
||||
#endif
|
||||
#include <set>
|
||||
|
||||
#define CWD_API __attribute__ ((visibility("default")))
|
||||
|
||||
@@ -118,6 +205,8 @@ extern CWD_API channel_ct sdl;
|
||||
extern CWD_API channel_ct backtrace;
|
||||
extern CWD_API channel_ct statemachine;
|
||||
extern CWD_API channel_ct caps;
|
||||
extern CWD_API channel_ct curl;
|
||||
extern CWD_API channel_ct curlio;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -186,6 +275,8 @@ class BackTrace {
|
||||
private:
|
||||
boost::shared_array<void*> M_buffer;
|
||||
int M_frames;
|
||||
public:
|
||||
static ll_thread_local size_t S_number;
|
||||
public:
|
||||
BackTrace(void** buffer, int frames) : M_buffer(new void* [frames]), M_frames(frames) { std::memcpy(M_buffer.get(), buffer, sizeof(void*) * frames); }
|
||||
|
||||
@@ -212,19 +303,81 @@ extern pthread_mutex_t backtrace_mutex;
|
||||
using namespace debug; \
|
||||
void* buffer[32]; \
|
||||
int frames = backtrace(buffer, 32); \
|
||||
size_t size; \
|
||||
{ \
|
||||
pthread_mutex_lock(&backtrace_mutex); \
|
||||
backtraces.push_back(BackTrace(buffer, frames)); \
|
||||
size = backtraces.size(); \
|
||||
BackTrace::S_number = backtraces.size(); \
|
||||
pthread_mutex_unlock(&backtrace_mutex); \
|
||||
} \
|
||||
Dout(dc::backtrace, "Stored backtrace #" << size); \
|
||||
Dout(dc::backtrace, "Stored backtrace #" << BackTrace::S_number); \
|
||||
} while(0)
|
||||
|
||||
class LL_COMMON_API BackTraces {
|
||||
private:
|
||||
typedef std::vector<size_t> trace_container_type;
|
||||
trace_container_type mBackTraces;
|
||||
|
||||
public:
|
||||
void store_trace(size_t trace);
|
||||
void remove_trace(size_t trace);
|
||||
|
||||
void dump(void) const;
|
||||
};
|
||||
|
||||
class LL_COMMON_API BackTraceTracker {
|
||||
private:
|
||||
BackTraces* mBackTraces;
|
||||
size_t mTrace;
|
||||
|
||||
public:
|
||||
BackTraceTracker(BackTraces* back_traces);
|
||||
~BackTraceTracker();
|
||||
|
||||
BackTraceTracker(BackTraceTracker const&);
|
||||
BackTraceTracker& operator=(BackTraceTracker const&);
|
||||
|
||||
void dump(void) const { mBackTraces->dump(); }
|
||||
};
|
||||
|
||||
#else
|
||||
#define BACKTRACE do { } while(0)
|
||||
#endif // CWDEBUG_LOCATION
|
||||
|
||||
template<class T>
|
||||
class LL_COMMON_API InstanceTracker {
|
||||
private:
|
||||
T const* mInstance;
|
||||
static pthread_mutex_t sInstancesMutex;
|
||||
static std::set<T const*> sInstances;
|
||||
static void remember(T const* instance) { pthread_mutex_lock(&sInstancesMutex); sInstances.insert(instance); pthread_mutex_unlock(&sInstancesMutex); }
|
||||
static void forget(T const* instance) { pthread_mutex_lock(&sInstancesMutex); sInstances.erase(instance); pthread_mutex_unlock(&sInstancesMutex); }
|
||||
public:
|
||||
InstanceTracker(T const* instance) : mInstance(instance) { remember(mInstance); }
|
||||
~InstanceTracker() { forget(mInstance); }
|
||||
InstanceTracker& operator=(InstanceTracker const& orig) { forget(mInstance); mInstance = orig.mInstance; remember(mInstance); return *this; }
|
||||
static void dump(void);
|
||||
private:
|
||||
// Non-copyable. Instead of copying, call InstanceTracker(T const*) with the this pointer of the new instance.
|
||||
InstanceTracker(InstanceTracker const& orig);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
pthread_mutex_t InstanceTracker<T>::sInstancesMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
template<class T>
|
||||
std::set<T const*> InstanceTracker<T>::sInstances;
|
||||
|
||||
template<class T>
|
||||
void InstanceTracker<T>::dump(void)
|
||||
{
|
||||
pthread_mutex_lock(&sInstancesMutex);
|
||||
for (typename std::set<T const*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter)
|
||||
{
|
||||
std::cout << *iter << std::endl;
|
||||
}
|
||||
pthread_mutex_unlock(&sInstancesMutex);
|
||||
}
|
||||
|
||||
} // namespace debug
|
||||
|
||||
//! Debugging macro.
|
||||
|
||||
@@ -782,13 +782,14 @@ Commands:
|
||||
|
||||
Command-options for "configure":
|
||||
We use cmake variables to change the build configuration.
|
||||
-DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
|
||||
-DVIEWER:BOOL=OFF Don't configure the viewer
|
||||
-DPACKAGE:BOOL=ON Create "package" target to make installers
|
||||
-DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
|
||||
-DLL_TESTS:BOOL=OFF Don't generate unit test projects
|
||||
-DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project
|
||||
-VISTA_ICON:BOOL=ON Allow pre-2008 VS to use vista-optimized resource file. (Requires updated rcdll.dll!)
|
||||
-DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
|
||||
-DVIEWER:BOOL=OFF Don't configure the viewer
|
||||
-DPACKAGE:BOOL=ON Create "package" target to make installers
|
||||
-DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
|
||||
-DLL_TESTS:BOOL=OFF Don't generate unit test projects
|
||||
-DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project
|
||||
-DDISABLE_TCMALLOC:BOOL=ON Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)
|
||||
-DVISTA_ICON:BOOL=ON Allow pre-2008 VS to use vista-optimized resource file. (Requires updated rcdll.dll!)
|
||||
|
||||
Examples:
|
||||
Set up a viewer-only project for your system:
|
||||
|
||||
@@ -7,14 +7,15 @@ include(00-Common)
|
||||
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
set(OPENJPEG_VERSION_MAJOR 1)
|
||||
set(OPENJPEG_VERSION_MINOR 4)
|
||||
set(OPENJPEG_VERSION_BUILD 0)
|
||||
set(OPENJPEG_VERSION_MINOR 5)
|
||||
set(OPENJPEG_VERSION_BUILD 2)
|
||||
set(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
|
||||
set(openjpeg_SOURCE_FILES
|
||||
bio.c
|
||||
cio.c
|
||||
cidx_manager.c
|
||||
dwt.c
|
||||
event.c
|
||||
image.c
|
||||
@@ -26,20 +27,26 @@ set(openjpeg_SOURCE_FILES
|
||||
mqc.c
|
||||
openjpeg.c
|
||||
pi.c
|
||||
phix_manager.c
|
||||
ppix_manager.c
|
||||
raw.c
|
||||
t1.c
|
||||
t2.c
|
||||
tcd.c
|
||||
tgt.c
|
||||
thix_manager.c
|
||||
tpix_manager.c
|
||||
)
|
||||
|
||||
set(openjpeg_HEADER_FILES
|
||||
bio.h
|
||||
cio.h
|
||||
cidx_manager.h
|
||||
dwt.h
|
||||
event.h
|
||||
event.h
|
||||
fix.h
|
||||
image.h
|
||||
indexbox_manager.h
|
||||
int.h
|
||||
j2k.h
|
||||
j2k_lib.h
|
||||
@@ -48,6 +55,7 @@ set(openjpeg_HEADER_FILES
|
||||
mct.h
|
||||
mqc.h
|
||||
openjpeg.h
|
||||
opj_config.h
|
||||
opj_includes.h
|
||||
opj_malloc.h
|
||||
pi.h
|
||||
|
||||
211
indra/libopenjpeg/cidx_manager.c
Normal file
211
indra/libopenjpeg/cidx_manager.c
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opj_includes.h"
|
||||
|
||||
|
||||
/*
|
||||
* Write CPTR Codestream finder box
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] clen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
*/
|
||||
void write_cptr(int coff, int clen, opj_cio_t *cio);
|
||||
|
||||
|
||||
/*
|
||||
* Write main header index table (box)
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] cio file output handle
|
||||
* @return length of mainmhix box
|
||||
*/
|
||||
int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
|
||||
|
||||
|
||||
/*
|
||||
* Check if EPH option is used
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] markers marker information
|
||||
* @param[in] marknum number of markers
|
||||
* @param[in] cio file output handle
|
||||
* @return true if EPH is used
|
||||
*/
|
||||
opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio);
|
||||
|
||||
|
||||
int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen)
|
||||
{
|
||||
int len, i, lenp;
|
||||
opj_jp2_box_t *box;
|
||||
int num_box = 0;
|
||||
opj_bool EPHused;
|
||||
(void)image; /* unused ? */
|
||||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
|
||||
|
||||
for (i=0;i<2;i++){
|
||||
|
||||
if(i)
|
||||
cio_seek( cio, lenp);
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_CIDX, 4); /* CIDX */
|
||||
write_cptr( offset, cstr_info.codestream_size, cio);
|
||||
|
||||
write_manf( i, num_box, box, cio);
|
||||
|
||||
num_box = 0;
|
||||
box[num_box].length = write_mainmhix( offset, cstr_info, cio);
|
||||
box[num_box].type = JPIP_MHIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio);
|
||||
box[num_box].type = JPIP_TPIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = write_thix( offset, cstr_info, cio);
|
||||
box[num_box].type = JPIP_THIX;
|
||||
num_box++;
|
||||
|
||||
EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio);
|
||||
|
||||
box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio);
|
||||
box[num_box].type = JPIP_PPIX;
|
||||
num_box++;
|
||||
|
||||
box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio);
|
||||
box[num_box].type = JPIP_PHIX;
|
||||
num_box++;
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
opj_free( box);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void write_cptr(int coff, int clen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp;
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_CPTR, 4); /* T */
|
||||
cio_write( cio, 0, 2); /* DR A PRECISER !! */
|
||||
cio_write( cio, 0, 2); /* CONT */
|
||||
cio_write( cio, coff, 8); /* COFF A PRECISER !! */
|
||||
cio_write( cio, clen, 8); /* CLEN */
|
||||
len = cio_tell( cio) - lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp, i;
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_MANF,4); /* T */
|
||||
|
||||
if (second){ /* Write only during the second pass */
|
||||
for( i=0; i<v; i++){
|
||||
cio_write( cio, box[i].length, 4); /* Box length */
|
||||
cio_write( cio, box[i].type, 4); /* Box type */
|
||||
}
|
||||
}
|
||||
|
||||
len = cio_tell( cio) - lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
|
||||
{
|
||||
int i;
|
||||
int len, lenp;
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_MHIX, 4); /* MHIX */
|
||||
|
||||
cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */
|
||||
|
||||
for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */
|
||||
cio_write( cio, cstr_info.marker[i].type, 2);
|
||||
cio_write( cio, 0, 2);
|
||||
cio_write( cio, cstr_info.marker[i].pos-coff, 8);
|
||||
cio_write( cio, cstr_info.marker[i].len, 2);
|
||||
}
|
||||
|
||||
len = cio_tell( cio) - lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio)
|
||||
{
|
||||
opj_bool EPHused = OPJ_FALSE;
|
||||
int i=0;
|
||||
int org_pos;
|
||||
unsigned int Scod;
|
||||
|
||||
for(i = 0; i < marknum; i++){
|
||||
if( markers[i].type == J2K_MS_COD){
|
||||
org_pos = cio_tell( cio);
|
||||
cio_seek( cio, coff+markers[i].pos+2);
|
||||
|
||||
Scod = cio_read( cio, 1);
|
||||
if( ((Scod >> 2) & 1))
|
||||
EPHused = OPJ_TRUE;
|
||||
cio_seek( cio, org_pos);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return EPHused;
|
||||
}
|
||||
56
indra/libopenjpeg/cidx_manager.h
Normal file
56
indra/libopenjpeg/cidx_manager.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.h from 2KAN indexer
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CIDX_MANAGER_H_
|
||||
# define CIDX_MANAGER_H_
|
||||
|
||||
#include "openjpeg.h"
|
||||
|
||||
|
||||
/*
|
||||
* Write Codestream index box (superbox)
|
||||
*
|
||||
* @param[in] offset offset of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @param[in] image image data
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @return length of cidx box
|
||||
*/
|
||||
int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen);
|
||||
|
||||
|
||||
#endif /* !CIDX_MANAGER_H_ */
|
||||
@@ -126,13 +126,13 @@ unsigned char *cio_getbp(opj_cio_t *cio) {
|
||||
/*
|
||||
* Write a byte.
|
||||
*/
|
||||
bool cio_byteout(opj_cio_t *cio, unsigned char v) {
|
||||
opj_bool cio_byteout(opj_cio_t *cio, unsigned char v) {
|
||||
if (cio->bp >= cio->end) {
|
||||
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
*cio->bp++ = v;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) {
|
||||
* v : value to write
|
||||
* n : number of bytes to write
|
||||
*/
|
||||
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
|
||||
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
|
||||
int i;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
||||
|
||||
@@ -31,6 +31,13 @@
|
||||
|
||||
#ifndef __CIO_H
|
||||
#define __CIO_H
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#define int64 __int64
|
||||
#else
|
||||
#define int64 long long
|
||||
#endif
|
||||
|
||||
/**
|
||||
@file cio.h
|
||||
@brief Implementation of a byte input-output process (CIO)
|
||||
@@ -63,7 +70,7 @@ Write some bytes
|
||||
@param n Number of bytes to write
|
||||
@return Returns the number of bytes written or 0 if an error occured
|
||||
*/
|
||||
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
|
||||
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n);
|
||||
/**
|
||||
Read some bytes
|
||||
@param cio CIO handle
|
||||
|
||||
@@ -64,12 +64,12 @@ typedef struct v4dwt_local {
|
||||
int cas ;
|
||||
} v4dwt_t ;
|
||||
|
||||
static const float dwt_alpha = 1.586134342f; // 12994
|
||||
static const float dwt_beta = 0.052980118f; // 434
|
||||
static const float dwt_gamma = -0.882911075f; // -7233
|
||||
static const float dwt_delta = -0.443506852f; // -3633
|
||||
static const float dwt_alpha = 1.586134342f; /* 12994 */
|
||||
static const float dwt_beta = 0.052980118f; /* 434 */
|
||||
static const float dwt_gamma = -0.882911075f; /* -7233 */
|
||||
static const float dwt_delta = -0.443506852f; /* -3633 */
|
||||
|
||||
static const float K = 1.230174105f; // 10078
|
||||
static const float K = 1.230174105f; /* 10078 */
|
||||
/* FIXME: What is this constant? */
|
||||
static const float c13318 = 1.625732422f;
|
||||
|
||||
@@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
|
||||
|
||||
int w = tilec->x1 - tilec->x0;
|
||||
|
||||
h.mem = (int *)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
||||
h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
||||
v.mem = h.mem;
|
||||
|
||||
while( --numres) {
|
||||
@@ -570,7 +570,7 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in
|
||||
int count = w->sn;
|
||||
int i, k;
|
||||
for(k = 0; k < 2; ++k){
|
||||
if (count + 3 * x < size && ((long) a & 0x0f) == 0 && ((long) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
if (count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
/* Fast code path */
|
||||
for(i = 0; i < count; ++i){
|
||||
int j = i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -26,6 +26,42 @@
|
||||
|
||||
#include "opj_includes.h"
|
||||
|
||||
/* ==========================================================
|
||||
Utility functions
|
||||
==========================================================*/
|
||||
|
||||
#ifdef OPJ_CODE_NOT_USED
|
||||
#ifndef _WIN32
|
||||
static char*
|
||||
i2a(unsigned i, char *a, unsigned r) {
|
||||
if (i/r > 0) a = i2a(i/r,a,r);
|
||||
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
|
||||
return a+1;
|
||||
}
|
||||
|
||||
/**
|
||||
Transforms integer i into an ascii string and stores the result in a;
|
||||
string is encoded in the base indicated by r.
|
||||
@param i Number to be converted
|
||||
@param a String result
|
||||
@param r Base of value; must be in the range 2 - 36
|
||||
@return Returns a
|
||||
*/
|
||||
static char *
|
||||
_itoa(int i, char *a, int r) {
|
||||
r = ((r < 2) || (r > 36)) ? 10 : r;
|
||||
if(i < 0) {
|
||||
*a = '-';
|
||||
*i2a(-i, a+1, r) = 0;
|
||||
}
|
||||
else *i2a(i, a, r) = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif /* !_WIN32 */
|
||||
#endif
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
|
||||
if(cinfo) {
|
||||
opj_event_mgr_t *previous = cinfo->event_mgr;
|
||||
@@ -37,7 +73,7 @@ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
|
||||
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
|
||||
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
|
||||
opj_msg_callback msg_handler = NULL;
|
||||
|
||||
@@ -57,30 +93,29 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
|
||||
break;
|
||||
}
|
||||
if(msg_handler == NULL) {
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if ((fmt != NULL) && (event_mgr != NULL)) {
|
||||
va_list arg;
|
||||
int str_length/*, i, j*/; /* UniPG */
|
||||
char message[MSG_SIZE];
|
||||
memset(message, 0, MSG_SIZE);
|
||||
/* initialize the optional parameter list */
|
||||
va_start(arg, fmt);
|
||||
/* check the length of the format string */
|
||||
str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
|
||||
/* parse the format string and put the result in 'message' */
|
||||
vsprintf(message, fmt, arg); /* UniPG */
|
||||
str_length = vsnprintf(message, MSG_SIZE, fmt, arg); /* UniPG */
|
||||
/* deinitialize the optional parameter list */
|
||||
va_end(arg);
|
||||
|
||||
/* output the message to the user program */
|
||||
msg_handler(message, cinfo->client_data);
|
||||
if( str_length > -1 && str_length < MSG_SIZE )
|
||||
msg_handler(message, cinfo->client_data);
|
||||
else return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -49,7 +49,7 @@ Write formatted data to a string and send the string to a user callback.
|
||||
@param fmt Format-control string (plus optionnal arguments)
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
|
||||
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
opj_image_t* opj_image_create0(void) {
|
||||
opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
|
||||
image->comps=NULL;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
118
indra/libopenjpeg/indexbox_manager.h
Normal file
118
indra/libopenjpeg/indexbox_manager.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.c from 2KAN indexer
|
||||
*/
|
||||
|
||||
#ifndef INDEXBOX_MANAGER_H_
|
||||
# define INDEXBOX_MANAGER_H_
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "j2k.h" /* needed to use jp2.h */
|
||||
#include "jp2.h"
|
||||
|
||||
#define JPIP_CIDX 0x63696478 /* Codestream index */
|
||||
#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
|
||||
#define JPIP_MANF 0x6d616e66 /* Manifest Box */
|
||||
#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
|
||||
#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
|
||||
#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
|
||||
#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
|
||||
#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
|
||||
#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
|
||||
#define JPIP_FIDX 0x66696478 /* File Index */
|
||||
#define JPIP_FPTR 0x66707472 /* File Finder */
|
||||
#define JPIP_PRXY 0x70727879 /* Proxy boxes */
|
||||
#define JPIP_IPTR 0x69707472 /* Index finder box */
|
||||
#define JPIP_PHLD 0x70686c64 /* Place holder */
|
||||
|
||||
|
||||
/*
|
||||
* Write tile-part Index table box (superbox)
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of tpix box
|
||||
*/
|
||||
int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
|
||||
|
||||
|
||||
/*
|
||||
* Write tile header index table box (superbox)
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information pointer
|
||||
* @param[in] cio file output handle
|
||||
* @return length of thix box
|
||||
*/
|
||||
int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
|
||||
|
||||
|
||||
/*
|
||||
* Write precinct packet index table box (superbox)
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] EPHused true if EPH option used
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of ppix box
|
||||
*/
|
||||
int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
|
||||
|
||||
|
||||
/*
|
||||
* Write packet header index table box (superbox)
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] EPHused true if EPH option used
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of ppix box
|
||||
*/
|
||||
int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
|
||||
|
||||
/*
|
||||
* Wriet manifest box (box)
|
||||
*
|
||||
* @param[in] second number to be visited
|
||||
* @param[in] v number of boxes
|
||||
* @param[in] box box to be manifested
|
||||
* @param[in] cio file output handle
|
||||
*/
|
||||
void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio);
|
||||
|
||||
|
||||
#endif /* !INDEXBOX_MANAGER_H_ */
|
||||
@@ -6,6 +6,7 @@
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -228,6 +229,23 @@ Read an unknown marker
|
||||
@param j2k J2K handle
|
||||
*/
|
||||
static void j2k_read_unk(opj_j2k_t *j2k);
|
||||
/**
|
||||
Add main header marker information
|
||||
@param cstr_info Codestream information structure
|
||||
@param type marker type
|
||||
@param pos byte offset of marker segment
|
||||
@param len length of marker segment
|
||||
*/
|
||||
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
|
||||
/**
|
||||
Add tile header marker information
|
||||
@param tileno tile index number
|
||||
@param cstr_info Codestream information structure
|
||||
@param type marker type
|
||||
@param pos byte offset of marker segment
|
||||
@param len length of marker segment
|
||||
*/
|
||||
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -258,80 +276,6 @@ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
|
||||
return po->str_prog;
|
||||
}
|
||||
|
||||
void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||
int compno;
|
||||
fprintf(fd, "image {\n");
|
||||
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_image_comp_t *comp = &img->comps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||
fprintf(fd, " prec=%d\n", comp->prec);
|
||||
//fprintf(fd, " bpp=%d\n", comp->bpp);
|
||||
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||
int tileno, compno, layno, bandno, resno, numbands;
|
||||
fprintf(fd, "coding parameters {\n");
|
||||
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||
fprintf(fd, " tile %d {\n", tileno);
|
||||
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||
fprintf(fd, " rates=");
|
||||
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||
fprintf(fd, " stepsizes=");
|
||||
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||
for (bandno = 0; bandno < numbands; bandno++) {
|
||||
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||
tccp->stepsizes[bandno].expn);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
|
||||
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||
fprintf(fd, " prcw=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, " prch=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
|
||||
char *prog;
|
||||
@@ -371,6 +315,9 @@ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
|
||||
/** mem allocation for TLM marker*/
|
||||
int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){
|
||||
int pino,tileno,totnum_tp=0;
|
||||
|
||||
OPJ_ARG_NOT_USED(img_numcomp);
|
||||
|
||||
j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int));
|
||||
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||
int cur_totnum_tp = 0;
|
||||
@@ -399,12 +346,14 @@ static void j2k_write_soc(opj_j2k_t *j2k) {
|
||||
opj_cio_t *cio = j2k->cio;
|
||||
cio_write(cio, J2K_MS_SOC, 2);
|
||||
|
||||
if(j2k->cstr_info)
|
||||
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio), 0);
|
||||
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
|
||||
/* update markers struct */
|
||||
j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2);
|
||||
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
}
|
||||
@@ -425,7 +374,7 @@ static void j2k_write_siz(opj_j2k_t *j2k) {
|
||||
opj_cio_t *cio = j2k->cio;
|
||||
opj_image_t *image = j2k->image;
|
||||
opj_cp_t *cp = j2k->cp;
|
||||
|
||||
|
||||
cio_write(cio, J2K_MS_SIZ, 2); /* SIZ */
|
||||
lenp = cio_tell(cio);
|
||||
cio_skip(cio, 2);
|
||||
@@ -448,6 +397,9 @@ static void j2k_write_siz(opj_j2k_t *j2k) {
|
||||
cio_seek(cio, lenp);
|
||||
cio_write(cio, len, 2); /* Lsiz */
|
||||
cio_seek(cio, lenp + len);
|
||||
|
||||
if(j2k->cstr_info)
|
||||
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SIZ, lenp, len);
|
||||
}
|
||||
|
||||
static void j2k_read_siz(opj_j2k_t *j2k) {
|
||||
@@ -516,6 +468,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
|
||||
}
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
/* prevent division by zero */
|
||||
if (!(cp->tdx * cp->tdy)) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid tile size (tdx: %d, tdy: %d)\n", cp->tdx, cp->tdy);
|
||||
return;
|
||||
}
|
||||
|
||||
image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
|
||||
for (i = 0; i < image->numcomps; i++) {
|
||||
int tmp, w, h;
|
||||
@@ -554,6 +512,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
|
||||
}
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
/* prevent division by zero */
|
||||
if (!(image->comps[i].dx * image->comps[i].dy)) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid component size (dx: %d, dy: %d)\n", image->comps[i].dx, image->comps[i].dy);
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: unused ? */
|
||||
w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx);
|
||||
h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy);
|
||||
@@ -606,7 +570,17 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
|
||||
if (cp->tcps == NULL)
|
||||
{
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
return;
|
||||
}
|
||||
cp->tileno = (int*) opj_malloc(cp->tw * cp->th * sizeof(int));
|
||||
if (cp->tileno == NULL)
|
||||
{
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
return;
|
||||
}
|
||||
cp->tileno_size = 0;
|
||||
|
||||
#ifdef USE_JPWL
|
||||
@@ -678,6 +652,11 @@ static void j2k_write_com(opj_j2k_t *j2k) {
|
||||
cio_seek(cio, lenp);
|
||||
cio_write(cio, len, 2);
|
||||
cio_seek(cio, lenp + len);
|
||||
|
||||
|
||||
if(j2k->cstr_info)
|
||||
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COM, lenp, len);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,12 +700,18 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) {
|
||||
|
||||
tccp->numresolutions = cio_read(cio, 1) + 1; /* SPcox (D) */
|
||||
|
||||
// If user wants to remove more resolutions than the codestream contains, return error
|
||||
/* If user wants to remove more resolutions than the codestream contains, return error*/
|
||||
if (cp->reduce >= tccp->numresolutions) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number "
|
||||
"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
|
||||
j2k->state |= J2K_STATE_ERR;
|
||||
}
|
||||
if( tccp->numresolutions > J2K_MAXRLVLS ) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions is too big: %d vs max= %d. Truncating.\n\n",
|
||||
compno, tccp->numresolutions, J2K_MAXRLVLS);
|
||||
j2k->state |= J2K_STATE_ERR;
|
||||
tccp->numresolutions = J2K_MAXRLVLS;
|
||||
}
|
||||
|
||||
tccp->cblkw = cio_read(cio, 1) + 2; /* SPcox (E) */
|
||||
tccp->cblkh = cio_read(cio, 1) + 2; /* SPcox (F) */
|
||||
@@ -781,6 +766,10 @@ static void j2k_write_cod(opj_j2k_t *j2k) {
|
||||
cio_seek(cio, lenp);
|
||||
cio_write(cio, len, 2); /* Lcod */
|
||||
cio_seek(cio, lenp + len);
|
||||
|
||||
if(j2k->cstr_info)
|
||||
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COD, lenp, len);
|
||||
|
||||
}
|
||||
|
||||
static void j2k_read_cod(opj_j2k_t *j2k) {
|
||||
@@ -846,6 +835,12 @@ static void j2k_read_coc(opj_j2k_t *j2k) {
|
||||
|
||||
len = cio_read(cio, 2); /* Lcoc */
|
||||
compno = cio_read(cio, image->numcomps <= 256 ? 1 : 2); /* Ccoc */
|
||||
if (compno >= image->numcomps) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||
"bad component number in COC (%d out of a maximum of %d)\n",
|
||||
compno, image->numcomps);
|
||||
return;
|
||||
}
|
||||
tcp->tccps[compno].csty = cio_read(cio, 1); /* Scoc */
|
||||
j2k_read_cox(j2k, compno);
|
||||
}
|
||||
@@ -909,6 +904,15 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) {
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
/* We check whether there are too many subbands */
|
||||
if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) {
|
||||
opj_event_msg(j2k->cinfo, EVT_WARNING ,
|
||||
"bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n"
|
||||
"- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS);
|
||||
}
|
||||
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
for (bandno = 0; bandno < numbands; bandno++) {
|
||||
@@ -921,8 +925,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) {
|
||||
expn = tmp >> 11;
|
||||
mant = tmp & 0x7ff;
|
||||
}
|
||||
tccp->stepsizes[bandno].expn = expn;
|
||||
tccp->stepsizes[bandno].mant = mant;
|
||||
if (bandno < J2K_MAXBANDS){
|
||||
tccp->stepsizes[bandno].expn = expn;
|
||||
tccp->stepsizes[bandno].mant = mant;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add Antonin : if scalar_derived -> compute other stepsizes */
|
||||
@@ -950,6 +956,9 @@ static void j2k_write_qcd(opj_j2k_t *j2k) {
|
||||
cio_seek(cio, lenp);
|
||||
cio_write(cio, len, 2); /* Lqcd */
|
||||
cio_seek(cio, lenp + len);
|
||||
|
||||
if(j2k->cstr_info)
|
||||
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_QCD, lenp, len);
|
||||
}
|
||||
|
||||
static void j2k_read_qcd(opj_j2k_t *j2k) {
|
||||
@@ -986,7 +995,7 @@ static void j2k_read_qcc(opj_j2k_t *j2k) {
|
||||
int len, compno;
|
||||
int numcomp = j2k->image->numcomps;
|
||||
opj_cio_t *cio = j2k->cio;
|
||||
|
||||
|
||||
len = cio_read(cio, 2); /* Lqcc */
|
||||
compno = cio_read(cio, numcomp <= 256 ? 1 : 2); /* Cqcc */
|
||||
|
||||
@@ -1013,9 +1022,16 @@ static void j2k_read_qcc(opj_j2k_t *j2k) {
|
||||
|
||||
/* keep your private count of tiles */
|
||||
backup_compno++;
|
||||
};
|
||||
}
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
if ((compno < 0) || (compno >= numcomp)) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||
"bad component number in QCC (%d out of a maximum of %d)\n",
|
||||
compno, j2k->image->numcomps);
|
||||
return;
|
||||
}
|
||||
|
||||
j2k_read_qcx(j2k, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
|
||||
}
|
||||
|
||||
@@ -1271,6 +1287,10 @@ static void j2k_write_sot(opj_j2k_t *j2k) {
|
||||
j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2);
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
|
||||
if( j2k->cstr_info && j2k->cur_tp_num==0){
|
||||
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOT, lenp, len);
|
||||
}
|
||||
}
|
||||
|
||||
static void j2k_read_sot(opj_j2k_t *j2k) {
|
||||
@@ -1354,6 +1374,11 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
|
||||
|
||||
partno = cio_read(cio, 1);
|
||||
numparts = cio_read(cio, 1);
|
||||
|
||||
if (partno >= numparts) {
|
||||
opj_event_msg(j2k->cinfo, EVT_WARNING, "SOT marker inconsistency in tile %d: tile-part index greater (%d) than number of tile-parts (%d)\n", tileno, partno, numparts);
|
||||
numparts = partno+1;
|
||||
}
|
||||
|
||||
j2k->curtileno = tileno;
|
||||
j2k->cur_tp_num = partno;
|
||||
@@ -1369,15 +1394,14 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
|
||||
j2k->cstr_info->tile[tileno].tileno = tileno;
|
||||
j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12;
|
||||
j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1;
|
||||
j2k->cstr_info->tile[tileno].num_tps = numparts;
|
||||
if (numparts)
|
||||
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t));
|
||||
else
|
||||
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
j2k->cstr_info->tile[tileno].end_pos += totlen;
|
||||
}
|
||||
}
|
||||
j2k->cstr_info->tile[tileno].num_tps = numparts;
|
||||
if (numparts)
|
||||
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, numparts * sizeof(opj_tp_info_t));
|
||||
else
|
||||
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, 10 * sizeof(opj_tp_info_t)); /* Fixme (10)*/
|
||||
j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12;
|
||||
j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos =
|
||||
j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1;
|
||||
@@ -1413,6 +1437,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
|
||||
tcd->cur_tp_num = j2k->cur_tp_num;
|
||||
|
||||
cio_write(cio, J2K_MS_SOD, 2);
|
||||
|
||||
if( j2k->cstr_info && j2k->cur_tp_num==0){
|
||||
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOD, cio_tell(cio), 0);
|
||||
}
|
||||
|
||||
if (j2k->curtileno == 0) {
|
||||
j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
|
||||
}
|
||||
@@ -1489,6 +1518,24 @@ static void j2k_read_sod(opj_j2k_t *j2k) {
|
||||
truncate = 1; /* Case of a truncate codestream */
|
||||
}
|
||||
|
||||
{/* chop padding bytes: */
|
||||
unsigned char *s, *e;
|
||||
|
||||
s = cio_getbp(cio);
|
||||
e = s + len;
|
||||
|
||||
if(len > 8) s = e - 8;
|
||||
|
||||
if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */
|
||||
{
|
||||
while(e > s)
|
||||
{
|
||||
if(e[-2] == 0xff && e[-1] == 0xd9) break;
|
||||
--len; --e; truncate = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data = j2k->tile_data[curtileno];
|
||||
data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char));
|
||||
|
||||
@@ -1548,6 +1595,13 @@ static void j2k_read_rgn(opj_j2k_t *j2k) {
|
||||
};
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
if (compno >= numcomps) {
|
||||
opj_event_msg(j2k->cinfo, EVT_ERROR,
|
||||
"bad component number in RGN (%d out of a maximum of %d)\n",
|
||||
compno, j2k->image->numcomps);
|
||||
return;
|
||||
}
|
||||
|
||||
tcp->tccps[compno].roishift = cio_read(cio, 1); /* SPrgn */
|
||||
}
|
||||
|
||||
@@ -1566,7 +1620,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) {
|
||||
|
||||
static void j2k_read_eoc(opj_j2k_t *j2k) {
|
||||
int i, tileno;
|
||||
bool success;
|
||||
opj_bool success = OPJ_FALSE;
|
||||
|
||||
/* if packets should be decoded */
|
||||
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
|
||||
@@ -1574,12 +1628,17 @@ static void j2k_read_eoc(opj_j2k_t *j2k) {
|
||||
tcd_malloc_decode(tcd, j2k->image, j2k->cp);
|
||||
for (i = 0; i < j2k->cp->tileno_size; i++) {
|
||||
tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
|
||||
tileno = j2k->cp->tileno[i];
|
||||
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
|
||||
opj_free(j2k->tile_data[tileno]);
|
||||
j2k->tile_data[tileno] = NULL;
|
||||
tcd_free_decode_tile(tcd, i);
|
||||
if (success == false) {
|
||||
if (j2k->cp->tileno[i] != -1)
|
||||
{
|
||||
tileno = j2k->cp->tileno[i];
|
||||
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
|
||||
opj_free(j2k->tile_data[tileno]);
|
||||
j2k->tile_data[tileno] = NULL;
|
||||
tcd_free_decode_tile(tcd, i);
|
||||
}
|
||||
else
|
||||
success = OPJ_FALSE;
|
||||
if (success == OPJ_FALSE) {
|
||||
j2k->state |= J2K_STATE_ERR;
|
||||
break;
|
||||
}
|
||||
@@ -1749,6 +1808,14 @@ void j2k_destroy_decompress(opj_j2k_t *j2k) {
|
||||
opj_free(j2k->tile_len);
|
||||
}
|
||||
if(j2k->tile_data != NULL) {
|
||||
if(j2k->cp != NULL) {
|
||||
for (i = 0; i < j2k->cp->tileno_size; i++) {
|
||||
int tileno = j2k->cp->tileno[i];
|
||||
opj_free(j2k->tile_data[tileno]);
|
||||
j2k->tile_data[tileno] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
opj_free(j2k->tile_data);
|
||||
}
|
||||
if(j2k->default_tcp != NULL) {
|
||||
@@ -1834,7 +1901,7 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
||||
if (j2k->cp->correct) {
|
||||
|
||||
int orig_pos = cio_tell(cio);
|
||||
bool status;
|
||||
opj_bool status;
|
||||
|
||||
/* call the corrector */
|
||||
status = jpwl_correct(j2k);
|
||||
@@ -1868,18 +1935,24 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
if (id >> 8 != 0xff) {
|
||||
opj_image_destroy(image);
|
||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
return 0;
|
||||
if(cio_numbytesleft(cio) != 0) /* not end of file reached and no EOC */
|
||||
{
|
||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
opj_image_destroy(image);
|
||||
return 0;
|
||||
}
|
||||
opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
j2k->state = J2K_STATE_NEOC;
|
||||
break;
|
||||
}
|
||||
e = j2k_dec_mstab_lookup(id);
|
||||
// Check if the marker is known
|
||||
/* Check if the marker is known*/
|
||||
if (!(j2k->state & e->states)) {
|
||||
opj_image_destroy(image);
|
||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
|
||||
return 0;
|
||||
}
|
||||
// Check if the decoding is limited to the main header
|
||||
/* Check if the decoding is limited to the main header*/
|
||||
if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) {
|
||||
opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n");
|
||||
return image;
|
||||
@@ -1889,7 +1962,10 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
||||
(*e->handler)(j2k);
|
||||
}
|
||||
if (j2k->state & J2K_STATE_ERR)
|
||||
{
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (j2k->state == J2K_STATE_MT) {
|
||||
break;
|
||||
@@ -1905,7 +1981,6 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
||||
if (j2k->state != J2K_STATE_MT) {
|
||||
opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -1917,9 +1992,10 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre
|
||||
opj_image_t *image = NULL;
|
||||
opj_jpt_msg_header_t header;
|
||||
int position;
|
||||
|
||||
opj_common_ptr cinfo = j2k->cinfo;
|
||||
|
||||
|
||||
OPJ_ARG_NOT_USED(cstr_info);
|
||||
|
||||
j2k->cio = cio;
|
||||
|
||||
/* create an empty image */
|
||||
@@ -1961,9 +2037,15 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre
|
||||
|
||||
id = cio_read(cio, 2);
|
||||
if (id >> 8 != 0xff) {
|
||||
opj_image_destroy(image);
|
||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
return 0;
|
||||
if(cio_numbytesleft(cio) != 0) /* no end of file reached and no EOC */
|
||||
{
|
||||
opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
opj_image_destroy(image);
|
||||
return 0;
|
||||
}
|
||||
opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id);
|
||||
j2k->state = J2K_STATE_NEOC;
|
||||
break;
|
||||
}
|
||||
e = j2k_dec_mstab_lookup(id);
|
||||
if (!(j2k->state & e->states)) {
|
||||
@@ -2110,12 +2192,12 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
int i;
|
||||
|
||||
/* set JPWL on */
|
||||
cp->epc_on = true;
|
||||
cp->info_on = false; /* no informative technique */
|
||||
cp->epc_on = OPJ_TRUE;
|
||||
cp->info_on = OPJ_FALSE; /* no informative technique */
|
||||
|
||||
/* set EPB on */
|
||||
if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
|
||||
cp->epb_on = true;
|
||||
cp->epb_on = OPJ_TRUE;
|
||||
|
||||
cp->hprot_MH = parameters->jpwl_hprot_MH;
|
||||
for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
|
||||
@@ -2136,7 +2218,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
|
||||
/* set ESD writing */
|
||||
if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
|
||||
cp->esd_on = true;
|
||||
cp->esd_on = OPJ_TRUE;
|
||||
|
||||
cp->sens_size = parameters->jpwl_sens_size;
|
||||
cp->sens_addr = parameters->jpwl_sens_addr;
|
||||
@@ -2150,10 +2232,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
}
|
||||
|
||||
/* always set RED writing to false: we are at the encoder */
|
||||
cp->red_on = false;
|
||||
cp->red_on = OPJ_FALSE;
|
||||
|
||||
} else {
|
||||
cp->epc_on = false;
|
||||
cp->epc_on = OPJ_FALSE;
|
||||
}
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
@@ -2226,10 +2308,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
|
||||
if(parameters->cp_cinema)
|
||||
{
|
||||
//Precinct size for lowest frequency subband=128
|
||||
/*Precinct size for lowest frequency subband=128*/
|
||||
tccp->prcw[0] = 7;
|
||||
tccp->prch[0] = 7;
|
||||
//Precinct size at all other resolutions = 256
|
||||
/*Precinct size at all other resolutions = 256*/
|
||||
for (j = 1; j < tccp->numresolutions; j++) {
|
||||
tccp->prcw[j] = 8;
|
||||
tccp->prch[j] = 8;
|
||||
@@ -2271,7 +2353,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
}
|
||||
p++;
|
||||
/*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */
|
||||
} //end for
|
||||
} /*end for*/
|
||||
} else {
|
||||
for (j = 0; j < tccp->numresolutions; j++) {
|
||||
tccp->prcw[j] = 15;
|
||||
@@ -2285,7 +2367,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
|
||||
}
|
||||
}
|
||||
|
||||
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
||||
opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
||||
int tileno, compno;
|
||||
opj_cp_t *cp = NULL;
|
||||
|
||||
@@ -2296,8 +2378,6 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
|
||||
|
||||
cp = j2k->cp;
|
||||
|
||||
/* j2k_dump_cp(stdout, image, cp); */
|
||||
|
||||
/* INDEX >> */
|
||||
j2k->cstr_info = cstr_info;
|
||||
if (cstr_info) {
|
||||
@@ -2394,6 +2474,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
|
||||
/* INDEX >> */
|
||||
if(cstr_info) {
|
||||
cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction;
|
||||
cstr_info->tile[j2k->curtileno].maxmarknum = 10;
|
||||
cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t));
|
||||
cstr_info->tile[j2k->curtileno].marknum = 0;
|
||||
}
|
||||
/* << INDEX */
|
||||
|
||||
@@ -2500,11 +2583,46 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
|
||||
}
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
|
||||
|
||||
if (!cstr_info)
|
||||
return;
|
||||
|
||||
/* expand the list? */
|
||||
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
|
||||
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
|
||||
cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
|
||||
}
|
||||
|
||||
/* add the marker */
|
||||
cstr_info->marker[cstr_info->marknum].type = type;
|
||||
cstr_info->marker[cstr_info->marknum].pos = pos;
|
||||
cstr_info->marker[cstr_info->marknum].len = len;
|
||||
cstr_info->marknum++;
|
||||
|
||||
}
|
||||
|
||||
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
|
||||
|
||||
opj_marker_info_t *marker;
|
||||
|
||||
if (!cstr_info)
|
||||
return;
|
||||
|
||||
/* expand the list? */
|
||||
if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) {
|
||||
cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F);
|
||||
cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum);
|
||||
}
|
||||
|
||||
marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]);
|
||||
|
||||
/* add the marker */
|
||||
marker->type = type;
|
||||
marker->pos = pos;
|
||||
marker->len = len;
|
||||
cstr_info->tile[tileno].marknum++;
|
||||
}
|
||||
|
||||
@@ -265,15 +265,15 @@ typedef struct opj_cp {
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
/** enables writing of EPC in MH, thus activating JPWL */
|
||||
bool epc_on;
|
||||
opj_bool epc_on;
|
||||
/** enables writing of EPB, in case of activated JPWL */
|
||||
bool epb_on;
|
||||
opj_bool epb_on;
|
||||
/** enables writing of ESD, in case of activated JPWL */
|
||||
bool esd_on;
|
||||
opj_bool esd_on;
|
||||
/** enables writing of informative techniques of ESD, in case of activated JPWL */
|
||||
bool info_on;
|
||||
opj_bool info_on;
|
||||
/** enables writing of RED, in case of activated JPWL */
|
||||
bool red_on;
|
||||
opj_bool red_on;
|
||||
/** error protection method for MH (0,1,16,32,37-128) */
|
||||
int hprot_MH;
|
||||
/** tile number of header protection specification (>=0) */
|
||||
@@ -299,7 +299,7 @@ typedef struct opj_cp {
|
||||
/** sensitivity methods for TPHs (-1,0-7) */
|
||||
int sens_TPH[JPWL_MAX_NO_TILESPECS];
|
||||
/** enables JPWL correction at the decoder */
|
||||
bool correct;
|
||||
opj_bool correct;
|
||||
/** expected number of components at the decoder */
|
||||
int exp_comps;
|
||||
/** maximum number of tiles at the decoder */
|
||||
@@ -436,10 +436,8 @@ Encode an image into a JPEG-2000 codestream
|
||||
@param cstr_info Codestream information structure if required, NULL otherwise
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
|
||||
void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||
void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -24,18 +24,18 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/times.h>
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
#include "opj_includes.h"
|
||||
|
||||
double opj_clock(void) {
|
||||
#ifdef WIN32
|
||||
/* WIN32: use QueryPerformance (very accurate) */
|
||||
#ifdef _WIN32
|
||||
/* _WIN32: use QueryPerformance (very accurate) */
|
||||
LARGE_INTEGER freq , t ;
|
||||
/* freq is the clock speed of the CPU */
|
||||
QueryPerformanceFrequency(&freq) ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,11 +46,64 @@
|
||||
#define JP2_COLR 0x636f6c72 /**< Colour specification box */
|
||||
#define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */
|
||||
#define JP2_URL 0x75726c20 /**< URL box */
|
||||
#define JP2_DBTL 0x6474626c /**< ??? */
|
||||
#define JP2_DTBL 0x6474626c /**< Data Reference box */
|
||||
#define JP2_BPCC 0x62706363 /**< Bits per component box */
|
||||
#define JP2_JP2 0x6a703220 /**< File type fields */
|
||||
#define JP2_PCLR 0x70636c72 /**< Palette box */
|
||||
#define JP2_CMAP 0x636d6170 /**< Component Mapping box */
|
||||
#define JP2_CDEF 0x63646566 /**< Channel Definition box */
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/**
|
||||
Channel description: channel index, type, assocation
|
||||
*/
|
||||
typedef struct opj_jp2_cdef_info
|
||||
{
|
||||
unsigned short cn, typ, asoc;
|
||||
} opj_jp2_cdef_info_t;
|
||||
|
||||
/**
|
||||
Channel descriptions and number of descriptions
|
||||
*/
|
||||
typedef struct opj_jp2_cdef
|
||||
{
|
||||
opj_jp2_cdef_info_t *info;
|
||||
unsigned short n;
|
||||
} opj_jp2_cdef_t;
|
||||
|
||||
/**
|
||||
Component mappings: channel index, mapping type, palette index
|
||||
*/
|
||||
typedef struct opj_jp2_cmap_comp
|
||||
{
|
||||
unsigned short cmp;
|
||||
unsigned char mtyp, pcol;
|
||||
} opj_jp2_cmap_comp_t;
|
||||
|
||||
/**
|
||||
Palette data: table entries, palette columns
|
||||
*/
|
||||
typedef struct opj_jp2_pclr
|
||||
{
|
||||
unsigned int *entries;
|
||||
unsigned char *channel_sign;
|
||||
unsigned char *channel_size;
|
||||
opj_jp2_cmap_comp_t *cmap;
|
||||
unsigned short nr_entries, nr_channels;
|
||||
} opj_jp2_pclr_t;
|
||||
|
||||
/**
|
||||
Collector for ICC profile, palette, component mapping, channel description
|
||||
*/
|
||||
typedef struct opj_jp2_color
|
||||
{
|
||||
unsigned char *icc_profile_buf;
|
||||
int icc_profile_len;
|
||||
|
||||
opj_jp2_cdef_t *jp2_cdef;
|
||||
opj_jp2_pclr_t *jp2_pclr;
|
||||
unsigned char jp2_has_colr;
|
||||
} opj_jp2_color_t;
|
||||
|
||||
/**
|
||||
JP2 component
|
||||
@@ -87,6 +140,8 @@ typedef struct opj_jp2 {
|
||||
opj_jp2_comps_t *comps;
|
||||
unsigned int j2k_codestream_offset;
|
||||
unsigned int j2k_codestream_length;
|
||||
opj_bool jpip_on;
|
||||
opj_bool ignore_pclr_cmap_cdef;
|
||||
} opj_jp2_t;
|
||||
|
||||
/**
|
||||
@@ -111,9 +166,10 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio);
|
||||
Read the JP2H box - JP2 Header box (used in MJ2)
|
||||
@param jp2 JP2 handle
|
||||
@param cio Input buffer stream
|
||||
@param ext Collector for profile, cdef and pclr data
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio);
|
||||
opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color);
|
||||
/**
|
||||
Creates a JP2 decompression structure
|
||||
@param cinfo Codec context info
|
||||
@@ -139,7 +195,7 @@ Decode an image from a JPEG-2000 file stream
|
||||
@param cstr_info Codestream information structure if required, NULL otherwise
|
||||
@return Returns a decoded image if successful, returns NULL otherwise
|
||||
*/
|
||||
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
|
||||
opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
|
||||
/**
|
||||
Creates a JP2 compression structure
|
||||
@param cinfo Codec context info
|
||||
@@ -167,7 +223,8 @@ Encode an image into a JPEG-2000 file stream
|
||||
@param cstr_info Codestream information structure if required, NULL otherwise
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -521,22 +521,21 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
|
||||
unsigned int c;
|
||||
unsigned int *ip;
|
||||
unsigned char *end = mqc->end - 1;
|
||||
mqc->buffer = opj_realloc(mqc->buffer, (2 * len + 1) * sizeof(unsigned int));
|
||||
mqc->buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(unsigned int));
|
||||
ip = (unsigned int *) mqc->buffer;
|
||||
|
||||
while (bp != end) {
|
||||
while (bp < end) {
|
||||
c = *(bp + 1);
|
||||
if (*bp == 0xff) {
|
||||
if (c > 0x8f) {
|
||||
*ip = 0x0000ff18;
|
||||
break;
|
||||
} else {
|
||||
bp++;
|
||||
*ip = 0x00000017 | (c << 9);
|
||||
}
|
||||
} else {
|
||||
bp++;
|
||||
*ip = 0x00000018 | (c << 8);
|
||||
}
|
||||
bp++;
|
||||
ip++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -24,17 +24,22 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "opj_includes.h"
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#ifndef OPJ_STATIC
|
||||
BOOL APIENTRY
|
||||
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
|
||||
OPJ_ARG_NOT_USED(lpReserved);
|
||||
OPJ_ARG_NOT_USED(hModule);
|
||||
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH :
|
||||
break;
|
||||
@@ -48,19 +53,19 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* OPJ_STATIC */
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
const char* OPJ_CALLCONV opj_version(void) {
|
||||
return OPENJPEG_VERSION;
|
||||
return PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
|
||||
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t));
|
||||
if(!dinfo) return NULL;
|
||||
dinfo->is_decompressor = true;
|
||||
dinfo->is_decompressor = OPJ_TRUE;
|
||||
switch(format) {
|
||||
case CODEC_J2K:
|
||||
case CODEC_JPT:
|
||||
@@ -120,9 +125,10 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
|
||||
|
||||
parameters->decod_format = -1;
|
||||
parameters->cod_format = -1;
|
||||
parameters->flags = 0;
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
parameters->jpwl_correct = false;
|
||||
parameters->jpwl_correct = OPJ_FALSE;
|
||||
parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
|
||||
parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
|
||||
#endif /* USE_JPWL */
|
||||
@@ -159,7 +165,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci
|
||||
case CODEC_JPT:
|
||||
return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
|
||||
case CODEC_JP2:
|
||||
return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
|
||||
return opj_jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
|
||||
case CODEC_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
@@ -171,7 +177,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci
|
||||
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
|
||||
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t));
|
||||
if(!cinfo) return NULL;
|
||||
cinfo->is_decompressor = false;
|
||||
cinfo->is_decompressor = OPJ_FALSE;
|
||||
switch(format) {
|
||||
case CODEC_J2K:
|
||||
/* get a J2K coder handle */
|
||||
@@ -243,10 +249,10 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
|
||||
parameters->cp_disto_alloc = 0;
|
||||
parameters->cp_fixed_alloc = 0;
|
||||
parameters->cp_fixed_quality = 0;
|
||||
|
||||
parameters->jpip_on = OPJ_FALSE;
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
parameters->jpwl_epc_on = false;
|
||||
parameters->jpwl_epc_on = OPJ_FALSE;
|
||||
parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
|
||||
{
|
||||
int i;
|
||||
@@ -296,7 +302,7 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param
|
||||
}
|
||||
}
|
||||
|
||||
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
|
||||
opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
|
||||
if (index != NULL)
|
||||
opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n"
|
||||
"To extract the index, use the opj_encode_with_info() function.\n"
|
||||
@@ -304,20 +310,20 @@ bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *im
|
||||
return opj_encode_with_info(cinfo, cio, image, NULL);
|
||||
}
|
||||
|
||||
bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
||||
opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
||||
if(cinfo && cio && image) {
|
||||
switch(cinfo->codec_format) {
|
||||
case CODEC_J2K:
|
||||
return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info);
|
||||
case CODEC_JP2:
|
||||
return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
|
||||
return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
|
||||
case CODEC_JPT:
|
||||
case CODEC_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
|
||||
@@ -328,6 +334,7 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
|
||||
opj_free(tile_info->thresh);
|
||||
opj_free(tile_info->packet);
|
||||
opj_free(tile_info->tp);
|
||||
opj_free(tile_info->marker);
|
||||
}
|
||||
opj_free(cstr_info->tile);
|
||||
opj_free(cstr_info->marker);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -32,7 +33,6 @@
|
||||
#ifndef OPENJPEG_H
|
||||
#define OPENJPEG_H
|
||||
|
||||
#define OPENJPEG_VERSION "1.4.0.635"
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
@@ -40,7 +40,7 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
#if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
|
||||
#if defined(OPJ_STATIC) || !defined(_WIN32)
|
||||
#define OPJ_API
|
||||
#define OPJ_CALLCONV
|
||||
#else
|
||||
@@ -53,38 +53,19 @@ that uses this DLL. This way any other project whose source files include this f
|
||||
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
defined with this macro as being exported.
|
||||
*/
|
||||
#ifdef OPJ_EXPORTS
|
||||
#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
|
||||
#define OPJ_API __declspec(dllexport)
|
||||
#else
|
||||
#define OPJ_API __declspec(dllimport)
|
||||
#endif /* OPJ_EXPORTS */
|
||||
#endif /* !OPJ_STATIC || !WIN32 */
|
||||
#endif /* !OPJ_STATIC || !_WIN32 */
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if defined(HAVE_STDBOOL_H)
|
||||
/*
|
||||
The C language implementation does correctly provide the standard header
|
||||
file "stdbool.h".
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
/*
|
||||
The C language implementation does not provide the standard header file
|
||||
"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this
|
||||
braindamage below.
|
||||
*/
|
||||
#if !defined(bool)
|
||||
#define bool int
|
||||
#endif
|
||||
#if !defined(true)
|
||||
#define true 1
|
||||
#endif
|
||||
#if !defined(false)
|
||||
#define false 0
|
||||
#endif
|
||||
#endif
|
||||
#endif /* __cplusplus */
|
||||
typedef int opj_bool;
|
||||
#define OPJ_TRUE 1
|
||||
#define OPJ_FALSE 0
|
||||
|
||||
/* Avoid compile-time warning because parameter is not used */
|
||||
#define OPJ_ARG_NOT_USED(x) (void)(x)
|
||||
/*
|
||||
==========================================================
|
||||
Useful constant definitions
|
||||
@@ -154,14 +135,18 @@ typedef enum COLOR_SPACE {
|
||||
CLRSPC_SYCC = 3 /**< YUV */
|
||||
} OPJ_COLOR_SPACE;
|
||||
|
||||
#define ENUMCS_SRGB 16
|
||||
#define ENUMCS_GRAY 17
|
||||
#define ENUMCS_SYCC 18
|
||||
|
||||
/**
|
||||
Supported codec
|
||||
*/
|
||||
typedef enum CODEC_FORMAT {
|
||||
CODEC_UNKNOWN = -1, /**< place-holder */
|
||||
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
|
||||
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
|
||||
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
|
||||
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
|
||||
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
|
||||
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
|
||||
} OPJ_CODEC_FORMAT;
|
||||
|
||||
/**
|
||||
@@ -244,7 +229,7 @@ Compression parameters
|
||||
*/
|
||||
typedef struct opj_cparameters {
|
||||
/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
|
||||
bool tile_size_on;
|
||||
opj_bool tile_size_on;
|
||||
/** XTOsiz */
|
||||
int cp_tx0;
|
||||
/** YTOsiz */
|
||||
@@ -326,7 +311,7 @@ typedef struct opj_cparameters {
|
||||
/**@name JPWL encoding parameters */
|
||||
/*@{*/
|
||||
/** enables writing of EPC in MH, thus activating JPWL */
|
||||
bool jpwl_epc_on;
|
||||
opj_bool jpwl_epc_on;
|
||||
/** error protection method for MH (0,1,16,32,37-128) */
|
||||
int jpwl_hprot_MH;
|
||||
/** tile number of header protection specification (>=0) */
|
||||
@@ -366,8 +351,12 @@ typedef struct opj_cparameters {
|
||||
char tp_flag;
|
||||
/** MCT (multiple component transform) */
|
||||
char tcp_mct;
|
||||
/** Enable JPIP indexing*/
|
||||
opj_bool jpip_on;
|
||||
} opj_cparameters_t;
|
||||
|
||||
#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
|
||||
|
||||
/**
|
||||
Decompression parameters
|
||||
*/
|
||||
@@ -404,7 +393,7 @@ typedef struct opj_dparameters {
|
||||
/**@name JPWL decoding parameters */
|
||||
/*@{*/
|
||||
/** activates the JPWL correction capabilities */
|
||||
bool jpwl_correct;
|
||||
opj_bool jpwl_correct;
|
||||
/** expected number of components */
|
||||
int jpwl_exp_comps;
|
||||
/** maximum number of tiles */
|
||||
@@ -420,6 +409,7 @@ typedef struct opj_dparameters {
|
||||
*/
|
||||
OPJ_LIMIT_DECODING cp_limit_decoding;
|
||||
|
||||
unsigned int flags;
|
||||
} opj_dparameters_t;
|
||||
|
||||
/** Common fields between JPEG-2000 compression and decompression master structs. */
|
||||
@@ -427,7 +417,7 @@ typedef struct opj_dparameters {
|
||||
#define opj_common_fields \
|
||||
opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\
|
||||
void * client_data; /**< Available for use by application */\
|
||||
bool is_decompressor; /**< So common code can tell which is which */\
|
||||
opj_bool is_decompressor; /**< So common code can tell which is which */\
|
||||
OPJ_CODEC_FORMAT codec_format; /**< selected codec */\
|
||||
void *j2k_handle; /**< pointer to the J2K codec */\
|
||||
void *jp2_handle; /**< pointer to the JP2 codec */\
|
||||
@@ -555,6 +545,10 @@ typedef struct opj_image {
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
/** image components */
|
||||
opj_image_comp_t *comps;
|
||||
/** 'restricted' ICC profile */
|
||||
unsigned char *icc_profile_buf;
|
||||
/** size of ICC profile */
|
||||
int icc_profile_len;
|
||||
} opj_image_t;
|
||||
|
||||
/**
|
||||
@@ -601,6 +595,21 @@ typedef struct opj_packet_info {
|
||||
double disto;
|
||||
} opj_packet_info_t;
|
||||
|
||||
|
||||
/* UniPG>> */
|
||||
/**
|
||||
Marker structure
|
||||
*/
|
||||
typedef struct opj_marker_info_t {
|
||||
/** marker type */
|
||||
unsigned short int type;
|
||||
/** position in codestream */
|
||||
int pos;
|
||||
/** length, marker val included */
|
||||
int len;
|
||||
} opj_marker_info_t;
|
||||
/* <<UniPG */
|
||||
|
||||
/**
|
||||
Index structure : Information concerning tile-parts
|
||||
*/
|
||||
@@ -645,26 +654,18 @@ typedef struct opj_tile_info {
|
||||
int numpix;
|
||||
/** add fixed_quality */
|
||||
double distotile;
|
||||
/** number of markers */
|
||||
int marknum;
|
||||
/** list of markers */
|
||||
opj_marker_info_t *marker;
|
||||
/** actual size of markers array */
|
||||
int maxmarknum;
|
||||
/** number of tile parts */
|
||||
int num_tps;
|
||||
/** information concerning tile parts */
|
||||
opj_tp_info_t *tp;
|
||||
} opj_tile_info_t;
|
||||
|
||||
/* UniPG>> */
|
||||
/**
|
||||
Marker structure
|
||||
*/
|
||||
typedef struct opj_marker_info_t {
|
||||
/** marker type */
|
||||
unsigned short int type;
|
||||
/** position in codestream */
|
||||
int pos;
|
||||
/** length, marker val included */
|
||||
int len;
|
||||
} opj_marker_info_t;
|
||||
/* <<UniPG */
|
||||
|
||||
/**
|
||||
Index structure of the codestream
|
||||
*/
|
||||
@@ -883,13 +884,13 @@ Setup the encoder parameters using the current image and using user parameters.
|
||||
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
|
||||
/**
|
||||
Encode an image into a JPEG-2000 codestream
|
||||
@param cinfo compressor handle
|
||||
3@param cinfo compressor handle
|
||||
@param cio Output buffer stream
|
||||
@param image Image to encode
|
||||
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
|
||||
OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
|
||||
/**
|
||||
Encode an image into a JPEG-2000 codestream and extract the codestream information
|
||||
@param cinfo compressor handle
|
||||
@@ -898,13 +899,14 @@ Encode an image into a JPEG-2000 codestream and extract the codestream informati
|
||||
@param cstr_info Codestream information structure if needed afterwards, NULL otherwise
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||
/**
|
||||
Destroy Codestream information after compression or decompression
|
||||
@param cstr_info Codestream information structure
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
36
indra/libopenjpeg/opj_config.h
Normal file
36
indra/libopenjpeg/opj_config.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* create config.h for CMake */
|
||||
#define PACKAGE_VERSION "1.5.2"
|
||||
|
||||
#define HAVE_INTTYPES_H
|
||||
#define HAVE_MEMORY_H
|
||||
#define HAVE_STDINT_H
|
||||
#define HAVE_STDLIB_H
|
||||
#define HAVE_STRINGS_H
|
||||
#define HAVE_STRING_H
|
||||
#define HAVE_SYS_STAT_H
|
||||
#define HAVE_SYS_TYPES_H
|
||||
#define HAVE_UNISTD_H
|
||||
/* #define HAVE_LIBPNG */
|
||||
/* #define HAVE_PNG_H */
|
||||
/* #define HAVE_LIBTIFF */
|
||||
/* #define HAVE_TIFF_H */
|
||||
|
||||
/* #undef HAVE_LIBLCMS1 */
|
||||
/* #undef HAVE_LIBLCMS2 */
|
||||
/* #undef HAVE_LCMS1_H */
|
||||
/* #undef HAVE_LCMS2_H */
|
||||
|
||||
/* Byte order. */
|
||||
/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
|
||||
* __LITTLE_ENDIAN__ to match the endianness of the architecture being
|
||||
* compiled for. This is not necessarily the same as the architecture of the
|
||||
* machine doing the building. In order to support Universal Binaries on
|
||||
* Mac OS X, we prefer those defines to decide the endianness.
|
||||
* On other platforms we use the result of the TRY_RUN. */
|
||||
#if !defined(__APPLE__)
|
||||
/* #undef OPJ_BIG_ENDIAN */
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
# define OPJ_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -89,20 +89,25 @@ Most compilers implement their own version of this keyword ...
|
||||
/* MSVC and Borland C do not have lrintf */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
static INLINE long lrintf(float f){
|
||||
int i;
|
||||
|
||||
_asm{
|
||||
fld f
|
||||
fistp i
|
||||
};
|
||||
|
||||
return i;
|
||||
#ifdef _M_X64
|
||||
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
|
||||
#else
|
||||
int i;
|
||||
|
||||
_asm{
|
||||
fld f
|
||||
fistp i
|
||||
};
|
||||
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "j2k_lib.h"
|
||||
#include "opj_malloc.h"
|
||||
#include "event.h"
|
||||
#include "bio.h"
|
||||
#include "cio.h"
|
||||
|
||||
#include "image.h"
|
||||
@@ -123,9 +128,12 @@ static INLINE long lrintf(float f){
|
||||
#include "int.h"
|
||||
#include "fix.h"
|
||||
|
||||
#include "cidx_manager.h"
|
||||
#include "indexbox_manager.h"
|
||||
|
||||
/* JPWL>> */
|
||||
#ifdef USE_JPWL
|
||||
#include "../jpwl/jpwl.h"
|
||||
#include "./jpwl/jpwl.h"
|
||||
#endif /* USE_JPWL */
|
||||
/* <<JPWL */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -69,7 +69,7 @@ Allocate memory aligned to a 16 byte boundry
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
@@ -80,11 +80,13 @@ Allocate memory aligned to a 16 byte boundry
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not WIN32 */
|
||||
#else /* Not _WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
#elif defined(__FreeBSD__)
|
||||
#define HAVE_POSIX_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__)
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@@ -130,22 +132,22 @@ Allocate memory aligned to a 16 byte boundry
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@param memblock Pointer to previously allocated memory block
|
||||
@param size New size in bytes
|
||||
@param m Pointer to previously allocated memory block
|
||||
@param s New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * _Memory, size_t NewSize);
|
||||
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param memblock Previously allocated memory block to be freed
|
||||
@param m Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * _Memory);
|
||||
void OPJ_CALLCONV opj_free(void * m);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
|
||||
170
indra/libopenjpeg/phix_manager.c
Normal file
170
indra/libopenjpeg/phix_manager.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.c from 2KAN indexer
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "opj_includes.h"
|
||||
|
||||
/*
|
||||
* Write faix box of phix
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] compno component number
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] EPHused true if if EPH option used
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of faix box
|
||||
*/
|
||||
int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
|
||||
|
||||
int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp=0, compno, i;
|
||||
opj_jp2_box_t *box;
|
||||
|
||||
box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
for( i=0;i<2;i++){
|
||||
if (i) cio_seek( cio, lenp);
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_PHIX, 4); /* PHIX */
|
||||
|
||||
write_manf( i, cstr_info.numcomps, box, cio);
|
||||
|
||||
for( compno=0; compno<cstr_info.numcomps; compno++){
|
||||
box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
|
||||
box[compno].type = JPIP_FAIX;
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
opj_free(box);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
|
||||
opj_tile_info_t *tile_Idx;
|
||||
opj_packet_info_t packet;
|
||||
int resno, precno, layno, num_packet;
|
||||
int numOfres, numOfprec, numOflayers;
|
||||
packet.end_ph_pos = packet.start_pos = -1;
|
||||
(void)EPHused; /* unused ? */
|
||||
|
||||
if( j2klen > pow( 2.0, 32)){
|
||||
size_of_coding = 8;
|
||||
version = 1;
|
||||
}
|
||||
else{
|
||||
size_of_coding = 4;
|
||||
version = 0;
|
||||
}
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
|
||||
cio_write( cio, version,1); /* Version 0 = 4 bytes */
|
||||
|
||||
nmax = 0;
|
||||
for( i=0; i<=cstr_info.numdecompos[compno]; i++)
|
||||
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
|
||||
|
||||
cio_write( cio, nmax, size_of_coding); /* NMAX */
|
||||
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
|
||||
|
||||
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
|
||||
tile_Idx = &cstr_info.tile[ tileno];
|
||||
|
||||
num_packet = 0;
|
||||
numOfres = cstr_info.numdecompos[compno] + 1;
|
||||
|
||||
for( resno=0; resno<numOfres ; resno++){
|
||||
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
|
||||
for( precno=0; precno<numOfprec; precno++){
|
||||
numOflayers = cstr_info.numlayers;
|
||||
for( layno=0; layno<numOflayers; layno++){
|
||||
|
||||
switch ( cstr_info.prog){
|
||||
case LRCP:
|
||||
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
|
||||
break;
|
||||
case RLCP:
|
||||
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
|
||||
break;
|
||||
case RPCL:
|
||||
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
|
||||
break;
|
||||
case PCRL:
|
||||
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
|
||||
break;
|
||||
case CPRL:
|
||||
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "failed to ppix indexing\n");
|
||||
}
|
||||
|
||||
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
|
||||
cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */
|
||||
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
while( num_packet < nmax){
|
||||
cio_write( cio, 0, size_of_coding); /* start position */
|
||||
cio_write( cio, 0, size_of_coding); /* length */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -43,31 +43,31 @@ Get next packet in layer-resolution-component-precinct order.
|
||||
@param pi packet iterator to modify
|
||||
@return returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
static bool pi_next_lrcp(opj_pi_iterator_t * pi);
|
||||
static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi);
|
||||
/**
|
||||
Get next packet in resolution-layer-component-precinct order.
|
||||
@param pi packet iterator to modify
|
||||
@return returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
static bool pi_next_rlcp(opj_pi_iterator_t * pi);
|
||||
static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi);
|
||||
/**
|
||||
Get next packet in resolution-precinct-component-layer order.
|
||||
@param pi packet iterator to modify
|
||||
@return returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
static bool pi_next_rpcl(opj_pi_iterator_t * pi);
|
||||
static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi);
|
||||
/**
|
||||
Get next packet in precinct-component-resolution-layer order.
|
||||
@param pi packet iterator to modify
|
||||
@return returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
static bool pi_next_pcrl(opj_pi_iterator_t * pi);
|
||||
static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi);
|
||||
/**
|
||||
Get next packet in component-precinct-resolution-layer order.
|
||||
@param pi packet iterator to modify
|
||||
@return returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
static bool pi_next_cprl(opj_pi_iterator_t * pi);
|
||||
static opj_bool pi_next_cprl(opj_pi_iterator_t * pi);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -79,7 +79,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi);
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
|
||||
static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi) {
|
||||
opj_pi_comp_t *comp = NULL;
|
||||
opj_pi_resolution_t *res = NULL;
|
||||
long index = 0;
|
||||
@@ -108,7 +108,7 @@ static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
|
||||
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
|
||||
if (!pi->include[index]) {
|
||||
pi->include[index] = 1;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
LABEL_SKIP:;
|
||||
}
|
||||
@@ -116,10 +116,10 @@ LABEL_SKIP:;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
|
||||
static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi) {
|
||||
opj_pi_comp_t *comp = NULL;
|
||||
opj_pi_resolution_t *res = NULL;
|
||||
long index = 0;
|
||||
@@ -147,7 +147,7 @@ static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
|
||||
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
|
||||
if (!pi->include[index]) {
|
||||
pi->include[index] = 1;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
LABEL_SKIP:;
|
||||
}
|
||||
@@ -155,10 +155,10 @@ LABEL_SKIP:;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
|
||||
static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi) {
|
||||
opj_pi_comp_t *comp = NULL;
|
||||
opj_pi_resolution_t *res = NULL;
|
||||
long index = 0;
|
||||
@@ -229,7 +229,7 @@ if (!pi->tp_on){
|
||||
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
|
||||
if (!pi->include[index]) {
|
||||
pi->include[index] = 1;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
LABEL_SKIP:;
|
||||
}
|
||||
@@ -238,10 +238,10 @@ LABEL_SKIP:;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
|
||||
static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi) {
|
||||
opj_pi_comp_t *comp = NULL;
|
||||
opj_pi_resolution_t *res = NULL;
|
||||
long index = 0;
|
||||
@@ -310,7 +310,7 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
|
||||
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
|
||||
if (!pi->include[index]) {
|
||||
pi->include[index] = 1;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
LABEL_SKIP:;
|
||||
}
|
||||
@@ -319,10 +319,10 @@ LABEL_SKIP:;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
static bool pi_next_cprl(opj_pi_iterator_t * pi) {
|
||||
static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) {
|
||||
opj_pi_comp_t *comp = NULL;
|
||||
opj_pi_resolution_t *res = NULL;
|
||||
long index = 0;
|
||||
@@ -389,7 +389,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) {
|
||||
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
|
||||
if (!pi->include[index]) {
|
||||
pi->include[index] = 1;
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
LABEL_SKIP:;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ LABEL_SKIP:;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -707,7 +707,7 @@ void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
|
||||
}
|
||||
}
|
||||
|
||||
bool pi_next(opj_pi_iterator_t * pi) {
|
||||
opj_bool pi_next(opj_pi_iterator_t * pi) {
|
||||
switch (pi->poc.prg) {
|
||||
case LRCP:
|
||||
return pi_next_lrcp(pi);
|
||||
@@ -720,13 +720,13 @@ bool pi_next(opj_pi_iterator_t * pi) {
|
||||
case CPRL:
|
||||
return pi_next_cprl(pi);
|
||||
case PROG_UNKNOWN:
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
|
||||
opj_bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
|
||||
char prog[4];
|
||||
int i;
|
||||
int incr_top=1,resetX=0;
|
||||
@@ -748,7 +748,7 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
|
||||
case RPCL: strncpy(prog, "RPCL",4);
|
||||
break;
|
||||
case PROG_UNKNOWN:
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
|
||||
@@ -958,6 +958,6 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,12 +115,14 @@ Modify the packet iterator for enabling tile part generation
|
||||
@param pi Handle to the packet iterator generated in pi_initialise_encode
|
||||
@param cp Coding parameters
|
||||
@param tileno Number that identifies the tile for which to list the packets
|
||||
@param pino Iterator index for pi
|
||||
@param tpnum Tile part number of the current tile
|
||||
@param tppos The position of the tile part flag in the progression order
|
||||
@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
|
||||
@param cur_totnum_tp The total number of tile parts in the current tile
|
||||
@return Returns true if an error is detected
|
||||
*/
|
||||
bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
|
||||
opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
|
||||
/**
|
||||
Create a packet iterator for Decoder
|
||||
@param image Raw image for which the packets will be listed
|
||||
@@ -145,7 +147,7 @@ Modify the packet iterator to point to the next packet
|
||||
@param pi Packet iterator to modify
|
||||
@return Returns false if pi pointed to the last packet or else returns true
|
||||
*/
|
||||
bool pi_next(opj_pi_iterator_t * pi);
|
||||
opj_bool pi_next(opj_pi_iterator_t * pi);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
|
||||
173
indra/libopenjpeg/ppix_manager.c
Normal file
173
indra/libopenjpeg/ppix_manager.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.c from 2KAN indexer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "opj_includes.h"
|
||||
|
||||
/*
|
||||
* Write faix box of ppix
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] compno component number
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] EPHused true if if EPH option used
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of faix box
|
||||
*/
|
||||
int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
|
||||
|
||||
int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp, compno, i;
|
||||
opj_jp2_box_t *box;
|
||||
|
||||
/* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
|
||||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
for (i=0;i<2;i++){
|
||||
if (i) cio_seek( cio, lenp);
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_PPIX, 4); /* PPIX */
|
||||
|
||||
write_manf( i, cstr_info.numcomps, box, cio);
|
||||
|
||||
for (compno=0; compno<cstr_info.numcomps; compno++){
|
||||
box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
|
||||
box[compno].type = JPIP_FAIX;
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
opj_free(box);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
|
||||
opj_tile_info_t *tile_Idx;
|
||||
opj_packet_info_t packet;
|
||||
int resno, precno, layno, num_packet;
|
||||
int numOfres, numOfprec, numOflayers;
|
||||
packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
|
||||
(void)EPHused; /* unused ? */
|
||||
|
||||
if( j2klen > pow( 2.0, 32)){
|
||||
size_of_coding = 8;
|
||||
version = 1;
|
||||
}
|
||||
else{
|
||||
size_of_coding = 4;
|
||||
version = 0;
|
||||
}
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
|
||||
cio_write( cio, version, 1); /* Version 0 = 4 bytes */
|
||||
|
||||
nmax = 0;
|
||||
for( i=0; i<=cstr_info.numdecompos[compno]; i++)
|
||||
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
|
||||
|
||||
cio_write( cio, nmax, size_of_coding); /* NMAX */
|
||||
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
|
||||
|
||||
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
|
||||
tile_Idx = &cstr_info.tile[ tileno];
|
||||
|
||||
num_packet=0;
|
||||
numOfres = cstr_info.numdecompos[compno] + 1;
|
||||
|
||||
for( resno=0; resno<numOfres ; resno++){
|
||||
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
|
||||
for( precno=0; precno<numOfprec; precno++){
|
||||
numOflayers = cstr_info.numlayers;
|
||||
for( layno=0; layno<numOflayers; layno++){
|
||||
|
||||
switch ( cstr_info.prog){
|
||||
case LRCP:
|
||||
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
|
||||
break;
|
||||
case RLCP:
|
||||
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
|
||||
break;
|
||||
case RPCL:
|
||||
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
|
||||
break;
|
||||
case PCRL:
|
||||
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
|
||||
break;
|
||||
case CPRL:
|
||||
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "failed to ppix indexing\n");
|
||||
}
|
||||
|
||||
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
|
||||
cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
|
||||
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while( num_packet < nmax){ /* PADDING */
|
||||
cio_write( cio, 0, size_of_coding); /* start position */
|
||||
cio_write( cio, 0, size_of_coding); /* length */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -123,20 +123,20 @@ static void t1_enc_refpass_step(
|
||||
/**
|
||||
Decode refinement pass
|
||||
*/
|
||||
static void INLINE t1_dec_refpass_step_raw(
|
||||
static INLINE void t1_dec_refpass_step_raw(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
int *datap,
|
||||
int poshalf,
|
||||
int neghalf,
|
||||
int vsc);
|
||||
static void INLINE t1_dec_refpass_step_mqc(
|
||||
static INLINE void t1_dec_refpass_step_mqc(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
int *datap,
|
||||
int poshalf,
|
||||
int neghalf);
|
||||
static void INLINE t1_dec_refpass_step_mqc_vsc(
|
||||
static INLINE void t1_dec_refpass_step_mqc_vsc(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
int *datap,
|
||||
@@ -240,6 +240,7 @@ Encode 1 code-block
|
||||
@param stepsize
|
||||
@param cblksty Code-block style
|
||||
@param numcomps
|
||||
@param mct
|
||||
@param tile
|
||||
*/
|
||||
static void t1_encode_cblk(
|
||||
@@ -381,9 +382,10 @@ static INLINE void t1_dec_sigpass_step_raw(
|
||||
int vsc)
|
||||
{
|
||||
int v, flag;
|
||||
|
||||
opj_raw_t *raw = t1->raw; /* RAW component */
|
||||
|
||||
OPJ_ARG_NOT_USED(orient);
|
||||
|
||||
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
||||
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
||||
if (raw_decode(raw)) {
|
||||
@@ -822,9 +824,10 @@ static void t1_dec_clnpass_step_partial(
|
||||
int oneplushalf)
|
||||
{
|
||||
int v, flag;
|
||||
|
||||
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
||||
|
||||
OPJ_ARG_NOT_USED(orient);
|
||||
|
||||
flag = *flagsp;
|
||||
mqc_setcurctx(mqc, t1_getctxno_sc(flag));
|
||||
v = mqc_decode(mqc) ^ t1_getspb(flag);
|
||||
@@ -1088,34 +1091,21 @@ static double t1_getwmsedec(
|
||||
int numcomps,
|
||||
int mct)
|
||||
{
|
||||
double w1 = 1, w2, wmsedec;
|
||||
|
||||
// Prevent running an MCT on more than 3 components. NB openjpeg v2.0 will support this via
|
||||
// custom MCT tables that can be passed as encode parameters, 1.3 cannot support this as it
|
||||
// uses a static table of 3 entries and there for can only cope with 3 components with out an
|
||||
// array overflow
|
||||
|
||||
if(numcomps==3) {
|
||||
if (qmfbid == 1) {
|
||||
w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0;
|
||||
} else {
|
||||
w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
double w1, w2, wmsedec;
|
||||
if (qmfbid == 1) {
|
||||
w1 = (mct && numcomps==3) ? mct_getnorm(compno) : 1.0;
|
||||
w2 = dwt_getnorm(level, orient);
|
||||
} else { /* if (qmfbid == 0) */
|
||||
w1 = (mct && numcomps==3) ? mct_getnorm_real(compno) : 1.0;
|
||||
w2 = dwt_getnorm_real(level, orient);
|
||||
}
|
||||
|
||||
wmsedec = w1 * w2 * stepsize * (1 << bpno);
|
||||
wmsedec *= wmsedec * nmsedec / 8192.0;
|
||||
|
||||
return wmsedec;
|
||||
}
|
||||
|
||||
static bool allocate_buffers(
|
||||
static opj_bool allocate_buffers(
|
||||
opj_t1_t *t1,
|
||||
int w,
|
||||
int h)
|
||||
@@ -1127,7 +1117,7 @@ static bool allocate_buffers(
|
||||
opj_aligned_free(t1->data);
|
||||
t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int));
|
||||
if(!t1->data){
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
t1->datasize=datasize;
|
||||
}
|
||||
@@ -1140,7 +1130,7 @@ static bool allocate_buffers(
|
||||
opj_aligned_free(t1->flags);
|
||||
t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
|
||||
if(!t1->flags){
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
t1->flagssize=flagssize;
|
||||
}
|
||||
@@ -1149,7 +1139,7 @@ static bool allocate_buffers(
|
||||
t1->w=w;
|
||||
t1->h=h;
|
||||
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
/** mod fixed_quality */
|
||||
@@ -1425,6 +1415,7 @@ void t1_encode_cblks(
|
||||
|
||||
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
||||
opj_tcd_band_t* restrict band = &res->bands[bandno];
|
||||
int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192));
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
||||
opj_tcd_precinct_t *prc = &band->precincts[precno];
|
||||
@@ -1475,7 +1466,7 @@ void t1_encode_cblks(
|
||||
datap[(j * cblk_w) + i] =
|
||||
fix_mul(
|
||||
tmp,
|
||||
8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS);
|
||||
bandconst) >> (11 - T1_NMSEDEC_FRACBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1586,6 +1577,7 @@ void t1_decode_cblks(
|
||||
opj_free(cblk->segs);
|
||||
} /* cblkno */
|
||||
opj_free(precinct->cblks.dec);
|
||||
precinct->cblks.dec = NULL;
|
||||
} /* precno */
|
||||
} /* bandno */
|
||||
} /* resno */
|
||||
|
||||
@@ -135,8 +135,8 @@ void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
|
||||
/**
|
||||
Decode the code-blocks of a tile
|
||||
@param t1 T1 handle
|
||||
@param tile The tile to decode
|
||||
@param tcp Tile coding parameters
|
||||
@param tilec The tile to decode
|
||||
@param tccp Tile coding parameters
|
||||
*/
|
||||
void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
@@ -59,11 +59,12 @@ Encode a packet of a tile to a destination buffer
|
||||
*/
|
||||
static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_codestream_info_t *cstr_info, int tileno);
|
||||
/**
|
||||
@param seg
|
||||
@param cblk
|
||||
@param index
|
||||
@param cblksty
|
||||
@param first
|
||||
*/
|
||||
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
|
||||
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
|
||||
/**
|
||||
Decode a packet of a tile from a source buffer
|
||||
@param t2 T2 handle
|
||||
@@ -72,6 +73,7 @@ Decode a packet of a tile from a source buffer
|
||||
@param tile Tile for which to write the packets
|
||||
@param tcp Tile coding parameters
|
||||
@param pi Packet identity
|
||||
@param pack_info Packet information
|
||||
@return
|
||||
*/
|
||||
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
|
||||
@@ -147,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||
c[1] = 145;
|
||||
c[2] = 0;
|
||||
c[3] = 4;
|
||||
c[4] = (tile->packno % 65536) / 256;
|
||||
c[5] = (tile->packno % 65536) % 256;
|
||||
c[4] = (unsigned char)((tile->packno % 65536) / 256);
|
||||
c[5] = (unsigned char)((tile->packno % 65536) % 256);
|
||||
c += 6;
|
||||
}
|
||||
/* </SOP> */
|
||||
@@ -253,8 +255,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||
/* </EPH> */
|
||||
|
||||
/* << INDEX */
|
||||
// End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value
|
||||
/* End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value */
|
||||
if(cstr_info && cstr_info->index_write) {
|
||||
opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
|
||||
info_PK->end_ph_pos = (int)(c - dest);
|
||||
@@ -294,9 +296,17 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
|
||||
return (c - dest);
|
||||
}
|
||||
|
||||
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
|
||||
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
|
||||
opj_tcd_seg_t* seg;
|
||||
cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
|
||||
opj_tcd_seg_t* segs;
|
||||
segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
|
||||
|
||||
if (segs == NULL)
|
||||
{
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
cblk->segs = segs;
|
||||
|
||||
seg = &cblk->segs[index];
|
||||
seg->data = NULL;
|
||||
seg->dataindex = 0;
|
||||
@@ -314,6 +324,8 @@ static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int fi
|
||||
} else {
|
||||
seg->maxpasses = 109;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
|
||||
@@ -401,8 +413,8 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
}
|
||||
|
||||
/* << INDEX */
|
||||
// End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value
|
||||
/* End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value*/
|
||||
if(pack_info) {
|
||||
pack_info->end_ph_pos = (int)(c - src);
|
||||
}
|
||||
@@ -460,12 +472,22 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
cblk->numlenbits += increment;
|
||||
segno = 0;
|
||||
if (!cblk->numsegs) {
|
||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1);
|
||||
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1))
|
||||
{
|
||||
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
bio_destroy(bio);
|
||||
return -999;
|
||||
}
|
||||
} else {
|
||||
segno = cblk->numsegs - 1;
|
||||
if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
|
||||
++segno;
|
||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
|
||||
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
|
||||
{
|
||||
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
bio_destroy(bio);
|
||||
return -999;
|
||||
}
|
||||
}
|
||||
}
|
||||
n = cblk->numnewpasses;
|
||||
@@ -476,7 +498,12 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
n -= cblk->segs[segno].numnewpasses;
|
||||
if (n > 0) {
|
||||
++segno;
|
||||
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
|
||||
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
|
||||
{
|
||||
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
bio_destroy(bio);
|
||||
return -999;
|
||||
}
|
||||
}
|
||||
} while (n > 0);
|
||||
}
|
||||
@@ -494,14 +521,15 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
|
||||
opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n");
|
||||
return -999;
|
||||
} else {
|
||||
hd += 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* << INDEX */
|
||||
// End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value
|
||||
/* End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value*/
|
||||
if(pack_info) {
|
||||
pack_info->end_ph_pos = (int)(hd - src);
|
||||
}
|
||||
@@ -565,7 +593,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char*));
|
||||
cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char));
|
||||
memcpy(cblk->data + cblk->len, c, seg->newlen);
|
||||
if (seg->numpasses == 0) {
|
||||
seg->data = &cblk->data;
|
||||
@@ -659,8 +687,8 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
|
||||
info_PK->start_pos = ((cp->tp_on | tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
|
||||
}
|
||||
info_PK->end_pos = info_PK->start_pos + e - 1;
|
||||
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
|
||||
// to start of packet is incremented by value of start of packet
|
||||
info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance
|
||||
// to start of packet is incremented by value of start of packet*/
|
||||
}
|
||||
|
||||
cstr_info->packno++;
|
||||
@@ -711,7 +739,11 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
||||
} else {
|
||||
e = 0;
|
||||
}
|
||||
|
||||
if(e == -999)
|
||||
{
|
||||
pi_destroy(pi, cp, tileno);
|
||||
return -999;
|
||||
}
|
||||
/* progression in resolution */
|
||||
image->comps[pi[pino].compno].resno_decoded =
|
||||
(e > 0) ?
|
||||
@@ -725,8 +757,9 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
||||
opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
|
||||
if (!cstr_info->packno) {
|
||||
info_PK->start_pos = info_TL->end_header + 1;
|
||||
} else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ // New tile part
|
||||
info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part
|
||||
} else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ /* New tile part*/
|
||||
info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part*/
|
||||
info_TL->tp[curtp].tp_start_pack = tp_start_packno;
|
||||
tp_start_packno = cstr_info->packno;
|
||||
curtp++;
|
||||
info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header+1;
|
||||
@@ -734,8 +767,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
||||
info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
|
||||
}
|
||||
info_PK->end_pos = info_PK->start_pos + e - 1;
|
||||
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
|
||||
// to start of packet is incremented by value of start of packet
|
||||
info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance
|
||||
// to start of packet is incremented by value of start of packet*/
|
||||
cstr_info->packno++;
|
||||
}
|
||||
/* << INDEX */
|
||||
@@ -749,7 +782,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
||||
}
|
||||
/* INDEX >> */
|
||||
if(cstr_info) {
|
||||
cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in last tile-part
|
||||
cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part*/
|
||||
cstr_info->tile[tileno].tp[curtp].tp_start_pack = tp_start_packno;
|
||||
}
|
||||
/* << INDEX */
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ Encode the packets of a tile to a destination buffer
|
||||
@param cstr_info Codestream information structure
|
||||
@param tpnum Tile part number of the current tile
|
||||
@param tppos The position of the tile part flag in the progression order
|
||||
@param pino
|
||||
@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
|
||||
@param cur_totnum_tp The total number of tile parts in the current tile
|
||||
*/
|
||||
@@ -78,6 +79,7 @@ Decode the packets of a tile from a source buffer
|
||||
@param len length of the source buffer
|
||||
@param tileno number that identifies the tile for which to decode the packets
|
||||
@param tile tile for which to decode the packets
|
||||
@param cstr_info Codestream information structure
|
||||
*/
|
||||
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info);
|
||||
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _ISOC99_SOURCE /* lrintf is C99 */
|
||||
#include "opj_includes.h"
|
||||
|
||||
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
|
||||
int tileno, compno, resno, bandno, precno;//, cblkno;
|
||||
int tileno, compno, resno, bandno, precno;/*, cblkno;*/
|
||||
|
||||
fprintf(fd, "image {\n");
|
||||
fprintf(fd, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n",
|
||||
@@ -290,6 +291,7 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
|
||||
for (i = 0; i < res->pw * res->ph * 3; i++) {
|
||||
band->precincts[i].imsbtree = NULL;
|
||||
band->precincts[i].incltree = NULL;
|
||||
band->precincts[i].cblks.enc = NULL;
|
||||
}
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; precno++) {
|
||||
@@ -332,8 +334,10 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
|
||||
cblk->y0 = int_max(cblkystart, prc->y0);
|
||||
cblk->x1 = int_min(cblkxend, prc->x1);
|
||||
cblk->y1 = int_min(cblkyend, prc->y1);
|
||||
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
|
||||
cblk->data = (unsigned char*) opj_calloc(9728+2, sizeof(unsigned char));
|
||||
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
||||
cblk->data[0] = 0;
|
||||
cblk->data[1] = 0;
|
||||
cblk->data += 2;
|
||||
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
||||
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
||||
@@ -593,6 +597,8 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur
|
||||
cblk->y1 = int_min(cblkyend, prc->y1);
|
||||
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
|
||||
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
|
||||
cblk->data[0] = 0;
|
||||
cblk->data[1] = 0;
|
||||
cblk->data += 2;
|
||||
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
||||
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
||||
@@ -613,7 +619,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
|
||||
tcd->image = image;
|
||||
tcd->tcd_image->tw = cp->tw;
|
||||
tcd->tcd_image->th = cp->th;
|
||||
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tcd_tile_t));
|
||||
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(cp->tw * cp->th, sizeof(opj_tcd_tile_t));
|
||||
|
||||
/*
|
||||
Allocate place to store the decoded data = final image
|
||||
@@ -656,7 +662,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
|
||||
tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy);
|
||||
|
||||
x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0);
|
||||
y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->x0);
|
||||
y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->y0);
|
||||
x1 = j == 0 ? tilec->x1 : int_max(x1, (unsigned int) tilec->x1);
|
||||
y1 = j == 0 ? tilec->y1 : int_max(y1, (unsigned int) tilec->y1);
|
||||
}
|
||||
@@ -676,6 +682,8 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
|
||||
opj_tcp_t *tcp;
|
||||
opj_tcd_tile_t *tile;
|
||||
|
||||
OPJ_ARG_NOT_USED(cstr_info);
|
||||
|
||||
tcd->cp = cp;
|
||||
|
||||
tcp = &(cp->tcps[cp->tileno[tileno]]);
|
||||
@@ -687,6 +695,12 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
|
||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
|
||||
if (tccp->numresolutions <= 0)
|
||||
{
|
||||
cp->tileno[tileno] = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
/* border of each tile component (global) */
|
||||
tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
|
||||
tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
|
||||
@@ -997,7 +1011,7 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
|
||||
}
|
||||
}
|
||||
|
||||
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
|
||||
opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
|
||||
int compno, resno, bandno, precno, cblkno, passno, layno;
|
||||
double min, max;
|
||||
double cumdisto[100]; /* fixed_quality */
|
||||
@@ -1149,7 +1163,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if(cstr_info) { /* Threshold for Marcela Index */
|
||||
@@ -1161,7 +1175,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
|
||||
cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
|
||||
}
|
||||
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
|
||||
@@ -1313,7 +1327,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op
|
||||
return l;
|
||||
}
|
||||
|
||||
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
|
||||
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
|
||||
int l;
|
||||
int compno;
|
||||
int eof = 0;
|
||||
@@ -1349,7 +1363,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
}
|
||||
else {
|
||||
cstr_info->tile[tileno].pdx[resno] = 15;
|
||||
cstr_info->tile[tileno].pdx[resno] = 15;
|
||||
cstr_info->tile[tileno].pdy[resno] = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1373,14 +1387,24 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
|
||||
t1_time = opj_clock(); /* time needed to decode a tile */
|
||||
t1 = t1_create(tcd->cinfo);
|
||||
if (t1 == NULL)
|
||||
{
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
t1_destroy(t1);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
for (compno = 0; compno < tile->numcomps; ++compno) {
|
||||
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
||||
/* The +3 is headroom required by the vectorized DWT */
|
||||
tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
|
||||
if(tilec->data)
|
||||
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
|
||||
else
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: tile size invalid\n");
|
||||
if (tilec->data == NULL)
|
||||
{
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
|
||||
}
|
||||
t1_destroy(t1);
|
||||
t1_time = opj_clock() - t1_time;
|
||||
@@ -1394,18 +1418,15 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
int numres2decode;
|
||||
|
||||
if (tcd->cp->reduce != 0) {
|
||||
tcd->image->comps[compno].resno_decoded =
|
||||
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
|
||||
if (tcd->image->comps[compno].resno_decoded < 0) {
|
||||
if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) {
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
|
||||
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(!tilec->data) {
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. null data\n");
|
||||
return false;
|
||||
else {
|
||||
tcd->image->comps[compno].resno_decoded =
|
||||
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
|
||||
}
|
||||
}
|
||||
|
||||
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
|
||||
@@ -1424,18 +1445,23 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
|
||||
if (tcd->tcp->mct) {
|
||||
int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
|
||||
if (tcd->tcp->tccps[0].qmfbid == 1) {
|
||||
mct_decode(
|
||||
tile->comps[0].data,
|
||||
tile->comps[1].data,
|
||||
tile->comps[2].data,
|
||||
n);
|
||||
} else {
|
||||
mct_decode_real(
|
||||
(float*)tile->comps[0].data,
|
||||
(float*)tile->comps[1].data,
|
||||
(float*)tile->comps[2].data,
|
||||
n);
|
||||
|
||||
if (tile->numcomps >= 3 ){
|
||||
if (tcd->tcp->tccps[0].qmfbid == 1) {
|
||||
mct_decode(
|
||||
tile->comps[0].data,
|
||||
tile->comps[1].data,
|
||||
tile->comps[2].data,
|
||||
n);
|
||||
} else {
|
||||
mct_decode_real(
|
||||
(float*)tile->comps[0].data,
|
||||
(float*)tile->comps[1].data,
|
||||
(float*)tile->comps[2].data,
|
||||
n);
|
||||
}
|
||||
} else{
|
||||
opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1459,6 +1485,11 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
if(!imagec->data){
|
||||
imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
|
||||
}
|
||||
if (!imagec->data)
|
||||
{
|
||||
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if(tcd->tcp->tccps[compno].qmfbid == 1) {
|
||||
for(j = res->y0; j < res->y1; ++j) {
|
||||
for(i = res->x0; i < res->x1; ++i) {
|
||||
@@ -1484,40 +1515,59 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
|
||||
opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
|
||||
|
||||
if (eof) {
|
||||
return false;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
return true;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
void tcd_free_decode(opj_tcd_t *tcd) {
|
||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||
int i = 0;
|
||||
for (i = 0; i < tcd_image->tw * tcd_image->th; i++)
|
||||
{
|
||||
tcd_free_decode_tile(tcd, i);
|
||||
}
|
||||
|
||||
opj_free(tcd_image->tiles);
|
||||
}
|
||||
|
||||
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
|
||||
int compno,resno,bandno,precno;
|
||||
int compno,resno,bandno,precno,cblkno;
|
||||
|
||||
opj_tcd_image_t *tcd_image = tcd->tcd_image;
|
||||
|
||||
opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
for (resno = 0; resno < tilec->numresolutions; resno++) {
|
||||
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
opj_tcd_band_t *band = &res->bands[bandno];
|
||||
for (precno = 0; precno < res->ph * res->pw; precno++) {
|
||||
opj_tcd_precinct_t *prec = &band->precincts[precno];
|
||||
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
|
||||
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
|
||||
if (tile->comps != NULL) {
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
for (resno = 0; resno < tilec->numresolutions; resno++) {
|
||||
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
opj_tcd_band_t *band = &res->bands[bandno];
|
||||
for (precno = 0; precno < res->ph * res->pw; precno++) {
|
||||
opj_tcd_precinct_t *prec = &band->precincts[precno];
|
||||
if (prec->cblks.dec != NULL) {
|
||||
for (cblkno = 0; cblkno < prec->cw * prec->ch; ++cblkno) {
|
||||
opj_tcd_cblk_dec_t* cblk = &prec->cblks.dec[cblkno];
|
||||
opj_free(cblk->data);
|
||||
opj_free(cblk->segs);
|
||||
}
|
||||
opj_free(prec->cblks.dec);
|
||||
}
|
||||
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
|
||||
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
|
||||
|
||||
|
||||
}
|
||||
opj_free(band->precincts);
|
||||
}
|
||||
opj_free(band->precincts);
|
||||
}
|
||||
opj_free(tilec->resolutions);
|
||||
}
|
||||
opj_free(tilec->resolutions);
|
||||
opj_free(tile->comps);
|
||||
tile->comps = NULL;
|
||||
}
|
||||
opj_free(tile->comps);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
|
||||
void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
|
||||
void tcd_rateallocate_fixed(opj_tcd_t *tcd);
|
||||
void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
|
||||
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
|
||||
opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
|
||||
/**
|
||||
Encode a tile from the raw image into a buffer
|
||||
@param tcd TCD handle
|
||||
@@ -268,8 +268,9 @@ Decode a tile from a buffer into a raw image
|
||||
@param src Source buffer
|
||||
@param len Length of source buffer
|
||||
@param tileno Number that identifies one of the tiles to be decoded
|
||||
@param cstr_info Codestream information structure
|
||||
*/
|
||||
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
|
||||
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
|
||||
/**
|
||||
Free the memory allocated for decoding
|
||||
@param tcd TCD handle
|
||||
|
||||
120
indra/libopenjpeg/thix_manager.c
Normal file
120
indra/libopenjpeg/thix_manager.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.c from 2KAN indexer
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "opj_includes.h"
|
||||
|
||||
/*
|
||||
* Write tile-part headers mhix box
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] tileno tile number
|
||||
* @param[in] cio file output handle
|
||||
* @return length of mhix box
|
||||
*/
|
||||
int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio);
|
||||
|
||||
int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp, i;
|
||||
int tileno;
|
||||
opj_jp2_box_t *box;
|
||||
|
||||
lenp = 0;
|
||||
box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));
|
||||
|
||||
for ( i = 0; i < 2 ; i++ ){
|
||||
if (i)
|
||||
cio_seek( cio, lenp);
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_THIX, 4); /* THIX */
|
||||
write_manf( i, cstr_info.tw*cstr_info.th, box, cio);
|
||||
|
||||
for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
|
||||
box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio);
|
||||
box[tileno].type = JPIP_MHIX;
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
}
|
||||
|
||||
opj_free(box);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio)
|
||||
{
|
||||
int i;
|
||||
opj_tile_info_t tile;
|
||||
opj_tp_info_t tp;
|
||||
int len, lenp;
|
||||
opj_marker_info_t *marker;
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_MHIX, 4); /* MHIX */
|
||||
|
||||
tile = cstr_info.tile[tileno];
|
||||
tp = tile.tp[0];
|
||||
|
||||
cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */
|
||||
|
||||
marker = cstr_info.tile[tileno].marker;
|
||||
|
||||
for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */
|
||||
cio_write( cio, marker[i].type, 2);
|
||||
cio_write( cio, 0, 2);
|
||||
cio_write( cio, marker[i].pos-coff, 8);
|
||||
cio_write( cio, marker[i].len, 2);
|
||||
}
|
||||
|
||||
/* free( marker);*/
|
||||
|
||||
len = cio_tell( cio) - lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
153
indra/libopenjpeg/tpix_manager.c
Normal file
153
indra/libopenjpeg/tpix_manager.c
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
* \brief Modification of jpip.c from 2KAN indexer
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "opj_includes.h"
|
||||
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
|
||||
/*
|
||||
* Write faix box of tpix
|
||||
*
|
||||
* @param[in] coff offset of j2k codestream
|
||||
* @param[in] compno component number
|
||||
* @param[in] cstr_info codestream information
|
||||
* @param[in] j2klen length of j2k codestream
|
||||
* @param[in] cio file output handle
|
||||
* @return length of faix box
|
||||
*/
|
||||
int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
|
||||
|
||||
|
||||
int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp;
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_TPIX, 4); /* TPIX */
|
||||
|
||||
write_tpixfaix( coff, 0, cstr_info, j2klen, cio);
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get number of maximum tile parts per tile
|
||||
*
|
||||
* @param[in] cstr_info codestream information
|
||||
* @return number of maximum tile parts per tile
|
||||
*/
|
||||
int get_num_max_tile_parts( opj_codestream_info_t cstr_info);
|
||||
|
||||
int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
|
||||
{
|
||||
int len, lenp;
|
||||
int i, j;
|
||||
int Aux;
|
||||
int num_max_tile_parts;
|
||||
int size_of_coding; /* 4 or 8 */
|
||||
opj_tp_info_t tp;
|
||||
int version;
|
||||
|
||||
num_max_tile_parts = get_num_max_tile_parts( cstr_info);
|
||||
|
||||
if( j2klen > pow( 2.0, 32)){
|
||||
size_of_coding = 8;
|
||||
version = num_max_tile_parts == 1 ? 1:3;
|
||||
}
|
||||
else{
|
||||
size_of_coding = 4;
|
||||
version = num_max_tile_parts == 1 ? 0:2;
|
||||
}
|
||||
|
||||
lenp = cio_tell( cio);
|
||||
cio_skip( cio, 4); /* L [at the end] */
|
||||
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
|
||||
cio_write( cio, version, 1); /* Version 0 = 4 bytes */
|
||||
|
||||
cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */
|
||||
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
|
||||
for (i = 0; i < cstr_info.tw*cstr_info.th; i++){
|
||||
for (j = 0; j < cstr_info.tile[i].num_tps; j++){
|
||||
tp = cstr_info.tile[i].tp[j];
|
||||
cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */
|
||||
cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */
|
||||
if (version & 0x02){
|
||||
if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
|
||||
Aux = cstr_info.numdecompos[compno] + 1;
|
||||
else
|
||||
Aux = j + 1;
|
||||
|
||||
cio_write( cio, Aux,4);
|
||||
/*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
|
||||
/* fprintf(stderr,"AUX value %d\n",Aux);*/
|
||||
}
|
||||
/*cio_write(0,4);*/
|
||||
}
|
||||
/* PADDING */
|
||||
while (j < num_max_tile_parts){
|
||||
cio_write( cio, 0, size_of_coding); /* start position */
|
||||
cio_write( cio, 0, size_of_coding); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
len = cio_tell( cio)-lenp;
|
||||
cio_seek( cio, lenp);
|
||||
cio_write( cio, len, 4); /* L */
|
||||
cio_seek( cio, lenp+len);
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
int get_num_max_tile_parts( opj_codestream_info_t cstr_info)
|
||||
{
|
||||
int num_max_tp = 0, i;
|
||||
|
||||
for( i=0; i<cstr_info.tw*cstr_info.th; i++)
|
||||
num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp);
|
||||
|
||||
return num_max_tp;
|
||||
}
|
||||
89
indra/llappearance/CMakeLists.txt
Normal file
89
indra/llappearance/CMakeLists.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
project(llappearance)
|
||||
|
||||
include(00-Common)
|
||||
include(LLCommon)
|
||||
include(LLCharacter)
|
||||
include(LLImage)
|
||||
include(LLInventory)
|
||||
include(LLMath)
|
||||
include(LLMessage)
|
||||
include(LLRender)
|
||||
include(LLVFS)
|
||||
include(LLWindow)
|
||||
include(LLXML)
|
||||
include(Linking)
|
||||
|
||||
include_directories(
|
||||
${LLCOMMON_INCLUDE_DIRS}
|
||||
${LLCHARACTER_INCLUDE_DIRS}
|
||||
${LLIMAGE_INCLUDE_DIRS}
|
||||
${LLINVENTORY_INCLUDE_DIRS}
|
||||
${LLMATH_INCLUDE_DIRS}
|
||||
${LLRENDER_INCLUDE_DIRS}
|
||||
${LLVFS_INCLUDE_DIRS}
|
||||
${LLWINDOW_INCLUDE_DIRS}
|
||||
${LLXML_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(llappearance_SOURCE_FILES
|
||||
llavatarappearance.cpp
|
||||
llavatarjoint.cpp
|
||||
llavatarjointmesh.cpp
|
||||
lldriverparam.cpp
|
||||
lllocaltextureobject.cpp
|
||||
llpolyskeletaldistortion.cpp
|
||||
llpolymesh.cpp
|
||||
llpolymorph.cpp
|
||||
lltexglobalcolor.cpp
|
||||
lltexlayer.cpp
|
||||
lltexlayerparams.cpp
|
||||
lltexturemanagerbridge.cpp
|
||||
llwearable.cpp
|
||||
llwearabledata.cpp
|
||||
llwearabletype.cpp
|
||||
llviewervisualparam.cpp
|
||||
llavatarappearancedefines.cpp
|
||||
)
|
||||
|
||||
set(llappearance_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
llavatarappearance.h
|
||||
llavatarjoint.h
|
||||
llavatarjointmesh.h
|
||||
lldriverparam.h
|
||||
lljointpickname.h
|
||||
lllocaltextureobject.h
|
||||
llpolyskeletaldistortion.h
|
||||
llpolymesh.h
|
||||
llpolymorph.h
|
||||
lltexglobalcolor.h
|
||||
lltexlayer.h
|
||||
lltexlayerparams.h
|
||||
lltexturemanagerbridge.h
|
||||
llwearable.h
|
||||
llwearabledata.h
|
||||
llwearabletype.h
|
||||
llviewervisualparam.h
|
||||
llavatarappearancedefines.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${llappearance_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
list(APPEND llappearance_SOURCE_FILES ${llappearance_HEADER_FILES})
|
||||
|
||||
add_library (llappearance ${llappearance_SOURCE_FILES})
|
||||
|
||||
target_link_libraries(llappearance
|
||||
${LLCHARACTER_LIBRARIES}
|
||||
${LLINVENTORY_LIBRARIES}
|
||||
${LLIMAGE_LIBRARIES}
|
||||
${LLRENDER_LIBRARIES}
|
||||
${LLVFS_LIBRARIES}
|
||||
${LLMATH_LIBRARIES}
|
||||
${LLXML_LIBRARIES}
|
||||
${LLCOMMON_LIBRARIES}
|
||||
)
|
||||
2020
indra/llappearance/llavatarappearance.cpp
Normal file
2020
indra/llappearance/llavatarappearance.cpp
Normal file
File diff suppressed because it is too large
Load Diff
454
indra/llappearance/llavatarappearance.h
Normal file
454
indra/llappearance/llavatarappearance.h
Normal file
@@ -0,0 +1,454 @@
|
||||
/**
|
||||
* @file llavatarappearance.h
|
||||
* @brief Declaration of LLAvatarAppearance class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_AVATAR_APPEARANCE_H
|
||||
#define LL_AVATAR_APPEARANCE_H
|
||||
|
||||
#include "llcharacter.h"
|
||||
#include "llavatarappearancedefines.h"
|
||||
#include "llavatarjointmesh.h"
|
||||
#include "lldriverparam.h"
|
||||
#include "lltexlayer.h"
|
||||
#include "llviewervisualparam.h"
|
||||
#include "llxmltree.h"
|
||||
|
||||
class LLTexLayerSet;
|
||||
class LLTexGlobalColor;
|
||||
class LLTexGlobalColorInfo;
|
||||
class LLWearableData;
|
||||
class LLAvatarBoneInfo;
|
||||
class LLAvatarSkeletonInfo;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// LLAvatarAppearance
|
||||
//
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
class LLAvatarAppearance : public LLCharacter
|
||||
{
|
||||
LOG_CLASS(LLAvatarAppearance);
|
||||
|
||||
protected:
|
||||
struct LLAvatarXmlInfo;
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** INITIALIZATION
|
||||
**/
|
||||
private:
|
||||
// Hide default constructor.
|
||||
LLAvatarAppearance() {}
|
||||
|
||||
public:
|
||||
LLAvatarAppearance(LLWearableData* wearable_data);
|
||||
virtual ~LLAvatarAppearance();
|
||||
|
||||
static void initClass(); // initializes static members
|
||||
static void cleanupClass(); // Cleanup data that's only init'd once per class.
|
||||
virtual void initInstance(); // Called after construction to initialize the instance.
|
||||
virtual BOOL loadSkeletonNode();
|
||||
BOOL loadMeshNodes();
|
||||
BOOL loadLayersets();
|
||||
|
||||
|
||||
/** Initialization
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** INHERITED
|
||||
**/
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLCharacter interface and related
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
/*virtual*/ LLJoint* getCharacterJoint(U32 num);
|
||||
|
||||
/*virtual*/ const char* getAnimationPrefix() { return "avatar"; }
|
||||
/*virtual*/ LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
|
||||
/*virtual*/ LLJoint* findCollisionVolume(U32 volume_id);
|
||||
/*virtual*/ S32 getCollisionVolumeID(std::string &name);
|
||||
/*virtual*/ LLPolyMesh* getHeadMesh();
|
||||
/*virtual*/ LLPolyMesh* getUpperBodyMesh();
|
||||
LLPolyMesh* getMesh( LLPolyMeshSharedData *shared_data );
|
||||
|
||||
typedef std::map<S32, std::string> lod_mesh_map_t;
|
||||
typedef std::map<std::string, lod_mesh_map_t> mesh_info_t;
|
||||
static void getMeshInfo(mesh_info_t* mesh_info);
|
||||
|
||||
/** Inherited
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** STATE
|
||||
**/
|
||||
public:
|
||||
virtual bool isSelf() const { return false; } // True if this avatar is for this viewer's agent
|
||||
virtual BOOL isValid() const;
|
||||
//virtual BOOL isUsingServerBakes() const = 0;
|
||||
//virtual BOOL isUsingLocalAppearance() const = 0;
|
||||
//virtual BOOL isEditingAppearance() const = 0;
|
||||
BOOL isUsingLocalAppearance() const {return isEditingAppearance();}
|
||||
virtual BOOL isEditingAppearance() const {return FALSE;}
|
||||
|
||||
bool isBuilt() const { return mIsBuilt; }
|
||||
|
||||
virtual std::string getFullname() const = 0;
|
||||
/** State
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** SKELETON
|
||||
**/
|
||||
|
||||
protected:
|
||||
virtual LLAvatarJoint* createAvatarJoint() = 0;
|
||||
virtual LLAvatarJoint* createAvatarJoint(S32 joint_num) = 0;
|
||||
virtual LLAvatarJointMesh* createAvatarJointMesh() = 0;
|
||||
public:
|
||||
F32 getPelvisToFoot() const { return mPelvisToFoot; }
|
||||
/*virtual*/ LLJoint* getRootJoint() { return mRoot; }
|
||||
|
||||
LLVector3 mHeadOffset; // current head position
|
||||
LLAvatarJoint *mRoot;
|
||||
|
||||
typedef std::map<std::string, LLJoint*> joint_map_t;
|
||||
joint_map_t mJointMap;
|
||||
|
||||
void computeBodySize();
|
||||
|
||||
|
||||
protected:
|
||||
static BOOL parseSkeletonFile(const std::string& filename);
|
||||
virtual void buildCharacter();
|
||||
virtual BOOL loadAvatar();
|
||||
virtual void bodySizeChanged() = 0;
|
||||
|
||||
BOOL setupBone(const LLAvatarBoneInfo* info, LLJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num);
|
||||
BOOL allocateCharacterJoints(U32 num);
|
||||
BOOL buildSkeleton(const LLAvatarSkeletonInfo *info);
|
||||
protected:
|
||||
void clearSkeleton();
|
||||
BOOL mIsBuilt; // state of deferred character building
|
||||
typedef std::vector<LLAvatarJoint*> avatar_joint_list_t;
|
||||
avatar_joint_list_t mSkeleton;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Pelvis height adjustment members.
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
LLVector3 mBodySize;
|
||||
protected:
|
||||
F32 mPelvisToFoot;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Cached pointers to well known joints
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
LLJoint* mPelvisp;
|
||||
LLJoint* mTorsop;
|
||||
LLJoint* mChestp;
|
||||
LLJoint* mNeckp;
|
||||
LLJoint* mHeadp;
|
||||
LLJoint* mSkullp;
|
||||
LLJoint* mEyeLeftp;
|
||||
LLJoint* mEyeRightp;
|
||||
LLJoint* mHipLeftp;
|
||||
LLJoint* mHipRightp;
|
||||
LLJoint* mKneeLeftp;
|
||||
LLJoint* mKneeRightp;
|
||||
LLJoint* mAnkleLeftp;
|
||||
LLJoint* mAnkleRightp;
|
||||
LLJoint* mFootLeftp;
|
||||
LLJoint* mFootRightp;
|
||||
LLJoint* mWristLeftp;
|
||||
LLJoint* mWristRightp;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// XML parse tree
|
||||
//--------------------------------------------------------------------
|
||||
protected:
|
||||
static LLXmlTree sXMLTree; // avatar config file
|
||||
static LLXmlTree sSkeletonXMLTree; // avatar skeleton file
|
||||
|
||||
static LLAvatarSkeletonInfo* sAvatarSkeletonInfo;
|
||||
static LLAvatarXmlInfo* sAvatarXmlInfo;
|
||||
|
||||
|
||||
/** Skeleton
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** RENDERING
|
||||
**/
|
||||
public:
|
||||
BOOL mIsDummy; // for special views
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Morph masks
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
void addMaskedMorph(LLAvatarAppearanceDefines::EBakedTextureIndex index, LLVisualParam* morph_target, BOOL invert, std::string layer);
|
||||
virtual void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index = LLAvatarAppearanceDefines::BAKED_NUM_INDICES) = 0;
|
||||
|
||||
/** Rendering
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Composites
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
virtual void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result) = 0;
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** MESHES
|
||||
**/
|
||||
|
||||
public:
|
||||
virtual void updateMeshTextures() = 0;
|
||||
virtual void dirtyMesh() = 0; // Dirty the avatar mesh
|
||||
protected:
|
||||
virtual void dirtyMesh(S32 priority) = 0; // Dirty the avatar mesh, with priority
|
||||
|
||||
protected:
|
||||
typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t;
|
||||
polymesh_map_t mPolyMeshes;
|
||||
avatar_joint_list_t mMeshLOD;
|
||||
|
||||
/** Meshes
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** APPEARANCE
|
||||
**/
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Clothing colors (convenience functions to access visual parameters)
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
void setClothesColor(LLAvatarAppearanceDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake);
|
||||
LLColor4 getClothesColor(LLAvatarAppearanceDefines::ETextureIndex te);
|
||||
static BOOL teToColorParams(LLAvatarAppearanceDefines::ETextureIndex te, U32 *param_name);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Global colors
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
LLColor4 getGlobalColor(const std::string& color_name ) const;
|
||||
virtual void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake) = 0;
|
||||
protected:
|
||||
LLTexGlobalColor* mTexSkinColor;
|
||||
LLTexGlobalColor* mTexHairColor;
|
||||
LLTexGlobalColor* mTexEyeColor;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Visibility
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
static LLColor4 getDummyColor();
|
||||
/** Appearance
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** WEARABLES
|
||||
**/
|
||||
|
||||
public:
|
||||
LLWearableData* getWearableData() { return mWearableData; }
|
||||
const LLWearableData* getWearableData() const { return mWearableData; }
|
||||
virtual BOOL isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex te, U32 index = 0 ) const = 0;
|
||||
virtual BOOL isWearingWearableType(LLWearableType::EType type ) const;
|
||||
|
||||
private:
|
||||
LLWearableData* mWearableData;
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** BAKED TEXTURES
|
||||
**/
|
||||
public:
|
||||
LLTexLayerSet* getAvatarLayerSet(LLAvatarAppearanceDefines::EBakedTextureIndex baked_index) const;
|
||||
|
||||
protected:
|
||||
virtual LLTexLayerSet* createTexLayerSet() = 0;
|
||||
|
||||
protected:
|
||||
class LLMaskedMorph;
|
||||
typedef std::deque<LLMaskedMorph *> morph_list_t;
|
||||
struct BakedTextureData
|
||||
{
|
||||
LLUUID mLastTextureID;
|
||||
LLTexLayerSet* mTexLayerSet; // Only exists for self
|
||||
bool mIsLoaded;
|
||||
bool mIsUsed;
|
||||
LLAvatarAppearanceDefines::ETextureIndex mTextureIndex;
|
||||
U32 mMaskTexName;
|
||||
// Stores pointers to the joint meshes that this baked texture deals with
|
||||
avatar_joint_mesh_list_t mJointMeshes;
|
||||
morph_list_t mMaskedMorphs;
|
||||
};
|
||||
typedef std::vector<BakedTextureData> bakedtexturedata_vec_t;
|
||||
bakedtexturedata_vec_t mBakedTextureDatas;
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** PHYSICS
|
||||
**/
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Collision volumes
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
S32 mNumCollisionVolumes;
|
||||
LLAvatarJointCollisionVolume* mCollisionVolumes;
|
||||
protected:
|
||||
BOOL allocateCollisionVolumes(U32 num);
|
||||
|
||||
/** Physics
|
||||
** **
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
** **
|
||||
** SUPPORT CLASSES
|
||||
**/
|
||||
|
||||
struct LLAvatarXmlInfo
|
||||
{
|
||||
LLAvatarXmlInfo();
|
||||
~LLAvatarXmlInfo();
|
||||
|
||||
BOOL parseXmlSkeletonNode(LLXmlTreeNode* root);
|
||||
BOOL parseXmlMeshNodes(LLXmlTreeNode* root);
|
||||
BOOL parseXmlColorNodes(LLXmlTreeNode* root);
|
||||
BOOL parseXmlLayerNodes(LLXmlTreeNode* root);
|
||||
BOOL parseXmlDriverNodes(LLXmlTreeNode* root);
|
||||
BOOL parseXmlMorphNodes(LLXmlTreeNode* root);
|
||||
|
||||
struct LLAvatarMeshInfo
|
||||
{
|
||||
typedef std::pair<LLViewerVisualParamInfo*,BOOL> morph_info_pair_t; // LLPolyMorphTargetInfo stored here
|
||||
typedef std::vector<morph_info_pair_t> morph_info_list_t;
|
||||
|
||||
LLAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {}
|
||||
~LLAvatarMeshInfo()
|
||||
{
|
||||
morph_info_list_t::iterator iter;
|
||||
for (iter = mPolyMorphTargetInfoList.begin(); iter != mPolyMorphTargetInfoList.end(); iter++)
|
||||
{
|
||||
delete iter->first;
|
||||
}
|
||||
mPolyMorphTargetInfoList.clear();
|
||||
}
|
||||
|
||||
std::string mType;
|
||||
S32 mLOD;
|
||||
std::string mMeshFileName;
|
||||
std::string mReferenceMeshName;
|
||||
F32 mMinPixelArea;
|
||||
morph_info_list_t mPolyMorphTargetInfoList;
|
||||
};
|
||||
typedef std::vector<LLAvatarMeshInfo*> mesh_info_list_t;
|
||||
mesh_info_list_t mMeshInfoList;
|
||||
|
||||
typedef std::vector<LLViewerVisualParamInfo*> skeletal_distortion_info_list_t; // LLPolySkeletalDistortionInfo stored here
|
||||
skeletal_distortion_info_list_t mSkeletalDistortionInfoList;
|
||||
|
||||
struct LLAvatarAttachmentInfo
|
||||
{
|
||||
LLAvatarAttachmentInfo()
|
||||
: mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE),
|
||||
mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {}
|
||||
std::string mName;
|
||||
std::string mJointName;
|
||||
LLVector3 mPosition;
|
||||
LLVector3 mRotationEuler;
|
||||
S32 mGroup;
|
||||
S32 mAttachmentID;
|
||||
S32 mPieMenuSlice;
|
||||
BOOL mVisibleFirstPerson;
|
||||
BOOL mIsHUDAttachment;
|
||||
BOOL mHasPosition;
|
||||
BOOL mHasRotation;
|
||||
};
|
||||
typedef std::vector<LLAvatarAttachmentInfo*> attachment_info_list_t;
|
||||
attachment_info_list_t mAttachmentInfoList;
|
||||
|
||||
LLTexGlobalColorInfo *mTexSkinColorInfo;
|
||||
LLTexGlobalColorInfo *mTexHairColorInfo;
|
||||
LLTexGlobalColorInfo *mTexEyeColorInfo;
|
||||
|
||||
typedef std::vector<LLTexLayerSetInfo*> layer_info_list_t;
|
||||
layer_info_list_t mLayerInfoList;
|
||||
|
||||
typedef std::vector<LLDriverParamInfo*> driver_info_list_t;
|
||||
driver_info_list_t mDriverInfoList;
|
||||
|
||||
struct LLAvatarMorphInfo
|
||||
{
|
||||
LLAvatarMorphInfo()
|
||||
: mInvert(FALSE) {}
|
||||
std::string mName;
|
||||
std::string mRegion;
|
||||
std::string mLayer;
|
||||
BOOL mInvert;
|
||||
};
|
||||
|
||||
typedef std::vector<LLAvatarMorphInfo*> morph_info_list_t;
|
||||
morph_info_list_t mMorphMaskInfoList;
|
||||
};
|
||||
|
||||
|
||||
class LLMaskedMorph
|
||||
{
|
||||
public:
|
||||
LLMaskedMorph(LLVisualParam *morph_target, BOOL invert, std::string layer);
|
||||
|
||||
LLVisualParam *mMorphTarget;
|
||||
BOOL mInvert;
|
||||
std::string mLayer;
|
||||
};
|
||||
/** Support Classes
|
||||
** **
|
||||
*******************************************************************************/
|
||||
};
|
||||
|
||||
#endif // LL_AVATAR_APPEARANCE_H
|
||||
268
indra/llappearance/llavatarappearancedefines.cpp
Normal file
268
indra/llappearance/llavatarappearancedefines.cpp
Normal file
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* @file llavatarappearancedefines.cpp
|
||||
* @brief Implementation of LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llavatarappearancedefines.h"
|
||||
|
||||
const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH = 512;
|
||||
const S32 LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT = 512;
|
||||
const S32 LLAvatarAppearanceDefines::IMPOSTOR_PERIOD = 2;
|
||||
|
||||
using namespace LLAvatarAppearanceDefines;
|
||||
|
||||
/*********************************************************************************
|
||||
* Edit this function to add/remove/change textures and mesh definitions for avatars.
|
||||
*/
|
||||
|
||||
LLAvatarAppearanceDictionary::Textures::Textures()
|
||||
{
|
||||
addEntry(TEX_HEAD_BODYPAINT, new TextureEntry("head_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
|
||||
addEntry(TEX_UPPER_SHIRT, new TextureEntry("upper_shirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultShirtUUID", LLWearableType::WT_SHIRT));
|
||||
addEntry(TEX_LOWER_PANTS, new TextureEntry("lower_pants", TRUE, BAKED_NUM_INDICES, "UIImgDefaultPantsUUID", LLWearableType::WT_PANTS));
|
||||
addEntry(TEX_EYES_IRIS, new TextureEntry("eyes_iris", TRUE, BAKED_NUM_INDICES, "UIImgDefaultEyesUUID", LLWearableType::WT_EYES));
|
||||
addEntry(TEX_HAIR, new TextureEntry("hair_grain", TRUE, BAKED_NUM_INDICES, "UIImgDefaultHairUUID", LLWearableType::WT_HAIR));
|
||||
addEntry(TEX_UPPER_BODYPAINT, new TextureEntry("upper_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
|
||||
addEntry(TEX_LOWER_BODYPAINT, new TextureEntry("lower_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
|
||||
addEntry(TEX_LOWER_SHOES, new TextureEntry("lower_shoes", TRUE, BAKED_NUM_INDICES, "UIImgDefaultShoesUUID", LLWearableType::WT_SHOES));
|
||||
addEntry(TEX_LOWER_SOCKS, new TextureEntry("lower_socks", TRUE, BAKED_NUM_INDICES, "UIImgDefaultSocksUUID", LLWearableType::WT_SOCKS));
|
||||
addEntry(TEX_UPPER_JACKET, new TextureEntry("upper_jacket", TRUE, BAKED_NUM_INDICES, "UIImgDefaultJacketUUID", LLWearableType::WT_JACKET));
|
||||
addEntry(TEX_LOWER_JACKET, new TextureEntry("lower_jacket", TRUE, BAKED_NUM_INDICES, "UIImgDefaultJacketUUID", LLWearableType::WT_JACKET));
|
||||
addEntry(TEX_UPPER_GLOVES, new TextureEntry("upper_gloves", TRUE, BAKED_NUM_INDICES, "UIImgDefaultGlovesUUID", LLWearableType::WT_GLOVES));
|
||||
addEntry(TEX_UPPER_UNDERSHIRT, new TextureEntry("upper_undershirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultUnderwearUUID", LLWearableType::WT_UNDERSHIRT));
|
||||
addEntry(TEX_LOWER_UNDERPANTS, new TextureEntry("lower_underpants", TRUE, BAKED_NUM_INDICES, "UIImgDefaultUnderwearUUID", LLWearableType::WT_UNDERPANTS));
|
||||
addEntry(TEX_SKIRT, new TextureEntry("skirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultSkirtUUID", LLWearableType::WT_SKIRT));
|
||||
|
||||
addEntry(TEX_LOWER_ALPHA, new TextureEntry("lower_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
|
||||
addEntry(TEX_UPPER_ALPHA, new TextureEntry("upper_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
|
||||
addEntry(TEX_HEAD_ALPHA, new TextureEntry("head_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
|
||||
addEntry(TEX_EYES_ALPHA, new TextureEntry("eyes_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
|
||||
addEntry(TEX_HAIR_ALPHA, new TextureEntry("hair_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
|
||||
|
||||
addEntry(TEX_HEAD_TATTOO, new TextureEntry("head_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
|
||||
addEntry(TEX_UPPER_TATTOO, new TextureEntry("upper_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
|
||||
addEntry(TEX_LOWER_TATTOO, new TextureEntry("lower_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
|
||||
|
||||
addEntry(TEX_HEAD_BAKED, new TextureEntry("head-baked", FALSE, BAKED_HEAD, "head"));
|
||||
addEntry(TEX_UPPER_BAKED, new TextureEntry("upper-baked", FALSE, BAKED_UPPER, "upper"));
|
||||
addEntry(TEX_LOWER_BAKED, new TextureEntry("lower-baked", FALSE, BAKED_LOWER, "lower"));
|
||||
addEntry(TEX_EYES_BAKED, new TextureEntry("eyes-baked", FALSE, BAKED_EYES, "eyes"));
|
||||
addEntry(TEX_HAIR_BAKED, new TextureEntry("hair-baked", FALSE, BAKED_HAIR, "hair"));
|
||||
addEntry(TEX_SKIRT_BAKED, new TextureEntry("skirt-baked", FALSE, BAKED_SKIRT, "skirt"));
|
||||
}
|
||||
|
||||
LLAvatarAppearanceDictionary::BakedTextures::BakedTextures()
|
||||
{
|
||||
// Baked textures
|
||||
addEntry(BAKED_HEAD, new BakedEntry(TEX_HEAD_BAKED,
|
||||
"head", "a4b9dc38-e13b-4df9-b284-751efb0566ff",
|
||||
3, TEX_HEAD_BODYPAINT, TEX_HEAD_TATTOO, TEX_HEAD_ALPHA,
|
||||
5, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_HAIR, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
|
||||
|
||||
addEntry(BAKED_UPPER, new BakedEntry(TEX_UPPER_BAKED,
|
||||
"upper_body", "5943ff64-d26c-4a90-a8c0-d61f56bd98d4",
|
||||
7, TEX_UPPER_SHIRT,TEX_UPPER_BODYPAINT, TEX_UPPER_JACKET,
|
||||
TEX_UPPER_GLOVES, TEX_UPPER_UNDERSHIRT, TEX_UPPER_TATTOO, TEX_UPPER_ALPHA,
|
||||
8, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_SHIRT, LLWearableType::WT_JACKET, LLWearableType::WT_GLOVES, LLWearableType::WT_UNDERSHIRT, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
|
||||
|
||||
addEntry(BAKED_LOWER, new BakedEntry(TEX_LOWER_BAKED,
|
||||
"lower_body", "2944ee70-90a7-425d-a5fb-d749c782ed7d",
|
||||
8, TEX_LOWER_PANTS,TEX_LOWER_BODYPAINT,TEX_LOWER_SHOES, TEX_LOWER_SOCKS,
|
||||
TEX_LOWER_JACKET, TEX_LOWER_UNDERPANTS, TEX_LOWER_TATTOO, TEX_LOWER_ALPHA,
|
||||
9, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_PANTS, LLWearableType::WT_SHOES, LLWearableType::WT_SOCKS, LLWearableType::WT_JACKET, LLWearableType::WT_UNDERPANTS, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
|
||||
|
||||
addEntry(BAKED_EYES, new BakedEntry(TEX_EYES_BAKED,
|
||||
"eyes", "27b1bc0f-979f-4b13-95fe-b981c2ba9788",
|
||||
2, TEX_EYES_IRIS, TEX_EYES_ALPHA,
|
||||
2, LLWearableType::WT_EYES, LLWearableType::WT_ALPHA));
|
||||
|
||||
addEntry(BAKED_SKIRT, new BakedEntry(TEX_SKIRT_BAKED,
|
||||
"skirt", "03e7e8cb-1368-483b-b6f3-74850838ba63",
|
||||
1, TEX_SKIRT,
|
||||
1, LLWearableType::WT_SKIRT));
|
||||
|
||||
addEntry(BAKED_HAIR, new BakedEntry(TEX_HAIR_BAKED,
|
||||
"hair", "a60e85a9-74e8-48d8-8a2d-8129f28d9b61",
|
||||
2, TEX_HAIR, TEX_HAIR_ALPHA,
|
||||
2, LLWearableType::WT_HAIR, LLWearableType::WT_ALPHA));
|
||||
}
|
||||
|
||||
LLAvatarAppearanceDictionary::MeshEntries::MeshEntries()
|
||||
{
|
||||
// MeshEntries
|
||||
addEntry(MESH_ID_HAIR, new MeshEntry(BAKED_HAIR, "hairMesh", 6, PN_4));
|
||||
addEntry(MESH_ID_HEAD, new MeshEntry(BAKED_HEAD, "headMesh", 5, PN_5));
|
||||
addEntry(MESH_ID_EYELASH, new MeshEntry(BAKED_HEAD, "eyelashMesh", 1, PN_0)); // no baked mesh associated currently
|
||||
addEntry(MESH_ID_UPPER_BODY, new MeshEntry(BAKED_UPPER, "upperBodyMesh", 5, PN_1));
|
||||
addEntry(MESH_ID_LOWER_BODY, new MeshEntry(BAKED_LOWER, "lowerBodyMesh", 5, PN_2));
|
||||
addEntry(MESH_ID_EYEBALL_LEFT, new MeshEntry(BAKED_EYES, "eyeBallLeftMesh", 2, PN_3));
|
||||
addEntry(MESH_ID_EYEBALL_RIGHT, new MeshEntry(BAKED_EYES, "eyeBallRightMesh", 2, PN_3));
|
||||
addEntry(MESH_ID_SKIRT, new MeshEntry(BAKED_SKIRT, "skirtMesh", 5, PN_5));
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
LLAvatarAppearanceDictionary::LLAvatarAppearanceDictionary()
|
||||
{
|
||||
createAssociations();
|
||||
}
|
||||
|
||||
//virtual
|
||||
LLAvatarAppearanceDictionary::~LLAvatarAppearanceDictionary()
|
||||
{
|
||||
}
|
||||
|
||||
// Baked textures are composites of textures; for each such composited texture,
|
||||
// map it to the baked texture.
|
||||
void LLAvatarAppearanceDictionary::createAssociations()
|
||||
{
|
||||
for (BakedTextures::const_iterator iter = mBakedTextures.begin(); iter != mBakedTextures.end(); iter++)
|
||||
{
|
||||
const EBakedTextureIndex baked_index = (iter->first);
|
||||
const BakedEntry *dict = (iter->second);
|
||||
|
||||
// For each texture that this baked texture index affects, associate those textures
|
||||
// with this baked texture index.
|
||||
for (texture_vec_t::const_iterator local_texture_iter = dict->mLocalTextures.begin();
|
||||
local_texture_iter != dict->mLocalTextures.end();
|
||||
local_texture_iter++)
|
||||
{
|
||||
const ETextureIndex local_texture_index = (ETextureIndex) *local_texture_iter;
|
||||
mTextures[local_texture_index]->mIsUsedByBakedTexture = true;
|
||||
mTextures[local_texture_index]->mBakedTextureIndex = baked_index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LLAvatarAppearanceDictionary::TextureEntry::TextureEntry(const std::string &name,
|
||||
bool is_local_texture,
|
||||
EBakedTextureIndex baked_texture_index,
|
||||
const std::string &default_image_name,
|
||||
LLWearableType::EType wearable_type) :
|
||||
LLDictionaryEntry(name),
|
||||
mIsLocalTexture(is_local_texture),
|
||||
mIsBakedTexture(!is_local_texture),
|
||||
mIsUsedByBakedTexture(baked_texture_index != BAKED_NUM_INDICES),
|
||||
mBakedTextureIndex(baked_texture_index),
|
||||
mDefaultImageName(default_image_name),
|
||||
mWearableType(wearable_type)
|
||||
{
|
||||
}
|
||||
|
||||
LLAvatarAppearanceDictionary::MeshEntry::MeshEntry(EBakedTextureIndex baked_index,
|
||||
const std::string &name,
|
||||
U8 level,
|
||||
LLJointPickName pick) :
|
||||
LLDictionaryEntry(name),
|
||||
mBakedID(baked_index),
|
||||
mLOD(level),
|
||||
mPickName(pick)
|
||||
{
|
||||
}
|
||||
LLAvatarAppearanceDictionary::BakedEntry::BakedEntry(ETextureIndex tex_index,
|
||||
const std::string &name,
|
||||
const std::string &hash_name,
|
||||
U32 num_local_textures,
|
||||
... ) :
|
||||
LLDictionaryEntry(name),
|
||||
mWearablesHashID(LLUUID(hash_name)),
|
||||
mTextureIndex(tex_index)
|
||||
{
|
||||
va_list argp;
|
||||
|
||||
va_start(argp, num_local_textures);
|
||||
|
||||
// Read in local textures
|
||||
for (U8 i=0; i < num_local_textures; i++)
|
||||
{
|
||||
ETextureIndex t = (ETextureIndex)va_arg(argp,int);
|
||||
mLocalTextures.push_back(t);
|
||||
}
|
||||
|
||||
// Read in number of wearables
|
||||
const U32 num_wearables = (U32)va_arg(argp,int);
|
||||
// Read in wearables
|
||||
for (U8 i=0; i < num_wearables; i++)
|
||||
{
|
||||
LLWearableType::EType t = (LLWearableType::EType)va_arg(argp,int);
|
||||
mWearables.push_back(t);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
ETextureIndex LLAvatarAppearanceDictionary::bakedToLocalTextureIndex(EBakedTextureIndex index)
|
||||
{
|
||||
return LLAvatarAppearanceDictionary::getInstance()->getBakedTexture(index)->mTextureIndex;
|
||||
}
|
||||
|
||||
// static
|
||||
EBakedTextureIndex LLAvatarAppearanceDictionary::findBakedByRegionName(std::string name)
|
||||
{
|
||||
U8 index = 0;
|
||||
while (index < BAKED_NUM_INDICES)
|
||||
{
|
||||
const BakedEntry *be = LLAvatarAppearanceDictionary::getInstance()->getBakedTexture((EBakedTextureIndex) index);
|
||||
if (be && be->mName.compare(name) == 0)
|
||||
{
|
||||
// baked texture found
|
||||
return (EBakedTextureIndex) index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
// baked texture could not be found
|
||||
return BAKED_NUM_INDICES;
|
||||
}
|
||||
|
||||
// static
|
||||
EBakedTextureIndex LLAvatarAppearanceDictionary::findBakedByImageName(std::string name)
|
||||
{
|
||||
U8 index = 0;
|
||||
while (index < BAKED_NUM_INDICES)
|
||||
{
|
||||
const BakedEntry *be = LLAvatarAppearanceDictionary::getInstance()->getBakedTexture((EBakedTextureIndex) index);
|
||||
if (be)
|
||||
{
|
||||
const TextureEntry *te = LLAvatarAppearanceDictionary::getInstance()->getTexture(be->mTextureIndex);
|
||||
if (te && te->mDefaultImageName.compare(name) == 0)
|
||||
{
|
||||
// baked texture found
|
||||
return (EBakedTextureIndex) index;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
// baked texture could not be found
|
||||
return BAKED_NUM_INDICES;
|
||||
}
|
||||
|
||||
// static
|
||||
LLWearableType::EType LLAvatarAppearanceDictionary::getTEWearableType(ETextureIndex index )
|
||||
{
|
||||
return getInstance()->getTexture(index)->mWearableType;
|
||||
}
|
||||
|
||||
229
indra/llappearance/llavatarappearancedefines.h
Normal file
229
indra/llappearance/llavatarappearancedefines.h
Normal file
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
* @file llavatarappearancedefines.h
|
||||
* @brief Various LLAvatarAppearance related definitions
|
||||
* LLViewerObject
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_AVATARAPPEARANCE_DEFINES_H
|
||||
#define LL_AVATARAPPEARANCE_DEFINES_H
|
||||
|
||||
#include <vector>
|
||||
#include "lljointpickname.h"
|
||||
#include "lldictionary.h"
|
||||
#include "llwearabletype.h"
|
||||
#include "lluuid.h"
|
||||
|
||||
namespace LLAvatarAppearanceDefines
|
||||
{
|
||||
|
||||
extern const S32 SCRATCH_TEX_WIDTH;
|
||||
extern const S32 SCRATCH_TEX_HEIGHT;
|
||||
extern const S32 IMPOSTOR_PERIOD;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Enums
|
||||
//--------------------------------------------------------------------
|
||||
enum ETextureIndex
|
||||
{
|
||||
TEX_INVALID = -1,
|
||||
TEX_HEAD_BODYPAINT = 0,
|
||||
TEX_UPPER_SHIRT,
|
||||
TEX_LOWER_PANTS,
|
||||
TEX_EYES_IRIS,
|
||||
TEX_HAIR,
|
||||
TEX_UPPER_BODYPAINT,
|
||||
TEX_LOWER_BODYPAINT,
|
||||
TEX_LOWER_SHOES,
|
||||
TEX_HEAD_BAKED, // Pre-composited
|
||||
TEX_UPPER_BAKED, // Pre-composited
|
||||
TEX_LOWER_BAKED, // Pre-composited
|
||||
TEX_EYES_BAKED, // Pre-composited
|
||||
TEX_LOWER_SOCKS,
|
||||
TEX_UPPER_JACKET,
|
||||
TEX_LOWER_JACKET,
|
||||
TEX_UPPER_GLOVES,
|
||||
TEX_UPPER_UNDERSHIRT,
|
||||
TEX_LOWER_UNDERPANTS,
|
||||
TEX_SKIRT,
|
||||
TEX_SKIRT_BAKED, // Pre-composited
|
||||
TEX_HAIR_BAKED, // Pre-composited
|
||||
TEX_LOWER_ALPHA,
|
||||
TEX_UPPER_ALPHA,
|
||||
TEX_HEAD_ALPHA,
|
||||
TEX_EYES_ALPHA,
|
||||
TEX_HAIR_ALPHA,
|
||||
TEX_HEAD_TATTOO,
|
||||
TEX_UPPER_TATTOO,
|
||||
TEX_LOWER_TATTOO,
|
||||
TEX_NUM_INDICES
|
||||
};
|
||||
|
||||
enum EBakedTextureIndex
|
||||
{
|
||||
BAKED_HEAD = 0,
|
||||
BAKED_UPPER,
|
||||
BAKED_LOWER,
|
||||
BAKED_EYES,
|
||||
BAKED_SKIRT,
|
||||
BAKED_HAIR,
|
||||
BAKED_NUM_INDICES
|
||||
};
|
||||
|
||||
// Reference IDs for each mesh. Used as indices for vector of joints
|
||||
enum EMeshIndex
|
||||
{
|
||||
MESH_ID_HAIR = 0,
|
||||
MESH_ID_HEAD,
|
||||
MESH_ID_EYELASH,
|
||||
MESH_ID_UPPER_BODY,
|
||||
MESH_ID_LOWER_BODY,
|
||||
MESH_ID_EYEBALL_LEFT,
|
||||
MESH_ID_EYEBALL_RIGHT,
|
||||
MESH_ID_SKIRT,
|
||||
MESH_ID_NUM_INDICES
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Vector Types
|
||||
//--------------------------------------------------------------------
|
||||
typedef std::vector<ETextureIndex> texture_vec_t;
|
||||
typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t;
|
||||
typedef std::vector<EMeshIndex> mesh_vec_t;
|
||||
typedef std::vector<LLWearableType::EType> wearables_vec_t;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// LLAvatarAppearanceDictionary
|
||||
//
|
||||
// Holds dictionary static entries for textures, baked textures, meshes, etc.; i.e.
|
||||
// information that is common to all avatars.
|
||||
//
|
||||
// This holds const data - it is initialized once and the contents never change after that.
|
||||
//------------------------------------------------------------------------
|
||||
class LLAvatarAppearanceDictionary : public LLSingleton<LLAvatarAppearanceDictionary>
|
||||
{
|
||||
//--------------------------------------------------------------------
|
||||
// Constructors and Destructors
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
LLAvatarAppearanceDictionary();
|
||||
virtual ~LLAvatarAppearanceDictionary();
|
||||
private:
|
||||
void createAssociations();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Local and baked textures
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
struct TextureEntry : public LLDictionaryEntry
|
||||
{
|
||||
TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml
|
||||
bool is_local_texture,
|
||||
EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES,
|
||||
const std::string& default_image_name = "",
|
||||
LLWearableType::EType wearable_type = LLWearableType::WT_INVALID);
|
||||
const std::string mDefaultImageName;
|
||||
const LLWearableType::EType mWearableType;
|
||||
// It's either a local texture xor baked
|
||||
BOOL mIsLocalTexture;
|
||||
BOOL mIsBakedTexture;
|
||||
// If it's a local texture, it may be used by a baked texture
|
||||
BOOL mIsUsedByBakedTexture;
|
||||
EBakedTextureIndex mBakedTextureIndex;
|
||||
};
|
||||
|
||||
struct Textures : public LLDictionary<ETextureIndex, TextureEntry>
|
||||
{
|
||||
Textures();
|
||||
} mTextures;
|
||||
const TextureEntry* getTexture(ETextureIndex index) const { return mTextures.lookup(index); }
|
||||
const Textures& getTextures() const { return mTextures; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Meshes
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
struct MeshEntry : public LLDictionaryEntry
|
||||
{
|
||||
MeshEntry(EBakedTextureIndex baked_index,
|
||||
const std::string &name, // names of mesh types as they are used in avatar_lad.xml
|
||||
U8 level,
|
||||
LLJointPickName pick);
|
||||
// Levels of Detail for each mesh. Must match levels of detail present in avatar_lad.xml
|
||||
// Otherwise meshes will be unable to be found, or levels of detail will be ignored
|
||||
const U8 mLOD;
|
||||
const EBakedTextureIndex mBakedID;
|
||||
const LLJointPickName mPickName;
|
||||
};
|
||||
|
||||
struct MeshEntries : public LLDictionary<EMeshIndex, MeshEntry>
|
||||
{
|
||||
MeshEntries();
|
||||
} mMeshEntries;
|
||||
const MeshEntry* getMeshEntry(EMeshIndex index) const { return mMeshEntries.lookup(index); }
|
||||
const MeshEntries& getMeshEntries() const { return mMeshEntries; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Baked Textures
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
struct BakedEntry : public LLDictionaryEntry
|
||||
{
|
||||
BakedEntry(ETextureIndex tex_index,
|
||||
const std::string &name, // unused, but necessary for templating.
|
||||
const std::string &hash_name,
|
||||
U32 num_local_textures, ... ); // # local textures, local texture list, # wearables, wearable list
|
||||
// Local Textures
|
||||
const ETextureIndex mTextureIndex;
|
||||
texture_vec_t mLocalTextures;
|
||||
// Wearables
|
||||
const LLUUID mWearablesHashID;
|
||||
wearables_vec_t mWearables;
|
||||
};
|
||||
|
||||
struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry>
|
||||
{
|
||||
BakedTextures();
|
||||
} mBakedTextures;
|
||||
const BakedEntry* getBakedTexture(EBakedTextureIndex index) const { return mBakedTextures.lookup(index); }
|
||||
const BakedTextures& getBakedTextures() const { return mBakedTextures; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Convenience Functions
|
||||
//--------------------------------------------------------------------
|
||||
public:
|
||||
// Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED
|
||||
static ETextureIndex bakedToLocalTextureIndex(EBakedTextureIndex t);
|
||||
|
||||
// find a baked texture index based on its name
|
||||
static EBakedTextureIndex findBakedByRegionName(std::string name);
|
||||
static EBakedTextureIndex findBakedByImageName(std::string name);
|
||||
|
||||
// Given a texture entry, determine which wearable type owns it.
|
||||
static LLWearableType::EType getTEWearableType(ETextureIndex index);
|
||||
|
||||
}; // End LLAvatarAppearanceDictionary
|
||||
|
||||
} // End namespace LLAvatarAppearanceDefines
|
||||
|
||||
#endif //LL_AVATARAPPEARANCE_DEFINES_H
|
||||
326
indra/llappearance/llavatarjoint.cpp
Normal file
326
indra/llappearance/llavatarjoint.cpp
Normal file
@@ -0,0 +1,326 @@
|
||||
/**
|
||||
* @file llavatarjoint.cpp
|
||||
* @brief Implementation of LLAvatarJoint class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Header Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "llavatarjoint.h"
|
||||
|
||||
#include "llgl.h"
|
||||
#include "llrender.h"
|
||||
#include "llmath.h"
|
||||
#include "llglheaders.h"
|
||||
#include "llavatarappearance.h"
|
||||
|
||||
const F32 DEFAULT_AVATAR_JOINT_LOD = 0.0f;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Static Data
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLAvatarJoint::sDisableLOD = FALSE;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJoint()
|
||||
// Class Constructors
|
||||
//-----------------------------------------------------------------------------
|
||||
LLAvatarJoint::LLAvatarJoint() :
|
||||
LLJoint()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
LLAvatarJoint::LLAvatarJoint(const std::string &name, LLJoint *parent) :
|
||||
LLJoint(name, parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
LLAvatarJoint::LLAvatarJoint(S32 joint_num) :
|
||||
LLJoint(joint_num)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
void LLAvatarJoint::init()
|
||||
{
|
||||
mValid = FALSE;
|
||||
mComponents = SC_JOINT | SC_BONE | SC_AXES;
|
||||
mMinPixelArea = DEFAULT_AVATAR_JOINT_LOD;
|
||||
mPickName = PN_DEFAULT;
|
||||
mVisible = TRUE;
|
||||
mMeshID = 0;
|
||||
mIsTransparent = FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ~LLAvatarJoint()
|
||||
// Class Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
LLAvatarJoint::~LLAvatarJoint()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// setValid()
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJoint::setValid( BOOL valid, BOOL recursive )
|
||||
{
|
||||
//----------------------------------------------------------------
|
||||
// set visibility for this joint
|
||||
//----------------------------------------------------------------
|
||||
mValid = valid;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// set visibility for children
|
||||
//----------------------------------------------------------------
|
||||
if (recursive)
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = (LLAvatarJoint*)(*iter);
|
||||
joint->setValid(valid, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// setSkeletonComponents()
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJoint::setSkeletonComponents( U32 comp, BOOL recursive )
|
||||
{
|
||||
mComponents = comp;
|
||||
if (recursive)
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
joint->setSkeletonComponents(comp, recursive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive)
|
||||
{
|
||||
mVisible = visible;
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = (LLAvatarJoint*)(*iter);
|
||||
joint->setVisible(visible, recursive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLAvatarJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area)
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
joint->updateFaceSizes(num_vertices, num_indices, pixel_area);
|
||||
}
|
||||
}
|
||||
|
||||
void LLAvatarJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
joint->updateFaceData(face, pixel_area, damp_wind, terse_update);
|
||||
}
|
||||
}
|
||||
|
||||
void LLAvatarJoint::updateJointGeometry()
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
joint->updateJointGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate)
|
||||
{
|
||||
BOOL lod_changed = FALSE;
|
||||
BOOL found_lod = FALSE;
|
||||
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
F32 jointLOD = joint->getLOD();
|
||||
|
||||
if (found_lod || jointLOD == DEFAULT_AVATAR_JOINT_LOD)
|
||||
{
|
||||
// we've already found a joint to enable, so enable the rest as alternatives
|
||||
lod_changed |= joint->updateLOD(pixel_area, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pixel_area >= jointLOD || sDisableLOD)
|
||||
{
|
||||
lod_changed |= joint->updateLOD(pixel_area, TRUE);
|
||||
found_lod = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
lod_changed |= joint->updateLOD(pixel_area, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lod_changed;
|
||||
}
|
||||
|
||||
void LLAvatarJoint::dump()
|
||||
{
|
||||
for (child_list_t::iterator iter = mChildren.begin();
|
||||
iter != mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
|
||||
joint->dump();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLAvatarJoint::setMeshesToChildren()
|
||||
{
|
||||
removeAllChildren();
|
||||
for (avatar_joint_mesh_list_t::iterator iter = mMeshParts.begin();
|
||||
iter != mMeshParts.end(); iter++)
|
||||
{
|
||||
addChild((*iter));
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointCollisionVolume()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLAvatarJointCollisionVolume::LLAvatarJointCollisionVolume()
|
||||
{
|
||||
mUpdateXform = FALSE;
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
U32 LLAvatarJointCollisionVolume::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy )
|
||||
{
|
||||
llerrs << "Cannot call render() on LLAvatarJointCollisionVolume" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LLVector3 LLAvatarJointCollisionVolume::getVolumePos(LLVector3 &offset)
|
||||
{
|
||||
mUpdateXform = TRUE;
|
||||
|
||||
LLVector3 result = offset;
|
||||
result.scaleVec(getScale());
|
||||
result.rotVec(getWorldRotation());
|
||||
result += getWorldPosition();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void LLAvatarJointCollisionVolume::renderCollision()
|
||||
{
|
||||
updateWorldMatrix();
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix( &mXform.getWorldMatrix().mMatrix[0][0] );
|
||||
|
||||
gGL.diffuseColor3f( 0.f, 0.f, 1.f );
|
||||
|
||||
gGL.begin(LLRender::LINES);
|
||||
|
||||
LLVector3 v[] =
|
||||
{
|
||||
LLVector3(1,0,0),
|
||||
LLVector3(-1,0,0),
|
||||
LLVector3(0,1,0),
|
||||
LLVector3(0,-1,0),
|
||||
|
||||
LLVector3(0,0,-1),
|
||||
LLVector3(0,0,1),
|
||||
};
|
||||
|
||||
//sides
|
||||
gGL.vertex3fv(v[0].mV);
|
||||
gGL.vertex3fv(v[2].mV);
|
||||
|
||||
gGL.vertex3fv(v[0].mV);
|
||||
gGL.vertex3fv(v[3].mV);
|
||||
|
||||
gGL.vertex3fv(v[1].mV);
|
||||
gGL.vertex3fv(v[2].mV);
|
||||
|
||||
gGL.vertex3fv(v[1].mV);
|
||||
gGL.vertex3fv(v[3].mV);
|
||||
|
||||
|
||||
//top
|
||||
gGL.vertex3fv(v[0].mV);
|
||||
gGL.vertex3fv(v[4].mV);
|
||||
|
||||
gGL.vertex3fv(v[1].mV);
|
||||
gGL.vertex3fv(v[4].mV);
|
||||
|
||||
gGL.vertex3fv(v[2].mV);
|
||||
gGL.vertex3fv(v[4].mV);
|
||||
|
||||
gGL.vertex3fv(v[3].mV);
|
||||
gGL.vertex3fv(v[4].mV);
|
||||
|
||||
|
||||
//bottom
|
||||
gGL.vertex3fv(v[0].mV);
|
||||
gGL.vertex3fv(v[5].mV);
|
||||
|
||||
gGL.vertex3fv(v[1].mV);
|
||||
gGL.vertex3fv(v[5].mV);
|
||||
|
||||
gGL.vertex3fv(v[2].mV);
|
||||
gGL.vertex3fv(v[5].mV);
|
||||
|
||||
gGL.vertex3fv(v[3].mV);
|
||||
gGL.vertex3fv(v[5].mV);
|
||||
|
||||
gGL.end();
|
||||
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
|
||||
// End
|
||||
140
indra/llappearance/llavatarjoint.h
Normal file
140
indra/llappearance/llavatarjoint.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* @file llavatarjoint.h
|
||||
* @brief Implementation of LLAvatarJoint class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLAVATARJOINT_H
|
||||
#define LL_LLAVATARJOINT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Header Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "lljoint.h"
|
||||
#include "lljointpickname.h"
|
||||
|
||||
class LLFace;
|
||||
class LLAvatarJointMesh;
|
||||
|
||||
extern const F32 DEFAULT_AVATAR_JOINT_LOD;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// class LLViewerJoint
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLAvatarJoint :
|
||||
public LLJoint
|
||||
{
|
||||
public:
|
||||
LLAvatarJoint();
|
||||
LLAvatarJoint(S32 joint_num);
|
||||
// *TODO: Only used for LLVOAvatarSelf::mScreenp. *DOES NOT INITIALIZE mResetAfterRestoreOldXform*
|
||||
LLAvatarJoint(const std::string &name, LLJoint *parent = NULL);
|
||||
virtual ~LLAvatarJoint();
|
||||
|
||||
// Gets the validity of this joint
|
||||
BOOL getValid() { return mValid; }
|
||||
|
||||
// Sets the validity of this joint
|
||||
virtual void setValid( BOOL valid, BOOL recursive=FALSE );
|
||||
|
||||
// Returns true if this object is transparent.
|
||||
// This is used to determine in which order to draw objects.
|
||||
virtual BOOL isTransparent() { return mIsTransparent; }
|
||||
|
||||
// Returns true if this object should inherit scale modifiers from its immediate parent
|
||||
virtual BOOL inheritScale() { return FALSE; }
|
||||
|
||||
enum Components
|
||||
{
|
||||
SC_BONE = 1,
|
||||
SC_JOINT = 2,
|
||||
SC_AXES = 4
|
||||
};
|
||||
|
||||
// Selects which skeleton components to draw
|
||||
void setSkeletonComponents( U32 comp, BOOL recursive = TRUE );
|
||||
|
||||
// Returns which skeleton components are enables for drawing
|
||||
U32 getSkeletonComponents() { return mComponents; }
|
||||
|
||||
// Sets the level of detail for this node as a minimum
|
||||
// pixel area threshold. If the current pixel area for this
|
||||
// object is less than the specified threshold, the node is
|
||||
// not traversed. In addition, if a value is specified (not
|
||||
// default of 0.0), and the pixel area is larger than the
|
||||
// specified minimum, the node is rendered, but no other siblings
|
||||
// of this node under the same parent will be.
|
||||
F32 getLOD() { return mMinPixelArea; }
|
||||
void setLOD( F32 pixelArea ) { mMinPixelArea = pixelArea; }
|
||||
|
||||
void setPickName(LLJointPickName name) { mPickName = name; }
|
||||
LLJointPickName getPickName() { return mPickName; }
|
||||
|
||||
void setVisible( BOOL visible, BOOL recursive );
|
||||
|
||||
// Takes meshes in mMeshParts and sets each one as a child joint
|
||||
void setMeshesToChildren();
|
||||
|
||||
// LLViewerJoint interface
|
||||
virtual U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ) = 0;
|
||||
virtual void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
|
||||
virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
|
||||
virtual BOOL updateLOD(F32 pixel_area, BOOL activate);
|
||||
virtual void updateJointGeometry();
|
||||
virtual void dump();
|
||||
|
||||
|
||||
public:
|
||||
static BOOL sDisableLOD;
|
||||
avatar_joint_mesh_list_t mMeshParts; //LLViewerJointMesh*
|
||||
void setMeshID( S32 id ) {mMeshID = id;}
|
||||
|
||||
protected:
|
||||
void init();
|
||||
|
||||
BOOL mValid;
|
||||
BOOL mIsTransparent;
|
||||
U32 mComponents;
|
||||
F32 mMinPixelArea;
|
||||
LLJointPickName mPickName;
|
||||
BOOL mVisible;
|
||||
S32 mMeshID;
|
||||
};
|
||||
|
||||
class LLAvatarJointCollisionVolume : public LLAvatarJoint
|
||||
{
|
||||
public:
|
||||
LLAvatarJointCollisionVolume();
|
||||
virtual ~LLAvatarJointCollisionVolume() {};
|
||||
|
||||
/*virtual*/ BOOL inheritScale() { return TRUE; }
|
||||
/*virtual*/ U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE );
|
||||
|
||||
void renderCollision();
|
||||
|
||||
LLVector3 getVolumePos(LLVector3 &offset);
|
||||
};
|
||||
|
||||
#endif // LL_LLAVATARJOINT_H
|
||||
|
||||
|
||||
375
indra/llappearance/llavatarjointmesh.cpp
Normal file
375
indra/llappearance/llavatarjointmesh.cpp
Normal file
@@ -0,0 +1,375 @@
|
||||
/**
|
||||
* @file LLAvatarJointMesh.cpp
|
||||
* @brief Implementation of LLAvatarJointMesh class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Header Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "linden_common.h"
|
||||
#include "imageids.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "llrender.h"
|
||||
|
||||
#include "llavatarjointmesh.h"
|
||||
#include "llavatarappearance.h"
|
||||
//#include "llapr.h"
|
||||
//#include "llbox.h"
|
||||
//#include "lldrawable.h"
|
||||
//#include "lldrawpoolavatar.h"
|
||||
//#include "lldrawpoolbump.h"
|
||||
//#include "lldynamictexture.h"
|
||||
//#include "llface.h"
|
||||
//#include "llgldbg.h"
|
||||
//#include "llglheaders.h"
|
||||
#include "lltexlayer.h"
|
||||
//#include "llviewercamera.h"
|
||||
//#include "llviewercontrol.h"
|
||||
//#include "llviewertexturelist.h"
|
||||
//#include "llsky.h"
|
||||
//#include "pipeline.h"
|
||||
//#include "llviewershadermgr.h"
|
||||
#include "llmath.h"
|
||||
#include "v4math.h"
|
||||
#include "m3math.h"
|
||||
#include "m4math.h"
|
||||
#include "llmatrix4a.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::LLSkinJoint
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLSkinJoint
|
||||
//-----------------------------------------------------------------------------
|
||||
LLSkinJoint::LLSkinJoint()
|
||||
{
|
||||
mJoint = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ~LLSkinJoint
|
||||
//-----------------------------------------------------------------------------
|
||||
LLSkinJoint::~LLSkinJoint()
|
||||
{
|
||||
mJoint = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLSkinJoint::setupSkinJoint()
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLSkinJoint::setupSkinJoint( LLAvatarJoint *joint)
|
||||
{
|
||||
// find the named joint
|
||||
mJoint = joint;
|
||||
if ( !mJoint )
|
||||
{
|
||||
llinfos << "Can't find joint" << llendl;
|
||||
}
|
||||
|
||||
// compute the inverse root skin matrix
|
||||
mRootToJointSkinOffset.clearVec();
|
||||
|
||||
LLVector3 rootSkinOffset;
|
||||
while (joint)
|
||||
{
|
||||
rootSkinOffset += joint->getSkinOffset();
|
||||
joint = (LLAvatarJoint*)joint->getParent();
|
||||
}
|
||||
|
||||
mRootToJointSkinOffset = -rootSkinOffset;
|
||||
mRootToParentJointSkinOffset = mRootToJointSkinOffset;
|
||||
mRootToParentJointSkinOffset += mJoint->getSkinOffset();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BOOL LLAvatarJointMesh::sPipelineRender = FALSE;
|
||||
EAvatarRenderPass LLAvatarJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE;
|
||||
U32 LLAvatarJointMesh::sClothingMaskImageName = 0;
|
||||
LLColor4 LLAvatarJointMesh::sClothingInnerColor;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLAvatarJointMesh::LLAvatarJointMesh()
|
||||
:
|
||||
mTexture( NULL ),
|
||||
mLayerSet( NULL ),
|
||||
mTestImageName( 0 ),
|
||||
mFaceIndexCount(0)
|
||||
{
|
||||
|
||||
mColor[0] = 1.0f;
|
||||
mColor[1] = 1.0f;
|
||||
mColor[2] = 1.0f;
|
||||
mColor[3] = 1.0f;
|
||||
mShiny = 0.0f;
|
||||
mCullBackFaces = TRUE;
|
||||
|
||||
mMesh = NULL;
|
||||
|
||||
mNumSkinJoints = 0;
|
||||
mSkinJoints = NULL;
|
||||
|
||||
mFace = NULL;
|
||||
|
||||
mMeshID = 0;
|
||||
mUpdateXform = FALSE;
|
||||
|
||||
mValid = FALSE;
|
||||
|
||||
mIsTransparent = FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ~LLAvatarJointMesh()
|
||||
// Class Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
LLAvatarJointMesh::~LLAvatarJointMesh()
|
||||
{
|
||||
mMesh = NULL;
|
||||
mTexture = NULL;
|
||||
freeSkinData();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::allocateSkinData()
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLAvatarJointMesh::allocateSkinData( U32 numSkinJoints )
|
||||
{
|
||||
mSkinJoints = new LLSkinJoint[ numSkinJoints ];
|
||||
mNumSkinJoints = numSkinJoints;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::freeSkinData()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::freeSkinData()
|
||||
{
|
||||
mNumSkinJoints = 0;
|
||||
delete [] mSkinJoints;
|
||||
mSkinJoints = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::getColor()
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::getColor( F32 *red, F32 *green, F32 *blue, F32 *alpha )
|
||||
{
|
||||
*red = mColor[0];
|
||||
*green = mColor[1];
|
||||
*blue = mColor[2];
|
||||
*alpha = mColor[3];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::setColor()
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::setColor( F32 red, F32 green, F32 blue, F32 alpha )
|
||||
{
|
||||
mColor[0] = red;
|
||||
mColor[1] = green;
|
||||
mColor[2] = blue;
|
||||
mColor[3] = alpha;
|
||||
}
|
||||
|
||||
void LLAvatarJointMesh::setColor( const LLColor4& color )
|
||||
{
|
||||
mColor = color;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::getTexture()
|
||||
//--------------------------------------------------------------------
|
||||
//LLViewerTexture *LLAvatarJointMesh::getTexture()
|
||||
//{
|
||||
// return mTexture;
|
||||
//}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::setTexture()
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::setTexture( LLGLTexture *texture )
|
||||
{
|
||||
mTexture = texture;
|
||||
|
||||
// texture and dynamic_texture are mutually exclusive
|
||||
if( texture )
|
||||
{
|
||||
mLayerSet = NULL;
|
||||
//texture->bindTexture(0);
|
||||
//texture->setClamp(TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL LLAvatarJointMesh::hasGLTexture() const
|
||||
{
|
||||
return mTexture.notNull() && mTexture->hasGLTexture();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::setLayerSet()
|
||||
// Sets the shape texture (takes precedence over normal texture)
|
||||
//--------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::setLayerSet( LLTexLayerSet* layer_set )
|
||||
{
|
||||
mLayerSet = layer_set;
|
||||
|
||||
// texture and dynamic_texture are mutually exclusive
|
||||
if( layer_set )
|
||||
{
|
||||
mTexture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLAvatarJointMesh::hasComposite() const
|
||||
{
|
||||
return (mLayerSet && mLayerSet->hasComposite());
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::getMesh()
|
||||
//--------------------------------------------------------------------
|
||||
LLPolyMesh *LLAvatarJointMesh::getMesh()
|
||||
{
|
||||
return mMesh;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLAvatarJointMesh::setMesh()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh )
|
||||
{
|
||||
// set the mesh pointer
|
||||
mMesh = mesh;
|
||||
|
||||
// release any existing skin joints
|
||||
freeSkinData();
|
||||
|
||||
if ( mMesh == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// acquire the transform from the mesh object
|
||||
setPosition( mMesh->getPosition() );
|
||||
setRotation( mMesh->getRotation() );
|
||||
setScale( mMesh->getScale() );
|
||||
|
||||
// create skin joints if necessary
|
||||
if ( mMesh->hasWeights() && !mMesh->isLOD())
|
||||
{
|
||||
U32 numJointNames = mMesh->getNumJointNames();
|
||||
|
||||
allocateSkinData( numJointNames );
|
||||
std::string *jointNames = mMesh->getJointNames();
|
||||
|
||||
U32 jn;
|
||||
for (jn = 0; jn < numJointNames; jn++)
|
||||
{
|
||||
//llinfos << "Setting up joint " << jointNames[jn] << llendl;
|
||||
LLAvatarJoint* joint = (LLAvatarJoint*)(getRoot()->findJoint(jointNames[jn]) );
|
||||
mSkinJoints[jn].setupSkinJoint( joint );
|
||||
}
|
||||
}
|
||||
|
||||
// setup joint array
|
||||
if (!mMesh->isLOD())
|
||||
{
|
||||
setupJoint((LLAvatarJoint*)getRoot());
|
||||
}
|
||||
|
||||
// llinfos << "joint render entries: " << mMesh->mJointRenderData.count() << llendl;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// setupJoint()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint)
|
||||
{
|
||||
// llinfos << "Mesh: " << getName() << llendl;
|
||||
|
||||
// S32 joint_count = 0;
|
||||
U32 sj;
|
||||
for (sj=0; sj<mNumSkinJoints; sj++)
|
||||
{
|
||||
LLSkinJoint &js = mSkinJoints[sj];
|
||||
|
||||
if (js.mJoint != current_joint)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// we've found a skinjoint for this joint..
|
||||
|
||||
// is the last joint in the array our parent?
|
||||
if(mMesh->mJointRenderData.count() && mMesh->mJointRenderData[mMesh->mJointRenderData.count() - 1]->mWorldMatrix == ¤t_joint->getParent()->getWorldMatrix())
|
||||
{
|
||||
// ...then just add ourselves
|
||||
LLAvatarJoint* jointp = js.mJoint;
|
||||
mMesh->mJointRenderData.put(new LLJointRenderData(&jointp->getWorldMatrix(), &js));
|
||||
// llinfos << "joint " << joint_count << js.mJoint->getName() << llendl;
|
||||
// joint_count++;
|
||||
}
|
||||
// otherwise add our parent and ourselves
|
||||
else
|
||||
{
|
||||
mMesh->mJointRenderData.put(new LLJointRenderData(¤t_joint->getParent()->getWorldMatrix(), NULL));
|
||||
// llinfos << "joint " << joint_count << current_joint->getParent()->getName() << llendl;
|
||||
// joint_count++;
|
||||
mMesh->mJointRenderData.put(new LLJointRenderData(¤t_joint->getWorldMatrix(), &js));
|
||||
// llinfos << "joint " << joint_count << current_joint->getName() << llendl;
|
||||
// joint_count++;
|
||||
}
|
||||
}
|
||||
|
||||
// depth-first traversal
|
||||
for (LLJoint::child_list_t::iterator iter = current_joint->mChildren.begin();
|
||||
iter != current_joint->mChildren.end(); ++iter)
|
||||
{
|
||||
LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter);
|
||||
setupJoint(child_joint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// End
|
||||
142
indra/llappearance/llavatarjointmesh.h
Normal file
142
indra/llappearance/llavatarjointmesh.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @file llavatarjointmesh.h
|
||||
* @brief Declaration of LLAvatarJointMesh class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLAVATARJOINTMESH_H
|
||||
#define LL_LLAVATARJOINTMESH_H
|
||||
|
||||
#include "llavatarjoint.h"
|
||||
#include "llgltexture.h"
|
||||
#include "llpolymesh.h"
|
||||
#include "v4color.h"
|
||||
|
||||
class LLDrawable;
|
||||
class LLFace;
|
||||
class LLCharacter;
|
||||
class LLTexLayerSet;
|
||||
|
||||
typedef enum e_avatar_render_pass
|
||||
{
|
||||
AVATAR_RENDER_PASS_SINGLE,
|
||||
AVATAR_RENDER_PASS_CLOTHING_INNER,
|
||||
AVATAR_RENDER_PASS_CLOTHING_OUTER
|
||||
} EAvatarRenderPass;
|
||||
|
||||
class LLSkinJoint
|
||||
{
|
||||
public:
|
||||
LLSkinJoint();
|
||||
~LLSkinJoint();
|
||||
BOOL setupSkinJoint( LLAvatarJoint *joint);
|
||||
|
||||
LLAvatarJoint *mJoint;
|
||||
LLVector3 mRootToJointSkinOffset;
|
||||
LLVector3 mRootToParentJointSkinOffset;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// class LLViewerJointMesh
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLAvatarJointMesh : public virtual LLAvatarJoint
|
||||
{
|
||||
protected:
|
||||
LLColor4 mColor; // color value
|
||||
// LLColor4 mSpecular; // specular color (always white for now)
|
||||
F32 mShiny; // shiny value
|
||||
LLPointer<LLGLTexture> mTexture; // ptr to a global texture
|
||||
LLTexLayerSet* mLayerSet; // ptr to a layer set owned by the avatar
|
||||
U32 mTestImageName; // handle to a temporary texture for previewing uploads
|
||||
LLPolyMesh* mMesh; // ptr to a global polymesh
|
||||
BOOL mCullBackFaces; // true by default
|
||||
LLFace* mFace; // ptr to a face w/ AGP copy of mesh
|
||||
|
||||
U32 mFaceIndexCount;
|
||||
|
||||
U32 mNumSkinJoints;
|
||||
LLSkinJoint* mSkinJoints;
|
||||
S32 mMeshID;
|
||||
|
||||
public:
|
||||
static BOOL sPipelineRender;
|
||||
//RN: this is here for testing purposes
|
||||
static U32 sClothingMaskImageName;
|
||||
static EAvatarRenderPass sRenderPass;
|
||||
static LLColor4 sClothingInnerColor;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
LLAvatarJointMesh();
|
||||
|
||||
// Destructor
|
||||
virtual ~LLAvatarJointMesh();
|
||||
|
||||
// Gets the shape color
|
||||
void getColor( F32 *red, F32 *green, F32 *blue, F32 *alpha );
|
||||
|
||||
// Sets the shape color
|
||||
void setColor( F32 red, F32 green, F32 blue, F32 alpha );
|
||||
void setColor( const LLColor4& color );
|
||||
|
||||
// Sets the shininess
|
||||
void setSpecular( const LLColor4& color, F32 shiny ) { /*mSpecular = color;*/ mShiny = shiny; };
|
||||
|
||||
// Sets the shape texture
|
||||
void setTexture( LLGLTexture *texture );
|
||||
|
||||
BOOL hasGLTexture() const;
|
||||
|
||||
void setTestTexture( U32 name ) { mTestImageName = name; }
|
||||
|
||||
// Sets layer set responsible for a dynamic shape texture (takes precedence over normal texture)
|
||||
void setLayerSet( LLTexLayerSet* layer_set );
|
||||
|
||||
BOOL hasComposite() const;
|
||||
|
||||
// Gets the poly mesh
|
||||
LLPolyMesh *getMesh();
|
||||
|
||||
// Sets the poly mesh
|
||||
void setMesh( LLPolyMesh *mesh );
|
||||
|
||||
// Sets up joint matrix data for rendering
|
||||
void setupJoint(LLAvatarJoint* current_joint);
|
||||
|
||||
// Sets ID for picking
|
||||
void setMeshID( S32 id ) {mMeshID = id;}
|
||||
|
||||
// Gets ID for picking
|
||||
S32 getMeshID() { return mMeshID; }
|
||||
|
||||
void setIsTransparent(BOOL is_transparent) { mIsTransparent = is_transparent; }
|
||||
|
||||
private:
|
||||
// Allocate skin data
|
||||
BOOL allocateSkinData( U32 numSkinJoints );
|
||||
|
||||
// Free skin data
|
||||
void freeSkinData();
|
||||
};
|
||||
|
||||
#endif // LL_LLAVATARJOINTMESH_H
|
||||
@@ -24,22 +24,20 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "lldriverparam.h"
|
||||
|
||||
#include "llfasttimer.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llvoavatarself.h"
|
||||
#include "llagent.h"
|
||||
#include "llavatarappearance.h"
|
||||
#include "llwearable.h"
|
||||
#include "llagentwearables.h"
|
||||
#include "llwearabledata.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLDriverParamInfo
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLDriverParamInfo::LLDriverParamInfo()
|
||||
LLDriverParamInfo::LLDriverParamInfo() :
|
||||
mDriverParam(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,12 +110,14 @@ void LLDriverParamInfo::toStream(std::ostream &out)
|
||||
|
||||
out << std::endl;
|
||||
|
||||
if(isAgentAvatarValid())
|
||||
if(mDriverParam && mDriverParam->getAvatarAppearance()->isSelf() &&
|
||||
mDriverParam->getAvatarAppearance()->isValid())
|
||||
{
|
||||
for (entry_info_list_t::iterator iter = mDrivenInfoList.begin(); iter != mDrivenInfoList.end(); iter++)
|
||||
{
|
||||
LLDrivenEntryInfo driven = *iter;
|
||||
LLViewerVisualParam *param = (LLViewerVisualParam*)gAgentAvatarp->getVisualParam(driven.mDrivenID);
|
||||
LLViewerVisualParam *param =
|
||||
(LLViewerVisualParam*)mDriverParam->getAvatarAppearance()->getVisualParam(driven.mDrivenID);
|
||||
if (param)
|
||||
{
|
||||
param->getInfo()->toStream(out);
|
||||
@@ -139,7 +139,9 @@ void LLDriverParamInfo::toStream(std::ostream &out)
|
||||
}
|
||||
else
|
||||
{
|
||||
llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatarp.get() << " for driver parameter " << getID() << llendl;
|
||||
llwarns << "could not get parameter " << driven.mDrivenID << " from avatar "
|
||||
<< mDriverParam->getAvatarAppearance()
|
||||
<< " for driver parameter " << getID() << llendl;
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
@@ -150,18 +152,17 @@ void LLDriverParamInfo::toStream(std::ostream &out)
|
||||
// LLDriverParam
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLDriverParam::LLDriverParam(LLVOAvatar *avatarp) :
|
||||
LLDriverParam::LLDriverParam(LLAvatarAppearance *appearance, LLWearable* wearable /* = NULL */) :
|
||||
mCurrentDistortionParam( NULL ),
|
||||
mAvatarp(avatarp),
|
||||
mWearablep(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
LLDriverParam::LLDriverParam(LLWearable *wearablep) :
|
||||
mCurrentDistortionParam( NULL ),
|
||||
mAvatarp(NULL),
|
||||
mWearablep(wearablep)
|
||||
mAvatarAppearance(appearance),
|
||||
mWearablep(wearable)
|
||||
{
|
||||
llassert(mAvatarAppearance);
|
||||
if (mWearablep)
|
||||
{
|
||||
llassert(mAvatarAppearance->isSelf());
|
||||
}
|
||||
mDefaultVec.clear();
|
||||
}
|
||||
|
||||
LLDriverParam::~LLDriverParam()
|
||||
@@ -175,49 +176,22 @@ BOOL LLDriverParam::setInfo(LLDriverParamInfo *info)
|
||||
return FALSE;
|
||||
mInfo = info;
|
||||
mID = info->mID;
|
||||
info->mDriverParam = this;
|
||||
|
||||
setWeight(getDefaultWeight(), FALSE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void LLDriverParam::setWearable(LLWearable *wearablep)
|
||||
{
|
||||
if (wearablep)
|
||||
{
|
||||
mWearablep = wearablep;
|
||||
mAvatarp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void LLDriverParam::setAvatar(LLVOAvatar *avatarp)
|
||||
{
|
||||
if (avatarp)
|
||||
{
|
||||
mWearablep = NULL;
|
||||
mAvatarp = avatarp;
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ LLViewerVisualParam* LLDriverParam::cloneParam(LLWearable* wearable) const
|
||||
{
|
||||
LLDriverParam *new_param;
|
||||
if (wearable)
|
||||
{
|
||||
new_param = new LLDriverParam(wearable);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mWearablep)
|
||||
{
|
||||
new_param = new LLDriverParam(mWearablep);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_param = new LLDriverParam(mAvatarp);
|
||||
}
|
||||
}
|
||||
llassert(wearable);
|
||||
LLDriverParam *new_param = new LLDriverParam(mAvatarAppearance, wearable);
|
||||
// FIXME DRANO this clobbers mWearablep, which means any code
|
||||
// currently using mWearablep is wrong, or at least untested.
|
||||
*new_param = *this;
|
||||
//new_param->mWearablep = wearable;
|
||||
// new_param->mDriven.clear(); // clear driven list to avoid overwriting avatar driven params from wearables.
|
||||
return new_param;
|
||||
}
|
||||
|
||||
@@ -341,18 +315,19 @@ F32 LLDriverParam::getTotalDistortion()
|
||||
return sum;
|
||||
}
|
||||
|
||||
const LLVector3 &LLDriverParam::getAvgDistortion()
|
||||
const LLVector4a &LLDriverParam::getAvgDistortion()
|
||||
{
|
||||
// It's not actually correct to take the average of averages, but it good enough here.
|
||||
LLVector3 sum;
|
||||
LLVector4a sum;
|
||||
sum.clear();
|
||||
S32 count = 0;
|
||||
for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
|
||||
{
|
||||
LLDrivenEntry* driven = &(*iter);
|
||||
sum += driven->mParam->getAvgDistortion();
|
||||
sum.add(driven->mParam->getAvgDistortion());
|
||||
count++;
|
||||
}
|
||||
sum /= (F32)count;
|
||||
sum.mul( 1.f/(F32)count);
|
||||
|
||||
mDefaultVec = sum;
|
||||
return mDefaultVec;
|
||||
@@ -375,21 +350,22 @@ F32 LLDriverParam::getMaxDistortion()
|
||||
}
|
||||
|
||||
|
||||
LLVector3 LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
|
||||
LLVector4a LLDriverParam::getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)
|
||||
{
|
||||
LLVector3 sum;
|
||||
LLVector4a sum;
|
||||
sum.clear();
|
||||
for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
|
||||
{
|
||||
LLDrivenEntry* driven = &(*iter);
|
||||
sum += driven->mParam->getVertexDistortion( index, poly_mesh );
|
||||
sum.add(driven->mParam->getVertexDistortion( index, poly_mesh ));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
const LLVector3* LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
|
||||
const LLVector4a* LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)
|
||||
{
|
||||
mCurrentDistortionParam = NULL;
|
||||
const LLVector3* v = NULL;
|
||||
const LLVector4a* v = NULL;
|
||||
for( entry_list_t::iterator iter = mDriven.begin(); iter != mDriven.end(); iter++ )
|
||||
{
|
||||
LLDrivenEntry* driven = &(*iter);
|
||||
@@ -404,7 +380,7 @@ const LLVector3* LLDriverParam::getFirstDistortion(U32 *index, LLPolyMesh **poly
|
||||
return v;
|
||||
};
|
||||
|
||||
const LLVector3* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
|
||||
const LLVector4a* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)
|
||||
{
|
||||
llassert( mCurrentDistortionParam );
|
||||
if( !mCurrentDistortionParam )
|
||||
@@ -432,7 +408,7 @@ const LLVector3* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_
|
||||
}
|
||||
|
||||
// We're already in the middle of a param's distortions, so get the next one.
|
||||
const LLVector3* v = driven->mParam->getNextDistortion( index, poly_mesh );
|
||||
const LLVector4a* v = driven->mParam->getNextDistortion( index, poly_mesh );
|
||||
if( (!v) && (iter != mDriven.end()) )
|
||||
{
|
||||
// This param is finished, so start the next param. It might not have any
|
||||
@@ -452,6 +428,20 @@ const LLVector3* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_
|
||||
return v;
|
||||
};
|
||||
|
||||
S32 LLDriverParam::getDrivenParamsCount() const
|
||||
{
|
||||
return mDriven.size();
|
||||
}
|
||||
|
||||
const LLViewerVisualParam* LLDriverParam::getDrivenParam(S32 index) const
|
||||
{
|
||||
if (0 > index || index >= (S32)mDriven.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return mDriven[index].mParam;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// setAnimationTarget()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -507,6 +497,7 @@ BOOL LLDriverParam::linkDrivenParams(visual_param_mapper mapper, BOOL only_cross
|
||||
if (!found)
|
||||
{
|
||||
LLViewerVisualParam* param = (LLViewerVisualParam*)mapper(driven_id);
|
||||
if (param) param->setParamLocation(this->getParamLocation());
|
||||
bool push = param && (!only_cross_params || param->getCrossWearable());
|
||||
if (push)
|
||||
{
|
||||
@@ -551,7 +542,7 @@ void LLDriverParam::updateCrossDrivenParams(LLWearableType::EType driven_type)
|
||||
// Thus this wearable needs to get updates from the driver wearable.
|
||||
// The call to setVisualParamWeight seems redundant, but is necessary
|
||||
// as the number of driven wearables has changed since the last update. -Nyx
|
||||
LLWearable *wearable = gAgentWearables.getTopWearable(driver_type);
|
||||
LLWearable *wearable = mAvatarAppearance->getWearableData()->getTopWearable(driver_type);
|
||||
if (wearable)
|
||||
{
|
||||
wearable->setVisualParamWeight(mID, wearable->getVisualParamWeight(mID), false);
|
||||
@@ -619,13 +610,22 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight
|
||||
|
||||
void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake)
|
||||
{
|
||||
if(isAgentAvatarValid() &&
|
||||
mWearablep &&
|
||||
driven->mParam->getCrossWearable() &&
|
||||
mWearablep->isOnTop())
|
||||
bool use_self = false;
|
||||
if(mWearablep &&
|
||||
mAvatarAppearance->isValid() &&
|
||||
driven->mParam->getCrossWearable())
|
||||
{
|
||||
LLWearable* wearable = dynamic_cast<LLWearable*> (mWearablep);
|
||||
if (mAvatarAppearance->getWearableData()->isOnTop(wearable))
|
||||
{
|
||||
use_self = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (use_self)
|
||||
{
|
||||
// call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values
|
||||
gAgentAvatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake );
|
||||
mAvatarAppearance->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "llviewervisualparam.h"
|
||||
#include "llwearabletype.h"
|
||||
|
||||
class LLPhysicsMotion;
|
||||
class LLVOAvatar;
|
||||
class LLAvatarAppearance;
|
||||
class LLDriverParam;
|
||||
class LLWearable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -71,25 +71,39 @@ public:
|
||||
protected:
|
||||
typedef std::deque<LLDrivenEntryInfo> entry_info_list_t;
|
||||
entry_info_list_t mDrivenInfoList;
|
||||
LLDriverParam* mDriverParam; // backpointer
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class LLDriverParam : public LLViewerVisualParam
|
||||
{
|
||||
friend class LLPhysicsMotion; // physics motion needs to access driven params directly.
|
||||
friend class LLPhysicsMotion;
|
||||
private:
|
||||
// Hide the default constructor. Force construction with LLAvatarAppearance.
|
||||
LLDriverParam() {}
|
||||
public:
|
||||
LLDriverParam(LLVOAvatar *avatarp);
|
||||
LLDriverParam(LLWearable *wearablep);
|
||||
LLDriverParam(LLAvatarAppearance *appearance, LLWearable* wearable = NULL);
|
||||
~LLDriverParam();
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return ll_aligned_malloc_16(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
ll_aligned_free_16(ptr);
|
||||
}
|
||||
|
||||
// Special: These functions are overridden by child classes
|
||||
LLDriverParamInfo* getInfo() const { return (LLDriverParamInfo*)mInfo; }
|
||||
// This sets mInfo and calls initialization functions
|
||||
BOOL setInfo(LLDriverParamInfo *info);
|
||||
|
||||
void setWearable(LLWearable *wearablep);
|
||||
void setAvatar(LLVOAvatar *avatarp);
|
||||
LLAvatarAppearance* getAvatarAppearance() { return mAvatarAppearance; }
|
||||
const LLAvatarAppearance* getAvatarAppearance() const { return mAvatarAppearance; }
|
||||
|
||||
void updateCrossDrivenParams(LLWearableType::EType driven_type);
|
||||
|
||||
/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
|
||||
@@ -105,23 +119,26 @@ public:
|
||||
|
||||
// LLViewerVisualParam Virtual functions
|
||||
/*virtual*/ F32 getTotalDistortion();
|
||||
/*virtual*/ const LLVector3& getAvgDistortion();
|
||||
/*virtual*/ const LLVector4a& getAvgDistortion();
|
||||
/*virtual*/ F32 getMaxDistortion();
|
||||
/*virtual*/ LLVector3 getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
|
||||
/*virtual*/ const LLVector3* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
/*virtual*/ const LLVector3* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
/*virtual*/ LLVector4a getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
|
||||
/*virtual*/ const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
/*virtual*/ const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
|
||||
S32 getDrivenParamsCount() const;
|
||||
const LLViewerVisualParam* getDrivenParam(S32 index) const;
|
||||
|
||||
protected:
|
||||
F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
|
||||
void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake);
|
||||
|
||||
|
||||
LLVector3 mDefaultVec; // temp holder
|
||||
LLVector4a mDefaultVec; // temp holder
|
||||
typedef std::vector<LLDrivenEntry> entry_list_t;
|
||||
entry_list_t mDriven;
|
||||
LLViewerVisualParam* mCurrentDistortionParam;
|
||||
// Backlink only; don't make this an LLPointer.
|
||||
LLVOAvatar* mAvatarp;
|
||||
LLAvatarAppearance* mAvatarAppearance;
|
||||
LLWearable* mWearablep;
|
||||
};
|
||||
|
||||
49
indra/llappearance/lljointpickname.h
Normal file
49
indra/llappearance/lljointpickname.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file lljointpickname.h
|
||||
* @brief Defines OpenGL seleciton stack names
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LL_LLJOINTPICKNAME_H
|
||||
#define LL_LLJOINTPICKNAME_H
|
||||
|
||||
class LLAvatarJointMesh;
|
||||
|
||||
// Sets the OpenGL selection stack name that is pushed and popped
|
||||
// with this joint state. The default value indicates that no name
|
||||
// should be pushed/popped.
|
||||
enum LLJointPickName
|
||||
{
|
||||
PN_DEFAULT = -1,
|
||||
PN_0 = 0,
|
||||
PN_1 = 1,
|
||||
PN_2 = 2,
|
||||
PN_3 = 3,
|
||||
PN_4 = 4,
|
||||
PN_5 = 5
|
||||
};
|
||||
|
||||
typedef std::vector<LLAvatarJointMesh*> avatar_joint_mesh_list_t;
|
||||
|
||||
#endif // LL_LLJOINTPICKNAME_H
|
||||
@@ -23,13 +23,14 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "lllocaltextureobject.h"
|
||||
|
||||
#include "llimage.h"
|
||||
#include "llrender.h"
|
||||
#include "lltexlayer.h"
|
||||
#include "llviewertexture.h"
|
||||
#include "lltextureentry.h"
|
||||
#include "llgltexture.h"
|
||||
#include "lluuid.h"
|
||||
#include "llwearable.h"
|
||||
|
||||
@@ -41,7 +42,7 @@ LLLocalTextureObject::LLLocalTextureObject() :
|
||||
mImage = NULL;
|
||||
}
|
||||
|
||||
LLLocalTextureObject::LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id) :
|
||||
LLLocalTextureObject::LLLocalTextureObject(LLGLTexture* image, const LLUUID& id) :
|
||||
mIsBakedReady(FALSE),
|
||||
mDiscard(MAX_DISCARD_LEVEL+1)
|
||||
{
|
||||
@@ -77,7 +78,7 @@ LLLocalTextureObject::~LLLocalTextureObject()
|
||||
{
|
||||
}
|
||||
|
||||
LLViewerFetchedTexture* LLLocalTextureObject::getImage() const
|
||||
LLGLTexture* LLLocalTextureObject::getImage() const
|
||||
{
|
||||
return mImage;
|
||||
}
|
||||
@@ -126,7 +127,7 @@ BOOL LLLocalTextureObject::getBakedReady() const
|
||||
return mIsBakedReady;
|
||||
}
|
||||
|
||||
void LLLocalTextureObject::setImage(LLViewerFetchedTexture* new_image)
|
||||
void LLLocalTextureObject::setImage(LLGLTexture* new_image)
|
||||
{
|
||||
mImage = new_image;
|
||||
}
|
||||
@@ -29,11 +29,10 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "llviewertexture.h"
|
||||
#include "llpointer.h"
|
||||
#include "llgltexture.h"
|
||||
|
||||
class LLUUID;
|
||||
class LLTexLayer;
|
||||
class LLTextureEntry;
|
||||
class LLTexLayerTemplate;
|
||||
class LLWearable;
|
||||
|
||||
@@ -44,11 +43,11 @@ class LLLocalTextureObject
|
||||
{
|
||||
public:
|
||||
LLLocalTextureObject();
|
||||
LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id);
|
||||
LLLocalTextureObject(LLGLTexture* image, const LLUUID& id);
|
||||
LLLocalTextureObject(const LLLocalTextureObject& lto);
|
||||
~LLLocalTextureObject();
|
||||
|
||||
LLViewerFetchedTexture* getImage() const;
|
||||
LLGLTexture* getImage() const;
|
||||
LLTexLayer* getTexLayer(U32 index) const;
|
||||
LLTexLayer* getTexLayer(const std::string &name);
|
||||
U32 getNumTexLayers() const;
|
||||
@@ -56,7 +55,7 @@ public:
|
||||
S32 getDiscard() const;
|
||||
BOOL getBakedReady() const;
|
||||
|
||||
void setImage(LLViewerFetchedTexture* new_image);
|
||||
void setImage(LLGLTexture* new_image);
|
||||
BOOL setTexLayer(LLTexLayer *new_tex_layer, U32 index);
|
||||
BOOL addTexLayer(LLTexLayer *new_tex_layer, LLWearable *wearable);
|
||||
BOOL addTexLayer(LLTexLayerTemplate *new_tex_layer, LLWearable *wearable);
|
||||
@@ -70,7 +69,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
LLPointer<LLViewerFetchedTexture> mImage;
|
||||
LLPointer<LLGLTexture> mImage;
|
||||
// NOTE: LLLocalTextureObject should be the exclusive owner of mTexEntry and mTexLayer
|
||||
// using shared pointers here only for smart assignment & cleanup
|
||||
// do NOT create new shared pointers to these objects, or keep pointers to them around
|
||||
@@ -27,25 +27,24 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Header Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llpolymesh.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "llmemory.h"
|
||||
|
||||
#include "llviewercontrol.h"
|
||||
//#include "llviewercontrol.h"
|
||||
#include "llxmltree.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llwearable.h"
|
||||
#include "llavatarappearance.h"
|
||||
//#include "llwearable.h"
|
||||
#include "lldir.h"
|
||||
#include "llvolume.h"
|
||||
#include "llendianswizzle.h"
|
||||
|
||||
#include "llpolymesh.h"
|
||||
|
||||
#define HEADER_ASCII "Linden Mesh 1.0"
|
||||
#define HEADER_BINARY "Linden Binary Mesh 1.0"
|
||||
|
||||
extern LLControlGroup gSavedSettings; // read only
|
||||
//extern LLControlGroup gSavedSettings; // read only
|
||||
|
||||
LLPolyMorphData *clone_morph_param_duplicate(const LLPolyMorphData *src_data,
|
||||
const std::string &name);
|
||||
@@ -125,28 +124,28 @@ void LLPolyMeshSharedData::setupLOD(LLPolyMeshSharedData* reference_data)
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLPolyMeshSharedData::freeMeshData()
|
||||
{
|
||||
if (!mReferenceData)
|
||||
{
|
||||
mNumVertices = 0;
|
||||
if (!mReferenceData)
|
||||
{
|
||||
mNumVertices = 0;
|
||||
|
||||
delete [] mBaseCoords;
|
||||
mBaseCoords = NULL;
|
||||
ll_aligned_free_16(mBaseCoords);
|
||||
mBaseCoords = NULL;
|
||||
|
||||
delete [] mBaseNormals;
|
||||
mBaseNormals = NULL;
|
||||
ll_aligned_free_16(mBaseNormals);
|
||||
mBaseNormals = NULL;
|
||||
|
||||
delete [] mBaseBinormals;
|
||||
mBaseBinormals = NULL;
|
||||
ll_aligned_free_16(mBaseBinormals);
|
||||
mBaseBinormals = NULL;
|
||||
|
||||
delete [] mTexCoords;
|
||||
mTexCoords = NULL;
|
||||
ll_aligned_free_16(mTexCoords);
|
||||
mTexCoords = NULL;
|
||||
|
||||
delete [] mDetailTexCoords;
|
||||
mDetailTexCoords = NULL;
|
||||
ll_aligned_free_16(mDetailTexCoords);
|
||||
mDetailTexCoords = NULL;
|
||||
|
||||
delete [] mWeights;
|
||||
mWeights = NULL;
|
||||
}
|
||||
ll_aligned_free_16(mWeights);
|
||||
mWeights = NULL;
|
||||
}
|
||||
|
||||
mNumFaces = 0;
|
||||
delete [] mFaces;
|
||||
@@ -228,17 +227,21 @@ U32 LLPolyMeshSharedData::getNumKB()
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
|
||||
{
|
||||
U32 i;
|
||||
mBaseCoords = new LLVector3[ numVertices ];
|
||||
mBaseNormals = new LLVector3[ numVertices ];
|
||||
mBaseBinormals = new LLVector3[ numVertices ];
|
||||
mTexCoords = new LLVector2[ numVertices ];
|
||||
mDetailTexCoords = new LLVector2[ numVertices ];
|
||||
mWeights = new F32[ numVertices ];
|
||||
for (i = 0; i < numVertices; i++)
|
||||
U32 i;
|
||||
mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
|
||||
mBaseNormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
|
||||
mBaseBinormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
|
||||
mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
|
||||
mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
|
||||
mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32));
|
||||
for (i = 0; i < numVertices; i++)
|
||||
{
|
||||
mBaseCoords[i].clear();
|
||||
mBaseNormals[i].clear();
|
||||
mBaseBinormals[i].clear();
|
||||
mTexCoords[i].clear();
|
||||
mWeights[i] = 0.f;
|
||||
}
|
||||
}
|
||||
mNumVertices = numVertices;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -408,40 +411,48 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName )
|
||||
|
||||
allocateVertexData( numVertices );
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Coords
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(mBaseCoords, 3*sizeof(float), numVertices, fp);
|
||||
llendianswizzle(mBaseCoords, sizeof(float), 3*numVertices);
|
||||
if (numRead != numVertices)
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
llerrs << "can't read Coordinates from " << fileName << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
// Coords
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(&mBaseCoords[i], sizeof(float), 3, fp);
|
||||
llendianswizzle(&mBaseCoords[i], sizeof(float), 3);
|
||||
if (numRead != 3)
|
||||
{
|
||||
llerrs << "can't read Coordinates from " << fileName << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Normals
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(mBaseNormals, 3*sizeof(float), numVertices, fp);
|
||||
llendianswizzle(mBaseNormals, sizeof(float), 3*numVertices);
|
||||
if (numRead != numVertices)
|
||||
{
|
||||
llerrs << " can't read Normals from " << fileName << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
//----------------------------------------------------------------
|
||||
// Normals
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(&mBaseNormals[i], sizeof(float), 3, fp);
|
||||
llendianswizzle(&mBaseNormals[i], sizeof(float), 3);
|
||||
if (numRead != 3)
|
||||
{
|
||||
llerrs << " can't read Normals from " << fileName << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Binormals
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(mBaseBinormals, 3*sizeof(float), numVertices, fp);
|
||||
llendianswizzle(mBaseBinormals, sizeof(float), 3*numVertices);
|
||||
if (numRead != numVertices)
|
||||
{
|
||||
llerrs << " can't read Binormals from " << fileName << llendl;
|
||||
return FALSE;
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
//----------------------------------------------------------------
|
||||
// Binormals
|
||||
//----------------------------------------------------------------
|
||||
numRead = fread(&mBaseBinormals[i], sizeof(float), 3, fp);
|
||||
llendianswizzle(&mBaseBinormals[i], sizeof(float), 3);
|
||||
if (numRead != 3)
|
||||
{
|
||||
llerrs << " can't read Binormals from " << fileName << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// TexCoords
|
||||
//----------------------------------------------------------------
|
||||
@@ -767,21 +778,28 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
|
||||
{
|
||||
// Allocate memory without initializing every vector
|
||||
// NOTE: This makes asusmptions about the size of LLVector[234]
|
||||
int nverts = mSharedData->mNumVertices;
|
||||
int nfloats = nverts * (2*4 + 3*3 + 2 + 4);
|
||||
S32 nverts = mSharedData->mNumVertices;
|
||||
//make sure it's an even number of verts for alignment
|
||||
nverts += nverts%2;
|
||||
S32 nfloats = nverts * (
|
||||
4 + //coords
|
||||
4 + //normals
|
||||
4 + //weights
|
||||
2 + //coords
|
||||
4 + //scaled normals
|
||||
4 + //binormals
|
||||
4); //scaled binormals
|
||||
|
||||
//use 16 byte aligned vertex data to make LLPolyMesh SSE friendly
|
||||
mVertexData = (F32*) ll_aligned_malloc_16(nfloats*4);
|
||||
int offset = 0;
|
||||
mCoords = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
|
||||
mNormals = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
|
||||
mClothingWeights = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
|
||||
mTexCoords = (LLVector2*)(mVertexData + offset); offset += 2*nverts;
|
||||
|
||||
// these members don't need to be 16-byte aligned, but the first one might be
|
||||
// read during an aligned memcpy of mTexCoords
|
||||
mScaledNormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
|
||||
mBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
|
||||
mScaledBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
|
||||
S32 offset = 0;
|
||||
mCoords = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
mNormals = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
mClothingWeights = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
mTexCoords = (LLVector2*)(mVertexData + offset); offset += 2*nverts;
|
||||
mScaledNormals = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
mBinormals = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
mScaledBinormals = (LLVector4a*)(mVertexData + offset); offset += 4*nverts;
|
||||
initializeForMorph();
|
||||
}
|
||||
}
|
||||
@@ -966,38 +984,47 @@ BOOL LLPolyMesh::saveLLM(LLFILE *fp)
|
||||
//----------------------------------------------------------------
|
||||
// Coords
|
||||
//----------------------------------------------------------------
|
||||
LLVector3* coords = mSharedData->mBaseCoords;
|
||||
|
||||
llendianswizzle(coords, sizeof(float), 3*numVertices);
|
||||
if (fwrite(coords, 3*sizeof(float), numVertices, fp) != numVertices)
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
LLVector4a& coords = mSharedData->mBaseCoords[i];
|
||||
|
||||
llendianswizzle(coords.getF32ptr(), sizeof(float), 3);
|
||||
if (fwrite(coords.getF32ptr(), 3*sizeof(float), 1, fp) != 1)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
}
|
||||
llendianswizzle(coords.getF32ptr(), sizeof(float), 3);
|
||||
}
|
||||
llendianswizzle(coords, sizeof(float), 3*numVertices);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Normals
|
||||
//----------------------------------------------------------------
|
||||
LLVector3* normals = mSharedData->mBaseNormals;
|
||||
|
||||
llendianswizzle(normals, sizeof(float), 3*numVertices);
|
||||
if (fwrite(normals, 3*sizeof(float), numVertices, fp) != numVertices)
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
LLVector4a& normals = mSharedData->mBaseNormals[i];
|
||||
|
||||
llendianswizzle(normals.getF32ptr(), sizeof(float), 3);
|
||||
if (fwrite(normals.getF32ptr(), 3*sizeof(float), 1, fp) != 1)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
}
|
||||
llendianswizzle(normals.getF32ptr(), sizeof(float), 3);
|
||||
}
|
||||
llendianswizzle(normals, sizeof(float), 3*numVertices);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Binormals
|
||||
//----------------------------------------------------------------
|
||||
LLVector3* binormals = mSharedData->mBaseBinormals;
|
||||
|
||||
llendianswizzle(binormals, sizeof(float), 3*numVertices);
|
||||
if (fwrite(binormals, 3*sizeof(float), numVertices, fp) != numVertices)
|
||||
for (U16 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
LLVector4a& binormals = mSharedData->mBaseBinormals[i];
|
||||
|
||||
llendianswizzle(binormals.getF32ptr(), sizeof(float), 3);
|
||||
if (fwrite(binormals.getF32ptr(), 3*sizeof(float), 1, fp) != 1)
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
}
|
||||
llendianswizzle(binormals.getF32ptr(), sizeof(float), 3);
|
||||
}
|
||||
llendianswizzle(binormals, sizeof(float), 3*numVertices);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// TexCoords
|
||||
@@ -1224,24 +1251,24 @@ BOOL LLPolyMesh::saveOBJ(LLFILE *fp)
|
||||
int nfaces = mSharedData->mNumFaces;
|
||||
int i;
|
||||
|
||||
LLVector4* coords = getWritableCoords();
|
||||
LLVector4a* coords = getWritableCoords();
|
||||
for ( i=0; i<nverts; i++) {
|
||||
std::string outstring = llformat("v %f %f %f\n",
|
||||
coords[i][0],
|
||||
coords[i][1],
|
||||
coords[i][2]);
|
||||
coords[i].getF32ptr()[0],
|
||||
coords[i].getF32ptr()[1],
|
||||
coords[i].getF32ptr()[2]);
|
||||
if (fwrite(outstring.c_str(), 1, outstring.length(), fp) != outstring.length())
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
LLVector4* normals = getWritableNormals();
|
||||
LLVector4a* normals = getWritableNormals();
|
||||
for ( i=0; i<nverts; i++) {
|
||||
std::string outstring = llformat("vn %f %f %f\n",
|
||||
normals[i][0],
|
||||
normals[i][1],
|
||||
normals[i][2]);
|
||||
normals[i].getF32ptr()[0],
|
||||
normals[i].getF32ptr()[1],
|
||||
normals[i].getF32ptr()[2]);
|
||||
if (fwrite(outstring.c_str(), 1, outstring.length(), fp) != outstring.length())
|
||||
{
|
||||
llwarns << "Short write" << llendl;
|
||||
@@ -1293,9 +1320,9 @@ BOOL LLPolyMesh::loadOBJ(LLFILE *fp)
|
||||
int nnormals = 0;
|
||||
int ntexcoords = 0;
|
||||
|
||||
LLVector4* coords = getWritableCoords();
|
||||
LLVector4* normals = getWritableNormals();
|
||||
LLVector3* binormals = getWritableBinormals();
|
||||
LLVector4a* coords = getWritableCoords();
|
||||
LLVector4a* normals = getWritableNormals();
|
||||
LLVector4a* binormals = getWritableBinormals();
|
||||
LLVector2* tex = getWritableTexCoords();
|
||||
LLPolyFace* faces = getFaces();
|
||||
|
||||
@@ -1398,7 +1425,7 @@ BOOL LLPolyMesh::loadOBJ(LLFILE *fp)
|
||||
int v;
|
||||
for ( v=0; v<nverts; v++)
|
||||
{
|
||||
binormals[v].setZero();
|
||||
binormals[v].clear();
|
||||
}
|
||||
|
||||
int f;
|
||||
@@ -1408,29 +1435,18 @@ BOOL LLPolyMesh::loadOBJ(LLFILE *fp)
|
||||
S32 f1 = faces[f][1];
|
||||
S32 f2 = faces[f][2];
|
||||
|
||||
LLVector4a v0;
|
||||
LLVector4a v1;
|
||||
LLVector4a v2;
|
||||
v0.load3(coords[f0].mV);;
|
||||
v1.load3(coords[f1].mV);;
|
||||
v2.load3(coords[f2].mV);;
|
||||
LLVector2& t0 = tex[f0];
|
||||
LLVector2& t1 = tex[f1];
|
||||
LLVector2& t2 = tex[f2];
|
||||
|
||||
LLVector4a binorm;
|
||||
calc_binormal_from_triangle(binorm, v0, t0, v1, t1, v2, t2);
|
||||
calc_binormal_from_triangle(binorm, coords[f0], tex[f0], coords[f1], tex[f1], coords[f2], tex[f2]);
|
||||
binorm.normalize3fast();
|
||||
|
||||
LLVector3 binormdelta(binorm.getF32ptr());
|
||||
binormals[f0] += binormdelta;
|
||||
binormals[f1] += binormdelta;
|
||||
binormals[f2] += binormdelta;
|
||||
binormals[f0].add(binorm);
|
||||
binormals[f1].add(binorm);
|
||||
binormals[f2].add(binorm);
|
||||
}
|
||||
|
||||
for ( v=0; v<nverts; v++)
|
||||
{
|
||||
binormals[v].normVec();
|
||||
binormals[v].normalize3();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -1449,57 +1465,59 @@ BOOL LLPolyMesh::setSharedFromCurrent()
|
||||
LLPolyMesh delta(mSharedData, NULL);
|
||||
U32 nverts = delta.getNumVertices();
|
||||
|
||||
LLVector4 *delta_coords = delta.getWritableCoords();
|
||||
LLVector4 *delta_normals = delta.getWritableNormals();
|
||||
LLVector3 *delta_binormals = delta.getWritableBinormals();
|
||||
LLVector4a *delta_coords = delta.getWritableCoords();
|
||||
LLVector4a *delta_normals = delta.getWritableNormals();
|
||||
LLVector4a *delta_binormals = delta.getWritableBinormals();
|
||||
LLVector2 *delta_tex_coords = delta.getWritableTexCoords();
|
||||
|
||||
U32 vert_index;
|
||||
for( vert_index = 0; vert_index < nverts; vert_index++)
|
||||
{
|
||||
delta_coords[vert_index] -= mCoords[vert_index];
|
||||
delta_normals[vert_index] -= mNormals[vert_index];
|
||||
delta_binormals[vert_index] -= mBinormals[vert_index];
|
||||
delta_tex_coords[vert_index] -= mTexCoords[vert_index];
|
||||
delta_coords[vert_index].sub( mCoords[vert_index]);
|
||||
delta_normals[vert_index].sub( mNormals[vert_index]);
|
||||
delta_binormals[vert_index].sub( mBinormals[vert_index]);
|
||||
delta_tex_coords[vert_index] -= mTexCoords[vert_index];
|
||||
}
|
||||
|
||||
// Now copy the new base mesh
|
||||
|
||||
memcpy(mSharedData->mBaseCoords, mCoords, sizeof(LLVector3) * mSharedData->mNumVertices);
|
||||
memcpy(mSharedData->mBaseNormals, mNormals, sizeof(LLVector3) * mSharedData->mNumVertices);
|
||||
memcpy(mSharedData->mBaseBinormals, mBinormals, sizeof(LLVector3) * mSharedData->mNumVertices);
|
||||
memcpy(mSharedData->mTexCoords, mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mSharedData->mBaseCoords, (F32*) mCoords, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mSharedData->mBaseNormals, (F32*) mNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mSharedData->mBaseBinormals, (F32*) mBinormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mSharedData->mTexCoords, (F32*) mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2));
|
||||
|
||||
// Update all avatars by applying the delta
|
||||
|
||||
std::vector< LLCharacter* >::iterator avatar_it;
|
||||
for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it)
|
||||
{
|
||||
LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it;
|
||||
LLAvatarAppearance* avatarp = (LLAvatarAppearance*)*avatar_it;
|
||||
LLPolyMesh* mesh = avatarp->getMesh(mSharedData);
|
||||
if (mesh)
|
||||
{
|
||||
LLVector4 *mesh_coords = mesh->getWritableCoords();
|
||||
LLVector4 *mesh_normals = mesh->getWritableNormals();
|
||||
LLVector3 *mesh_binormals = mesh->getWritableBinormals();
|
||||
LLVector2 *mesh_tex_coords = mesh->getWritableTexCoords();
|
||||
LLVector3 *mesh_scaled_normals = mesh->getScaledNormals();
|
||||
LLVector3 *mesh_scaled_binormals = mesh->getScaledBinormals();
|
||||
LLVector4a *mesh_coords = mesh->getWritableCoords();
|
||||
LLVector4a *mesh_normals = mesh->getWritableNormals();
|
||||
LLVector4a *mesh_binormals = mesh->getWritableBinormals();
|
||||
LLVector2 *mesh_tex_coords = mesh->getWritableTexCoords();
|
||||
LLVector4a *mesh_scaled_normals = mesh->getScaledNormals();
|
||||
LLVector4a *mesh_scaled_binormals = mesh->getScaledBinormals();
|
||||
|
||||
for( vert_index = 0; vert_index < nverts; vert_index++)
|
||||
{
|
||||
mesh_coords[vert_index] -= delta_coords[vert_index];
|
||||
mesh_coords[vert_index].sub(delta_coords[vert_index]);
|
||||
mesh_tex_coords[vert_index] -= delta_tex_coords[vert_index];
|
||||
|
||||
mesh_scaled_normals[vert_index] -= LLVector3(delta_normals[vert_index]);
|
||||
LLVector3 normalized_normal = mesh_scaled_normals[vert_index];
|
||||
normalized_normal.normVec();
|
||||
mesh_normals[vert_index] = LLVector4(normalized_normal);
|
||||
mesh_scaled_normals[vert_index].sub(delta_normals[vert_index]);
|
||||
LLVector4a normalized_normal = mesh_scaled_normals[vert_index];
|
||||
normalized_normal.normalize3();
|
||||
mesh_normals[vert_index] = normalized_normal;
|
||||
|
||||
mesh_scaled_binormals[vert_index] -= delta_binormals[vert_index];
|
||||
LLVector3 tangent = mesh_scaled_binormals[vert_index] % normalized_normal;
|
||||
LLVector3 normalized_binormal = normalized_normal % tangent;
|
||||
normalized_binormal.normVec();
|
||||
mesh_scaled_binormals[vert_index].sub(delta_binormals[vert_index]);
|
||||
LLVector4a tangent;
|
||||
tangent.setCross3(mesh_scaled_binormals[vert_index], normalized_normal);
|
||||
LLVector4a normalized_binormal;
|
||||
normalized_binormal.setCross3(normalized_normal, tangent);
|
||||
normalized_binormal.normalize3();
|
||||
mesh_binormals[vert_index] = normalized_binormal;
|
||||
}
|
||||
|
||||
@@ -1598,7 +1616,7 @@ void LLPolyMesh::dumpDiagInfo(void*)
|
||||
//-----------------------------------------------------------------------------
|
||||
// getWritableCoords()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector4 *LLPolyMesh::getWritableCoords()
|
||||
LLVector4a *LLPolyMesh::getWritableCoords()
|
||||
{
|
||||
return mCoords;
|
||||
}
|
||||
@@ -1606,7 +1624,7 @@ LLVector4 *LLPolyMesh::getWritableCoords()
|
||||
//-----------------------------------------------------------------------------
|
||||
// getWritableNormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector4 *LLPolyMesh::getWritableNormals()
|
||||
LLVector4a *LLPolyMesh::getWritableNormals()
|
||||
{
|
||||
return mNormals;
|
||||
}
|
||||
@@ -1614,7 +1632,7 @@ LLVector4 *LLPolyMesh::getWritableNormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
// getWritableBinormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector3 *LLPolyMesh::getWritableBinormals()
|
||||
LLVector4a *LLPolyMesh::getWritableBinormals()
|
||||
{
|
||||
return mBinormals;
|
||||
}
|
||||
@@ -1623,7 +1641,7 @@ LLVector3 *LLPolyMesh::getWritableBinormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
// getWritableClothingWeights()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector4 *LLPolyMesh::getWritableClothingWeights()
|
||||
LLVector4a *LLPolyMesh::getWritableClothingWeights()
|
||||
{
|
||||
return mClothingWeights;
|
||||
}
|
||||
@@ -1639,7 +1657,7 @@ LLVector2 *LLPolyMesh::getWritableTexCoords()
|
||||
//-----------------------------------------------------------------------------
|
||||
// getScaledNormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector3 *LLPolyMesh::getScaledNormals()
|
||||
LLVector4a *LLPolyMesh::getScaledNormals()
|
||||
{
|
||||
return mScaledNormals;
|
||||
}
|
||||
@@ -1647,7 +1665,7 @@ LLVector3 *LLPolyMesh::getScaledNormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
// getScaledBinormals()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector3 *LLPolyMesh::getScaledBinormals()
|
||||
LLVector4a *LLPolyMesh::getScaledBinormals()
|
||||
{
|
||||
return mScaledBinormals;
|
||||
}
|
||||
@@ -1661,19 +1679,20 @@ void LLPolyMesh::initializeForMorph()
|
||||
if (!mSharedData)
|
||||
return;
|
||||
|
||||
LLVector4a::memcpyNonAliased16((F32*) mCoords, (F32*) mSharedData->mBaseCoords, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mScaledNormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mScaledBinormals, (F32*) mSharedData->mBaseNormals, sizeof(LLVector4a) * mSharedData->mNumVertices);
|
||||
LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) mSharedData->mTexCoords, sizeof(LLVector2) * (mSharedData->mNumVertices + mSharedData->mNumVertices%2));
|
||||
|
||||
for (U32 i = 0; i < (U32)mSharedData->mNumVertices; ++i)
|
||||
{
|
||||
mCoords[i] = LLVector4(mSharedData->mBaseCoords[i]);
|
||||
mNormals[i] = LLVector4(mSharedData->mBaseNormals[i]);
|
||||
mClothingWeights[i].clear();
|
||||
}
|
||||
|
||||
memcpy(mScaledNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
|
||||
memcpy(mBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
|
||||
memcpy(mScaledBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
|
||||
memcpy(mTexCoords, mSharedData->mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
|
||||
memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// getMorphList()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1750,233 +1769,4 @@ F32* LLPolyMesh::getWritableWeights() const
|
||||
return mSharedData->mWeights;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolySkeletalDistortionInfo()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLPolySkeletalDistortionInfo::LLPolySkeletalDistortionInfo()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LLPolySkeletalDistortionInfo::parseXml(LLXmlTreeNode* node)
|
||||
{
|
||||
llassert( node->hasName( "param" ) && node->getChildByName( "param_skeleton" ) );
|
||||
|
||||
if (!LLViewerVisualParamInfo::parseXml(node))
|
||||
return FALSE;
|
||||
|
||||
LLXmlTreeNode* skeletalParam = node->getChildByName("param_skeleton");
|
||||
|
||||
if (NULL == skeletalParam)
|
||||
{
|
||||
llwarns << "Failed to getChildByName(\"param_skeleton\")"
|
||||
<< llendl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for( LLXmlTreeNode* bone = skeletalParam->getFirstChild(); bone; bone = skeletalParam->getNextChild() )
|
||||
{
|
||||
if (bone->hasName("bone"))
|
||||
{
|
||||
std::string name;
|
||||
LLVector3 scale;
|
||||
LLVector3 pos;
|
||||
BOOL haspos = FALSE;
|
||||
|
||||
static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
|
||||
if (!bone->getFastAttributeString(name_string, name))
|
||||
{
|
||||
llwarns << "No bone name specified for skeletal param." << llendl;
|
||||
continue;
|
||||
}
|
||||
|
||||
static LLStdStringHandle scale_string = LLXmlTree::addAttributeString("scale");
|
||||
if (!bone->getFastAttributeVector3(scale_string, scale))
|
||||
{
|
||||
llwarns << "No scale specified for bone " << name << "." << llendl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// optional offset deformation (translation)
|
||||
static LLStdStringHandle offset_string = LLXmlTree::addAttributeString("offset");
|
||||
if (bone->getFastAttributeVector3(offset_string, pos))
|
||||
{
|
||||
haspos = TRUE;
|
||||
}
|
||||
mBoneInfoList.push_back(LLPolySkeletalBoneInfo(name, scale, pos, haspos));
|
||||
}
|
||||
else
|
||||
{
|
||||
llwarns << "Unrecognized element " << bone->getName() << " in skeletal distortion" << llendl;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolySkeletalDistortion()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLPolySkeletalDistortion::LLPolySkeletalDistortion(LLVOAvatar *avatarp)
|
||||
{
|
||||
mAvatar = avatarp;
|
||||
mDefaultVec.setVec(0.001f, 0.001f, 0.001f);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ~LLPolySkeletalDistortion()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLPolySkeletalDistortion::~LLPolySkeletalDistortion()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
|
||||
{
|
||||
llassert(mInfo == NULL);
|
||||
if (info->mID < 0)
|
||||
return FALSE;
|
||||
mInfo = info;
|
||||
mID = info->mID;
|
||||
setWeight(getDefaultWeight(), FALSE );
|
||||
|
||||
LLPolySkeletalDistortionInfo::bone_info_list_t::iterator iter;
|
||||
for (iter = getInfo()->mBoneInfoList.begin(); iter != getInfo()->mBoneInfoList.end(); iter++)
|
||||
{
|
||||
LLPolySkeletalBoneInfo *bone_info = &(*iter);
|
||||
LLJoint* joint = mAvatar->getJoint(bone_info->mBoneName);
|
||||
if (!joint)
|
||||
{
|
||||
llwarns << "Joint " << bone_info->mBoneName << " not found." << llendl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mJointScales.find(joint) != mJointScales.end())
|
||||
{
|
||||
llwarns << "Scale deformation already supplied for joint " << joint->getName() << "." << llendl;
|
||||
}
|
||||
|
||||
// store it
|
||||
mJointScales[joint] = bone_info->mScaleDeformation;
|
||||
|
||||
// apply to children that need to inherit it
|
||||
for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
|
||||
iter != joint->mChildren.end(); ++iter)
|
||||
{
|
||||
LLViewerJoint* child_joint = (LLViewerJoint*)(*iter);
|
||||
if (child_joint->inheritScale())
|
||||
{
|
||||
LLVector3 childDeformation = LLVector3(child_joint->getScale());
|
||||
childDeformation.scaleVec(bone_info->mScaleDeformation);
|
||||
mJointScales[child_joint] = childDeformation;
|
||||
}
|
||||
}
|
||||
|
||||
if (bone_info->mHasPositionDeformation)
|
||||
{
|
||||
if (mJointOffsets.find(joint) != mJointOffsets.end())
|
||||
{
|
||||
llwarns << "Offset deformation already supplied for joint " << joint->getName() << "." << llendl;
|
||||
}
|
||||
mJointOffsets[joint] = bone_info->mPositionDeformation;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*virtual*/ LLViewerVisualParam* LLPolySkeletalDistortion::cloneParam(LLWearable* wearable) const
|
||||
{
|
||||
LLPolySkeletalDistortion *new_param = new LLPolySkeletalDistortion(mAvatar);
|
||||
*new_param = *this;
|
||||
return new_param;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLPolySkeletalDistortion::apply( ESex avatar_sex )
|
||||
{
|
||||
F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight();
|
||||
|
||||
LLJoint* joint;
|
||||
joint_vec_map_t::iterator iter;
|
||||
|
||||
for (iter = mJointScales.begin();
|
||||
iter != mJointScales.end();
|
||||
iter++)
|
||||
{
|
||||
joint = iter->first;
|
||||
LLVector3 newScale = joint->getScale();
|
||||
LLVector3 scaleDelta = iter->second;
|
||||
newScale = newScale + (effective_weight * scaleDelta) - (mLastWeight * scaleDelta);
|
||||
joint->setScale(newScale);
|
||||
}
|
||||
|
||||
for (iter = mJointOffsets.begin();
|
||||
iter != mJointOffsets.end();
|
||||
iter++)
|
||||
{
|
||||
joint = iter->first;
|
||||
LLVector3 newPosition = joint->getPosition();
|
||||
LLVector3 positionDelta = iter->second;
|
||||
newPosition = newPosition + (effective_weight * positionDelta) - (mLastWeight * positionDelta);
|
||||
joint->setPosition(newPosition);
|
||||
}
|
||||
|
||||
if (mLastWeight != mCurWeight && !mIsAnimating)
|
||||
{
|
||||
mAvatar->setSkeletonSerialNum(mAvatar->getSkeletonSerialNum() + 1);
|
||||
}
|
||||
mLastWeight = mCurWeight;
|
||||
}
|
||||
|
||||
|
||||
LLPolyMorphData *clone_morph_param_duplicate(const LLPolyMorphData *src_data,
|
||||
const std::string &name)
|
||||
{
|
||||
LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
|
||||
cloned_morph_data->mName = name;
|
||||
for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
|
||||
{
|
||||
cloned_morph_data->mCoords[v] = src_data->mCoords[v];
|
||||
cloned_morph_data->mNormals[v] = src_data->mNormals[v];
|
||||
cloned_morph_data->mBinormals[v] = src_data->mBinormals[v];
|
||||
}
|
||||
return cloned_morph_data;
|
||||
}
|
||||
|
||||
LLPolyMorphData *clone_morph_param_direction(const LLPolyMorphData *src_data,
|
||||
const LLVector3 &direction,
|
||||
const std::string &name)
|
||||
{
|
||||
LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
|
||||
cloned_morph_data->mName = name;
|
||||
for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
|
||||
{
|
||||
cloned_morph_data->mCoords[v] = direction;
|
||||
cloned_morph_data->mNormals[v] = LLVector3(0,0,0);
|
||||
cloned_morph_data->mBinormals[v] = LLVector3(0,0,0);
|
||||
}
|
||||
return cloned_morph_data;
|
||||
}
|
||||
|
||||
LLPolyMorphData *clone_morph_param_cleavage(const LLPolyMorphData *src_data,
|
||||
F32 scale,
|
||||
const std::string &name)
|
||||
{
|
||||
LLPolyMorphData* cloned_morph_data = new LLPolyMorphData(*src_data);
|
||||
cloned_morph_data->mName = name;
|
||||
for (U32 v=0; v < cloned_morph_data->mNumIndices; v++)
|
||||
{
|
||||
cloned_morph_data->mCoords[v] = src_data->mCoords[v]*scale;
|
||||
cloned_morph_data->mNormals[v] = src_data->mNormals[v]*scale;
|
||||
cloned_morph_data->mBinormals[v] = src_data->mBinormals[v]*scale;
|
||||
if (cloned_morph_data->mCoords[v][1] < 0)
|
||||
{
|
||||
cloned_morph_data->mCoords[v][1] *= -1;
|
||||
cloned_morph_data->mNormals[v][1] *= -1;
|
||||
cloned_morph_data->mBinormals[v][1] *= -1;
|
||||
}
|
||||
}
|
||||
return cloned_morph_data;
|
||||
}
|
||||
|
||||
// End
|
||||
391
indra/llappearance/llpolymesh.h
Normal file
391
indra/llappearance/llpolymesh.h
Normal file
@@ -0,0 +1,391 @@
|
||||
/**
|
||||
* @file llpolymesh.h
|
||||
* @brief Implementation of LLPolyMesh class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPOLYMESHINTERFACE_H
|
||||
#define LL_LLPOLYMESHINTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "llstl.h"
|
||||
|
||||
#include "v3math.h"
|
||||
#include "v2math.h"
|
||||
#include "llquaternion.h"
|
||||
#include "llpolymorph.h"
|
||||
#include "lljoint.h"
|
||||
//#include "lldarray.h"
|
||||
|
||||
class LLSkinJoint;
|
||||
class LLAvatarAppearance;
|
||||
class LLWearable;
|
||||
|
||||
//#define USE_STRIPS // Use tri-strips for rendering.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyFace
|
||||
// A set of 4 vertex indices.
|
||||
// An LLPolyFace can represent either a triangle or quad.
|
||||
// If the last index is -1, it's a triangle.
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef S32 LLPolyFace[3];
|
||||
|
||||
//struct PrimitiveGroup;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyMesh
|
||||
// A polyhedra consisting of any number of triangles and quads.
|
||||
// All instances contain a set of faces, and optionally may include
|
||||
// faces grouped into named face sets.
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLPolyMorphTarget;
|
||||
|
||||
class LLPolyMeshSharedData
|
||||
{
|
||||
friend class LLPolyMesh;
|
||||
private:
|
||||
// transform data
|
||||
LLVector3 mPosition;
|
||||
LLQuaternion mRotation;
|
||||
LLVector3 mScale;
|
||||
|
||||
// vertex data
|
||||
S32 mNumVertices;
|
||||
LLVector4a *mBaseCoords;
|
||||
LLVector4a *mBaseNormals;
|
||||
LLVector4a *mBaseBinormals;
|
||||
LLVector2 *mTexCoords;
|
||||
LLVector2 *mDetailTexCoords;
|
||||
F32 *mWeights;
|
||||
|
||||
BOOL mHasWeights;
|
||||
BOOL mHasDetailTexCoords;
|
||||
|
||||
// face data
|
||||
S32 mNumFaces;
|
||||
LLPolyFace *mFaces;
|
||||
|
||||
// face set data
|
||||
U32 mNumJointNames;
|
||||
std::string* mJointNames;
|
||||
|
||||
// morph targets
|
||||
typedef std::set<LLPolyMorphData*> morphdata_list_t;
|
||||
morphdata_list_t mMorphData;
|
||||
|
||||
std::map<S32, S32> mSharedVerts;
|
||||
|
||||
LLPolyMeshSharedData* mReferenceData;
|
||||
S32 mLastIndexOffset;
|
||||
|
||||
public:
|
||||
// Temporarily...
|
||||
// Triangle indices
|
||||
U32 mNumTriangleIndices;
|
||||
U32 *mTriangleIndices;
|
||||
|
||||
public:
|
||||
LLPolyMeshSharedData();
|
||||
~LLPolyMeshSharedData();
|
||||
|
||||
private:
|
||||
void setupLOD(LLPolyMeshSharedData* reference_data);
|
||||
|
||||
// Frees all mesh memory resources
|
||||
void freeMeshData();
|
||||
|
||||
void setPosition( const LLVector3 &pos ) { mPosition = pos; }
|
||||
void setRotation( const LLQuaternion &rot ) { mRotation = rot; }
|
||||
void setScale( const LLVector3 &scale ) { mScale = scale; }
|
||||
|
||||
BOOL allocateVertexData( U32 numVertices );
|
||||
|
||||
BOOL allocateFaceData( U32 numFaces );
|
||||
|
||||
BOOL allocateJointNames( U32 numJointNames );
|
||||
|
||||
// Retrieve the number of KB of memory used by this instance
|
||||
U32 getNumKB();
|
||||
|
||||
// Load mesh data from file
|
||||
BOOL loadMesh( const std::string& fileName );
|
||||
|
||||
public:
|
||||
void genIndices(S32 offset);
|
||||
|
||||
const LLVector2 &getUVs(U32 index);
|
||||
|
||||
const S32 *getSharedVert(S32 vert);
|
||||
|
||||
BOOL isLOD() { return (mReferenceData != NULL); }
|
||||
};
|
||||
|
||||
|
||||
class LLJointRenderData
|
||||
{
|
||||
public:
|
||||
LLJointRenderData(const LLMatrix4* world_matrix, LLSkinJoint* skin_joint) : mWorldMatrix(world_matrix), mSkinJoint(skin_joint) {}
|
||||
~LLJointRenderData(){}
|
||||
|
||||
const LLMatrix4* mWorldMatrix;
|
||||
LLSkinJoint* mSkinJoint;
|
||||
};
|
||||
|
||||
|
||||
class LLPolyMesh
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_mesh);
|
||||
|
||||
// Destructor
|
||||
~LLPolyMesh();
|
||||
|
||||
// Requests a mesh by name.
|
||||
// If the mesh already exists in the global mesh table, it is returned,
|
||||
// otherwise it is loaded from file, added to the table, and returned.
|
||||
static LLPolyMesh *getMesh( const std::string &name, LLPolyMesh* reference_mesh = NULL);
|
||||
|
||||
// Saves the mesh information as a binary Linden Lab Mesh file.
|
||||
BOOL saveLLM(LLFILE *fp);
|
||||
|
||||
// Saves the mesh information as an OBJ file.
|
||||
BOOL saveOBJ(LLFILE *fp);
|
||||
|
||||
// Loads new mesh information from an OBJ file.
|
||||
BOOL loadOBJ(LLFILE *fp);
|
||||
|
||||
// Copies the current mesh to the base mesh.
|
||||
BOOL setSharedFromCurrent();
|
||||
|
||||
// Gets the name of the mesh corresponding to the shared data
|
||||
static const std::string* getSharedMeshName(LLPolyMeshSharedData* shared);
|
||||
|
||||
// Requests mesh data by name. Returns null if not found.
|
||||
static LLPolyMeshSharedData *getMeshData( const std::string &name );
|
||||
|
||||
// Frees all loaded meshes.
|
||||
// This should only be called once you know there are no outstanding
|
||||
// references to these objects. Generally, upon exit of the application.
|
||||
static void freeAllMeshes();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Transform Data Access
|
||||
//--------------------------------------------------------------------
|
||||
// Get position
|
||||
const LLVector3 &getPosition() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mPosition;
|
||||
}
|
||||
|
||||
// Get rotation
|
||||
const LLQuaternion &getRotation() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mRotation;
|
||||
}
|
||||
|
||||
// Get scale
|
||||
const LLVector3 &getScale() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mScale;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Vertex Data Access
|
||||
//--------------------------------------------------------------------
|
||||
// Get number of vertices
|
||||
U32 getNumVertices() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mNumVertices;
|
||||
}
|
||||
|
||||
// Returns whether or not the mesh has detail texture coords
|
||||
BOOL hasDetailTexCoords() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mHasDetailTexCoords;
|
||||
}
|
||||
|
||||
// Returns whether or not the mesh has vertex weights
|
||||
BOOL hasWeights() const{
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mHasWeights;
|
||||
}
|
||||
|
||||
// Get coords
|
||||
const LLVector4a *getCoords() const{
|
||||
return mCoords;
|
||||
}
|
||||
|
||||
// non const version
|
||||
LLVector4a *getWritableCoords();
|
||||
|
||||
// Get normals
|
||||
const LLVector4a *getNormals() const{
|
||||
return mNormals;
|
||||
}
|
||||
|
||||
// Get normals
|
||||
const LLVector4a *getBinormals() const{
|
||||
return mBinormals;
|
||||
}
|
||||
|
||||
// Get base mesh normals
|
||||
const LLVector4a *getBaseNormals() const{
|
||||
llassert(mSharedData);
|
||||
return mSharedData->mBaseNormals;
|
||||
}
|
||||
|
||||
// Get base mesh normals
|
||||
const LLVector4a *getBaseBinormals() const{
|
||||
llassert(mSharedData);
|
||||
return mSharedData->mBaseBinormals;
|
||||
}
|
||||
|
||||
// intermediate morphed normals and output normals
|
||||
LLVector4a *getWritableNormals();
|
||||
LLVector4a *getScaledNormals();
|
||||
|
||||
LLVector4a *getWritableBinormals();
|
||||
LLVector4a *getScaledBinormals();
|
||||
|
||||
// Get texCoords
|
||||
const LLVector2 *getTexCoords() const {
|
||||
return mTexCoords;
|
||||
}
|
||||
|
||||
// non const version
|
||||
LLVector2 *getWritableTexCoords();
|
||||
|
||||
// Get detailTexCoords
|
||||
const LLVector2 *getDetailTexCoords() const {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mDetailTexCoords;
|
||||
}
|
||||
|
||||
// Get weights
|
||||
const F32 *getWeights() const {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mWeights;
|
||||
}
|
||||
|
||||
F32 *getWritableWeights() const;
|
||||
|
||||
LLVector4a *getWritableClothingWeights();
|
||||
|
||||
const LLVector4a *getClothingWeights()
|
||||
{
|
||||
return mClothingWeights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Face Data Access
|
||||
//--------------------------------------------------------------------
|
||||
// Get number of faces
|
||||
S32 getNumFaces() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mNumFaces;
|
||||
}
|
||||
|
||||
// Get faces
|
||||
LLPolyFace *getFaces() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mFaces;
|
||||
}
|
||||
|
||||
U32 getNumJointNames() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mNumJointNames;
|
||||
}
|
||||
|
||||
std::string *getJointNames() {
|
||||
llassert (mSharedData);
|
||||
return mSharedData->mJointNames;
|
||||
}
|
||||
|
||||
typedef std::map<std::string,LLPolyMorphData*> morph_list_t;
|
||||
static void getMorphList (const std::string& mesh_name, morph_list_t* morph_list);
|
||||
|
||||
LLPolyMorphData* getMorphData(const std::string& morph_name);
|
||||
// void removeMorphData(LLPolyMorphData *morph_target);
|
||||
// void deleteAllMorphData();
|
||||
|
||||
LLPolyMeshSharedData *getSharedData() const;
|
||||
LLPolyMesh *getReferenceMesh() { return mReferenceMesh ? mReferenceMesh : this; }
|
||||
|
||||
// Get indices
|
||||
U32* getIndices() { return mSharedData ? mSharedData->mTriangleIndices : NULL; }
|
||||
|
||||
BOOL isLOD() { return mSharedData && mSharedData->isLOD(); }
|
||||
|
||||
void setAvatar(LLAvatarAppearance* avatarp) { mAvatarp = avatarp; }
|
||||
LLAvatarAppearance* getAvatar() { return mAvatarp; }
|
||||
|
||||
LLDynamicArray<LLJointRenderData*> mJointRenderData;
|
||||
|
||||
U32 mFaceVertexOffset;
|
||||
U32 mFaceVertexCount;
|
||||
U32 mFaceIndexOffset;
|
||||
U32 mFaceIndexCount;
|
||||
U32 mCurVertexCount;
|
||||
|
||||
// Dumps diagnostic information about the global mesh table
|
||||
static void dumpDiagInfo(void*);
|
||||
|
||||
private:
|
||||
void initializeForMorph();
|
||||
|
||||
protected:
|
||||
// mesh data shared across all instances of a given mesh
|
||||
LLPolyMeshSharedData *mSharedData;
|
||||
// Single array of floats for allocation / deletion
|
||||
F32 *mVertexData;
|
||||
// deformed vertices (resulting from application of morph targets)
|
||||
LLVector4a *mCoords;
|
||||
// deformed normals (resulting from application of morph targets)
|
||||
LLVector4a *mScaledNormals;
|
||||
// output normals (after normalization)
|
||||
LLVector4a *mNormals;
|
||||
// deformed binormals (resulting from application of morph targets)
|
||||
LLVector4a *mScaledBinormals;
|
||||
// output binormals (after normalization)
|
||||
LLVector4a *mBinormals;
|
||||
// weight values that mark verts as clothing/skin
|
||||
LLVector4a *mClothingWeights;
|
||||
// output texture coordinates
|
||||
LLVector2 *mTexCoords;
|
||||
|
||||
LLPolyMesh *mReferenceMesh;
|
||||
|
||||
// global mesh list
|
||||
typedef std::map<std::string, LLPolyMeshSharedData*> LLPolyMeshSharedDataTable;
|
||||
static LLPolyMeshSharedDataTable sGlobalSharedMeshList;
|
||||
|
||||
// Backlink only; don't make this an LLPointer.
|
||||
LLAvatarAppearance* mAvatarp;
|
||||
};
|
||||
|
||||
#endif // LL_LLPOLYMESHINTERFACE_H
|
||||
|
||||
1081
indra/llappearance/llpolymorph.cpp
Normal file
1081
indra/llappearance/llpolymorph.cpp
Normal file
File diff suppressed because it is too large
Load Diff
199
indra/llappearance/llpolymorph.h
Normal file
199
indra/llappearance/llpolymorph.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* @file llpolymorph.h
|
||||
* @brief Implementation of LLPolyMesh class
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLPOLYMORPH_H
|
||||
#define LL_LLPOLYMORPH_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "llviewervisualparam.h"
|
||||
|
||||
class LLAvatarJointCollisionVolume;
|
||||
class LLPolyMeshSharedData;
|
||||
class LLVector2;
|
||||
class LLAvatarJointCollisionVolume;
|
||||
class LLWearable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyMorphData()
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLPolyMorphData
|
||||
{
|
||||
public:
|
||||
LLPolyMorphData(const std::string& morph_name);
|
||||
~LLPolyMorphData();
|
||||
LLPolyMorphData(const LLPolyMorphData &rhs);
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return ll_aligned_malloc_16(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
ll_aligned_free_16(ptr);
|
||||
}
|
||||
|
||||
BOOL loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
|
||||
const std::string& getName() { return mName; }
|
||||
|
||||
BOOL saveLLM(LLFILE *fp);
|
||||
BOOL saveOBJ(LLFILE *fp);
|
||||
BOOL setMorphFromMesh(LLPolyMesh *morph);
|
||||
|
||||
public:
|
||||
std::string mName;
|
||||
|
||||
// morphology
|
||||
U32 mNumIndices;
|
||||
U32* mVertexIndices;
|
||||
U32 mCurrentIndex;
|
||||
LLVector4a* mCoords;
|
||||
LLVector4a* mNormals;
|
||||
LLVector4a* mBinormals;
|
||||
LLVector2* mTexCoords;
|
||||
|
||||
F32 mTotalDistortion; // vertex distortion summed over entire morph
|
||||
F32 mMaxDistortion; // maximum single vertex distortion in a given morph
|
||||
LLVector4a mAvgDistortion; // average vertex distortion, to infer directionality of the morph
|
||||
LLPolyMeshSharedData* mMesh;
|
||||
|
||||
private:
|
||||
void freeData();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyVertexMask()
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLPolyVertexMask
|
||||
{
|
||||
public:
|
||||
LLPolyVertexMask(LLPolyMorphData* morph_data);
|
||||
~LLPolyVertexMask();
|
||||
|
||||
void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4a *clothing_weights);
|
||||
F32* getMorphMaskWeights();
|
||||
|
||||
|
||||
protected:
|
||||
F32* mWeights;
|
||||
LLPolyMorphData *mMorphData;
|
||||
BOOL mWeightsGenerated;
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyMorphTarget Data structs
|
||||
//-----------------------------------------------------------------------------
|
||||
struct LLPolyVolumeMorphInfo
|
||||
{
|
||||
LLPolyVolumeMorphInfo(std::string &name, LLVector3 &scale, LLVector3 &pos)
|
||||
: mName(name), mScale(scale), mPos(pos) {};
|
||||
|
||||
std::string mName;
|
||||
LLVector3 mScale;
|
||||
LLVector3 mPos;
|
||||
};
|
||||
|
||||
struct LLPolyVolumeMorph
|
||||
{
|
||||
LLPolyVolumeMorph(LLAvatarJointCollisionVolume* volume, LLVector3 scale, LLVector3 pos)
|
||||
: mVolume(volume), mScale(scale), mPos(pos) {};
|
||||
|
||||
LLAvatarJointCollisionVolume* mVolume;
|
||||
LLVector3 mScale;
|
||||
LLVector3 mPos;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyMorphTargetInfo
|
||||
// Shared information for LLPolyMorphTargets
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
|
||||
{
|
||||
friend class LLPolyMorphTarget;
|
||||
public:
|
||||
LLPolyMorphTargetInfo();
|
||||
/*virtual*/ ~LLPolyMorphTargetInfo() {};
|
||||
|
||||
/*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
|
||||
|
||||
protected:
|
||||
std::string mMorphName;
|
||||
BOOL mIsClothingMorph;
|
||||
typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t;
|
||||
volume_info_list_t mVolumeInfoList;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLPolyMorphTarget
|
||||
// A set of vertex data associated with morph target.
|
||||
// These morph targets must be topologically consistent with a given Polymesh
|
||||
// (share face sets)
|
||||
//-----------------------------------------------------------------------------
|
||||
class LLPolyMorphTarget : public LLViewerVisualParam
|
||||
{
|
||||
public:
|
||||
LLPolyMorphTarget(LLPolyMesh *poly_mesh);
|
||||
~LLPolyMorphTarget();
|
||||
|
||||
// Special: These functions are overridden by child classes
|
||||
LLPolyMorphTargetInfo* getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
|
||||
// This sets mInfo and calls initialization functions
|
||||
BOOL setInfo(LLPolyMorphTargetInfo *info);
|
||||
|
||||
/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
|
||||
|
||||
// LLVisualParam Virtual functions
|
||||
///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
|
||||
/*virtual*/ void apply( ESex sex );
|
||||
|
||||
// LLViewerVisualParam Virtual functions
|
||||
/*virtual*/ F32 getTotalDistortion();
|
||||
/*virtual*/ const LLVector4a& getAvgDistortion();
|
||||
/*virtual*/ F32 getMaxDistortion();
|
||||
/*virtual*/ LLVector4a getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
|
||||
/*virtual*/ const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
/*virtual*/ const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
|
||||
|
||||
void applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
|
||||
void addPendingMorphMask() { mNumMorphMasksPending++; }
|
||||
|
||||
protected:
|
||||
LLPolyMorphData* mMorphData;
|
||||
LLPolyMesh* mMesh;
|
||||
LLPolyVertexMask * mVertMask;
|
||||
ESex mLastSex;
|
||||
// number of morph masks that haven't been generated, must be 0 before this morph is applied
|
||||
BOOL mNumMorphMasksPending;
|
||||
|
||||
typedef std::vector<LLPolyVolumeMorph> volume_list_t;
|
||||
volume_list_t mVolumeMorphs;
|
||||
|
||||
};
|
||||
|
||||
#endif // LL_LLPOLYMORPH_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user