Compare commits
804 Commits
master
...
v1.7.0beta
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1c2e35ab73 | ||
![]() |
58cd558a43 | ||
![]() |
bdca749e35 | ||
![]() |
19855cd8b1 | ||
![]() |
9bda575f69 | ||
![]() |
66def3fb3c | ||
![]() |
8f4d83a881 | ||
![]() |
a9b02399ac | ||
![]() |
ba42eccb05 | ||
![]() |
7345c50aaa | ||
![]() |
20be5b5411 | ||
![]() |
750a023377 | ||
![]() |
e00c39596a | ||
![]() |
448fad2d02 | ||
![]() |
76a1f4bb3f | ||
![]() |
243d4e5f3f | ||
![]() |
48f8ca26e4 | ||
![]() |
6c9ecd348d | ||
![]() |
e6470a8876 | ||
![]() |
b14987b483 | ||
![]() |
7ed5c08fad | ||
![]() |
5a1f75289e | ||
![]() |
4caddaafbb | ||
![]() |
512336676e | ||
![]() |
0ea7a09ced | ||
![]() |
0b02a667cf | ||
![]() |
e1c7c0402c | ||
![]() |
2127ecd0fa | ||
![]() |
1757736115 | ||
![]() |
6f9a39848e | ||
![]() |
517fe770e2 | ||
![]() |
f911c1146a | ||
![]() |
28de8bf6cd | ||
![]() |
6f39846891 | ||
![]() |
07e2cf117f | ||
![]() |
f0ada4edee | ||
![]() |
3220f9c5a5 | ||
![]() |
5096cac90c | ||
![]() |
2a2373c1ec | ||
![]() |
4283e2bf66 | ||
![]() |
8ffea2e56b | ||
![]() |
99eb6b5d5d | ||
![]() |
096dbf8335 | ||
![]() |
9743d58bc0 | ||
![]() |
bdb730a593 | ||
![]() |
f1fb09c406 | ||
![]() |
83ca33b017 | ||
![]() |
aa78bc36d9 | ||
![]() |
f7b1d9a172 | ||
![]() |
ce67b437ea | ||
![]() |
86a3c4fb14 | ||
![]() |
4b846be113 | ||
![]() |
b9d7d5525b | ||
![]() |
0ecbe53243 | ||
![]() |
53bda5a7af | ||
![]() |
6a574a84bd | ||
![]() |
eaf7abfdc3 | ||
![]() |
0f5992051f | ||
![]() |
12c3c2e136 | ||
![]() |
d6037dcb09 | ||
![]() |
9dfdb2270b | ||
![]() |
29be8f11ed | ||
![]() |
8592a85535 | ||
![]() |
b21a37323f | ||
![]() |
7a0fe97841 | ||
![]() |
9a137f332f | ||
![]() |
8c8aea7fd4 | ||
![]() |
d52c8eba99 | ||
![]() |
b70b51ba17 | ||
![]() |
2b711a751c | ||
![]() |
2e68f96511 | ||
![]() |
8c7b59f2b9 | ||
![]() |
01ff090760 | ||
![]() |
120f80369b | ||
![]() |
1982dc6c2f | ||
![]() |
a1296131fe | ||
![]() |
5095b2adfb | ||
![]() |
5b19ac3019 | ||
![]() |
a5b340e20b | ||
![]() |
21f92eef89 | ||
![]() |
bf101dcea1 | ||
![]() |
764ae3995b | ||
![]() |
bd6fb5534f | ||
![]() |
f05407d292 | ||
![]() |
5652acdd48 | ||
![]() |
cf46e3748f | ||
![]() |
52c9e4fdd6 | ||
![]() |
4905ed4aae | ||
![]() |
ba356b4e4d | ||
![]() |
d23207b866 | ||
![]() |
a70f5053de | ||
![]() |
4cc89fb733 | ||
![]() |
e966fac5ac | ||
![]() |
cde9b583a8 | ||
![]() |
1fd42d849d | ||
![]() |
b6a1f48ab2 | ||
![]() |
bbe8ea6eb0 | ||
![]() |
6d2e06f25f | ||
![]() |
3fb14ea53b | ||
![]() |
af9ad9545d | ||
![]() |
5e88e9c396 | ||
![]() |
8498aa1c97 | ||
![]() |
8fb81acd98 | ||
![]() |
1a087bf921 | ||
![]() |
5a857b7d83 | ||
![]() |
e2414effed | ||
![]() |
023b399e40 | ||
![]() |
0b073f4a4d | ||
![]() |
a8b45d9f7e | ||
![]() |
c39c5640b4 | ||
![]() |
eb5e71cc8c | ||
![]() |
85cb69aa82 | ||
![]() |
dcb3f792d9 | ||
![]() |
9a6922896d | ||
![]() |
55d3b3226e | ||
![]() |
443694d7ac | ||
![]() |
f26fa77ef8 | ||
![]() |
e46cd2e6bc | ||
![]() |
f2a160299e | ||
![]() |
4697cbded6 | ||
![]() |
033a0d7b49 | ||
![]() |
eacf6f9637 | ||
![]() |
7912bf3037 | ||
![]() |
e4fad63915 | ||
![]() |
89287f10b8 | ||
![]() |
6271b4fc78 | ||
![]() |
3d024874a5 | ||
![]() |
2fce16e5c4 | ||
![]() |
fc322f6d48 | ||
![]() |
1afbb57994 | ||
![]() |
e393f19527 | ||
![]() |
79378d49b3 | ||
![]() |
d9d6b6e361 | ||
![]() |
b9014ed336 | ||
![]() |
faf68f8d57 | ||
![]() |
09a1afbb3d | ||
![]() |
27e11dc8cf | ||
![]() |
df4568f84b | ||
![]() |
6d5f00571d | ||
![]() |
4705951df1 | ||
![]() |
f33fe44b9f | ||
![]() |
43d0aa7218 | ||
![]() |
89ebb4dd52 | ||
![]() |
8d18e76f2b | ||
![]() |
fafbc6a458 | ||
![]() |
4253c4d759 | ||
![]() |
c90572ee77 | ||
![]() |
ef26a3f0fb | ||
![]() |
63ea57a796 | ||
![]() |
07c60a383a | ||
![]() |
8d124a250a | ||
![]() |
0340dcdcbd | ||
![]() |
ff57ec2126 | ||
![]() |
745a926a38 | ||
![]() |
4b1d9e8c2a | ||
![]() |
bb4bcecaa0 | ||
![]() |
28fa0d23c1 | ||
![]() |
1bfeb46881 | ||
![]() |
ace10ed9a2 | ||
![]() |
156006bb1a | ||
![]() |
8d48a512bd | ||
![]() |
c75a0a40b4 | ||
![]() |
fad9c9af47 | ||
![]() |
5695e897fd | ||
![]() |
0e249e9d93 | ||
![]() |
a78c4e286a | ||
![]() |
16424d20b5 | ||
![]() |
9c76207dbb | ||
![]() |
2023c4a0a5 | ||
![]() |
69ff249bc4 | ||
![]() |
844e264234 | ||
![]() |
61acc4c9ed | ||
![]() |
bd0bb3ca7f | ||
![]() |
386b2b0a7b | ||
![]() |
d103609ac5 | ||
![]() |
639f8a4668 | ||
![]() |
aed7f7aaf9 | ||
![]() |
15b6717221 | ||
![]() |
c9fda22f76 | ||
![]() |
4891f1a5a8 | ||
![]() |
abe4a4f049 | ||
![]() |
f3fa5dce47 | ||
![]() |
17bfbce61c | ||
![]() |
2933c2e361 | ||
![]() |
69f21bc6eb | ||
![]() |
454408799b | ||
![]() |
4c1ee27962 | ||
![]() |
26090a5f43 | ||
![]() |
bfd8446816 | ||
![]() |
605f8d046f | ||
![]() |
b8ab93dc6f | ||
![]() |
66b53bdd37 | ||
![]() |
dcbc357c46 | ||
![]() |
8ac1821831 | ||
![]() |
3407d0f7c4 | ||
![]() |
c8d2efcb50 | ||
![]() |
99436a407e | ||
![]() |
59136cc3b3 | ||
![]() |
afbaf7150b | ||
![]() |
86499967c3 | ||
![]() |
028d2c3fd6 | ||
![]() |
47ed19dfce | ||
![]() |
94a5189b1c | ||
![]() |
9fce04fcd6 | ||
![]() |
71c5123a4d | ||
![]() |
e9d567d9ec | ||
![]() |
37a50281cf | ||
![]() |
aacda27449 | ||
![]() |
b427d7216d | ||
![]() |
c46bd30b51 | ||
![]() |
0f2f0f7bbd | ||
![]() |
84a8bb8244 | ||
![]() |
8fe2eac47f | ||
![]() |
cb3402221b | ||
![]() |
8978eba436 | ||
![]() |
4792c8a751 | ||
![]() |
6bbc74d880 | ||
![]() |
b3a18efebf | ||
![]() |
14d11b9f35 | ||
![]() |
e41820cd0b | ||
![]() |
18211df70b | ||
![]() |
1775bdeb24 | ||
![]() |
8bffb48bc1 | ||
![]() |
edec44bfc4 | ||
![]() |
1c514557b6 | ||
![]() |
85d7eca204 | ||
![]() |
5357dd77f0 | ||
![]() |
5db709d83c | ||
![]() |
616ed1197b | ||
![]() |
0cb0a45721 | ||
![]() |
f476f13488 | ||
![]() |
8d93ec2eca | ||
![]() |
b0076faf1f | ||
![]() |
fa86bd2a61 | ||
![]() |
961d60b067 | ||
![]() |
764ae07652 | ||
![]() |
6803b09cb7 | ||
![]() |
7a7e4367d0 | ||
![]() |
b69df74b8e | ||
![]() |
a42416de9c | ||
![]() |
e51652b4db | ||
![]() |
771eb7d01e | ||
![]() |
368bb1b241 | ||
![]() |
504ebd427d | ||
![]() |
caa716d859 | ||
![]() |
0f2554a5e6 | ||
![]() |
9eb14136d8 | ||
![]() |
09c90236f4 | ||
![]() |
a3458a6ba0 | ||
![]() |
daf4b9dd18 | ||
![]() |
3a866cb451 | ||
![]() |
5592e0bc96 | ||
![]() |
57e92a8432 | ||
![]() |
d3c0359b23 | ||
![]() |
801608f8f4 | ||
![]() |
c09b3ab2c7 | ||
![]() |
722645fec5 | ||
![]() |
f72d0d01eb | ||
![]() |
97c4072cce | ||
![]() |
7a92725e17 | ||
![]() |
e916d9bb60 | ||
![]() |
ea41fd2161 | ||
![]() |
dbd98b8c68 | ||
![]() |
5cf6ed45c8 | ||
![]() |
9f7d5aa973 | ||
![]() |
5b05197604 | ||
![]() |
90992547c7 | ||
![]() |
13ce05daaf | ||
![]() |
2cd6d56ff6 | ||
![]() |
1af270dc19 | ||
![]() |
2ddd06c392 | ||
![]() |
33d4b5b66d | ||
![]() |
15a143e85e | ||
![]() |
bd55022b2d | ||
![]() |
c5bc9b668d | ||
![]() |
975d8fac6d | ||
![]() |
e76a320539 | ||
![]() |
eab2c419fa | ||
![]() |
23324b8559 | ||
![]() |
8dfa93beed | ||
![]() |
ed44394ad0 | ||
![]() |
c23bdb1445 | ||
![]() |
cbf4adee5c | ||
![]() |
1bc0781245 | ||
![]() |
7441965463 | ||
![]() |
8d6c21ce96 | ||
![]() |
8c94b1295f | ||
![]() |
1932e16c21 | ||
![]() |
a6278e7c87 | ||
![]() |
a5b993aaed | ||
![]() |
53e537439f | ||
![]() |
f1eec0ba62 | ||
![]() |
1e563f689c | ||
![]() |
0301cc2627 | ||
![]() |
9ee0b63b09 | ||
![]() |
2c13de800f | ||
![]() |
d394d889e1 | ||
![]() |
40d90d34a8 | ||
![]() |
3f6efbd8e2 | ||
![]() |
bf51c644f7 | ||
![]() |
05399c8c82 | ||
![]() |
8fae6609c0 | ||
![]() |
a2245a2c54 | ||
![]() |
46d3f863ca | ||
![]() |
7c9a08b8bc | ||
![]() |
c2a8a01b2a | ||
![]() |
8c025bcf3f | ||
![]() |
d555056b24 | ||
![]() |
69f2152c0f | ||
![]() |
e6a3e2456c | ||
![]() |
493bfd14a2 | ||
![]() |
8a9a3fb4dd | ||
![]() |
3e46c31961 | ||
![]() |
714515bc0c | ||
![]() |
38647d4b21 | ||
![]() |
f8d3e854cb | ||
![]() |
d280c3a6da | ||
![]() |
62dff2f97e | ||
![]() |
fea86b1c29 | ||
![]() |
601ae5387e | ||
![]() |
36ada4acae | ||
![]() |
bfc7affa0d | ||
![]() |
dba870122c | ||
![]() |
35abfe72d6 | ||
![]() |
497ff3400c | ||
![]() |
bb4e79c947 | ||
![]() |
b00bb570f8 | ||
![]() |
c68de14844 | ||
![]() |
cc7fa5e23f | ||
![]() |
ec99b373dd | ||
![]() |
3184947a25 | ||
![]() |
c5ead5d2cd | ||
![]() |
76c5c11168 | ||
![]() |
ddcca52933 | ||
![]() |
3bd90db79f | ||
![]() |
1fc5345bff | ||
![]() |
81b1cff052 | ||
![]() |
bc1d2b7d23 | ||
![]() |
a16d1ef27a | ||
![]() |
4b9fe200db | ||
![]() |
223aed9f90 | ||
![]() |
064ededa0f | ||
![]() |
92d7dd1ede | ||
![]() |
1b3d312513 | ||
![]() |
47b6a93924 | ||
![]() |
e1ff1cc930 | ||
![]() |
9acee8b4b2 | ||
![]() |
8ffa92dc25 | ||
![]() |
24382d838c | ||
![]() |
9307eef199 | ||
![]() |
3d1fec50e8 | ||
![]() |
0781bc4905 | ||
![]() |
188962a93b | ||
![]() |
e55c190818 | ||
![]() |
1a9eb510eb | ||
![]() |
77476d3c37 | ||
![]() |
a671f8baea | ||
![]() |
f32c657fc7 | ||
![]() |
381283fb5f | ||
![]() |
3dd43ae670 | ||
![]() |
13d83c6948 | ||
![]() |
f19f7a6c95 | ||
![]() |
e0fea61cd8 | ||
![]() |
689b9c58fe | ||
![]() |
dc6cddd798 | ||
![]() |
5d2841d272 | ||
![]() |
9012e3d108 | ||
![]() |
81d58f913e | ||
![]() |
0ee7a07a85 | ||
![]() |
6acc280403 | ||
![]() |
01358ecec2 | ||
![]() |
7a35bcac1a | ||
![]() |
673ae608ab | ||
![]() |
73ea393ab2 | ||
![]() |
dff4a834ce | ||
![]() |
ad817b9b2b | ||
![]() |
218b2d7c70 | ||
![]() |
67890a19f3 | ||
![]() |
53097f5bbb | ||
![]() |
36562c1032 | ||
![]() |
82fa6aed0e | ||
![]() |
382de60042 | ||
![]() |
06963c7841 | ||
![]() |
9f2fb72c67 | ||
![]() |
10ea5caef2 | ||
![]() |
2460d9494d | ||
![]() |
e8e7b6681e | ||
![]() |
033dd3f20a | ||
![]() |
341e23c009 | ||
![]() |
e4521a073c | ||
![]() |
5ff2d472e8 | ||
![]() |
f8eeac2b11 | ||
![]() |
e57ab4311b | ||
![]() |
9015c44736 | ||
![]() |
1d7f037627 | ||
![]() |
c4c28d7251 | ||
![]() |
0fba15c567 | ||
![]() |
c062330846 | ||
![]() |
0448d90f01 | ||
![]() |
127bede89c | ||
![]() |
3e4bd8c261 | ||
![]() |
cc085343ec | ||
![]() |
ea0197a3e3 | ||
![]() |
c2f0c9683f | ||
![]() |
79a332afd0 | ||
![]() |
352e2fe4c7 | ||
![]() |
3077b5e049 | ||
![]() |
98043c79a2 | ||
![]() |
2bf96d75ec | ||
![]() |
678020ae18 | ||
![]() |
58e69e45ff | ||
![]() |
7b51b8c13b | ||
![]() |
5f7e71fa78 | ||
![]() |
0cd3d25ae8 | ||
![]() |
83a2959908 | ||
![]() |
ab2ef2ceb1 | ||
![]() |
f0341bae80 | ||
![]() |
ed3543679a | ||
![]() |
9c7aee825c | ||
![]() |
d8055d7123 | ||
![]() |
92ef42d5e1 | ||
![]() |
1d3a1e36a7 | ||
![]() |
d368235da4 | ||
![]() |
06b0c83920 | ||
![]() |
2130a3cd20 | ||
![]() |
f1e4acb5b1 | ||
![]() |
7e56f5858d | ||
![]() |
82fca45d27 | ||
![]() |
f55ee011a2 | ||
![]() |
9c9009ec7d | ||
![]() |
01d91b4370 | ||
![]() |
1fd10de101 | ||
![]() |
9149259041 | ||
![]() |
8bc832389a | ||
![]() |
ba22b208ed | ||
![]() |
0f6d60e672 | ||
![]() |
6ce2d220b4 | ||
![]() |
d7312be749 | ||
![]() |
125eac0ee4 | ||
![]() |
ab95226db8 | ||
![]() |
3043819fb2 | ||
![]() |
565e1bc1ae | ||
![]() |
5bdcb914a4 | ||
![]() |
e8213aa68f | ||
![]() |
d4ac328617 | ||
![]() |
56e6741b25 | ||
![]() |
3e04e189d8 | ||
![]() |
eb67f8bcb1 | ||
![]() |
9c078fb7d2 | ||
![]() |
ae31a1ebdb | ||
![]() |
b1d49de5bc | ||
![]() |
d7e9c1c584 | ||
![]() |
28451a8797 | ||
![]() |
e6eb1d6fda | ||
![]() |
82dd5d3575 | ||
![]() |
a5b6764cea | ||
![]() |
56850aba35 | ||
![]() |
13f025c29a | ||
![]() |
d92b0f23e6 | ||
![]() |
eeab1cfefc | ||
![]() |
38d22ef928 | ||
![]() |
ab1ad88ecc | ||
![]() |
caa59e0007 | ||
![]() |
310ffb25f8 | ||
![]() |
c026b07529 | ||
![]() |
6988b31244 | ||
![]() |
b23a10f565 | ||
![]() |
201e9144a6 | ||
![]() |
ba8495bba9 | ||
![]() |
3393042627 | ||
![]() |
a072dfee8e | ||
![]() |
e39e182357 | ||
![]() |
ab71e135e7 | ||
![]() |
1b577e9bc6 | ||
![]() |
238fdc197d | ||
![]() |
8cfee5fa78 | ||
![]() |
44a9af81b0 | ||
![]() |
755f92fc41 | ||
![]() |
d9d1c997d8 | ||
![]() |
aeb4a22975 | ||
![]() |
9c0b5ab848 | ||
![]() |
05dcaffd38 | ||
![]() |
cca25b182f | ||
![]() |
f87df31c8c | ||
![]() |
41547820e8 | ||
![]() |
e5d462d829 | ||
![]() |
6f46730cb7 | ||
![]() |
67b88b8ee0 | ||
![]() |
7a4bfbdec1 | ||
![]() |
859254054a | ||
![]() |
515659d638 | ||
![]() |
fd409c8019 | ||
![]() |
9ee6678e1f | ||
![]() |
9b36280e31 | ||
![]() |
eaad9f9177 | ||
![]() |
70cd1a10f2 | ||
![]() |
7974d60f54 | ||
![]() |
c7e743d385 | ||
![]() |
b2e89f1af6 | ||
![]() |
ad30a1262b | ||
![]() |
35f88c1341 | ||
![]() |
4f8050416f | ||
![]() |
776d1768aa | ||
![]() |
d7078c52e2 | ||
![]() |
4a67ac3f1e | ||
![]() |
2799bf9a4f | ||
![]() |
34e49ae1bc | ||
![]() |
cea01951da | ||
![]() |
1a9c06b11a | ||
![]() |
f3b1eb68a6 | ||
![]() |
12845bc947 | ||
![]() |
3ac960f128 | ||
![]() |
eb2b0248e2 | ||
![]() |
e529698d38 | ||
![]() |
1a9e897289 | ||
![]() |
3a81956ffe | ||
![]() |
0acf4f9770 | ||
![]() |
b407af6503 | ||
![]() |
0fb41f05df | ||
![]() |
8ebdaa0700 | ||
![]() |
4e61b58980 | ||
![]() |
88e7d62fbc | ||
![]() |
43cd0a0bb5 | ||
![]() |
1345c5bff8 | ||
![]() |
39c420834f | ||
![]() |
f898f69f46 | ||
![]() |
352f43cdc6 | ||
![]() |
f99393490d | ||
![]() |
deb920b4a7 | ||
![]() |
148cdac18f | ||
![]() |
51ecc14a8a | ||
![]() |
713a20c57d | ||
![]() |
4526f546ba | ||
![]() |
0c5acfa19e | ||
![]() |
848eeacb41 | ||
![]() |
2ced844b0e | ||
![]() |
e2c5ed8d1d | ||
![]() |
76004ce6ed | ||
![]() |
258b986917 | ||
![]() |
50a09830b8 | ||
![]() |
9a3f244085 | ||
![]() |
fb1305faeb | ||
![]() |
3d7f3bbab7 | ||
![]() |
2d032e966d | ||
![]() |
8dd3784f7c | ||
![]() |
98b9371115 | ||
![]() |
d29413a2a9 | ||
![]() |
dc63b03da1 | ||
![]() |
cf354c2c82 | ||
![]() |
484dad1a19 | ||
![]() |
1695471118 | ||
![]() |
ae14dcd404 | ||
![]() |
302c58b8cf | ||
![]() |
39fee3cee1 | ||
![]() |
b7362c6738 | ||
![]() |
f2d8561fdc | ||
![]() |
1bd81ffa21 | ||
![]() |
6d2b1a7dbc | ||
![]() |
5daa97c2eb | ||
![]() |
9e441e96b9 | ||
![]() |
a0d314ce84 | ||
![]() |
b871b25997 | ||
![]() |
d38ebc9ded | ||
![]() |
995402ca6e | ||
![]() |
1982968dad | ||
![]() |
32cd66d619 | ||
![]() |
03a53fa429 | ||
![]() |
441de8f4fd | ||
![]() |
4e5c80034e | ||
![]() |
879d63156a | ||
![]() |
eb021245d0 | ||
![]() |
6607a3b905 | ||
![]() |
28711dff2a | ||
![]() |
4413d5dcd2 | ||
![]() |
206d1eed42 | ||
![]() |
114fa16ab3 | ||
![]() |
eb2af04bd3 | ||
![]() |
200fc68f52 | ||
![]() |
4cfd01a288 | ||
![]() |
e98229ceb0 | ||
![]() |
ad1a4c8cc3 | ||
![]() |
8df7c46e5b | ||
![]() |
99078ec8bd | ||
![]() |
a2c5f56e77 | ||
![]() |
9e168ea2c9 | ||
![]() |
06be739941 | ||
![]() |
448092b8eb | ||
![]() |
1faa6ff32c | ||
![]() |
3adf438f39 | ||
![]() |
d45a632529 | ||
![]() |
5a1b8d106d | ||
![]() |
05f896004f | ||
![]() |
a4f1de9109 | ||
![]() |
7ebb353944 | ||
![]() |
b1f0c7d0e5 | ||
![]() |
55df049962 | ||
![]() |
219ba1370e | ||
![]() |
4dc4471bb5 | ||
![]() |
a199a15b28 | ||
![]() |
e9446f2f95 | ||
![]() |
f70f2fcf48 | ||
![]() |
158c947ce2 | ||
![]() |
7e2707e2af | ||
![]() |
81824079b5 | ||
![]() |
e8e1add0a8 | ||
![]() |
a549223f91 | ||
![]() |
ebe7945b96 | ||
![]() |
e3e35aa980 | ||
![]() |
9f2fbcf5d8 | ||
![]() |
264ba68afe | ||
![]() |
3ef99c9316 | ||
![]() |
4b29f97f9b | ||
![]() |
fe6e6cf130 | ||
![]() |
547df4b9ca | ||
![]() |
a0d4a0b971 | ||
![]() |
72c2577302 | ||
![]() |
091fab713c | ||
![]() |
32aeb2cd4e | ||
![]() |
c1bcdc3a86 | ||
![]() |
553b8f85d3 | ||
![]() |
30666a6097 | ||
![]() |
0bfa63cd0d | ||
![]() |
b37a7c6674 | ||
![]() |
7657ac14f2 | ||
![]() |
d9f60caf72 | ||
![]() |
88c20ada06 | ||
![]() |
f3bfc4a142 | ||
![]() |
3fdef04d55 | ||
![]() |
eae431e514 | ||
![]() |
003590c361 | ||
![]() |
8e23262b2b | ||
![]() |
157e0649e0 | ||
![]() |
83f1287c02 | ||
![]() |
a1124a574a | ||
![]() |
6f27254a7e | ||
![]() |
79fc8fa0d9 | ||
![]() |
394bc6cdee | ||
![]() |
bb06552075 | ||
![]() |
a14071d814 | ||
![]() |
23f3e46518 | ||
![]() |
f97b2a6cde | ||
![]() |
23f4320775 | ||
![]() |
fb411867b0 | ||
![]() |
5aa2ca454d | ||
![]() |
7905286ffa | ||
![]() |
2edcb6ad0f | ||
![]() |
0f1599e6e5 | ||
![]() |
cbf22f30b4 | ||
![]() |
9bf3c70730 | ||
![]() |
1bc5747713 | ||
![]() |
4a7796faca | ||
![]() |
34081a0e2f | ||
![]() |
b88c94208a | ||
![]() |
30662f5e92 | ||
![]() |
46ad4c5bd4 | ||
![]() |
5c32606ec0 | ||
![]() |
a08ac031fc | ||
![]() |
c233ec8743 | ||
![]() |
d594be641a | ||
![]() |
4c9168875b | ||
![]() |
3c051ee282 | ||
![]() |
e1ded944f0 | ||
![]() |
c09dddc0cd | ||
![]() |
bd56d76417 | ||
![]() |
0cc23ac171 | ||
![]() |
cb10e19725 | ||
![]() |
9dba7219a0 | ||
![]() |
17c6af8c40 | ||
![]() |
6a02eb6d2c | ||
![]() |
40d41fe6f8 | ||
![]() |
7073d26e51 | ||
![]() |
cf76fe8654 | ||
![]() |
b780b64fbf | ||
![]() |
b1876ab6e2 | ||
![]() |
28a95d125f | ||
![]() |
993f68c006 | ||
![]() |
8d23524359 | ||
![]() |
e0f4aaa668 | ||
![]() |
3de174cd2f | ||
![]() |
eaf2f1dcbe | ||
![]() |
ea0b4c602e | ||
![]() |
371c3d4dfd | ||
![]() |
0bcf5fb451 | ||
![]() |
57d6907d89 | ||
![]() |
6cf97e37af | ||
![]() |
8ef61c4693 | ||
![]() |
25a116f97d | ||
![]() |
d6d41c847a | ||
![]() |
9e0297546f | ||
![]() |
d529363d13 | ||
![]() |
55e93d7090 | ||
![]() |
23674b75be | ||
![]() |
0ddf350360 | ||
![]() |
066f9862f0 | ||
![]() |
ae1a5c811c | ||
![]() |
5a1ce92c0c | ||
![]() |
7a498039c5 | ||
![]() |
40a93652aa | ||
![]() |
a1362f38de | ||
![]() |
30bc0333fe | ||
![]() |
55794013d4 | ||
![]() |
2e92b4dfa0 | ||
![]() |
f46106fa04 | ||
![]() |
0dcd32f39c | ||
![]() |
808ea281a4 | ||
![]() |
ec89aefb44 | ||
![]() |
6152dbd424 | ||
![]() |
fe18c0d9ea | ||
![]() |
1b0358302d | ||
![]() |
d20f9d5030 | ||
![]() |
fc447311aa | ||
![]() |
8e30e43587 | ||
![]() |
0403ccf1de | ||
![]() |
1a321cc088 | ||
![]() |
c9f99f487b | ||
![]() |
8360e60abc | ||
![]() |
2799f74489 | ||
![]() |
7363babe4f | ||
![]() |
e3a526f789 | ||
![]() |
8f0935b8dc | ||
![]() |
ae6503fe0e | ||
![]() |
851a6265a8 | ||
![]() |
ffa24d4108 | ||
![]() |
206f4d2678 | ||
![]() |
bb040784c2 | ||
![]() |
70e1af50ed | ||
![]() |
eb4a645eda | ||
![]() |
9f7f03a3c4 | ||
![]() |
395ddbd318 | ||
![]() |
9f0d36c85f | ||
![]() |
e9760e5e95 | ||
![]() |
b96b2b7e90 | ||
![]() |
9bb705e0a8 | ||
![]() |
e860f77393 | ||
![]() |
b5a7565908 | ||
![]() |
e88e221d91 | ||
![]() |
b10867cdc2 | ||
![]() |
bf7084b80d | ||
![]() |
6afcee826f | ||
![]() |
f15a5006c8 | ||
![]() |
cdbd5174bd | ||
![]() |
7a9b6203ef | ||
![]() |
803493e19c | ||
![]() |
4245e6b1b2 | ||
![]() |
81892f6b90 | ||
![]() |
862993827d | ||
![]() |
d304125332 | ||
![]() |
9124f3e29a | ||
![]() |
2969375aa6 | ||
![]() |
5e8ba1cbbf | ||
![]() |
8aee43d10a | ||
![]() |
e355657bbe | ||
![]() |
fb6ba9acf4 | ||
![]() |
815173a0b5 | ||
![]() |
7f489a77bb | ||
![]() |
8ec8e8fcd5 | ||
![]() |
a4e606dd5f | ||
![]() |
646de7962b | ||
![]() |
4accd423c2 | ||
![]() |
f62caaf4dc | ||
![]() |
b789bb84bb | ||
![]() |
ce60ad642b | ||
![]() |
ab097b1168 | ||
![]() |
3a737d86c7 | ||
![]() |
a1337e57a8 | ||
![]() |
247b3fcf49 | ||
![]() |
f01273b25c | ||
![]() |
8cb1a2ac6d | ||
![]() |
e6e5ac8cb7 | ||
![]() |
a4798fb83e | ||
![]() |
46369f35c5 | ||
![]() |
e699993d70 | ||
![]() |
5a0afcfa63 | ||
![]() |
3fc9cbf126 | ||
![]() |
36b628b19e | ||
![]() |
2c31365fd4 | ||
![]() |
e1e3c1a2a2 | ||
![]() |
b940e5dc5d | ||
![]() |
fbbbc620b8 | ||
![]() |
9b99600c4d | ||
![]() |
3129d7426e | ||
![]() |
325ceea971 | ||
![]() |
ac39fc3024 | ||
![]() |
99343407e6 | ||
![]() |
3e23f45ba9 | ||
![]() |
72389dec42 | ||
![]() |
1f0853f47e | ||
![]() |
32a60a4885 | ||
![]() |
5e07dc6970 | ||
![]() |
4b90a8d416 | ||
![]() |
d59c19b64c | ||
![]() |
bbabd977d1 | ||
![]() |
0cf9c7d63d | ||
![]() |
b4e241559e | ||
![]() |
1e15aee6be | ||
![]() |
d59e60d0fb | ||
![]() |
ec1d13a1d4 | ||
![]() |
d9002f94cb | ||
![]() |
1fa858db48 | ||
![]() |
0f2a5bac64 | ||
![]() |
eac85878bf | ||
![]() |
240ac287eb | ||
![]() |
3e42c81193 | ||
![]() |
ac3b4d9b69 |
99
.travis.yml
Normal file
@ -0,0 +1,99 @@
|
||||
language: c
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/pip
|
||||
- $HOME/deps
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=coverage
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=ubsan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=asan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=lsan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=msan
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
|
||||
install:
|
||||
- pip install --user 'requests[security]'
|
||||
- pip install --user cpp-coveralls
|
||||
- |
|
||||
mkdir -p deps
|
||||
pushd deps
|
||||
export PREFIXDIR=`pwd`
|
||||
if [ ! -f "libtool-2.4.6.tar.xz" ]; then
|
||||
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.xz
|
||||
fi
|
||||
if [ ! -f "automake-1.15.tar.xz" ]; then
|
||||
wget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz
|
||||
fi
|
||||
if [ ! -d "libtool-2.4.6" ]; then
|
||||
tar xf libtool-2.4.6.tar.xz
|
||||
pushd libtool-2.4.6/
|
||||
./configure --prefix=$PREFIXDIR
|
||||
make && make install
|
||||
popd
|
||||
cp $PREFIXDIR/bin/libtool $PREFIXDIR/bin/glibtool
|
||||
cp $PREFIXDIR/bin/libtoolize $PREFIXDIR/bin/glibtoolize
|
||||
fi
|
||||
if [ ! -d "automake-1.15" ]; then
|
||||
tar xf automake-1.15.tar.xz
|
||||
pushd automake-1.15/
|
||||
./configure --prefix=$PREFIXDIR
|
||||
make && make install
|
||||
popd
|
||||
fi
|
||||
export PATH="$PREFIXDIR/bin:$PATH"
|
||||
popd
|
||||
before_script:
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
export CFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
export LDFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "asan" ]; then
|
||||
export CFLAGS=-fsanitize=address
|
||||
export LDFLAGS=-fsanitize=address
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "lsan" ]; then
|
||||
export CFLAGS=-fsanitize=leak
|
||||
export LDFLAGS=-fsanitize=leak
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "msan" ]; then
|
||||
export CFLAGS=-fsanitize=memory
|
||||
export LDFLAGS=-fsanitize=memory
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "ubsan" ]; then
|
||||
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
|
||||
export LDFLAGS="-fsanitize=undefined"
|
||||
fi
|
||||
script:
|
||||
- ./autogen.sh && ./configure && make && make check
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
cpp-coveralls --gcov-options '\-lp'
|
||||
fi
|
738
CMakeLists.txt
@ -1,40 +1,41 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
|
||||
# Written by Christian Ehrlicher, 2007
|
||||
# Revised by Roger Lowman, 2009-2010
|
||||
# Revised by Clifford Yapp, 2011-2012
|
||||
# Revised by Roger Leigh, 2016
|
||||
# Revised by Andreas Franek, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
cmake_policy(VERSION 2.8.3)
|
||||
|
||||
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
|
||||
# workaround CMake 2.4.x bug
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
endif()
|
||||
endif()
|
||||
# Set MacOSX @rpath usage globally.
|
||||
if (POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
endif(POLICY CMP0020)
|
||||
if (POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif(POLICY CMP0042)
|
||||
# Use new variable expansion policy.
|
||||
if (POLICY CMP0053)
|
||||
cmake_policy(SET CMP0053 NEW)
|
||||
endif(POLICY CMP0053)
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif(POLICY CMP0054)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
||||
|
||||
project(libpng C)
|
||||
enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_MINOR 7)
|
||||
set(PNGLIB_RELEASE 0)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
@ -49,8 +50,7 @@ if(NOT WIN32)
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
if(NOT M_LIBRARY)
|
||||
message(STATUS
|
||||
"math library 'libm' not found - floating point support disabled")
|
||||
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||
endif()
|
||||
else()
|
||||
# not needed on windows
|
||||
@ -58,22 +58,47 @@ else()
|
||||
endif()
|
||||
|
||||
# COMMAND LINE OPTIONS
|
||||
if(DEFINED PNG_SHARED)
|
||||
option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
|
||||
else()
|
||||
option(PNG_SHARED "Build shared lib" ON)
|
||||
endif()
|
||||
if(DEFINED PNG_STATIC)
|
||||
option(PNG_STATIC "Build static lib" ${PNG_STATIC})
|
||||
else()
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
endif()
|
||||
|
||||
option(PNG_TESTS "Build libpng tests" YES)
|
||||
option(PNG_SHARED "Build shared lib" ON)
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
option(PNG_TESTS "Build libpng tests" ON)
|
||||
|
||||
# Many more configuration options could be added here
|
||||
option(PNG_DEBUG "Build with debug output" NO)
|
||||
option(PNGARG "Disable ANSI-C prototypes" NO)
|
||||
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
||||
option(PNG_DEBUG "Build with debug output" OFF)
|
||||
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
||||
|
||||
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
|
||||
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
|
||||
|
||||
# set definitions and sources for arm
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm" OR
|
||||
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
|
||||
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
|
||||
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
|
||||
check: (default) use internal checking code;
|
||||
off: disable the optimizations;
|
||||
on: turn on unconditionally.")
|
||||
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
|
||||
${PNG_ARM_NEON_POSSIBLE_VALUES})
|
||||
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
|
||||
set(libpng_arm_sources
|
||||
arm/arm_init.c
|
||||
arm/filter_neon.S
|
||||
arm/filter_neon_intrinsics.c)
|
||||
|
||||
if(${PNG_ARM_NEON} STREQUAL "on")
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
||||
elseif(${PNG_ARM_NEON} STREQUAL "check")
|
||||
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SET LIBNAME
|
||||
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
@ -81,26 +106,276 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
# to distinguish between debug and release lib
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
# Use the prebuilt pnglibconf.h file from the scripts folder
|
||||
# TODO: fix this by building with awk; without this no cmake build can be
|
||||
# configured directly (to do so indirectly use your local awk to build a
|
||||
# pnglibconf.h in the build directory.)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
||||
include(CheckCSourceCompiles)
|
||||
option(ld-version-script "Enable linker version script" ON)
|
||||
if(ld-version-script AND NOT APPLE)
|
||||
# Check if LD supports linker scripts.
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
|
||||
global: sym;
|
||||
local: *;
|
||||
};
|
||||
|
||||
VERS_2 {
|
||||
global: sym2;
|
||||
main;
|
||||
} VERS_1;
|
||||
")
|
||||
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
|
||||
check_c_source_compiles("void sym(void) {}
|
||||
void sym2(void) {}
|
||||
int main(void) {return 0;}
|
||||
" HAVE_LD_VERSION_SCRIPT)
|
||||
if(NOT HAVE_LD_VERSION_SCRIPT)
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
||||
check_c_source_compiles("void sym(void) {}
|
||||
void sym2(void) {}
|
||||
int main(void) {return 0;}
|
||||
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
||||
endif()
|
||||
|
||||
# Find symbol prefix. Likely obsolete and unnecessary with recent
|
||||
# toolchains (it's not done in many other projects).
|
||||
function(symbol_prefix)
|
||||
set(SYMBOL_PREFIX)
|
||||
|
||||
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
|
||||
INPUT_FILE /dev/null
|
||||
OUTPUT_VARIABLE OUT
|
||||
RESULT_VARIABLE STATUS)
|
||||
|
||||
if(CPP_FAIL)
|
||||
message(WARNING "Failed to run the C preprocessor")
|
||||
endif()
|
||||
|
||||
string(REPLACE "\n" ";" OUT "${OUT}")
|
||||
foreach(line ${OUT})
|
||||
string(REGEX MATCH "^PREFIX=" found_match "${line}")
|
||||
if(found_match)
|
||||
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
|
||||
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
|
||||
if(found_match)
|
||||
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
|
||||
endif()
|
||||
set(SYMBOL_PREFIX "${prefix}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
|
||||
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(UNIX)
|
||||
symbol_prefix()
|
||||
endif()
|
||||
|
||||
find_program(AWK NAMES gawk awk)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(NOT AWK)
|
||||
# No awk available to generate sources; use pre-built pnglibconf.h
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
||||
add_custom_target(genfiles) # Dummy
|
||||
else()
|
||||
include(CMakeParseArguments)
|
||||
# Generate .chk from .out with awk
|
||||
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_chk)
|
||||
set(options)
|
||||
set(oneValueArgs INPUT OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GC_INPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
||||
endif()
|
||||
if (NOT _GC_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GC_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DINPUT=${_GC_INPUT}"
|
||||
"-DOUTPUT=${_GC_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
|
||||
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Generate .out from .c with awk
|
||||
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_out)
|
||||
set(options)
|
||||
set(oneValueArgs INPUT OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GO_INPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
||||
endif()
|
||||
if (NOT _GO_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GO_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DINPUT=${_GO_INPUT}"
|
||||
"-DOUTPUT=${_GO_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
|
||||
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Generate specific source file with awk
|
||||
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_source)
|
||||
set(options)
|
||||
set(oneValueArgs OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GSO_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DOUTPUT=${_GSO_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
||||
DEPENDS ${_GSO_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Copy file
|
||||
function(generate_copy source destination)
|
||||
add_custom_command(OUTPUT "${destination}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
|
||||
"${destination}"
|
||||
DEPENDS "${source}")
|
||||
endfunction()
|
||||
|
||||
# Generate scripts/pnglibconf.h
|
||||
generate_source(OUTPUT "scripts/pnglibconf.c"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
||||
|
||||
# Generate pnglibconf.c
|
||||
generate_source(OUTPUT "pnglibconf.c"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
||||
|
||||
if(PNG_PREFIX)
|
||||
set(PNGLIBCONF_H_EXTRA_DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
|
||||
set(PNGPREFIX_H_EXTRA_DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
|
||||
endif()
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
||||
|
||||
# Generate pnglibconf.h
|
||||
generate_source(OUTPUT "pnglibconf.h"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
||||
${PNGLIBCONF_H_EXTRA_DEPENDS})
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
||||
|
||||
# Generate pngprefix.h
|
||||
generate_source(OUTPUT "pngprefix.h"
|
||||
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
|
||||
|
||||
add_custom_target(symbol-check DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
|
||||
|
||||
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
||||
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
||||
|
||||
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
||||
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
||||
|
||||
add_custom_target("genprebuilt"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# A single target handles generation of all generated files. If
|
||||
# they are dependend upon separately by multiple targets, this
|
||||
# confuses parallel make (it would require a separate top-level
|
||||
# target for each file to track the dependencies properly).
|
||||
add_custom_target(genfiles DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
|
||||
endif(NOT AWK)
|
||||
|
||||
# OUR SOURCES
|
||||
set(libpng_public_hdrs
|
||||
png.h
|
||||
pngconf.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
||||
)
|
||||
set(libpng_sources
|
||||
${libpng_public_hdrs}
|
||||
set(libpng_private_hdrs
|
||||
pngpriv.h
|
||||
pngdebug.h
|
||||
pnginfo.h
|
||||
pngpriv.h
|
||||
pngstruct.h
|
||||
pngchunk.h
|
||||
)
|
||||
if(AWK)
|
||||
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
|
||||
endif()
|
||||
set(libpng_sources
|
||||
${libpng_public_hdrs}
|
||||
${libpng_private_hdrs}
|
||||
png.c
|
||||
pngerror.c
|
||||
pngget.c
|
||||
@ -116,6 +391,7 @@ set(libpng_sources
|
||||
pngwrite.c
|
||||
pngwtran.c
|
||||
pngwutil.c
|
||||
${libpng_arm_sources}
|
||||
)
|
||||
set(pngtest_sources
|
||||
pngtest.c
|
||||
@ -126,7 +402,18 @@ set(pngvalid_sources
|
||||
set(pngstest_sources
|
||||
contrib/libtests/pngstest.c
|
||||
)
|
||||
# SOME NEEDED DEFINITIONS
|
||||
set(pngunknown_sources
|
||||
contrib/libtests/pngunknown.c
|
||||
)
|
||||
set(pngimage_sources
|
||||
contrib/libtests/pngimage.c
|
||||
)
|
||||
set(pngfix_sources
|
||||
contrib/tools/pngfix.c
|
||||
)
|
||||
set(png_fix_itxt_sources
|
||||
contrib/tools/png-fix-itxt.c
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
@ -139,74 +426,245 @@ endif()
|
||||
# NOW BUILD OUR TARGET
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
unset(PNG_LIB_TARGETS)
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
|
||||
add_library(png SHARED ${libpng_sources})
|
||||
set(PNG_LIB_TARGETS png)
|
||||
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
|
||||
add_dependencies(png genfiles)
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
|
||||
set_target_properties(png PROPERTIES PREFIX "lib")
|
||||
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
|
||||
endif()
|
||||
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
|
||||
if(UNIX AND AWK)
|
||||
if(HAVE_LD_VERSION_SCRIPT)
|
||||
set_target_properties(png PROPERTIES LINK_FLAGS
|
||||
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
||||
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
||||
set_target_properties(png PROPERTIES LINK_FLAGS
|
||||
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PNG_STATIC)
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
||||
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC png_static)
|
||||
add_library(png_static STATIC ${libpng_sources})
|
||||
add_dependencies(png_static genfiles)
|
||||
# MSVC doesn't use a different file extension for shared vs. static
|
||||
# libs. We are able to change OUTPUT_NAME to remove the _static
|
||||
# for all other platforms.
|
||||
if(NOT MSVC)
|
||||
set_target_properties(png_static PROPERTIES
|
||||
OUTPUT_NAME "${PNG_LIB_NAME}"
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
else()
|
||||
set_target_properties(png_static PROPERTIES
|
||||
OUTPUT_NAME "${PNG_LIB_NAME}_static"
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
list(APPEND PNG_LIB_TARGETS png_static)
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
||||
set_target_properties(png_static PROPERTIES PREFIX "lib")
|
||||
endif()
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PNG_FRAMEWORK)
|
||||
set(PNG_LIB_NAME_FRAMEWORK png_framework)
|
||||
add_library(png_framework SHARED ${libpng_sources})
|
||||
add_dependencies(png_framework genfiles)
|
||||
list(APPEND PNG_LIB_TARGETS png_framework)
|
||||
set_target_properties(png_framework PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
||||
PUBLIC_HEADER "${libpng_public_hdrs}"
|
||||
OUTPUT_NAME png)
|
||||
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: "
|
||||
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
|
||||
function(png_add_test)
|
||||
set(options)
|
||||
set(oneValueArgs NAME COMMAND)
|
||||
set(multiValueArgs OPTIONS FILES)
|
||||
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT _PAT_NAME)
|
||||
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
|
||||
endif()
|
||||
if (NOT _PAT_COMMAND)
|
||||
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
|
||||
endif()
|
||||
|
||||
set(TEST_OPTIONS "${_PAT_OPTIONS}")
|
||||
set(TEST_FILES "${_PAT_FILES}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
|
||||
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
|
||||
add_test(NAME "${_PAT_NAME}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DLIBPNG=$<TARGET_FILE:png>"
|
||||
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
||||
else() # old 2.x add_test; limited and won't work well on Windows
|
||||
# Note LIBPNG is a dummy value as there are no generator expressions
|
||||
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
|
||||
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
|
||||
"-DTEST_COMMAND=./${_PAT_COMMAND}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(PNG_TESTS AND PNG_SHARED)
|
||||
# does not work with msvc due to png_lib_ver issue
|
||||
# Find test PNG files by globbing, but sort lists to ensure
|
||||
# consistency between different filesystems.
|
||||
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
|
||||
list(SORT PNGSUITE_PNGS)
|
||||
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
|
||||
list(SORT TEST_PNGS)
|
||||
|
||||
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
|
||||
|
||||
add_executable(pngtest ${pngtest_sources})
|
||||
target_link_libraries(pngtest ${PNG_LIB_NAME})
|
||||
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
||||
#
|
||||
target_link_libraries(pngtest png)
|
||||
|
||||
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
|
||||
|
||||
add_executable(pngvalid ${pngvalid_sources})
|
||||
target_link_libraries(pngvalid ${PNG_LIB_NAME})
|
||||
add_test(pngvalid ./pngvalid)
|
||||
target_link_libraries(pngvalid png)
|
||||
|
||||
png_add_test(NAME pngvalid-gamma-16-to-8
|
||||
COMMAND pngvalid OPTIONS --gamma-16-to-8)
|
||||
png_add_test(NAME pngvalid-gamma-alpha-mode
|
||||
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
|
||||
png_add_test(NAME pngvalid-gamma-background
|
||||
COMMAND pngvalid OPTIONS --gamma-background)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
|
||||
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-background
|
||||
COMMAND pngvalid OPTIONS --gamma-background --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-transform
|
||||
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-sbit
|
||||
COMMAND pngvalid OPTIONS --gamma-sbit)
|
||||
png_add_test(NAME pngvalid-gamma-threshold
|
||||
COMMAND pngvalid OPTIONS --gamma-threshold)
|
||||
png_add_test(NAME pngvalid-gamma-transform
|
||||
COMMAND pngvalid OPTIONS --gamma-transform)
|
||||
png_add_test(NAME pngvalid-progressive-interlace-standard
|
||||
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
|
||||
png_add_test(NAME pngvalid-progressive-size
|
||||
COMMAND pngvalid OPTIONS --size --progressive-read)
|
||||
png_add_test(NAME pngvalid-progressive-standard
|
||||
COMMAND pngvalid OPTIONS --standard --progressive-read)
|
||||
png_add_test(NAME pngvalid-standard
|
||||
COMMAND pngvalid OPTIONS --standard)
|
||||
png_add_test(NAME pngvalid-transform
|
||||
COMMAND pngvalid OPTIONS --transform)
|
||||
|
||||
add_executable(pngstest ${pngstest_sources})
|
||||
target_link_libraries(pngstest ${PNG_LIB_NAME})
|
||||
add_test(pngstest ./pngstest
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
|
||||
)
|
||||
target_link_libraries(pngstest png)
|
||||
|
||||
foreach(gamma_type 1.8 linear none sRGB)
|
||||
foreach(alpha_type none alpha)
|
||||
set(PNGSTEST_FILES)
|
||||
foreach(test_png ${TEST_PNGS})
|
||||
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
|
||||
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
|
||||
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
|
||||
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
|
||||
|
||||
set(TEST_PNG_VALID TRUE)
|
||||
|
||||
if(TEST_PNG_ALPHA)
|
||||
if (NOT "${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
else()
|
||||
if ("${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_PNG_LINEAR)
|
||||
if(NOT "${gamma_type}" STREQUAL "linear")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
elseif(TEST_PNG_SRGB)
|
||||
if(NOT "${gamma_type}" STREQUAL "sRGB")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
elseif(TEST_PNG_G18)
|
||||
if(NOT "${gamma_type}" STREQUAL "1.8")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
else()
|
||||
if(NOT "${gamma_type}" STREQUAL "none")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_PNG_VALID)
|
||||
list(APPEND PNGSTEST_FILES "${test_png}")
|
||||
endif()
|
||||
endforeach()
|
||||
# Should already be sorted, but sort anyway to be certain.
|
||||
list(SORT PNGSTEST_FILES)
|
||||
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
|
||||
COMMAND pngstest
|
||||
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
|
||||
FILES ${PNGSTEST_FILES})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
add_executable(pngunknown ${pngunknown_sources})
|
||||
target_link_libraries(pngunknown png)
|
||||
|
||||
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
|
||||
|
||||
add_executable(pngimage ${pngimage_sources})
|
||||
target_link_libraries(pngimage png)
|
||||
|
||||
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
|
||||
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_executable(pngfix ${pngfix_sources})
|
||||
target_link_libraries(pngfix png)
|
||||
set(PNG_BIN_TARGETS pngfix)
|
||||
|
||||
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
||||
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
||||
endif()
|
||||
|
||||
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
||||
@ -222,17 +680,28 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_TARGETS}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endmacro()
|
||||
|
||||
# Create source generation scripts.
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
|
||||
|
||||
|
||||
# libpng is a library so default to 'lib'
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR lib)
|
||||
@ -259,22 +728,12 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta33
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
set_target_properties(png PROPERTIES
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta88
|
||||
VERSION 17.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 17
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
if(PNG_STATIC)
|
||||
# MSVC doesn't use a different file extension for shared vs. static
|
||||
# libs. We are able to change OUTPUT_NAME to remove the _static
|
||||
# for all other platforms.
|
||||
if(NOT MSVC)
|
||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
|
||||
OUTPUT_NAME ${PNG_LIB_NAME}
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If CMake > 2.4.x, we set a variable used below to export
|
||||
# targets to an export file.
|
||||
@ -287,40 +746,34 @@ endif()
|
||||
|
||||
# INSTALL
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
if(PNG_SHARED)
|
||||
install(TARGETS ${PNG_LIB_NAME}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${PNG_LIB_TARGETS}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN OR MINGW)
|
||||
|
||||
if(NOT WIN32)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||
${PNG_EXPORT_RULE}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
get_target_property(BUILD_TARGET_LOCATION png_static LOCATION_${CMAKE_BUILD_TYPE})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
@ -339,6 +792,11 @@ if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
|
||||
install(TARGETS ${PNG_BIN_TARGETS}
|
||||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
# Install man pages
|
||||
if(NOT PNG_MAN_DIR)
|
||||
@ -365,7 +823,7 @@ if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
||||
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
||||
endif()
|
||||
|
||||
# what's with libpng-$VER%.txt and all the extra files?
|
||||
# what's with libpng-manual.txt and all the extra files?
|
||||
|
||||
# UNINSTALL
|
||||
# do we need this?
|
||||
|
362
INSTALL
@ -1,5 +1,27 @@
|
||||
|
||||
Installing libpng
|
||||
Installing libpng
|
||||
|
||||
Contents
|
||||
|
||||
I. Simple installation
|
||||
II. Rebuilding the configure scripts
|
||||
III. Using scripts/makefile*
|
||||
IV. Using cmake
|
||||
V. Directory structure
|
||||
VI. Building with project files
|
||||
VII. Building with makefiles
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
IX. Configuring for DOS
|
||||
X. Configuring for Medium Model
|
||||
XI. Prepending a prefix to exported symbols
|
||||
XII. Configuring for compiler xxx:
|
||||
XIII. Removing unwanted object code
|
||||
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||
XV. Setjmp/longjmp issues
|
||||
XVI. Common linking failures
|
||||
XVII. Other sources of information about libpng
|
||||
|
||||
I. Simple installation
|
||||
|
||||
On Unix/Linux and similar systems, you can simply type
|
||||
|
||||
@ -7,13 +29,28 @@ On Unix/Linux and similar systems, you can simply type
|
||||
make check
|
||||
make install
|
||||
|
||||
and ignore the rest of this document.
|
||||
and ignore the rest of this document. "/path" is the path to the directory
|
||||
where you want to install the libpng "lib", "include", and "bin"
|
||||
subdirectories.
|
||||
|
||||
If you downloaded a GIT clone, you will need to run ./autogen.sh before
|
||||
running ./configure, to create "configure" and "Makefile.in" which are
|
||||
not included in the GIT repository.
|
||||
|
||||
Note that "configure" is only included in the "*.tar" distributions and not
|
||||
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
|
||||
distributions, see "Building with project files" or "Building with makefiles",
|
||||
below.
|
||||
|
||||
II. Rebuilding the configure scripts
|
||||
|
||||
If configure does not work on your system, or if you have a need to
|
||||
change configure.ac or Makefile.am, and you have a reasonably
|
||||
up-to-date set of tools, running ./autogen.sh in a git clone before
|
||||
running ./configure may fix the problem. To be really sure that you
|
||||
aren't using any of the included pre-built scripts, you can do this:
|
||||
aren't using any of the included pre-built scripts, especially if you
|
||||
are building from a tar distribution instead of a git distribution,
|
||||
do this:
|
||||
|
||||
./configure --enable-maintainer-mode
|
||||
make maintainer-clean
|
||||
@ -24,9 +61,12 @@ aren't using any of the included pre-built scripts, you can do this:
|
||||
make install
|
||||
make check
|
||||
|
||||
III. Using scripts/makefile*
|
||||
|
||||
Instead, you can use one of the custom-built makefiles in the
|
||||
"scripts" directory
|
||||
|
||||
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||
cp scripts/makefile.system makefile
|
||||
make test
|
||||
make install
|
||||
@ -38,31 +78,54 @@ Or you can use one of the "projects" in the "projects" directory.
|
||||
|
||||
Before installing libpng, you must first install zlib, if it
|
||||
is not already on your system. zlib can usually be found
|
||||
wherever you got libpng. zlib can be placed in another directory,
|
||||
at the same level as libpng.
|
||||
|
||||
If you want to use "cmake" (see www.cmake.org), type
|
||||
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||
make
|
||||
make install
|
||||
wherever you got libpng; otherwise go to http://zlib.net. You can place
|
||||
zlib in the same directory as libpng or in another directory.
|
||||
|
||||
If your system already has a preinstalled zlib you will still need
|
||||
to have access to the zlib.h and zconf.h include files that
|
||||
correspond to the version of zlib that's installed.
|
||||
|
||||
If you wish to test with a particular zlib that is not first in the
|
||||
standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
|
||||
and LD_LIBRARY_PATH in your environment before running "make test"
|
||||
or "make distcheck":
|
||||
|
||||
ZLIBLIB=/path/to/lib export ZLIBLIB
|
||||
ZLIBINC=/path/to/include export ZLIBINC
|
||||
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
|
||||
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
|
||||
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
|
||||
|
||||
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
||||
in your environment and type
|
||||
|
||||
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
|
||||
|
||||
IV. Using cmake
|
||||
|
||||
If you want to use "cmake" (see www.cmake.org), type
|
||||
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||
make
|
||||
make install
|
||||
|
||||
As when using the simple configure method described above, "/path" points to
|
||||
the installation directory where you want to put the libpng "lib", "include",
|
||||
and "bin" subdirectories.
|
||||
|
||||
V. Directory structure
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
|
||||
or "zlib125") so that you have directories called "zlib" and "libpng".
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
||||
or "zlib128") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
.. (the parent directory)
|
||||
libpng (this directory)
|
||||
.. (the parent directory)
|
||||
libpng (this directory)
|
||||
INSTALL (this file)
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
*.h, *.c => libpng source files
|
||||
CMakeLists.txt => "cmake" script
|
||||
configuration files:
|
||||
configure.ac, configure, Makefile.am, Makefile.in,
|
||||
@ -70,14 +133,10 @@ Your directory structure should look like this:
|
||||
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||
contrib
|
||||
gregbook
|
||||
pngminim
|
||||
pngminus
|
||||
pngsuite
|
||||
visupng
|
||||
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||
pngminus, pngsuite, tools, visupng
|
||||
projects
|
||||
visualc71
|
||||
vstudio
|
||||
cbuilder5, owatcom, visualc71, vstudio, xcode
|
||||
scripts
|
||||
makefile.*
|
||||
*.def (module definition files)
|
||||
@ -85,29 +144,36 @@ Your directory structure should look like this:
|
||||
pngtest.png
|
||||
etc.
|
||||
zlib
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
contrib
|
||||
etc.
|
||||
README, *.h, *.c contrib, etc.
|
||||
|
||||
If the line endings in the files look funny, you may wish to get the other
|
||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||
endings) and zip (DOS style line endings) formats.
|
||||
|
||||
VI. Building with project files
|
||||
|
||||
If you are building libpng with MSVC, you can enter the
|
||||
libpng projects\visualc6 or visualc71 directory and follow the instructions
|
||||
libpng projects\visualc71 or vstudio directory and follow the instructions
|
||||
in README.txt.
|
||||
|
||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
||||
then come back here and run "configure" or choose the appropriate
|
||||
makefile.sys in the scripts directory.
|
||||
|
||||
VII. Building with makefiles
|
||||
|
||||
Copy the file (or files) that you need from the
|
||||
scripts directory into this directory, for example
|
||||
|
||||
MSDOS example: copy scripts\makefile.msc makefile
|
||||
UNIX example: cp scripts/makefile.std makefile
|
||||
MSDOS example:
|
||||
|
||||
copy scripts\makefile.msc makefile
|
||||
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
|
||||
|
||||
UNIX example:
|
||||
|
||||
cp scripts/makefile.std makefile
|
||||
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||
|
||||
Read the makefile to see if you need to change any source or
|
||||
target directories to match your preferences.
|
||||
@ -130,26 +196,220 @@ do that, run "make install" in the zlib directory first if necessary).
|
||||
Some also allow you to run "make test-installed" after you have
|
||||
run "make install".
|
||||
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more than 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
IX. Configuring for DOS
|
||||
|
||||
For DOS users who only have access to the lower 640K, you will
|
||||
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
|
||||
X. Configuring for Medium Model
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
XI. Prepending a prefix to exported symbols
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||
"configure" script) to prefix all exported symbols by means of the
|
||||
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
||||
string beginning with a letter and containing only uppercase
|
||||
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
XII. Configuring for compiler xxx:
|
||||
|
||||
All includes for libpng are in pngconf.h. If you need to add, change
|
||||
or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers. As of libpng-1.7.0,
|
||||
pngchunk.h is also included, and is used privately by pngrutil.c.
|
||||
|
||||
XIII. Removing unwanted object code
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
"PNG_NO_".
|
||||
|
||||
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four, along with directives to turn on any of the capabilities that
|
||||
you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
|
||||
extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks. Use of the
|
||||
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
||||
that is incapable of reading or writing ancillary chunks. If you are
|
||||
not using the progressive reading capability, you can turn that off
|
||||
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
||||
capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
If you are creating or distributing a dynamically linked library (a .so
|
||||
or DLL file), you should not remove or disable any parts of the library,
|
||||
as this will cause applications linked with different versions of the
|
||||
library to fail if they call functions not available in your library.
|
||||
The size of the library itself should not be an issue, because only
|
||||
those sections that are actually used will be loaded into memory.
|
||||
|
||||
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||
|
||||
Details of internal changes to the library code can be found in the CHANGES
|
||||
file and in the GIT repository logs. These will be of no concern to the vast
|
||||
majority of library users or builders; however, the few who configure libpng
|
||||
to a non-default feature set may need to change how this is done.
|
||||
|
||||
There should be no need for library builders to alter build scripts if
|
||||
these use the distributed build support - configure or the makefiles -
|
||||
however, users of the makefiles may care to update their build scripts
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
A. Specific changes to library configuration capabilities
|
||||
|
||||
The exact mechanism used to control attributes of API functions has
|
||||
changed. A single set of operating system independent macro definitions
|
||||
is used and operating system specific directives are defined in
|
||||
pnglibconf.h
|
||||
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far ("__cdecl" on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
necessary to set PNG_API_RULE to 1 should advise the mailing list
|
||||
(png-mng-implement) of this and library builders who use Openwatcom and
|
||||
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
||||
|
||||
B. Changes to the configuration mechanism
|
||||
|
||||
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
||||
had either to modify the exported pngconf.h header file to add system
|
||||
specific configuration or had to write feature selection macros into
|
||||
pngusr.h and cause this to be included into pngconf.h by defining
|
||||
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
||||
application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, at the time the exported header file pnglibconf.h is
|
||||
built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
|
||||
after the build of pnglibconf.h and it is never included in an application
|
||||
build.
|
||||
|
||||
The formerly used alternative of adding a list of feature macros to the
|
||||
CPPFLAGS setting in the build also still works; however, the macros will be
|
||||
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||
when the individual C files are compiled.
|
||||
|
||||
All configuration now only works if pnglibconf.h is built from
|
||||
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
(the original author of awk) maintains C source code of that awk and this
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
file also includes dependency information that ensures a configuration is
|
||||
consistent; that is, if a feature is switched off, dependent features are
|
||||
also switched off. As a recommended alternative to using feature macros in
|
||||
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
||||
(or, indeed, any file) and add that to the configuration by setting
|
||||
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
||||
how to do this, and also illustrate a case where pngusr.h is still required.
|
||||
|
||||
After you have built libpng, the definitions that were recorded in
|
||||
pnglibconf.h are available to your application (pnglibconf.h is included
|
||||
in png.h and gets installed alongside png.h and pngconf.h in your
|
||||
$PREFIX/include directory). Do not edit pnglibconf.h after you have built
|
||||
libpng, because than the settings would not accurately reflect the settings
|
||||
that were used to build libpng.
|
||||
|
||||
XV. Setjmp/longjmp issues
|
||||
|
||||
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
|
||||
is known to be not thread-safe on some platforms and we don't know of
|
||||
any platform where it is guaranteed to be thread-safe. Therefore, if
|
||||
your application is going to be using multiple threads, you should
|
||||
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
|
||||
-DPNG_NO_SETJMP on your compile line, or with
|
||||
|
||||
#undef PNG_SETJMP_SUPPORTED
|
||||
|
||||
in your pnglibconf.h or pngusr.h.
|
||||
|
||||
Starting with libpng-1.6.0, the library included a "simplified API".
|
||||
This requires setjmp/longjmp, so you must either build the library
|
||||
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
|
||||
|
||||
XVI. Common linking failures
|
||||
|
||||
If your application fails to find libpng or zlib entries while linking:
|
||||
|
||||
Be sure "-lz" appears after "-lpng" on your linking command.
|
||||
|
||||
Be sure you have built libpng, zlib, and your application for the
|
||||
same platform (e.g., 32-bit or 64-bit).
|
||||
|
||||
If you are using the vstudio project, observe the WARNING in
|
||||
project/vstudio/README.txt.
|
||||
|
||||
XVII. Other sources of information about libpng:
|
||||
|
||||
Further information can be found in the README and libpng-manual.txt
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
|
||||
Using the ./configure script -- 16 December 2002.
|
||||
=================================================
|
||||
|
||||
The ./configure script should work compatibly with what scripts/makefile.*
|
||||
did, however there are some options you might need to add to configure
|
||||
explicitly, which previously was done semi-automatically (if you didn't edit
|
||||
scripts/makefile.* yourself, that is)
|
||||
|
||||
CFLAGS="-Wall -O -funroll-loops \
|
||||
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
|
||||
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
||||
|
||||
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
||||
/usr/include/libpng%NN%, or whatever.
|
||||
|
||||
If you find that the configure script is out-of-date or is not supporting
|
||||
your platform properly, try running autogen.sh to regenerate "configure",
|
||||
"Makefile.in", and the other configuration files. Then try configure again.
|
||||
|
||||
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
and license in png.h.
|
||||
|
81
LICENSE
@ -10,21 +10,18 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
Cosmin Truta
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.7.0beta88, August 6, 2017 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
@ -35,19 +32,25 @@ and with the following additions to the disclaimer:
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
|
||||
Some files in the "contrib" directory and some configure-generated
|
||||
files that are distributed with libpng have other copyright owners and
|
||||
are released under other open source licenses.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.96,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
libpng-0.96, and are distributed according to the same disclaimer and
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
and are distributed according to the same disclaimer and license as
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
@ -56,8 +59,11 @@ with the following individuals added to the list of Contributing Authors:
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
Some files in the "scripts" directory have other copyright owners
|
||||
but are released under this license.
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
@ -80,13 +86,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
@ -94,18 +100,31 @@ supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
|
||||
A "png_get_copyright" function is available, for convenient use in "about"
|
||||
boxes and the like:
|
||||
TRADEMARK:
|
||||
|
||||
printf("%s",png_get_copyright(NULL));
|
||||
The name "libpng" has not been registered by the Copyright owner
|
||||
as a trademark in any jurisdiction. However, because libpng has
|
||||
been distributed and maintained world-wide, continually since 1995,
|
||||
the Copyright owner claims "common-law trademark protection" in any
|
||||
jurisdiction where common-law trademark is recognized.
|
||||
|
||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
OSI CERTIFICATION:
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
EXPORT CONTROL:
|
||||
|
||||
The Copyright owner believes that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because
|
||||
it is open source, publicly available software, that does not contain
|
||||
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
||||
734.7(b).
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 10, 2012
|
||||
August 6, 2017
|
||||
|
260
Makefile.am
@ -1,30 +1,80 @@
|
||||
# Makefile.am:
|
||||
# Source file for Makefile.in (and hence Makefile)
|
||||
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||
#
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
||||
check_PROGRAMS= pngtest
|
||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
|
||||
if HAVE_CLOCK_GETTIME
|
||||
check_PROGRAMS += timepng
|
||||
endif
|
||||
|
||||
# Utilities - installed
|
||||
bin_PROGRAMS= pngfix png-fix-itxt
|
||||
|
||||
# This ensures that pnglibconf.h gets built at the start of 'make all' or
|
||||
# 'make check', but it does not add dependencies to the individual programs,
|
||||
# this is done below.
|
||||
#
|
||||
# IMPORTANT: always add the object modules of new programs to the list below
|
||||
# because otherwise the sequence 'configure; make new-program' will *sometimes*
|
||||
# result in the installed (system) pnglibconf.h being used and the result is
|
||||
# always wrong and always very confusing.
|
||||
BUILT_SOURCES = pnglibconf.h
|
||||
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS = test-pngtest.sh
|
||||
|
||||
# Only do the following if the contrib directory is present.
|
||||
check_PROGRAMS+= pngvalid pngstest pngunknown
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS += contrib/libtests/test-pngunknown.sh\
|
||||
contrib/libtests/test-pngvalid-simple.sh\
|
||||
contrib/libtests/test-pngvalid-full.sh\
|
||||
contrib/libtests/test-pngstest.sh
|
||||
|
||||
pngimage_SOURCES = contrib/libtests/pngimage.c
|
||||
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngfix_SOURCES = contrib/tools/pngfix.c
|
||||
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||
|
||||
timepng_SOURCES = contrib/libtests/timepng.c
|
||||
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngcp_SOURCES = contrib/tools/pngcp.c
|
||||
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
# Generally these are single line shell scripts to run a test with a particular
|
||||
# set of parameters:
|
||||
TESTS =\
|
||||
tests/pngtest\
|
||||
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
||||
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
||||
tests/pngvalid-gamma-expand16-background\
|
||||
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
|
||||
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
|
||||
tests/pngvalid-progressive-size tests/pngvalid-size\
|
||||
tests/pngvalid-progressive-interlace-standard\
|
||||
tests/pngvalid-transform tests/pngvalid-interlace-transform\
|
||||
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
|
||||
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
|
||||
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
|
||||
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
||||
tests/pngimage-quick tests/pngimage-full
|
||||
|
||||
# man pages
|
||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||
@ -40,10 +90,15 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
|
||||
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h \
|
||||
pngusr.dfa
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
|
||||
# Include libpng extensions, if appropriate. This uses a Makefile.am fragment,
|
||||
# pre-set things that might be changed by addition:
|
||||
AM_CPPFLAGS =
|
||||
DFA_EXTENSION =
|
||||
if LIBPNG_EXTENSIONS
|
||||
include $(top_srcdir)/contrib/extensions.am
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@ -76,19 +131,22 @@ nodist_pkginclude_HEADERS= pnglibconf.h
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
|
||||
#extra source distribution files.
|
||||
# Extra source distribution files, '${srcdir}' is used below to stop build files
|
||||
# from those directories being included. This only works if the configure is
|
||||
# not done in the source directory!
|
||||
EXTRA_DIST= \
|
||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||
$(TESTS) \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
CMakeLists.txt example.c libpng-manual.txt
|
||||
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.c
|
||||
|
||||
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
||||
check.new pnglibconf.* pngprefix.h symbols.new pngtest-log.txt \
|
||||
check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \
|
||||
pnglibconf.out pnglibconf.c pnglibconf.dfn pnglibconf.pre \
|
||||
$(SCRIPT_CLEANFILES)
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
||||
@ -100,14 +158,14 @@ config.sub configure depcomp install-sh ltmain.sh missing
|
||||
PNG_COPTS = @PNG_COPTS@
|
||||
AM_CFLAGS = ${PNG_COPTS}
|
||||
|
||||
# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
|
||||
# other operating systems (NeXT?) the C preprocessor selected by configure
|
||||
# DFNCPP is normally just "CPP -E" - the C preprocessor - but on Solaris and
|
||||
# maybe other operating systems (NeXT?) the C preprocessor selected by configure
|
||||
# checks input tokens for validity - effectively it performs part of the ANSI-C
|
||||
# parsing - and therefore fails with the .df files. configure.ac has special
|
||||
# checks for this and sets DFNCPP appropriately.
|
||||
DFNCPP = @DFNCPP@
|
||||
|
||||
SUFFIXES = .chk .dfn .out
|
||||
SUFFIXES = .chk .out
|
||||
|
||||
$(PNGLIB_BASENAME).pc: libpng.pc
|
||||
cp libpng.pc $@
|
||||
@ -118,6 +176,9 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/prefix.out: png.h pngconf.h pnglibconf.out
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
scripts/intprefix.out: pnglibconf.h
|
||||
|
||||
pnglibconf.out: config.h
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@ -130,7 +191,7 @@ if DO_PNG_PREFIX
|
||||
# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix.
|
||||
# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
|
||||
# implementation of the macro).
|
||||
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst
|
||||
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst config.h
|
||||
rm -f $@
|
||||
$(AWK) 's==0 && NR>1{print prev}\
|
||||
s==0{prev=$$0}\
|
||||
@ -156,14 +217,29 @@ endif
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2
|
||||
@echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2
|
||||
@exit 1
|
||||
|
||||
# The following is necessary to ensure that the local pnglibconf.h is used, not
|
||||
# an installed one (this can happen immediately after on a clean system if
|
||||
# 'make test' is the first thing the user does.)
|
||||
contrib/libtests/pngstest.o contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
|
||||
# 'make test' is the first thing the user does.) Only files which include
|
||||
# one of the png source files (typically png.h or pngpriv.h) need to be listed
|
||||
# here:
|
||||
pngtest.o: pnglibconf.h
|
||||
|
||||
contrib/libtests/makepng.o: pnglibconf.h
|
||||
contrib/libtests/pngstest.o: pnglibconf.h
|
||||
contrib/libtests/pngunknown.o: pnglibconf.h
|
||||
contrib/libtests/pngimage.o: pnglibconf.h
|
||||
contrib/libtests/pngvalid.o: pnglibconf.h
|
||||
contrib/libtests/readpng.o: pnglibconf.h
|
||||
contrib/libtests/tarith.o: pnglibconf.h
|
||||
contrib/libtests/timepng.o: pnglibconf.h
|
||||
|
||||
contrib/tools/makesRGB.o: pnglibconf.h
|
||||
contrib/tools/pngfix.o: pnglibconf.h
|
||||
contrib/tools/pngcp.o: pnglibconf.h
|
||||
|
||||
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
|
||||
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
|
||||
@ -177,24 +253,21 @@ if DO_PNG_PREFIX
|
||||
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ $*.c $*.tf[123]
|
||||
test -d scripts || mkdir scripts
|
||||
echo '#include "$<"' >$*.c
|
||||
.c.out:
|
||||
rm -f $@ $*.tf[12]
|
||||
test -d scripts || mkdir scripts || test -d scripts
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
$*.tf1 >$*.tf2
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
|
||||
rm -f $*.c $*.tf[12]
|
||||
mv $*.tf3 $@
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
|
||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||
rm -f $*.tf1
|
||||
mv $*.tf2 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
# The .c file for pnglibconf.h is machine generated
|
||||
pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_EXTENSION) $(DFA_XTRA)
|
||||
rm -f $@ $*.tf[45]
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||
$(DFA_EXTENSION) ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||
rm $*.tf4
|
||||
mv $*.tf5 $@
|
||||
@ -210,10 +283,11 @@ scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.ou
|
||||
|
||||
# used on demand to regenerate the standard header, CPPFLAGS should
|
||||
# be empty - no non-standard defines
|
||||
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
rm -f $@ pnglibconf.tf[67]
|
||||
test -z "$(CPPFLAGS)"
|
||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||
test -z "$(CPPFLAGS)" -a -z "$(AM_CPPFLAGS)"
|
||||
(echo "com libpng @PNGLIB_VERSION@ STANDARD API DEFINITION";\
|
||||
echo "com") |\
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\
|
||||
logunsupported=1 version=search ${srcdir}/pngconf.h -\
|
||||
${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||
@ -222,7 +296,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
rm pnglibconf.tf6
|
||||
mv pnglibconf.tf7 $@
|
||||
|
||||
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \
|
||||
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h pngchunk.h \
|
||||
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h
|
||||
|
||||
test: check-am
|
||||
@ -234,34 +308,76 @@ check: scripts/symbols.chk
|
||||
dist-hook:
|
||||
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
|
||||
|
||||
# install the .../include headers as links to the new ones
|
||||
install-data-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
|
||||
pngconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
|
||||
pnglibconf.h
|
||||
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
|
||||
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
||||
# Make links between installed files with release-specific names and the generic
|
||||
# file names. If this install rule is run the generic names will be deleted and
|
||||
# recreated - this has obvious issues for systems with multiple installations.
|
||||
|
||||
# do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir); rm -f libpng-config
|
||||
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
||||
@set -x;\
|
||||
cd $(DESTDIR)$(libdir);\
|
||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
|
||||
rm -f libpng.$$ext;\
|
||||
if test -f $(PNGLIB_BASENAME).$$ext; then\
|
||||
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
|
||||
fi;\
|
||||
install-header-links:
|
||||
@set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \
|
||||
rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done
|
||||
|
||||
uninstall-header-links:
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS)
|
||||
|
||||
install-libpng-pc:
|
||||
@set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \
|
||||
$(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc
|
||||
|
||||
uninstall-libpng-pc:
|
||||
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||
|
||||
# EXT_LIST is a list of the possibly library directory extensions, this exists
|
||||
# because we can't find a good way of discovering the file extensions that are
|
||||
# actually installed on a given system, so instead we check for every extension
|
||||
# we have seen.
|
||||
|
||||
EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib
|
||||
|
||||
install-library-links:
|
||||
@set -x; cd '$(DESTDIR)$(libdir)';\
|
||||
for ext in $(EXT_LIST); do\
|
||||
rm -f "libpng.$$ext";\
|
||||
if test -f "$(PNGLIB_BASENAME).$$ext"; then\
|
||||
$(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\
|
||||
fi;\
|
||||
done
|
||||
|
||||
uninstall-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
|
||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.a
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.la
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.dll.a
|
||||
uninstall-library-links:
|
||||
@set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\
|
||||
rm -f "libpng.$$ext"; done
|
||||
|
||||
install-libpng-config:
|
||||
@set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \
|
||||
$(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config
|
||||
|
||||
uninstall-libpng-config:
|
||||
rm -f '$(DESTDIR)$(bindir)/libpng-config'
|
||||
|
||||
if DO_INSTALL_LINKS
|
||||
# If --enable-unversioned-links is specified the header and lib file links
|
||||
# will be automatically made on a 'make install':
|
||||
|
||||
install-data-hook: install-header-links
|
||||
uninstall-hook: uninstall-header-links
|
||||
install-exec-hook: install-library-links
|
||||
uninstall-hook: uninstall-library-links
|
||||
endif
|
||||
|
||||
if DO_INSTALL_LIBPNG_PC
|
||||
# Likewise, --install-pc causes libpng.pc to be constructed:
|
||||
|
||||
install-data-hook: install-libpng-pc
|
||||
uninstall-hook: uninstall-libpng-pc
|
||||
endif
|
||||
|
||||
if DO_INSTALL_LIBPNG_CONFIG
|
||||
# And --install-config:
|
||||
|
||||
install-exec-hook: install-libpng-config
|
||||
uninstall-hook: uninstall-libpng-config
|
||||
endif
|
||||
|
||||
# The following addition ensures that 'make all' always builds the test programs
|
||||
# too. It used to, but some change either in libpng or configure stopped this
|
||||
# working.
|
||||
all-am: $(check_PROGRAMS)
|
||||
|
66
README
@ -1,11 +1,11 @@
|
||||
README for libpng version 1.6.0beta33 - December 10, 2012 (shared library 16.0)
|
||||
README for libpng version 1.7.0beta88 - August 6, 2017 (shared library 17.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
|
||||
To avoid problems with changes to the internals of png_info_struct,
|
||||
To avoid problems with changes to the internals of the png info_struct,
|
||||
new APIs have been made available in 0.95 to avoid direct application
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs do not make current programs
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library. However, it is strongly suggested that new programs use
|
||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
||||
be converted to the new format, to facilitate upgrades in the future.
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
@ -77,17 +84,21 @@ compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
This code is currently being archived at libpng.sourceforge.io in the
|
||||
[DOWNLOAD] area, and at ftp://ftp-osl.osuosl.org/pub/libpng/src . If you
|
||||
can't find it in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because it
|
||||
is open source, publicly available software, that does not contain any
|
||||
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
@ -123,7 +134,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for sixteen years now, and it is official and
|
||||
been discussing PNG for twenty years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
@ -149,6 +160,7 @@ Files in this distribution:
|
||||
pngstruct.h => png_struct declaration (private)
|
||||
pnginfo.h => png_info struct declaration (private)
|
||||
pngdebug.h => debugging macros (private)
|
||||
pngchunk.h => PNG chunk descriptions (private, new in libpng17)
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
@ -167,23 +179,25 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
contrib => Contributions
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
libtests => Test programs
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
8
TODO
@ -5,7 +5,10 @@ Final bug fixes.
|
||||
Better C++ wrapper/full C++ implementation?
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Remove setjmp/longjmp usage in favor of returning error codes.
|
||||
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
|
||||
this, minimize the use of png_error(), replacing them with
|
||||
png_warning(); return(0); or similar.
|
||||
Palette creation.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
@ -21,7 +24,8 @@ Use greater precision when changing to linear gamma for compositing against
|
||||
background and doing rgb-to-gray transformation.
|
||||
Investigate pre-incremented loop counters and other loop constructions.
|
||||
Add interpolated method of handling interlacing.
|
||||
Switch to the simpler zlib (zlib/libpng) license if legally possible.
|
||||
Extend pngvalid.c to validate more of the libpng transformations.
|
||||
Refactor preprocessor conditionals to compile entire statements
|
||||
Quiet compiler warnings (mostly -Wconversion warnings).
|
||||
|
||||
*/
|
||||
|
18
autogen.sh
@ -9,15 +9,15 @@
|
||||
#
|
||||
# For regular ("tarball") distributions all the files should exist. We do not
|
||||
# want them to be updated *under any circumstances*. It should never be
|
||||
# necessary to rune autogen.sh because ./configure --enable-maintainer-mode says
|
||||
# what to do if Makeile.am or configure.ac are changed.
|
||||
# necessary to run autogen.sh because ./configure --enable-maintainer-mode says
|
||||
# what to do if Makefile.am or configure.ac are changed.
|
||||
#
|
||||
# It is *probably* OK to update the files on a GIT checkout, because they have
|
||||
# come from the local tools, but leave that to the user who is assumed to know
|
||||
# whether it is ok or required.
|
||||
#
|
||||
# This script is intended to work without arguments, there are, however, hidden
|
||||
# arguments for (a) use while testing the script and (b) to fix up systems that
|
||||
# arguments (a) for use while testing the script and (b) to fix up systems that
|
||||
# have been broken. If (b) is required the script prompts for the correct
|
||||
# options. For this reason the options are *NOT* documented in the help; this
|
||||
# is deliberate; UTSL.
|
||||
@ -73,8 +73,13 @@ done
|
||||
# present bad things are happening.
|
||||
#
|
||||
# The autotools generated files:
|
||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
|
||||
config.sub configure depcomp install-sh ltmain.sh missing"
|
||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
|
||||
config.sub configure depcomp install-sh ltmain.sh missing\
|
||||
test-driver"
|
||||
#
|
||||
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
|
||||
# versions than those required by configure.ac):
|
||||
libpng_autotools_extra="compile config.h.in~"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
@ -94,6 +99,7 @@ libpng_configure_dirs=".deps"
|
||||
# of Makefile. These functions do the two bits of cleaning.
|
||||
clean_autotools(){
|
||||
rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs
|
||||
rm -rf $libpng_autotools_extra
|
||||
}
|
||||
|
||||
clean_configure(){
|
||||
@ -198,7 +204,7 @@ case "$mode" in
|
||||
echo " You can run autoreconf yourself if you don't like maintainer"
|
||||
echo " mode and you can also just run autoreconf -f -i to initialize"
|
||||
echo " everything in the first place; this script is only for"
|
||||
echo " compatiblity with prior releases."
|
||||
echo " compatibility with prior releases."
|
||||
exit 1
|
||||
else
|
||||
exec >&2
|
||||
|
280
configure.ac
@ -1,5 +1,13 @@
|
||||
# configure.ac
|
||||
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
dnl Minor upgrades (compatible ABI): increment the package version
|
||||
@ -18,7 +26,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.0beta33],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.7.0beta88],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@ -26,9 +34,12 @@ AC_CONFIG_MACRO_DIR([scripts])
|
||||
# silent-rules requires automake 1.11 or later
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||
AM_INIT_AUTOMAKE([1.12.2 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
# 1.13 is required for parallel tests
|
||||
# 1.14.1 is required for %reldir% support
|
||||
AM_INIT_AUTOMAKE([1.15 foreign dist-xz color-tests silent-rules subdir-objects])
|
||||
# The following line causes --disable-maintainer-mode to be the default to
|
||||
# configure. This is necessary because libpng distributions cannot rely on the
|
||||
# time stamps of the autotools generated files being correct
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||
@ -37,9 +48,9 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.0beta33
|
||||
PNGLIB_VERSION=1.7.0beta88
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_MINOR=7
|
||||
PNGLIB_RELEASE=0
|
||||
|
||||
dnl End of version number stuff
|
||||
@ -53,41 +64,33 @@ AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
LT_PATH_LD
|
||||
AC_PROG_CPP
|
||||
AC_CHECK_TOOL(SED, sed, :)
|
||||
AC_CHECK_TOOL(AWK, awk, :)
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
|
||||
dnl libtool/libtoolize; version 2.4.4 is the tested version, this or any
|
||||
dnl compatible later version may be used
|
||||
LT_INIT([win32-dll])
|
||||
LT_PREREQ([2.4.2])
|
||||
LT_PREREQ([2.4.4])
|
||||
|
||||
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
|
||||
# does some input parsing. We need strict ANSI-C style tokenization,
|
||||
# check this:
|
||||
AC_REQUIRE_CPP
|
||||
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"],
|
||||
[ DFNCPP=""
|
||||
sav_CPP="$CPP"
|
||||
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"
|
||||
do
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"]
|
||||
[break],,)
|
||||
done
|
||||
CPP="$sav_CPP"
|
||||
])
|
||||
if test -n "$DFNCPP"; then
|
||||
AC_MSG_RESULT([$DFNCPP])
|
||||
AC_SUBST(DFNCPP)
|
||||
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
|
||||
# to make sure this doesn't happen
|
||||
AC_MSG_CHECKING([that AWK works])
|
||||
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
${srcdir}/pngusr.dfa 1>&2
|
||||
then
|
||||
AC_MSG_RESULT([ok])
|
||||
else
|
||||
AC_MSG_FAILURE([not found], 1)
|
||||
AC_MSG_FAILURE([failed], 1)
|
||||
fi
|
||||
|
||||
# This is a remnant of the old cc -E validation, where it may have been
|
||||
# necessary to use a different preprocessor for .dfn files
|
||||
DFNCPP="$CPP -E"
|
||||
AC_SUBST(DFNCPP)
|
||||
|
||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||
# checks the compiler with a program that generates a warning), add the
|
||||
# following option to deal with this
|
||||
@ -115,31 +118,151 @@ AC_ARG_ENABLE(werror,
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
||||
# Headers used in pngpriv.h:
|
||||
AC_CHECK_HEADERS([assert.h stdlib.h string.h float.h fp.h math.h m68881.h])
|
||||
# Additional headers used in pngconf.h:
|
||||
AC_CHECK_HEADERS([limits.h stddef.h stdio.h setjmp.h time.h])
|
||||
# Used by pngread.c (for the simplified API):
|
||||
AC_CHECK_HEADERS([errno.h])
|
||||
# The following are not required for the standard 'make' build of libpng:
|
||||
# Additional requirements of contrib/libtests/makepng.c:
|
||||
AC_CHECK_HEADERS([ctype.h])
|
||||
# Additional requirements of contrib/libtests/pngvalid.c:
|
||||
AC_CHECK_HEADERS([fenv.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_STRUCT_TM
|
||||
# Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
|
||||
# behaviors and the result were, anyway, not used by earlier versions of libpng.
|
||||
AC_C_RESTRICT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||
AC_ARG_WITH(zlib-prefix,
|
||||
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
||||
[prefix that may have been used in installed zlib]),
|
||||
[ZPREFIX=${withval}],
|
||||
[ZPREFIX='z_'])
|
||||
AC_CHECK_LIB(z, zlibVersion, ,
|
||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
||||
# Checks for library functions; these need to be in order, least demanding to
|
||||
# most because the -l directives are added to the head of the list at each
|
||||
# check.
|
||||
# ANSI-C functions: all are required but they don't have to be implemented in
|
||||
# libc, it is perfectly ok to configure with an extra, wrapper, library preset
|
||||
# in LIBS. NOTE: this list may not be complete
|
||||
AC_CHECK_FUNCS([memset memcpy strncpy],,
|
||||
AC_MSG_FAILURE([missing ANSI-C functions]))
|
||||
|
||||
# Some later POSIX 1003.1 functions are required for test programs, failure here
|
||||
# is soft (the corresponding test program is not built).
|
||||
AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])])
|
||||
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
|
||||
|
||||
# floor and ceil are required for FLOATING_POINT, but they can be turned off on
|
||||
# the configure command line (and they are independent.) Default is to 'on'
|
||||
AC_ARG_ENABLE([floating-point],
|
||||
AS_HELP_STRING([[[--enabled-floating-point]]],
|
||||
[Enable floating point APIs (default: yes)]),,
|
||||
[enable_floating_point=yes])
|
||||
|
||||
AC_ARG_ENABLE([fixed-point],
|
||||
AS_HELP_STRING([[[--enable-fixed-point]]],
|
||||
[Enable fixed point APIs (default: yes)]),,
|
||||
[enable_fixed_point=yes])
|
||||
|
||||
AC_ARG_ENABLE([floating-arithmetic],
|
||||
AS_HELP_STRING([[[--enable-floating-arithmetic]]],
|
||||
[Use floating point arithmetic internally (default: yes)]),,
|
||||
[enable_floating_arithmetic=yes])
|
||||
|
||||
# Check for a requirement for math library support
|
||||
if test "$enable_floating_arithmetic" = yes
|
||||
then
|
||||
AC_SEARCH_LIBS([floor],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([frexp],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([modf],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([atof],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([pow],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
fi
|
||||
|
||||
# Set the relevant defines if required (only if required). This will override
|
||||
# anything on the command line.
|
||||
if test "$enable_floating_point" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Floating point APIs disabled])
|
||||
AC_DEFINE([PNG_NO_FLOATING_POINT],[1],
|
||||
[No support for floating point APIs])
|
||||
fi
|
||||
if test "$enable_fixed_point" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Fixed point APIs disabled])
|
||||
AC_DEFINE([PNG_NO_FIXED_POINT],[1],
|
||||
[No support for fixed point APIs])
|
||||
fi
|
||||
if test "$enable_floating_arithmetic" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Fixed point arithmetic will be used])
|
||||
AC_DEFINE([PNG_NO_FLOATING_ARITHMETIC],[1],
|
||||
[No support for floating point arithmetic])
|
||||
fi
|
||||
|
||||
# The following is for pngvalid, to ensure it catches FP errors even on
|
||||
# platforms that don't enable FP exceptions, the function appears in the math
|
||||
# library (typically), it's not an error if it is not found.
|
||||
AC_CHECK_LIB([m], [feenableexcept])
|
||||
AC_CHECK_FUNCS([feenableexcept])
|
||||
AC_SEARCH_LIBS([feenableexcept],[m],AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],
|
||||
[Define to 1 if the feenableexcept function is available]))
|
||||
# Required by pngvalid:
|
||||
AC_SEARCH_LIBS([ceil],[m])
|
||||
|
||||
# zlib checks and arguments;
|
||||
# package zlib: argument is the name of the library
|
||||
# zlib-header: the name of the header file
|
||||
# zlib-prefix: the prefix for library functions, if any
|
||||
AC_ARG_WITH([zlib],
|
||||
AS_HELP_STRING([[[--with-zlib=<name>]]],
|
||||
[base name of the zlib implementation (e.g. 'z')]),,
|
||||
[with_zlib='z'])
|
||||
|
||||
z_prefix=
|
||||
AC_ARG_WITH([zlib-prefix],
|
||||
AS_HELP_STRING([[[--with-zlib-prefix=<prefix>]]],
|
||||
[prefix for zlib API functions]),
|
||||
[if test "$withval" = "" -o "$withval" = yes; then
|
||||
with_zlib_prefix='z_'
|
||||
AC_DEFINE([PNG_ZLIB_PREFIX],[z_],[Standard zlib prefix])
|
||||
elif test "${withval}" != "no"; then
|
||||
AC_DEFINE_UNQUOTED([PNG_ZLIB_PREFIX],[${withval}],
|
||||
[User defined zlib prefix])
|
||||
else
|
||||
with_zlib_prefix=
|
||||
fi
|
||||
if test "$with_zlib_prefix" != ""; then
|
||||
AC_DEFINE([Z_PREFIX],[1],[Tell zlib.h to prefix function names])
|
||||
z_prefix="#define Z_PREFIX 1"
|
||||
fi])
|
||||
|
||||
AC_ARG_WITH([zlib-header],
|
||||
AS_HELP_STRING([[[--with-zlib-header='<file>' or '"file"']]],
|
||||
[C include argument to locate zlib header file, e.g. <zlib.h>, take
|
||||
care to put single quotes round this on the command line]),
|
||||
[AC_DEFINE_UNQUOTED([PNG_ZLIB_HEADER],[${withval}],[Zlib header file])],
|
||||
with_zlib_header='<zlib.h>')
|
||||
|
||||
# AC_CHECK_LIB isn't quite enough for this because we need the special header
|
||||
# file too.
|
||||
LIBS="-l${with_zlib} $LIBS"
|
||||
AC_MSG_CHECKING(
|
||||
[[Library '${with_zlib}' and #include ${with_zlib_header} for symbol '${with_zlib_prefix}zlibVersion']])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
${z_prefix}
|
||||
#include ${with_zlib_header}
|
||||
]],
|
||||
[[(void)${with_zlib_prefix}zlibVersion();]])],
|
||||
AC_MSG_RESULT([ok]),
|
||||
AC_MSG_FAILURE([not found]))
|
||||
|
||||
AC_MSG_CHECKING([if using Solaris linker])
|
||||
SLD=`$LD --version 2>&1 | grep Solaris`
|
||||
@ -185,7 +308,7 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
if test "$have_ld_version_script" = "yes"; then
|
||||
AC_MSG_CHECKING([for symbol prefix])
|
||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${DFNCPP-${CC-gcc -E}} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
AC_SUBST(SYMBOL_PREFIX)
|
||||
@ -233,24 +356,55 @@ AC_ARG_WITH(libpng-prefix,
|
||||
fi])
|
||||
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
|
||||
# Because GCC by default assembles code with an executable stack, even though it
|
||||
# compiles C code with a non-executable stack, it is necessary to do a fixup
|
||||
# here (this may by GCC specific)
|
||||
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
|
||||
# Control over what links are made for installed files. Versioned files are
|
||||
# always installed, when the following options are turned on corresponding
|
||||
# unversioned links are also created (normally as symbolic links):
|
||||
AC_ARG_ENABLE([unversioned-links],
|
||||
AS_HELP_STRING([[[--enable-unversioned-links]]],
|
||||
[Installed libpng header files are placed in a versioned subdirectory]
|
||||
[and installed libpng library (including DLL) files are versioned.]
|
||||
[If this option is enabled unversioned links will be created pointing to]
|
||||
[the corresponding installed files. If you use libpng.pc or]
|
||||
[libpng-config for all builds you do not need these links, but if you]
|
||||
[compile programs directly they will typically #include <png.h> and]
|
||||
[link with -lpng; in that case you need the links.]
|
||||
[The links can be installed manually using 'make install-header-links']
|
||||
[and 'make install-library-links' and can be removed using the]
|
||||
[corresponding uninstall- targets. If you do enable this option every]
|
||||
[libpng 'make install' will recreate the links to point to the just]
|
||||
[installed version of libpng. The default is to create the links;]
|
||||
[use --disable-unversioned-links to change this]))
|
||||
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
|
||||
[if test "${enableval}" = "yes"; then
|
||||
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations])
|
||||
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers])
|
||||
fi])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
|
||||
# The AM_CONDITIONAL test is written so that the default is enabled;
|
||||
# --disable-unversioned-links must be given to turn the option off.
|
||||
AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
|
||||
|
||||
AC_ARG_ENABLE([unversioned-libpng-pc],
|
||||
AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
|
||||
[Install the configuration file 'libpng.pc' as a link to the versioned]
|
||||
[version. This is done by default - use --disable-unversioned-libpng-pc]
|
||||
[to change this.]))
|
||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
|
||||
[test "$enable_unversioned_libpng_pc" != "no"])
|
||||
|
||||
AC_ARG_ENABLE([unversioned-libpng-config],
|
||||
AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
|
||||
[Install the configuration file 'libpng-config' as a link to the]
|
||||
[versioned version. This is done by default - use]
|
||||
[--disable-unversioned-libpng-config to change this.]))
|
||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||
[test "$enable_unversioned_libpng_config" != "no"])
|
||||
|
||||
# EXTENSIONS
|
||||
# Configure (and all other) support for extensions is included when autoconf is
|
||||
# run by virtue of the existence (or not) of the following file:
|
||||
sinclude([contrib/extensions.ac])
|
||||
AM_CONDITIONAL([LIBPNG_EXTENSIONS],[test -n "$libpng_automake_extensions"])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
# Config files, substituting as above
|
||||
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
||||
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
||||
[chmod +x libpng-config])
|
||||
AC_CONFIG_FILES([Makefile libpng.pc])
|
||||
AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
|
||||
|
||||
AC_OUTPUT
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
This "contrib" directory contains contributions which are not necessarily under
|
||||
the libpng license, although all are open source. They are not part of
|
||||
libpng proper and are not used for building the library.
|
||||
libpng proper and are not used for building the library, although some are used
|
||||
for testing the library via "make check".
|
||||
|
83
contrib/arm-neon/README
Normal file
@ -0,0 +1,83 @@
|
||||
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
|
||||
--------------------------------------------
|
||||
|
||||
Detection of the ability to execute ARM NEON on an ARM processor requires
|
||||
operating system support. (The information is not available in user mode.)
|
||||
|
||||
HOW TO USE THIS
|
||||
---------------
|
||||
|
||||
This directory contains C code fragments that can be included in arm/arm_init.c
|
||||
by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build
|
||||
time. This setting is not recorded in pnglibconf.h and can be changed simply by
|
||||
rebuilding arm/arm_init.o with the required macro definition.
|
||||
|
||||
For any of this code to be used the ARM NEON code must be enabled and run time
|
||||
checks must be supported. I.e.:
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
|
||||
This is done in a 'configure' build by passing configure the argument:
|
||||
|
||||
--enable-arm-neon=check
|
||||
|
||||
Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code
|
||||
is unsupported. That means that it is not even compiled on a regular basis and
|
||||
may be broken in any given minor release.
|
||||
|
||||
FILE FORMAT
|
||||
-----------
|
||||
|
||||
Each file documents its testing status as of the last time it was tested (which
|
||||
may have been a long time ago):
|
||||
|
||||
STATUS: one of:
|
||||
SUPPORTED: This indicates that the file is included in the regularly
|
||||
performed test builds and bugs are fixed when discovered.
|
||||
COMPILED: This indicates that the code did compile at least once. See the
|
||||
more detailed description for the extent to which the result was
|
||||
successful.
|
||||
TESTED: This means the code was fully compiled into the libpng test programs
|
||||
and these were run at least once.
|
||||
|
||||
BUG REPORTS: an email address to which to send reports of problems
|
||||
|
||||
The file is a fragment of C code. It should not define any 'extern' symbols;
|
||||
everything should be static. It must define the function:
|
||||
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
|
||||
That function must return 1 if ARM NEON instructions are supported, 0 if not.
|
||||
It must not execute png_error unless it detects a bug. A png_error will prevent
|
||||
the reading of the PNG and in the future, writing too.
|
||||
|
||||
BUG REPORTS
|
||||
-----------
|
||||
|
||||
If you mail a bug report for any file that is not SUPPORTED there may only be
|
||||
limited response. Consider fixing it and sending a patch to fix the problem -
|
||||
this is more likely to result in action.
|
||||
|
||||
CONTRIBUTIONS
|
||||
-------------
|
||||
|
||||
You may send contributions of new implementations to
|
||||
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
|
||||
possible. Obviously OS dependencies are to be expected. If you submit code you
|
||||
must have the authors permission and it must have a license that is acceptable
|
||||
to the current maintainer; in particular that license must permit modification
|
||||
and redistribution.
|
||||
|
||||
Please try to make the contribution a single file and give the file a clear and
|
||||
unambiguous name that identifies the target OS. If multiple files really are
|
||||
required put them all in a sub-directory.
|
||||
|
||||
You must also be prepared to handle bug reports from users of the code, either
|
||||
by joining the png-mng-implement mailing list or by providing an email for the
|
||||
"BUG REPORTS" entry or both. Please make sure that the header of the file
|
||||
contains the STATUS and BUG REPORTS fields as above.
|
||||
|
||||
Please list the OS requirements as precisely as possible. Ideally you should
|
||||
also list the environment in which the code has been tested and certainly list
|
||||
any environments where you suspect it might not work.
|
39
contrib/arm-neon/android-ndk.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* contrib/arm-neon/android-ndk.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: COMPILED, UNTESTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for the Android NDK, see:
|
||||
*
|
||||
* Documentation:
|
||||
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||
* https://code.google.com/p/android/issues/detail?id=49065
|
||||
*
|
||||
* NOTE: this requires that libpng is built against the Android NDK and linked
|
||||
* with an implementation of the Android ARM 'cpu-features' library. The code
|
||||
* has been compiled only, not linked: no version of the library has been found,
|
||||
* only the header files exist in the NDK.
|
||||
*/
|
||||
#include <cpu-features.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
/* This is a whole lot easier than the linux code, however it is probably
|
||||
* implemented as below, therefore it is better to cache the result (these
|
||||
* function calls may be slow!)
|
||||
*/
|
||||
PNG_UNUSED(png_ptr)
|
||||
return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
|
||||
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
|
||||
}
|
120
contrib/arm-neon/linux-auxv.c
Normal file
@ -0,0 +1,120 @@
|
||||
/* contrib/arm-neon/linux-auxv.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: COMPILED, TESTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for Linux versions which allow access to
|
||||
* /proc/self/auxv. This is probably faster, cleaner and safer than the code to
|
||||
* read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece
|
||||
* of potentially untested code and has more complex dependencies than the code
|
||||
* to read cpuinfo.
|
||||
*
|
||||
* This generic __linux__ implementation requires reading /proc/self/auxv and
|
||||
* looking at each element for one that records NEON capabilities.
|
||||
*/
|
||||
#include <unistd.h> /* for POSIX 1003.1 */
|
||||
#include <errno.h> /* for EINTR */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <elf.h>
|
||||
#include <asm/hwcap.h>
|
||||
|
||||
/* A read call may be interrupted, in which case it returns -1 and sets errno to
|
||||
* EINTR if nothing was done, otherwise (if something was done) a partial read
|
||||
* may result.
|
||||
*/
|
||||
static size_t
|
||||
safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes)
|
||||
{
|
||||
size_t ntotal = 0;
|
||||
char *buffer = png_voidcast(char*, buffer_in);
|
||||
|
||||
while (nbytes > 0)
|
||||
{
|
||||
unsigned int nread;
|
||||
int iread;
|
||||
|
||||
/* Passing nread > INT_MAX to read is implementation defined in POSIX
|
||||
* 1003.1, therefore despite the unsigned argument portable code must
|
||||
* limit the value to INT_MAX!
|
||||
*/
|
||||
if (nbytes > INT_MAX)
|
||||
nread = INT_MAX;
|
||||
|
||||
else
|
||||
nread = (unsigned int)/*SAFE*/nbytes;
|
||||
|
||||
iread = read(fd, buffer, nread);
|
||||
|
||||
if (iread == -1)
|
||||
{
|
||||
/* This is the devil in the details, a read can terminate early with 0
|
||||
* bytes read because of EINTR, yet it still returns -1 otherwise end
|
||||
* of file cannot be distinguished.
|
||||
*/
|
||||
if (errno != EINTR)
|
||||
{
|
||||
png_warning(png_ptr, "/proc read failed");
|
||||
return 0; /* I.e., a permanent failure */
|
||||
}
|
||||
}
|
||||
|
||||
else if (iread < 0)
|
||||
{
|
||||
/* Not a valid 'read' result: */
|
||||
png_warning(png_ptr, "OS /proc read bug");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (iread > 0)
|
||||
{
|
||||
/* Continue reading until a permanent failure, or EOF */
|
||||
buffer += iread;
|
||||
nbytes -= (unsigned int)/*SAFE*/iread;
|
||||
ntotal += (unsigned int)/*SAFE*/iread;
|
||||
}
|
||||
|
||||
else
|
||||
return ntotal;
|
||||
}
|
||||
|
||||
return ntotal; /* nbytes == 0 */
|
||||
}
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
int fd = open("/proc/self/auxv", O_RDONLY);
|
||||
Elf32_auxv_t aux;
|
||||
|
||||
/* Failsafe: failure to open means no NEON */
|
||||
if (fd == -1)
|
||||
{
|
||||
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux)
|
||||
{
|
||||
if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
161
contrib/arm-neon/linux.c
Normal file
@ -0,0 +1,161 @@
|
||||
/* contrib/arm-neon/linux.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: SUPPORTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
/* This is a simple state machine which reads the input byte-by-byte until
|
||||
* it gets a match on the 'neon' feature or reaches the end of the stream.
|
||||
*/
|
||||
static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 };
|
||||
static const char ch_neon[] = { 78, 69, 79, 78 };
|
||||
|
||||
enum
|
||||
{
|
||||
StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine
|
||||
} state;
|
||||
int counter;
|
||||
|
||||
for (state=StartLine, counter=0;;)
|
||||
{
|
||||
int ch = fgetc(f);
|
||||
|
||||
if (ch == EOF)
|
||||
{
|
||||
/* EOF means error or end-of-file, return false; neon at EOF is
|
||||
* assumed to be a mistake.
|
||||
*/
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case StartLine:
|
||||
/* Match spaces at the start of line */
|
||||
if (ch <= 32) /* skip control characters and space */
|
||||
break;
|
||||
|
||||
counter=0;
|
||||
state = Feature;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Feature:
|
||||
/* Match 'FEATURE', ASCII case insensitive. */
|
||||
if ((ch & ~0x20) == ch_feature[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_feature))
|
||||
state = Colon;
|
||||
break;
|
||||
}
|
||||
|
||||
/* did not match 'feature' */
|
||||
state = SkipLine;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipLine:
|
||||
skipLine:
|
||||
/* Skip everything until we see linefeed or carriage return */
|
||||
if (ch != 10 && ch != 13)
|
||||
break;
|
||||
|
||||
state = StartLine;
|
||||
break;
|
||||
|
||||
case Colon:
|
||||
/* Match any number of space or tab followed by ':' */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
if (ch == 58) /* i.e. ':' */
|
||||
{
|
||||
state = StartTag;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Either a bad line format or a 'feature' prefix followed by
|
||||
* other characters.
|
||||
*/
|
||||
state = SkipLine;
|
||||
goto skipLine;
|
||||
|
||||
case StartTag:
|
||||
/* Skip space characters before a tag */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
state = Neon;
|
||||
counter = 0;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Neon:
|
||||
/* Look for 'neon' tag */
|
||||
if ((ch & ~0x20) == ch_neon[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_neon))
|
||||
state = HaveNeon;
|
||||
break;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipTag:
|
||||
/* Skip non-space characters */
|
||||
if (ch == 10 || ch == 13)
|
||||
state = StartLine;
|
||||
|
||||
else if (ch == 32 || ch == 9)
|
||||
state = StartTag;
|
||||
break;
|
||||
|
||||
case HaveNeon:
|
||||
/* Have seen a 'neon' prefix, but there must be a space or new
|
||||
* line character to terminate it.
|
||||
*/
|
||||
if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
|
||||
{
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "png_have_neon: internal error (bug)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
49
contrib/conftest/README
Normal file
@ -0,0 +1,49 @@
|
||||
This directory contains test configuration files, currently always '.dfa' files
|
||||
intended to be used in the build by setting the make macro DFA_XTRA to the name
|
||||
of the file.
|
||||
|
||||
These files are used in release validation of the 'configure' builds of libpng
|
||||
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
|
||||
file.
|
||||
|
||||
The files in this directory may change between minor releases, however
|
||||
contributions describing specific builds of libpng are welcomed. There is no
|
||||
guarantee that libpng will continue to build with such configurations; support
|
||||
for given configurations can be, and has been, dropped between successive minor
|
||||
releases. However if a .dfa file describing a configuration is not in this
|
||||
directory it is very unlikely that it will be tested before a minor release!
|
||||
|
||||
You can use these .dfa files as the basis of new configurations. Files in this
|
||||
directory should not have any use restrictions or restrictive licenses.
|
||||
|
||||
This directory is not included in the .zip and .7z distributions, which do
|
||||
not contain 'configure' scripts.
|
||||
|
||||
DOCUMENTATION
|
||||
=============
|
||||
|
||||
Examples:
|
||||
${srcdir}/pngusr.dfa
|
||||
${srcdir}/contrib/pngminim/*/pngusr.dfa
|
||||
|
||||
Documentation of the options:
|
||||
${srcdir}/scripts/pnglibconf.dfa
|
||||
|
||||
Documentation of the file format:
|
||||
${srcdir}/scripts/options.awk
|
||||
|
||||
FILE NAMING
|
||||
===========
|
||||
|
||||
File names in this directory may NOT contain any of the five characters:
|
||||
|
||||
- , + * ?
|
||||
|
||||
Neither may they contain any space character.
|
||||
|
||||
While other characters may be used it is strongly suggested that file names be
|
||||
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
|
||||
necessary the underscore (_) character. File names should be about 8 characters
|
||||
long (excluding the .dfa extension). Submitted .dfa files should have names
|
||||
between 7 and 16 characters long, shorter names (6 characters or less) are
|
||||
reserved for standard tests.
|
38
contrib/conftest/pngcp.dfa
Normal file
@ -0,0 +1,38 @@
|
||||
# pngcp.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2016
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with support for pngcp. This means just png_read_png,
|
||||
# png_write_png and small number of configuration settings.
|
||||
#
|
||||
everything = off
|
||||
|
||||
# Options to turn on png_read_png and png_write_png:
|
||||
option WRITE_PNG on
|
||||
option READ_PNG on
|
||||
option EASY_ACCESS on
|
||||
option WRITE_16BIT on
|
||||
option SELECT_FILTER on
|
||||
|
||||
# pngcp needs this to preserve unknown chunks, switching all these on means that
|
||||
# pngcp can work without explicit known chunk reading suppport
|
||||
option SAVE_UNKNOWN_CHUNKS on
|
||||
option WRITE_UNKNOWN_CHUNKS on
|
||||
|
||||
# pngcp needs this to handle palette files with invalid indices:
|
||||
option CHECK_FOR_INVALID_INDEX on
|
||||
option GET_PALETTE_MAX on
|
||||
|
||||
# this is used to turn off limits:
|
||||
option USER_LIMITS on
|
||||
option SET_USER_LIMITS on
|
||||
|
||||
# these are are just required for specific customizations
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||
option WRITE_CUSTOMIZE_COMPRESSION on
|
58
contrib/conftest/read.dfa
Normal file
@ -0,0 +1,58 @@
|
||||
# read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with basic read support. This enables the lowest level libpng
|
||||
# read API - the one where the calling code has to use a loop to read each row.
|
||||
# At present this is the API used by most programs.
|
||||
#
|
||||
# Support is enabled only for those chunks and transformations that are
|
||||
# typically required - others can be added easily.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# The sequential read code is enabled here; the progressive code can be used
|
||||
# instead but there is no point enabling both.
|
||||
|
||||
option SEQUENTIAL_READ on
|
||||
|
||||
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
|
||||
# one or the other for both the API and the internal math.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# To read the full set of PNG images correctly interlace, transparency and
|
||||
# 16-bit support is required. The application can implement interlace itself,
|
||||
# but very few do and it's no longer possible to disable it when READ is
|
||||
# enabled.
|
||||
option READ_tRNS on
|
||||
option READ_16BIT on
|
||||
|
||||
# Everything else is application dependent. This file assumes the app handles
|
||||
# all the native PNG bit layouts, so it doesn't need any of layout change
|
||||
# transforms, but needs libpng to perform gamma correction. It doesn't do any
|
||||
# colorspace stuff and ignores the 'significant bit' information.
|
||||
#
|
||||
# If your app always expands the image to a limited set of bit layouts you
|
||||
# probably want to consider using the simplified API instead of the low level
|
||||
# one - see png.h and s_read.dfa.
|
||||
option READ_GAMMA on
|
35
contrib/conftest/s_read.dfa
Normal file
@ -0,0 +1,35 @@
|
||||
# s_read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with simplified read support (only). This builds a minimal
|
||||
# libpng able to read all PNG formats and convert them into a small number of
|
||||
# well understood memory formats.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
33
contrib/conftest/s_write.dfa
Normal file
@ -0,0 +1,33 @@
|
||||
# s_write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with (just) simplified write support
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
36
contrib/conftest/simple.dfa
Normal file
@ -0,0 +1,36 @@
|
||||
# simple.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with just the simplified APIs (read and write).
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
45
contrib/conftest/write.dfa
Normal file
@ -0,0 +1,45 @@
|
||||
# write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with no read support and minimal write support.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# Switch on the write code - this makes a minimalist encoder
|
||||
|
||||
option WRITE on
|
||||
|
||||
# Choose fixed or floating point APIs and arithmetic. The choices are
|
||||
# independent but normally they will match. It is typically better to use the
|
||||
# floating point if you have floating point hardware. If you don't know, or
|
||||
# (perhaps) to make libpng smaller used fixed point throughout.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# Everything else is optional. Unlike the read code in libpng the write code
|
||||
# does not need to deal with arbitrary formats, so only add support for things
|
||||
# you really do write! For example you might only write sRGB images, sometimes
|
||||
# with transparency and never write 16 bit images, so:
|
||||
option WRITE_sRGB on
|
||||
option WRITE_tRNS on
|
||||
#option WRITE_16BIT off (this is the default with 'everything = off')
|
@ -6,9 +6,9 @@
|
||||
* United States.
|
||||
*
|
||||
* Extract any icc profiles found in the given PNG files. This is a simple
|
||||
* example of a program which extracts information from the header of a PNG file
|
||||
* example of a program that extracts information from the header of a PNG file
|
||||
* without processing the image. Notice that some header information may occur
|
||||
* after the image data, textual data and comments are an example; the approach
|
||||
* after the image data. Textual data and comments are an example; the approach
|
||||
* in this file won't work reliably for such data because it only looks for the
|
||||
* information in the section of the file that preceeds the image data.
|
||||
*
|
||||
@ -26,6 +26,10 @@
|
||||
|
||||
#include <png.h>
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
|
||||
defined (PNG_iCCP_SUPPORTED)
|
||||
|
||||
|
||||
static int verbose = 1;
|
||||
static png_byte no_profile[] = "no profile";
|
||||
|
||||
@ -178,3 +182,4 @@ main(int argc, char **argv)
|
||||
/* Exit code is true if any extract succeeds */
|
||||
return extracted == 0;
|
||||
}
|
||||
#endif /* READ && STDIO && iCCP */
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Read a single pixel value from a PNG file.
|
||||
*
|
||||
* This code illustrates basic 'by-row' reading of a PNG file using libpng.
|
||||
* Rows are read until a particular pixel is found, the value of this pixel is
|
||||
* Rows are read until a particular pixel is found; the value of this pixel is
|
||||
* then printed on stdout.
|
||||
*
|
||||
* The code illustrates how to do this on interlaced as well as non-interlaced
|
||||
@ -27,6 +27,8 @@
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||
|
||||
/* Return component 'c' of pixel 'x' from the given row. */
|
||||
static unsigned int
|
||||
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
@ -37,7 +39,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
* bytes wide. Since the row fitted into memory, however, the following must
|
||||
* work:
|
||||
*/
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||
|
||||
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
|
||||
@ -56,7 +58,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
case 8: return row[0];
|
||||
case 16: return (row[0] << 8) + row[1];
|
||||
default:
|
||||
/* This should never happen, it indicates a bug in this program or in
|
||||
/* This should never happen; it indicates a bug in this program or in
|
||||
* libpng itself:
|
||||
*/
|
||||
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
|
||||
@ -85,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
*/
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
{
|
||||
PNG_CONST unsigned int index = component(row, x, 0, bit_depth, 1);
|
||||
PNG_CONST int index = component(row, x, 0, bit_depth, 1);
|
||||
png_colorp palette = NULL;
|
||||
int num_palette = 0;
|
||||
|
||||
@ -132,7 +134,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
return;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid color type");
|
||||
png_error(png_ptr, "pngpixel: invalid color type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,3 +368,4 @@ int main(int argc, const char **argv)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* READ && SEQUENTIAL_READ */
|
||||
|
@ -1,10 +1,12 @@
|
||||
/*- pngtopng
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011, 2017.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Last changed in libpng 1.6.29 [%RDATE%]
|
||||
*
|
||||
* Read a PNG and write it out in a fixed format, using the 'simplified API'
|
||||
* that was introduced in libpng-1.6.0.
|
||||
*
|
||||
@ -20,6 +22,8 @@
|
||||
* ensure the code picks up the local libpng implementation:
|
||||
*/
|
||||
#include "../../png.h"
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
@ -57,26 +61,27 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
||||
image.message);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
||||
image.message);
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
* complete the read because of running out of memory.
|
||||
*/
|
||||
png_image_free(&image);
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
* complete the read because of running out of memory and so libpng
|
||||
* has not got to the point where it can do cleanup.
|
||||
*/
|
||||
png_image_free(&image);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
@ -90,3 +95,4 @@ int main(int argc, const char **argv)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* READ && WRITE */
|
||||
|
648
contrib/examples/simpleover.c
Normal file
@ -0,0 +1,648 @@
|
||||
/*- simpleover
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2015.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Read several PNG files, which should have an alpha channel or transparency
|
||||
* information, and composite them together to produce one or more 16-bit linear
|
||||
* RGBA intermediates. This involves doing the correct 'over' composition to
|
||||
* combine the alpha channels and corresponding data.
|
||||
*
|
||||
* Finally read an output (background) PNG using the 24-bit RGB format (the
|
||||
* PNG will be composited on green (#00ff00) by default if it has an alpha
|
||||
* channel), and apply the intermediate image generated above to specified
|
||||
* locations in the image.
|
||||
*
|
||||
* The command line has the general format:
|
||||
*
|
||||
* simpleover <background.png> [output.png]
|
||||
* {--sprite=width,height,name {[--at=x,y] {sprite.png}}}
|
||||
* {--add=name {x,y}}
|
||||
*
|
||||
* The --sprite and --add options may occur multiple times. They are executed
|
||||
* in order. --add may refer to any sprite already read.
|
||||
*
|
||||
* This code is intended to show how to composite multiple images together
|
||||
* correctly. Apart from the libpng Simplified API the only work done in here
|
||||
* is to combine multiple input PNG images into a single sprite; this involves
|
||||
* a Porter-Duff 'over' operation and the input PNG images may, as a result,
|
||||
* be regarded as being layered one on top of the other with the first (leftmost
|
||||
* on the command line) being at the bottom and the last on the top.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||
* ensure the code picks up the local libpng implementation, so long as this
|
||||
* file is linked against a sufficiently recent libpng (1.6+) it is ok to
|
||||
* change this to <png.h>:
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
|
||||
#define sprite_name_chars 15
|
||||
struct sprite {
|
||||
FILE *file;
|
||||
png_uint_16p buffer;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
char name[sprite_name_chars+1];
|
||||
};
|
||||
|
||||
#if 0 /* div by 65535 test program */
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
double err = 0;
|
||||
unsigned int xerr = 0;
|
||||
unsigned int r = 32769;
|
||||
{
|
||||
unsigned int x = 0;
|
||||
|
||||
do {
|
||||
unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r;
|
||||
double v = x, errtest;
|
||||
|
||||
if (t < x) {
|
||||
fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
v /= 65535;
|
||||
errtest = v;
|
||||
t >>= 16;
|
||||
errtest -= t;
|
||||
|
||||
if (errtest > err) {
|
||||
err = errtest;
|
||||
xerr = x;
|
||||
|
||||
if (errtest >= .5) {
|
||||
fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n",
|
||||
x, v, t, errtest);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} while (++x <= 65535U*65535U);
|
||||
}
|
||||
|
||||
printf("error %f @ %u\n", err, xerr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* div by 65535 test program */
|
||||
|
||||
static void
|
||||
sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
png_imagep image, const png_uint_16 *buffer)
|
||||
{
|
||||
/* This is where the Porter-Duff 'Over' operator is evaluated; change this
|
||||
* code to change the operator (this could be parameterized). Any other
|
||||
* image processing operation could be used here.
|
||||
*/
|
||||
|
||||
|
||||
/* Check for an x or y offset that pushes any part of the image beyond the
|
||||
* right or bottom of the sprite:
|
||||
*/
|
||||
if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) &&
|
||||
(x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width))
|
||||
{
|
||||
unsigned int y = 0;
|
||||
|
||||
if (y_offset < 0)
|
||||
y = -y_offset; /* Skip to first visible row */
|
||||
|
||||
do
|
||||
{
|
||||
unsigned int x = 0;
|
||||
|
||||
if (x_offset < 0)
|
||||
x = -x_offset;
|
||||
|
||||
do
|
||||
{
|
||||
/* In and out are RGBA values, so: */
|
||||
const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4;
|
||||
png_uint_32 in_alpha = in_pixel[3];
|
||||
|
||||
/* This is the optimized Porter-Duff 'Over' operation, when the
|
||||
* input alpha is 0 the output is not changed.
|
||||
*/
|
||||
if (in_alpha > 0)
|
||||
{
|
||||
png_uint_16 *out_pixel = sprite->buffer +
|
||||
((y+y_offset) * sprite->width + (x+x_offset))*4;
|
||||
|
||||
/* This is the weight to apply to the output: */
|
||||
in_alpha = 65535-in_alpha;
|
||||
|
||||
if (in_alpha > 0)
|
||||
{
|
||||
/* The input must be composed onto the output. This means
|
||||
* multiplying the current output pixel value by the inverse
|
||||
* of the input alpha (1-alpha). A division is required but
|
||||
* it is by the constant 65535. Approximate this as:
|
||||
*
|
||||
* (x + (x >> 16) + 32769) >> 16;
|
||||
*
|
||||
* This is exact (and does not overflow) for all values of
|
||||
* x in the range 0..65535*65535. (Note that the calculation
|
||||
* produces the closest integer; the maximum error is <0.5).
|
||||
*/
|
||||
png_uint_32 tmp;
|
||||
|
||||
# define compose(c)\
|
||||
tmp = out_pixel[c] * in_alpha;\
|
||||
tmp = (tmp + (tmp >> 16) + 32769) >> 16;\
|
||||
out_pixel[c] = tmp + in_pixel[c]
|
||||
|
||||
/* The following is very vectorizable... */
|
||||
compose(0);
|
||||
compose(1);
|
||||
compose(2);
|
||||
compose(3);
|
||||
}
|
||||
|
||||
else
|
||||
out_pixel[0] = in_pixel[0],
|
||||
out_pixel[1] = in_pixel[1],
|
||||
out_pixel[2] = in_pixel[2],
|
||||
out_pixel[3] = in_pixel[3];
|
||||
}
|
||||
}
|
||||
while (++x < image->width);
|
||||
}
|
||||
while (++y < image->height);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||
{
|
||||
/* Read the arguments and create this sprite. The sprite buffer has already
|
||||
* been allocated. This reads the input PNGs one by one in linear format,
|
||||
* composes them onto the sprite buffer (the code in the function above)
|
||||
* then saves the result, converting it on the fly to PNG RGBA 8-bit format.
|
||||
*/
|
||||
while (*argc > 0)
|
||||
{
|
||||
char tombstone;
|
||||
int x = 0, y = 0;
|
||||
|
||||
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
|
||||
{
|
||||
/* The only supported option is --at. */
|
||||
if (sscanf((*argv)[0], "--at=%d,%d%c", &x, &y, &tombstone) != 2)
|
||||
break; /* success; caller will parse this option */
|
||||
|
||||
++*argv, --*argc;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* The argument has to be a file name */
|
||||
png_image image;
|
||||
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
image.opaque = NULL;
|
||||
|
||||
if (png_image_begin_read_from_file(&image, (*argv)[0]))
|
||||
{
|
||||
png_uint_16p buffer;
|
||||
|
||||
image.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
|
||||
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/,
|
||||
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||
{
|
||||
/* This is the place where the Porter-Duff 'Over' operator
|
||||
* needs to be done by this code. In fact, any image
|
||||
* processing required can be done here; the data is in
|
||||
* the correct format (linear, 16-bit) and source and
|
||||
* destination are in memory.
|
||||
*/
|
||||
sprite_op(sprite, x, y, &image, buffer);
|
||||
free(buffer);
|
||||
++*argv, --*argc;
|
||||
/* And continue to the next argument */
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
free(buffer);
|
||||
fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0],
|
||||
image.message);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* png_image_free must be called if we abort the Simplified API
|
||||
* read because of a problem detected in this code. If problems
|
||||
* are detected in the Simplified API it cleans up itself.
|
||||
*/
|
||||
png_image_free(&image);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Failed to read the first argument: */
|
||||
fprintf(stderr, "simpleover: %s: %s\n", (*argv)[0], image.message);
|
||||
}
|
||||
|
||||
return 0; /* failure */
|
||||
}
|
||||
}
|
||||
|
||||
/* All the sprite operations have completed successfully. Save the RGBA
|
||||
* buffer as a PNG using the simplified write API.
|
||||
*/
|
||||
sprite->file = tmpfile();
|
||||
|
||||
if (sprite->file != NULL)
|
||||
{
|
||||
png_image save;
|
||||
|
||||
memset(&save, 0, sizeof save);
|
||||
save.version = PNG_IMAGE_VERSION;
|
||||
save.opaque = NULL;
|
||||
save.width = sprite->width;
|
||||
save.height = sprite->height;
|
||||
save.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
|
||||
save.flags = PNG_IMAGE_FLAG_FAST;
|
||||
save.colormap_entries = 0;
|
||||
|
||||
if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/,
|
||||
sprite->buffer, 0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
/* Success; the buffer is no longer needed: */
|
||||
free(sprite->buffer);
|
||||
sprite->buffer = NULL;
|
||||
return 1; /* ok */
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name,
|
||||
save.message);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n",
|
||||
sprite->name, strerror(errno));
|
||||
|
||||
return 0; /* fail */
|
||||
}
|
||||
|
||||
static int
|
||||
add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
int *argc, const char ***argv)
|
||||
{
|
||||
/* Given a --add argument naming this sprite, perform the operations listed
|
||||
* in the following arguments. The arguments are expected to have the form
|
||||
* (x,y), which is just an offset at which to add the sprite to the
|
||||
* output.
|
||||
*/
|
||||
while (*argc > 0)
|
||||
{
|
||||
char tombstone;
|
||||
int x, y;
|
||||
|
||||
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
|
||||
return 1; /* success */
|
||||
|
||||
if (sscanf((*argv)[0], "%d,%d%c", &x, &y, &tombstone) == 2)
|
||||
{
|
||||
/* Now add the new image into the sprite data, but only if it
|
||||
* will fit.
|
||||
*/
|
||||
if (x < 0 || y < 0 ||
|
||||
(unsigned)/*SAFE*/x >= output->width ||
|
||||
(unsigned)/*SAFE*/y >= output->height ||
|
||||
sprite->width > output->width-x ||
|
||||
sprite->height > output->height-y)
|
||||
{
|
||||
fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n",
|
||||
sprite->name, x, y);
|
||||
/* Could just skip this, but for the moment it is an error */
|
||||
return 0; /* error */
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Since we know the sprite fits we can just read it into the
|
||||
* output using the simplified API.
|
||||
*/
|
||||
png_image in;
|
||||
|
||||
in.version = PNG_IMAGE_VERSION;
|
||||
rewind(sprite->file);
|
||||
|
||||
if (png_image_begin_read_from_stdio(&in, sprite->file))
|
||||
{
|
||||
in.format = PNG_FORMAT_RGB; /* force compose */
|
||||
|
||||
if (png_image_finish_read(&in, NULL/*background*/,
|
||||
out_buf + (y*output->width + x)*3/*RGB*/,
|
||||
output->width*3/*row_stride*/,
|
||||
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||
{
|
||||
++*argv, --*argc;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* The read failed: */
|
||||
fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name,
|
||||
in.message);
|
||||
return 0; /* error */
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: --add='%s': invalid position %s\n",
|
||||
sprite->name, (*argv)[0]);
|
||||
return 0; /* error */
|
||||
}
|
||||
}
|
||||
|
||||
return 1; /* ok */
|
||||
}
|
||||
|
||||
static int
|
||||
simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
const char **argv)
|
||||
{
|
||||
int result = 1; /* success */
|
||||
# define csprites 10/*limit*/
|
||||
# define str(a) #a
|
||||
int nsprites = 0;
|
||||
struct sprite sprites[csprites];
|
||||
|
||||
while (argc > 0)
|
||||
{
|
||||
result = 0; /* fail */
|
||||
|
||||
if (strncmp(argv[0], "--sprite=", 9) == 0)
|
||||
{
|
||||
char tombstone;
|
||||
|
||||
if (nsprites < csprites)
|
||||
{
|
||||
int n;
|
||||
|
||||
sprites[nsprites].width = sprites[nsprites].height = 0;
|
||||
sprites[nsprites].name[0] = 0;
|
||||
|
||||
n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
|
||||
&sprites[nsprites].width, &sprites[nsprites].height,
|
||||
sprites[nsprites].name, &tombstone);
|
||||
|
||||
if ((n == 2 || n == 3) &&
|
||||
sprites[nsprites].width > 0 && sprites[nsprites].height > 0)
|
||||
{
|
||||
size_t buf_size, tmp;
|
||||
|
||||
/* Default a name if not given. */
|
||||
if (sprites[nsprites].name[0] == 0)
|
||||
sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1);
|
||||
|
||||
/* Allocate a buffer for the sprite and calculate the buffer
|
||||
* size:
|
||||
*/
|
||||
buf_size = sizeof (png_uint_16 [4]);
|
||||
buf_size *= sprites[nsprites].width;
|
||||
buf_size *= sprites[nsprites].height;
|
||||
|
||||
/* This can overflow a (size_t); check for this: */
|
||||
tmp = buf_size;
|
||||
tmp /= sprites[nsprites].width;
|
||||
tmp /= sprites[nsprites].height;
|
||||
|
||||
if (tmp == sizeof (png_uint_16 [4]))
|
||||
{
|
||||
sprites[nsprites].buffer = malloc(buf_size);
|
||||
/* This buffer must be initialized to transparent: */
|
||||
memset(sprites[nsprites].buffer, 0, buf_size);
|
||||
|
||||
if (sprites[nsprites].buffer != NULL)
|
||||
{
|
||||
sprites[nsprites].file = NULL;
|
||||
++argv, --argc;
|
||||
|
||||
if (create_sprite(sprites+nsprites++, &argc, &argv))
|
||||
{
|
||||
result = 1; /* still ok */
|
||||
continue;
|
||||
}
|
||||
|
||||
break; /* error */
|
||||
}
|
||||
}
|
||||
|
||||
/* Overflow, or OOM */
|
||||
fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n",
|
||||
argv[0], sprites[nsprites].width, sprites[nsprites].height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: %s: too many sprites\n", argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(argv[0], "--add=", 6) == 0)
|
||||
{
|
||||
const char *name = argv[0]+6;
|
||||
int isprite = nsprites;
|
||||
|
||||
++argv, --argc;
|
||||
|
||||
while (--isprite >= 0)
|
||||
{
|
||||
if (strcmp(sprites[isprite].name, name) == 0)
|
||||
{
|
||||
if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv))
|
||||
goto out; /* error in add_sprite */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isprite < 0) /* sprite not found */
|
||||
{
|
||||
fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: %s: unrecognized operation\n", argv[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
result = 1; /* ok */
|
||||
}
|
||||
|
||||
/* Clean up the cache of sprites: */
|
||||
out:
|
||||
while (--nsprites >= 0)
|
||||
{
|
||||
if (sprites[nsprites].buffer != NULL)
|
||||
free(sprites[nsprites].buffer);
|
||||
|
||||
if (sprites[nsprites].file != NULL)
|
||||
(void)fclose(sprites[nsprites].file);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
int result = 1; /* default to fail */
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
int argi = 2;
|
||||
const char *output = NULL;
|
||||
png_image image;
|
||||
|
||||
if (argc > 2 && argv[2][0] != '-'/*an operation*/)
|
||||
{
|
||||
output = argv[2];
|
||||
argi = 3;
|
||||
}
|
||||
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
image.opaque = NULL;
|
||||
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
image.format = PNG_FORMAT_RGB; /* 24-bit RGB */
|
||||
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
png_color background = {0, 0xff, 0}; /* fully saturated green */
|
||||
|
||||
if (png_image_finish_read(&image, &background, buffer,
|
||||
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||
{
|
||||
/* At this point png_image_finish_read has cleaned up the
|
||||
* allocated data in png_image, and only the buffer needs to be
|
||||
* freed.
|
||||
*
|
||||
* Perform the remaining operations:
|
||||
*/
|
||||
if (simpleover_process(&image, buffer, argc-argi, argv+argi))
|
||||
{
|
||||
/* Write the output: */
|
||||
if ((output != NULL &&
|
||||
png_image_write_to_file(&image, output,
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/)) ||
|
||||
(output == NULL &&
|
||||
png_image_write_to_stdio(&image, stdout,
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/)))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: write %s: %s\n",
|
||||
output == NULL ? "stdout" : output, image.message);
|
||||
}
|
||||
|
||||
/* else simpleover_process writes an error message */
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: read %s: %s\n", argv[1],
|
||||
image.message);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
* complete the read because of running out of memory.
|
||||
*/
|
||||
png_image_free(&image);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Failed to read the first argument: */
|
||||
fprintf(stderr, "simpleover: %s: %s\n", argv[1], image.message);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Usage message */
|
||||
fprintf(stderr,
|
||||
"simpleover: usage: simpleover background.png [output.png]\n"
|
||||
" Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n"
|
||||
" or, if not given, stdout. 'background.png' will be composited\n"
|
||||
" on fully saturated green.\n"
|
||||
"\n"
|
||||
" Optionally, before output, process additional PNG files:\n"
|
||||
"\n"
|
||||
" --sprite=width,height,name {[--at=x,y] {sprite.png}}\n"
|
||||
" Produce a transparent sprite of size (width,height) and with\n"
|
||||
" name 'name'.\n"
|
||||
" For each sprite.png composite it using a Porter-Duff 'Over'\n"
|
||||
" operation at offset (x,y) in the sprite (defaulting to (0,0)).\n"
|
||||
" Input PNGs will be truncated to the area of the sprite.\n"
|
||||
"\n"
|
||||
" --add='name' {x,y}\n"
|
||||
" Optionally, before output, composite a sprite, 'name', which\n"
|
||||
" must have been previously produced using --sprite, at each\n"
|
||||
" offset (x,y) in the output image. Each sprite must fit\n"
|
||||
" completely within the output image.\n"
|
||||
"\n"
|
||||
" PNG files are processed in the order they occur on the command\n"
|
||||
" line and thus the first PNG processed appears as the bottommost\n"
|
||||
" in the output image.\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED_READ */
|
16
contrib/extensions.ac
Normal file
@ -0,0 +1,16 @@
|
||||
# CONTRIBUTED EXTENSIONS
|
||||
#
|
||||
# The following extensions are part of a standard libpng distribution. They are
|
||||
# not supported parts of libpng and they are not necessarily released under the
|
||||
# same license as libpng. Please consult the relevant directory for copyright
|
||||
# and support information before uncommenting any of the lines below.
|
||||
#
|
||||
# After you change this file you MUST re-run "autoreconf" to regenerate the
|
||||
# configure script, otherwise the change may have no effect.
|
||||
#
|
||||
# Include the ARM NEON extension:
|
||||
#sinclude([contrib/neon/neon.ac])
|
||||
#
|
||||
# If any of the extensions require automake support (this is likely) automake
|
||||
# must include the file contrib/extensions.am
|
||||
#libpng_automake_extensions="yes"
|
7
contrib/extensions.am
Normal file
@ -0,0 +1,7 @@
|
||||
# CONTRIBUTED EXTENSIONS
|
||||
#
|
||||
# Please read the file "contrib/extensions.ac" before making changes to this
|
||||
# file.
|
||||
#
|
||||
# Include the ARM NEON extension:
|
||||
#include %reldir%/neon/neon.am
|
@ -47,7 +47,8 @@ CC = gcc
|
||||
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
||||
LD = $(CC)
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
|
||||
CPPFLAGS = $(INCS)
|
||||
CFLAGS = -O -Wall $(MINGW_CCFLAGS)
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS = $(MINGW_LDFLAGS)
|
||||
@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
%.pic$(O): %.c
|
||||
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGINC = -I/usr/local/include/libpng16
|
||||
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
|
||||
PNGINC = -I/usr/local/include/libpng17
|
||||
PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
@ -53,7 +53,8 @@ CC = cc
|
||||
LD = cc
|
||||
RM = rm -f
|
||||
# ABI must be the same as that used to build libpng.
|
||||
ABI=
|
||||
ABI =
|
||||
CPPFLAGS =
|
||||
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
||||
LDFLAGS = $(ABI)
|
||||
O = .o
|
||||
@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
@ -26,14 +26,14 @@
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
#PNGDIR = /usr/local/lib
|
||||
#PNGINC = -I/usr/local/include/libpng16
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
|
||||
#PNGINC = -I/usr/local/include/libpng17
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
|
||||
# or:
|
||||
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
||||
#PNGDIR = ../libpng
|
||||
PNGINC = -I$(PNGDIR)
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
|
||||
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
||||
|
||||
ZDIR = /usr/local/lib
|
||||
@ -64,7 +64,8 @@ WLIBSs = $(PNGLIBs) $(ZLIBs)
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP
|
||||
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
||||
CFLAGS = -O -Wall
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS =
|
||||
@ -92,7 +93,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB)
|
||||
CC = cl
|
||||
LD = link
|
||||
RM = del
|
||||
CFLAGS = -nologo -O -W3 $(INCS) $(cvars)
|
||||
CPPFLAGS = $(INCS)
|
||||
CFLAGS = -nologo -O -W3 $(cvars)
|
||||
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
|
||||
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
||||
O = .obj
|
||||
@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
|
||||
13-15 of the book for detailed discussion of the three programs.
|
||||
|
||||
Greg Roelofs
|
||||
http://pobox.com/~newt/greg_contact.html
|
||||
https://pobox.com/~newt/greg_contact.html
|
||||
16 March 2008
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
|
||||
|
||||
- Prerequisites (in order of compilation):
|
||||
|
||||
- zlib http://zlib.net/
|
||||
- zlib https://zlib.net/
|
||||
- libpng http://www.libpng.org/pub/png/libpng.html
|
||||
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
||||
|
||||
|
@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
free(image_data);
|
||||
image_data = NULL;
|
||||
free(row_pointers);
|
||||
row_pointers = NULL;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@ -51,6 +51,11 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Changelog:
|
||||
%RDATE% - Check return value of png_get_bKGD() (Glenn R-P)
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -69,6 +74,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
png_uint_32 row_num, int pass);
|
||||
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
|
||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
|
||||
|
||||
|
||||
|
||||
@ -103,8 +109,8 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
|
||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
||||
readpng2_error_handler, NULL);
|
||||
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||
readpng2_error_handler, readpng2_warning_handler);
|
||||
if (!png_ptr)
|
||||
return 4; /* out of memory */
|
||||
|
||||
@ -260,36 +266,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
/* since we know we've read all of the PNG file's "header" (i.e., up
|
||||
* to IDAT), we can check for a background color here */
|
||||
|
||||
if (mainprog_ptr->need_bgcolor &&
|
||||
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
|
||||
if (mainprog_ptr->need_bgcolor)
|
||||
{
|
||||
png_color_16p pBackground;
|
||||
|
||||
/* it is not obvious from the libpng documentation, but this function
|
||||
* takes a pointer to a pointer, and it always returns valid red,
|
||||
* green and blue values, regardless of color_type: */
|
||||
png_get_bKGD(png_ptr, info_ptr, &pBackground);
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
|
||||
{
|
||||
|
||||
/* however, it always returns the raw bKGD data, regardless of any
|
||||
* bit-depth transformations, so check depth and adjust if necessary */
|
||||
if (bit_depth == 16) {
|
||||
mainprog_ptr->bg_red = pBackground->red >> 8;
|
||||
mainprog_ptr->bg_green = pBackground->green >> 8;
|
||||
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
||||
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
||||
if (bit_depth == 1)
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
||||
else if (bit_depth == 2)
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
||||
else /* bit_depth == 4 */
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
||||
} else {
|
||||
mainprog_ptr->bg_red = (uch)pBackground->red;
|
||||
mainprog_ptr->bg_green = (uch)pBackground->green;
|
||||
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
||||
/* however, it always returns the raw bKGD data, regardless of any
|
||||
* bit-depth transformations, so check depth and adjust if necessary
|
||||
*/
|
||||
if (bit_depth == 16) {
|
||||
mainprog_ptr->bg_red = pBackground->red >> 8;
|
||||
mainprog_ptr->bg_green = pBackground->green >> 8;
|
||||
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
||||
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
||||
if (bit_depth == 1)
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
||||
else if (bit_depth == 2)
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
||||
else /* bit_depth == 4 */
|
||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
||||
} else {
|
||||
mainprog_ptr->bg_red = (uch)pBackground->red;
|
||||
mainprog_ptr->bg_green = (uch)pBackground->green;
|
||||
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,6 +455,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
/* all done */
|
||||
|
||||
(void)info_ptr; /* Unused */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -467,7 +477,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
|
||||
fflush(stderr);
|
||||
(void)png_ptr; /* Unused */
|
||||
}
|
||||
|
||||
|
||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||
|
@ -163,8 +163,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
|
||||
/* now we can go ahead and just read the whole image */
|
||||
|
||||
fread(image_data, 1L, rowbytes*height, saved_infile);
|
||||
|
||||
if (fread(image_data, 1L, rowbytes*height, saved_infile) <
|
||||
rowbytes*height) {
|
||||
free (image_data);
|
||||
image_data = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image_data;
|
||||
}
|
||||
|
@ -41,10 +41,12 @@
|
||||
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
|
||||
paste bugs
|
||||
- 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options
|
||||
|
||||
- 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings
|
||||
about unused variables (GR-P)
|
||||
- 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P).
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2010, 2014-2015 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@ -95,7 +97,7 @@
|
||||
|
||||
#define PROGNAME "rpng2-x"
|
||||
#define LONGNAME "Progressive PNG Viewer for X"
|
||||
#define VERSION "2.03 of 25 February 2010"
|
||||
#define VERSION "2.04 of 15 June 2014"
|
||||
#define RESNAME "rpng2" /* our X resource application name */
|
||||
#define RESCLASS "Rpng" /* our X resource class name */
|
||||
|
||||
@ -111,6 +113,19 @@
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/keysym.h> /* defines XK_* macros */
|
||||
|
||||
#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */
|
||||
# undef usleep
|
||||
# define usleep(usec) { \
|
||||
struct timespec ts; \
|
||||
ts.tv_sec = 0; \
|
||||
ts.tv_nsec = (usec) * 1000; \
|
||||
nanosleep(&ts, NULL); }
|
||||
# endif
|
||||
|
||||
#ifndef usleep /* have neither nanosleep() nor usleep() */
|
||||
# define usleep(x) sleep(((x)+499999)/1000000)
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@ -456,40 +471,47 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||
readpng2_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
||||
"Usage: ");
|
||||
fprintf(stderr,
|
||||
"%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
||||
" %*s [-usleep dur | -timing] [-pause]\n",
|
||||
PROGNAME, (int)strlen(PROGNAME), " ");
|
||||
fprintf(stderr,
|
||||
#ifdef FEATURE_LOOP
|
||||
" %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n"
|
||||
#else
|
||||
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
|
||||
" [-loop [sec]]"
|
||||
#endif
|
||||
" file.png\n\n");
|
||||
fprintf(stderr,
|
||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n",
|
||||
default_display_exponent);
|
||||
fprintf(stderr,
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images; overrides -bgpat\n"
|
||||
" pat \tdesired background pattern number (0-%d); used with\n"
|
||||
"\t\t transparent images; overrides -bgcolor\n"
|
||||
"\t\t transparent images; overrides -bgcolor\n",
|
||||
num_bgpat-1);
|
||||
#ifdef FEATURE_LOOP
|
||||
fprintf(stderr,
|
||||
" -loop\tloops through background images after initial display\n"
|
||||
"\t\t is complete (depends on -bgpat)\n"
|
||||
" sec \tseconds to display each background image (default = 2)\n"
|
||||
" sec \tseconds to display each background image (default = 2)\n");
|
||||
#endif
|
||||
fprintf(stderr,
|
||||
" dur \tduration in microseconds to wait after displaying each\n"
|
||||
"\t\t row (for demo purposes)\n"
|
||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||
"\t\t download of image (~36 Kbps)\n"
|
||||
" -pause\tpauses after displaying each pass until mouse clicked\n"
|
||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||
"is displayed) to quit.\n"
|
||||
"\n", PROGNAME,
|
||||
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1);
|
||||
"is displayed) to quit.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (!(infile = fopen(filename, "rb"))) {
|
||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||
++error;
|
||||
@ -735,6 +757,8 @@ int main(int argc, char **argv)
|
||||
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
|
||||
rpng2_x_cleanup();
|
||||
|
||||
(void)argc; /* Unused */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1826,6 +1850,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow,
|
||||
XFlush(display);
|
||||
}
|
||||
|
||||
(void)startcol;
|
||||
(void)width;
|
||||
|
||||
} /* end function rpng2_x_redisplay_image() */
|
||||
|
||||
|
||||
|
65
contrib/libtests/fakepng.c
Normal file
@ -0,0 +1,65 @@
|
||||
/* Fake a PNG - just write it out directly.
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2014.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h> /* for crc32 */
|
||||
|
||||
void
|
||||
put_uLong(uLong val)
|
||||
{
|
||||
putchar(val >> 24);
|
||||
putchar(val >> 16);
|
||||
putchar(val >> 8);
|
||||
putchar(val >> 0);
|
||||
}
|
||||
|
||||
void
|
||||
put_chunk(const unsigned char *chunk, uInt length)
|
||||
{
|
||||
uLong crc;
|
||||
|
||||
put_uLong(length-4); /* Exclude the tag */
|
||||
|
||||
fwrite(chunk, length, 1, stdout);
|
||||
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
put_uLong(crc32(crc, chunk, length));
|
||||
}
|
||||
|
||||
const unsigned char signature[] =
|
||||
{
|
||||
137, 80, 78, 71, 13, 10, 26, 10
|
||||
};
|
||||
|
||||
const unsigned char IHDR[] =
|
||||
{
|
||||
73, 72, 68, 82, /* IHDR */
|
||||
0, 0, 0, 1, /* width */
|
||||
0, 0, 0, 1, /* height */
|
||||
1, /* bit depth */
|
||||
0, /* color type: greyscale */
|
||||
0, /* compression method */
|
||||
0, /* filter method */
|
||||
0 /* interlace method: none */
|
||||
};
|
||||
|
||||
const unsigned char unknown[] =
|
||||
{
|
||||
'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
|
||||
};
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fwrite(signature, sizeof signature, 1, stdout);
|
||||
put_chunk(IHDR, sizeof IHDR);
|
||||
|
||||
for (;;)
|
||||
put_chunk(unknown, sizeof unknown);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2012 John Cunningham Bowler
|
||||
# Copyright (c) 2013 John Cunningham Bowler
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,8 +1,9 @@
|
||||
/* makepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
/* makepng.c */
|
||||
#define _ISOC99_SOURCE
|
||||
/* Copyright: */
|
||||
#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler"
|
||||
/*
|
||||
* Last changed in libpng 1.6.20 [November 24, 2015]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -10,8 +11,8 @@
|
||||
*
|
||||
* Make a test PNG image. The arguments are as follows:
|
||||
*
|
||||
* makepng [--sRGB|--linear|--1.8] [--color=<color>] color-type bit-depth \
|
||||
* [file-name]
|
||||
* makepng [--sRGB|--linear|--1.8] [--tRNS] [--nofilters] \
|
||||
* color-type bit-depth [file-name]
|
||||
*
|
||||
* The color-type may be numeric (and must match the numbers used by the PNG
|
||||
* specification) or one of the format names listed below. The bit-depth is the
|
||||
@ -39,8 +40,8 @@
|
||||
* 4 channels: linear combinations of, from the top-left corner clockwise,
|
||||
* transparent, red, green, blue.
|
||||
*
|
||||
* For color-mapped images a four channel color-map is used and the PNG file has
|
||||
* a tRNS chunk, as follows:
|
||||
* For color-mapped images a four channel color-map is used and if --tRNS is
|
||||
* given the PNG file has a tRNS chunk, as follows:
|
||||
*
|
||||
* 1-bit: entry 0 is transparent-red, entry 1 is opaque-white
|
||||
* 2-bit: entry 0: transparent-green
|
||||
@ -53,6 +54,9 @@
|
||||
* The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The
|
||||
* image is the 1-channel diamond, but using palette index, not luminosity.
|
||||
*
|
||||
* For formats other than color-mapped ones if --tRNS is specified a tRNS chunk
|
||||
* is generated with all channels equal to the low bits of 0x0101.
|
||||
*
|
||||
* Image size is determined by the final pixel depth in bits, i.e. channels x
|
||||
* bit-depth, as follows:
|
||||
*
|
||||
@ -60,20 +64,64 @@
|
||||
* 16 bits: 256x256
|
||||
* More than 16 bits: 1024x1024
|
||||
*
|
||||
* Row filtering is turned off (the 'none' filter is used on every row) and the
|
||||
* images are not interlaced.
|
||||
* Row filtering is the libpng default but may be turned off (the 'none' filter
|
||||
* is used on every row) with the --nofilters option.
|
||||
*
|
||||
* The images are not interlaced.
|
||||
*
|
||||
* If file-name is given then the PNG is written to that file, else it is
|
||||
* written to stdout. Notice that stdout is not supported on systems where, by
|
||||
* default, it assumes text output; this program makes no attempt to change the
|
||||
* text mode of stdout!
|
||||
*
|
||||
* makepng --color=<color> ...
|
||||
*
|
||||
* If --color is given then the whole image has that color, color-mapped images
|
||||
* will have exactly one palette entry and all image files with be 16x16 in
|
||||
* size. The color value is 1 to 4 decimal numbers as appropriate for the color
|
||||
* type.
|
||||
*
|
||||
* If file-name is given then the PNG is written to that file, else it is
|
||||
* written to stdout. Notice that stdout is not supported on systems where, by
|
||||
* default, it assumes text output; this program makes no attempt to change the
|
||||
* text mode of stdout!
|
||||
* makepng --small ...
|
||||
*
|
||||
* If --small is given the images are no larger than required to include every
|
||||
* possible pixel value for the format.
|
||||
*
|
||||
* For formats with pixels 8 bits or fewer in size the images consist of a
|
||||
* single row with 2^pixel-depth pixels, one of every possible value.
|
||||
*
|
||||
* For formats with 16-bit pixels a 256x256 image is generated containing every
|
||||
* possible pixel value.
|
||||
*
|
||||
* For larger pixel sizes a 256x256 image is generated where the first row
|
||||
* consists of each pixel that has identical byte values throughout the pixel
|
||||
* followed by rows where the byte values differ within the pixel.
|
||||
*
|
||||
* In all cases the pixel values are arranged in such a way that the SUB and UP
|
||||
* filters give byte sequences for maximal zlib compression. By default (if
|
||||
* --nofilters is not given) the SUB filter is used on the first row and the UP
|
||||
* filter on all following rows.
|
||||
*
|
||||
* The --small option is meant to provide good test-case coverage, however the
|
||||
* images are not easy to examine visually. Without the --small option the
|
||||
* images contain identical color values; the pixel values are adjusted
|
||||
* according to the gamma encoding with no gamma encoding being interpreted as
|
||||
* sRGB.
|
||||
*
|
||||
* LICENSING
|
||||
* =========
|
||||
*
|
||||
* This code is copyright of the authors, see the COPYRIGHT define above. The
|
||||
* code is licensed as above, using the libpng license. The code generates
|
||||
* images which are solely the product of the code; the options choose which of
|
||||
* the many possibilities to generate. The images that result (but not the code
|
||||
* which generates them) are licensed as defined here:
|
||||
*
|
||||
* IMPORTANT: the COPYRIGHT #define must contain ISO-Latin-1 characters, the
|
||||
* IMAGE_LICENSING #define must contain UTF-8 characters. The 'copyright'
|
||||
* symbol 0xA9U (\251) in ISO-Latin-1 encoding and 0xC20xA9 (\302\251) in UTF-8.
|
||||
*/
|
||||
#define _ISOC99_SOURCE /* for strtoull */
|
||||
#define IMAGE_LICENSING "Dedicated to the public domain per Creative Commons "\
|
||||
"license \"CC0 1.0\"; https://creativecommons.org/publicdomain/zero/1.0/"
|
||||
|
||||
#include <stddef.h> /* for offsetof */
|
||||
#include <stdlib.h>
|
||||
@ -82,8 +130,10 @@
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@ -96,6 +146,25 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
/* Work round for GCC complaints about casting a (double) function result to
|
||||
* an unsigned:
|
||||
*/
|
||||
static unsigned int
|
||||
flooru(double d)
|
||||
{
|
||||
d = floor(d);
|
||||
return (unsigned int)d;
|
||||
}
|
||||
|
||||
static png_byte
|
||||
floorb(double d)
|
||||
{
|
||||
d = floor(d);
|
||||
return (png_byte)d;
|
||||
}
|
||||
|
||||
/* This structure is used for inserting extra chunks (the --insert argument, not
|
||||
* documented above.)
|
||||
*/
|
||||
@ -107,7 +176,7 @@ typedef struct chunk_insert
|
||||
png_charp parameters[1];
|
||||
} chunk_insert;
|
||||
|
||||
static int
|
||||
static unsigned int
|
||||
channels_of_type(int color_type)
|
||||
{
|
||||
if (color_type & PNG_COLOR_MASK_PALETTE)
|
||||
@ -128,14 +197,15 @@ channels_of_type(int color_type)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static unsigned int
|
||||
pixel_depth_of_type(int color_type, int bit_depth)
|
||||
{
|
||||
return channels_of_type(color_type) * bit_depth;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
|
||||
image_size_of_type(int color_type, int bit_depth, unsigned int *colors,
|
||||
int small)
|
||||
{
|
||||
if (*colors)
|
||||
return 16;
|
||||
@ -144,7 +214,16 @@ image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
|
||||
{
|
||||
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth < 8)
|
||||
if (small)
|
||||
{
|
||||
if (pixel_depth <= 8) /* there will be one row */
|
||||
return 1 << pixel_depth;
|
||||
|
||||
else
|
||||
return 256;
|
||||
}
|
||||
|
||||
else if (pixel_depth < 8)
|
||||
return 64;
|
||||
|
||||
else if (pixel_depth > 16)
|
||||
@ -217,7 +296,8 @@ generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
|
||||
else
|
||||
{
|
||||
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
|
||||
unsigned int x, y, ip;
|
||||
unsigned int x, y;
|
||||
volatile unsigned int ip = 0;
|
||||
|
||||
for (x=0; x<size; ++x) for (y=0; y<size; ++y)
|
||||
{
|
||||
@ -281,7 +361,7 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
||||
exit(1);
|
||||
|
||||
case 16:
|
||||
value = (unsigned int)floor(65535*pow(value/65535.,conv)+.5);
|
||||
value = flooru(65535*pow(value/65535.,conv)+.5);
|
||||
*row++ = (png_byte)(value >> 8);
|
||||
*row = (png_byte)value;
|
||||
return;
|
||||
@ -306,15 +386,148 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static int /* filter mask for row */
|
||||
generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
int bit_depth, png_const_bytep gamma_table, double conv,
|
||||
unsigned int *colors)
|
||||
unsigned int *colors, int small)
|
||||
{
|
||||
png_uint_32 size_max = image_size_of_type(color_type, bit_depth, colors)-1;
|
||||
int filters = 0; /* file *MASK*, 0 means the default, not NONE */
|
||||
png_uint_32 size_max =
|
||||
image_size_of_type(color_type, bit_depth, colors, small)-1;
|
||||
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
|
||||
|
||||
if (colors[0] == 0) switch (channels_of_type(color_type))
|
||||
if (colors[0] == 0) if (small)
|
||||
{
|
||||
unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
/* For pixel depths less than 16 generate a single row containing all the
|
||||
* possible pixel values. For 16 generate all 65536 byte pair
|
||||
* combinations in a 256x256 pixel array.
|
||||
*/
|
||||
switch (pixel_depth)
|
||||
{
|
||||
case 1:
|
||||
assert(y == 0 && rowbytes == 1 && size_max == 1);
|
||||
row[0] = 0x6CU; /* binary: 01101100, only top 2 bits used */
|
||||
filters = PNG_FILTER_NONE;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
assert(y == 0 && rowbytes == 1 && size_max == 3);
|
||||
row[0] = 0x1BU; /* binary 00011011, all bits used */
|
||||
filters = PNG_FILTER_NONE;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
assert(y == 0 && rowbytes == 8 && size_max == 15);
|
||||
row[0] = 0x01U;
|
||||
row[1] = 0x23U; /* SUB gives 0x22U for all following bytes */
|
||||
row[2] = 0x45U;
|
||||
row[3] = 0x67U;
|
||||
row[4] = 0x89U;
|
||||
row[5] = 0xABU;
|
||||
row[6] = 0xCDU;
|
||||
row[7] = 0xEFU;
|
||||
filters = PNG_FILTER_SUB;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
/* The row will have all the pixel values in order starting with
|
||||
* '1', the SUB filter will change every byte into '1' (including
|
||||
* the last, which generates pixel value '0'). Since the SUB filter
|
||||
* has value 1 this should result in maximum compression.
|
||||
*/
|
||||
assert(y == 0 && rowbytes == 256 && size_max == 255);
|
||||
for (;;)
|
||||
{
|
||||
row[size_max] = 0xFFU & (size_max+1);
|
||||
if (size_max == 0)
|
||||
break;
|
||||
--size_max;
|
||||
}
|
||||
filters = PNG_FILTER_SUB;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
/* Rows are generated such that each row has a constant difference
|
||||
* between the first and second byte of each pixel and so that the
|
||||
* difference increases by 1 at each row. The rows start with the
|
||||
* first byte value of 0 and the value increases to 255 across the
|
||||
* row.
|
||||
*
|
||||
* The difference starts at 1, so the first row is:
|
||||
*
|
||||
* 0 1 1 2 2 3 3 4 ... 254 255 255 0
|
||||
*
|
||||
* This means that running the SUB filter on the first row produces:
|
||||
*
|
||||
* [SUB==1] 0 1 0 1 0 1...
|
||||
*
|
||||
* Then the difference is 2 on the next row, giving:
|
||||
*
|
||||
* 0 2 1 3 2 4 3 5 ... 254 0 255 1
|
||||
*
|
||||
* When the UP filter is run on this libpng produces:
|
||||
*
|
||||
* [UP ==2] 0 1 0 1 0 1...
|
||||
*
|
||||
* And so on for all the remain rows to the final two * rows:
|
||||
*
|
||||
* row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254
|
||||
* row 255: 0 0 1 1 2 2 3 3 4 4 ... 254 254 255 255
|
||||
*/
|
||||
assert(rowbytes == 512 && size_max == 255);
|
||||
for (;;)
|
||||
{
|
||||
row[2*size_max ] = 0xFFU & size_max;
|
||||
row[2*size_max+1] = 0xFFU & (size_max+y+1);
|
||||
if (size_max == 0)
|
||||
break;
|
||||
--size_max;
|
||||
}
|
||||
/* The first row must include PNG_FILTER_UP so that libpng knows we
|
||||
* need to keep it for the following row:
|
||||
*/
|
||||
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
case 32:
|
||||
case 48:
|
||||
case 64:
|
||||
/* The rows are filled by an alogorithm similar to the above, in the
|
||||
* first row pixel bytes are all equal, increasing from 0 by 1 for
|
||||
* each pixel. In the second row the bytes within a pixel are
|
||||
* incremented 1,3,5,7,... from the previous row byte. Using an odd
|
||||
* number ensures all the possible byte values are used.
|
||||
*/
|
||||
assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3));
|
||||
pixel_depth >>= 3; /* now in bytes */
|
||||
while (rowbytes > 0)
|
||||
{
|
||||
const size_t pixel_index = --rowbytes/pixel_depth;
|
||||
|
||||
if (y == 0)
|
||||
row[rowbytes] = 0xFFU & pixel_index;
|
||||
|
||||
else
|
||||
{
|
||||
const size_t byte_offset =
|
||||
rowbytes - pixel_index * pixel_depth;
|
||||
|
||||
row[rowbytes] =
|
||||
0xFFU & (pixel_index + (byte_offset * 2*y) + 1);
|
||||
}
|
||||
}
|
||||
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0/*NOT REACHED*/);
|
||||
}
|
||||
}
|
||||
|
||||
else switch (channels_of_type(color_type))
|
||||
{
|
||||
/* 1 channel: a square image with a diamond, the least luminous colors are on
|
||||
* the edge of the image, the most luminous in the center.
|
||||
@ -440,7 +653,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
/* Palette with fixed color: the image rows are all 0 and the image width
|
||||
* is 16.
|
||||
*/
|
||||
memset(row, rowbytes, 0);
|
||||
memset(row, 0, rowbytes);
|
||||
}
|
||||
|
||||
else if (colors[0] == channels_of_type(color_type))
|
||||
@ -526,6 +739,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
colors[0], channels_of_type(color_type));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
@ -554,7 +769,7 @@ makepng_error(png_structp png_ptr, png_const_charp message)
|
||||
static int /* 0 on success, else an error code */
|
||||
write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
volatile png_fixed_point gamma, chunk_insert * volatile insert,
|
||||
unsigned int filters, unsigned int *colors)
|
||||
unsigned int filters, unsigned int *colors, int small, int tRNS)
|
||||
{
|
||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
name, makepng_error, makepng_warning);
|
||||
@ -581,6 +796,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
|
||||
/* Allow benign errors so that we can write PNGs with errors */
|
||||
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||
|
||||
/* Max out the text compression level in an attempt to make the license
|
||||
* small. If --small then do the same for the IDAT.
|
||||
*/
|
||||
if (small)
|
||||
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
|
||||
|
||||
png_set_text_compression_level(png_ptr, Z_BEST_COMPRESSION);
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
@ -588,11 +812,37 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
{
|
||||
unsigned int size = image_size_of_type(color_type, bit_depth, colors);
|
||||
const unsigned int size =
|
||||
image_size_of_type(color_type, bit_depth, colors, small);
|
||||
unsigned int ysize;
|
||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||
png_byte gamma_table[256];
|
||||
double conv;
|
||||
|
||||
/* Normally images are square, but with 'small' we want to simply generate
|
||||
* all the pixel values, or all that we reasonably can:
|
||||
*/
|
||||
if (small)
|
||||
{
|
||||
const unsigned int pixel_depth =
|
||||
pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth <= 8U)
|
||||
{
|
||||
assert(size == (1U<<pixel_depth));
|
||||
ysize = 1U;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
assert(size == 256U);
|
||||
ysize = 256U;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
ysize = size;
|
||||
|
||||
/* This function uses the libpng values used on read to carry extra
|
||||
* information about the gamma:
|
||||
*/
|
||||
@ -624,14 +874,14 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
|
||||
gamma_table[0] = 0;
|
||||
|
||||
for (i=0; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
|
||||
for (i=1; i<255; ++i)
|
||||
gamma_table[i] = floorb(pow(i/255.,conv) * 255 + .5);
|
||||
|
||||
gamma_table[255] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, size, size, bit_depth, color_type,
|
||||
png_set_IHDR(png_ptr, info_ptr, size, ysize, bit_depth, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_PALETTE)
|
||||
@ -643,14 +893,26 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
|
||||
colors);
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
|
||||
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
|
||||
NULL/*transparent color*/);
|
||||
|
||||
if (tRNS)
|
||||
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
|
||||
NULL/*transparent color*/);
|
||||
|
||||
/* Reset gamma_table to prevent the image rows being changed */
|
||||
for (npalette=0; npalette<256; ++npalette)
|
||||
gamma_table[npalette] = (png_byte)npalette;
|
||||
}
|
||||
|
||||
else if (tRNS)
|
||||
{
|
||||
png_color_16 col;
|
||||
|
||||
col.red = col.green = col.blue = col.gray =
|
||||
0x0101U & ((1U<<bit_depth)-1U);
|
||||
col.index = 0U;
|
||||
png_set_tRNS(png_ptr, info_ptr, NULL/*trans*/, 1U, &col);
|
||||
}
|
||||
|
||||
if (gamma == PNG_DEFAULT_sRGB)
|
||||
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
|
||||
|
||||
@ -682,7 +944,11 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
|
||||
|
||||
{
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
# else /* !WRITE_INTERLACING */
|
||||
int passes = 1;
|
||||
# endif /* !WRITE_INTERLACING */
|
||||
int pass;
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
@ -695,10 +961,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
{
|
||||
unsigned int y;
|
||||
|
||||
for (y=0; y<size; ++y)
|
||||
for (y=0; y<ysize; ++y)
|
||||
{
|
||||
generate_row(row, rowbytes, y, color_type, bit_depth,
|
||||
gamma_table, conv, colors);
|
||||
unsigned int row_filters =
|
||||
generate_row(row, rowbytes, y, color_type, bit_depth,
|
||||
gamma_table, conv, colors, small);
|
||||
|
||||
if (row_filters != 0 && filters == PNG_ALL_FILTERS)
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, row_filters);
|
||||
|
||||
png_write_row(png_ptr, row);
|
||||
}
|
||||
}
|
||||
@ -827,7 +1098,7 @@ static png_size_t
|
||||
load_fake(png_charp param, png_bytepp profile)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
unsigned long long int size = strtoull(param, &endptr, 0/*base*/);
|
||||
uint64_t size = strtoull(param, &endptr, 0/*base*/);
|
||||
|
||||
/* The 'fake' format is <number>*[string] */
|
||||
if (endptr != NULL && *endptr == '*')
|
||||
@ -1062,7 +1333,8 @@ insert_iTXt(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
}
|
||||
|
||||
static void
|
||||
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
|
||||
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
png_charpp params)
|
||||
{
|
||||
int i;
|
||||
png_uint_16 freq[256];
|
||||
@ -1089,6 +1361,56 @@ insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp par
|
||||
png_set_hIST(png_ptr, info_ptr, freq);
|
||||
}
|
||||
|
||||
static png_byte
|
||||
bval(png_const_structrp png_ptr, png_charp param, unsigned int maxval)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
unsigned long int l = strtoul(param, &endptr, 0/*base*/);
|
||||
|
||||
if (param[0] && *endptr == 0 && l <= maxval)
|
||||
return (png_byte)l;
|
||||
|
||||
else
|
||||
png_error(png_ptr, "sBIT: invalid sBIT value");
|
||||
}
|
||||
|
||||
static void
|
||||
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
png_charpp params)
|
||||
{
|
||||
const int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
(ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
|
||||
const unsigned int maxval =
|
||||
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
|
||||
png_color_8 sBIT;
|
||||
|
||||
if (nparams != c)
|
||||
png_error(png_ptr, "sBIT: incorrect parameter count");
|
||||
|
||||
if (ct & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
sBIT.red = bval(png_ptr, params[0], maxval);
|
||||
sBIT.green = bval(png_ptr, params[1], maxval);
|
||||
sBIT.blue = bval(png_ptr, params[2], maxval);
|
||||
sBIT.gray = 42;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sBIT.red = sBIT.green = sBIT.blue = 42;
|
||||
sBIT.gray = bval(png_ptr, params[0], maxval);
|
||||
}
|
||||
|
||||
if (ct & PNG_COLOR_MASK_ALPHA)
|
||||
sBIT.alpha = bval(png_ptr, params[nparams-1], maxval);
|
||||
|
||||
else
|
||||
sBIT.alpha = 42;
|
||||
|
||||
png_set_sBIT(png_ptr, info_ptr, &sBIT);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
insert_sPLT(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
|
||||
@ -1216,6 +1538,11 @@ find_insert(png_const_charp what, png_charp param)
|
||||
return make_insert(what, insert_hIST, nparams, parameter_list);
|
||||
break;
|
||||
|
||||
case CHUNK(115,66,73,84): /* sBIT */
|
||||
if (nparams <= 4)
|
||||
return make_insert(what, insert_sBIT, nparams, parameter_list);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case CHUNK(115,80,76,84): /* sPLT */
|
||||
return make_insert(what, insert_sPLT, nparams, parameter_list);
|
||||
@ -1231,6 +1558,80 @@ find_insert(png_const_charp what, png_charp param)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is necessary because libpng expects writeable strings for things like
|
||||
* text chunks (maybe this should be fixed...)
|
||||
*/
|
||||
static png_charp
|
||||
strstash(png_const_charp foo)
|
||||
{
|
||||
/* The program indicates a memory allocation error by crashing, this is by
|
||||
* design.
|
||||
*/
|
||||
if (foo != NULL)
|
||||
{
|
||||
png_charp bar = malloc(strlen(foo)+1);
|
||||
return strcpy(bar, foo);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static png_charp
|
||||
strstash_list(const png_const_charp *text)
|
||||
{
|
||||
size_t foo = 0;
|
||||
png_charp result, bar;
|
||||
const png_const_charp *line = text;
|
||||
|
||||
while (*line != NULL)
|
||||
foo += strlen(*line++);
|
||||
|
||||
result = bar = malloc(foo+1);
|
||||
|
||||
line = text;
|
||||
while (*line != NULL)
|
||||
{
|
||||
foo = strlen(*line);
|
||||
memcpy(bar, *line++, foo);
|
||||
bar += foo;
|
||||
}
|
||||
|
||||
*bar = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* These are used to insert Copyright and Licence fields, they allow the text to
|
||||
* have \n unlike the --insert option.
|
||||
*/
|
||||
static chunk_insert *
|
||||
add_tEXt(const char *key, const png_const_charp *text)
|
||||
{
|
||||
static char what[5] = { 116, 69, 88, 116, 0 };
|
||||
png_charp parameter_list[3];
|
||||
|
||||
parameter_list[0] = strstash(key);
|
||||
parameter_list[1] = strstash_list(text);
|
||||
parameter_list[2] = NULL;
|
||||
|
||||
return make_insert(what, insert_tEXt, 2, parameter_list);
|
||||
}
|
||||
|
||||
static chunk_insert *
|
||||
add_iTXt(const char *key, const char *language, const char *language_key,
|
||||
const png_const_charp *text)
|
||||
{
|
||||
static char what[5] = { 105, 84, 88, 116, 0 };
|
||||
png_charp parameter_list[5];
|
||||
|
||||
parameter_list[0] = strstash(key);
|
||||
parameter_list[1] = strstash(language);
|
||||
parameter_list[2] = strstash(language_key);
|
||||
parameter_list[3] = strstash_list(text);
|
||||
parameter_list[4] = NULL;
|
||||
|
||||
return make_insert(what, insert_iTXt, 4, parameter_list);
|
||||
}
|
||||
|
||||
/* This is a not-very-good parser for a sequence of numbers (including 0). It
|
||||
* doesn't accept some apparently valid things, but it accepts all the sensible
|
||||
* combinations.
|
||||
@ -1280,6 +1681,8 @@ main(int argc, char **argv)
|
||||
const char *file_name = NULL;
|
||||
int color_type = 8; /* invalid */
|
||||
int bit_depth = 32; /* invalid */
|
||||
int small = 0; /* make full size images */
|
||||
int tRNS = 0; /* don't output a tRNS chunk */
|
||||
unsigned int colors[5];
|
||||
unsigned int filters = PNG_ALL_FILTERS;
|
||||
png_fixed_point gamma = 0; /* not set */
|
||||
@ -1292,6 +1695,18 @@ main(int argc, char **argv)
|
||||
{
|
||||
char *arg = *++argv;
|
||||
|
||||
if (strcmp(arg, "--small") == 0)
|
||||
{
|
||||
small = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(arg, "--tRNS") == 0)
|
||||
{
|
||||
tRNS = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(arg, "--sRGB") == 0)
|
||||
{
|
||||
gamma = PNG_DEFAULT_sRGB;
|
||||
@ -1432,9 +1847,10 @@ main(int argc, char **argv)
|
||||
|
||||
if (color_type == 8 || bit_depth == 32)
|
||||
{
|
||||
fprintf(stderr, "usage: makepng [--sRGB|--linear|--1.8] "
|
||||
fprintf(stderr, "usage: makepng [--small] [--sRGB|--linear|--1.8] "
|
||||
"[--color=...] color-type bit-depth [file-name]\n"
|
||||
" Make a test PNG file, by default writes to stdout.\n");
|
||||
" Make a test PNG file, by default writes to stdout.\n"
|
||||
" Other options are available, UTSL.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1453,10 +1869,19 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* small and colors are incomparible (will probably crash if both are used at
|
||||
* the same time!)
|
||||
*/
|
||||
if (small && colors[0] != 0)
|
||||
{
|
||||
fprintf(stderr, "makepng: --color --small: only one at a time!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Restrict the filters for more speed to those we know are used for the
|
||||
* generated images.
|
||||
*/
|
||||
if (filters == PNG_ALL_FILTERS)
|
||||
if (filters == PNG_ALL_FILTERS && !small/*small provides defaults*/)
|
||||
{
|
||||
if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8)
|
||||
filters = PNG_FILTER_NONE;
|
||||
@ -1474,9 +1899,39 @@ main(int argc, char **argv)
|
||||
filters &= ~PNG_FILTER_NONE;
|
||||
}
|
||||
|
||||
/* Insert standard copyright and licence text. */
|
||||
{
|
||||
static png_const_charp copyright[] =
|
||||
{
|
||||
COPYRIGHT, /* ISO-Latin-1 */
|
||||
NULL
|
||||
};
|
||||
static png_const_charp licensing[] =
|
||||
{
|
||||
IMAGE_LICENSING, /* UTF-8 */
|
||||
NULL
|
||||
};
|
||||
|
||||
chunk_insert *new_insert;
|
||||
|
||||
new_insert = add_tEXt("Copyright", copyright);
|
||||
if (new_insert != NULL)
|
||||
{
|
||||
*insert_ptr = new_insert;
|
||||
insert_ptr = &new_insert->next;
|
||||
}
|
||||
|
||||
new_insert = add_iTXt("Licensing", "en", NULL, licensing);
|
||||
if (new_insert != NULL)
|
||||
{
|
||||
*insert_ptr = new_insert;
|
||||
insert_ptr = &new_insert->next;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int ret = write_png(&file_name, fp, color_type, bit_depth, gamma,
|
||||
head_insert, filters, colors);
|
||||
head_insert, filters, colors, small, tRNS);
|
||||
|
||||
if (ret != 0 && file_name != NULL)
|
||||
remove(file_name);
|
||||
|
1712
contrib/libtests/pngimage.c
Normal file
165
contrib/libtests/pngstest-errors.h
Normal file
@ -0,0 +1,165 @@
|
||||
/* contrib/libtests/pngstest-errors.h
|
||||
*
|
||||
* BUILT USING: libpng version 1.7.0beta66 - September 18, 2015
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* THIS IS A MACHINE GENERATED FILE: do not edit it directly!
|
||||
* Instead run:
|
||||
*
|
||||
* pngstest --accumulate
|
||||
*
|
||||
* on as many PNG files as possible; at least PNGSuite and
|
||||
* contrib/libtests/testpngs.
|
||||
*/
|
||||
static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =
|
||||
{
|
||||
{ /* input: sRGB-gray */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: sRGB-gray+alpha */
|
||||
{ 0, 19, 1, 0 }, { 0, 0, 0, 0 }, { 0, 20, 1, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: sRGB-rgb */
|
||||
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 893, 0 }, { 0, 0, 893, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: sRGB-rgb+alpha */
|
||||
{ 0, 14, 13, 0 }, { 0, 15, 13, 0 }, { 0, 19, 1, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 832, 764, 0 }, { 0, 832, 764, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: linear-gray */
|
||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: linear-gray+alpha */
|
||||
{ 0, 74, 9, 0 }, { 0, 20, 9, 0 }, { 0, 74, 9, 0 }, { 0, 20, 9, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: linear-rgb */
|
||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||
{ 0, 0, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: linear-rgb+alpha */
|
||||
{ 0, 126, 143, 0 }, { 0, 11, 7, 0 }, { 0, 74, 9, 0 }, { 0, 17, 9, 0 },
|
||||
{ 0, 4, 4, 0 }, { 0, 5, 4, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-sRGB-gray */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-sRGB-rgb */
|
||||
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 8, 0 }, { 0, 0, 8, 0 },
|
||||
{ 0, 0, 673, 0 }, { 0, 0, 673, 0 }, { 0, 0, 674, 0 }, { 0, 0, 674, 0 },
|
||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 460, 0 }, { 0, 0, 460, 0 }, { 0, 0, 263, 0 }, { 0, 0, 263, 0 }
|
||||
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||
{ 0, 6, 8, 0 }, { 0, 7, 8, 0 }, { 0, 75, 8, 0 }, { 0, 9, 8, 0 },
|
||||
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 584, 0 }, { 0, 717, 584, 0 },
|
||||
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 13323, 460, 0 }, { 0, 427, 460, 0 }, { 0, 16480, 263, 0 }, { 0, 243, 263, 0 }
|
||||
}, { /* input: color-mapped-linear-gray */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-gray+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 253, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-rgb */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 265, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 243, 265, 0 }
|
||||
}
|
||||
};
|
||||
static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =
|
||||
{
|
||||
{ /* input: sRGB-gray */
|
||||
{ 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }
|
||||
}, { /* input: sRGB-gray+alpha */
|
||||
{ 0, 15, 15, 0 }, { 0, 186, 15, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||
}, { /* input: sRGB-rgb */
|
||||
{ 0, 0, 20, 0 }, { 0, 0, 20, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
|
||||
}, { /* input: sRGB-rgb+alpha */
|
||||
{ 0, 12, 14, 0 }, { 0, 180, 14, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||
}, { /* input: linear-gray */
|
||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||
}, { /* input: linear-gray+alpha */
|
||||
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||
}, { /* input: linear-rgb */
|
||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||
}, { /* input: linear-rgb+alpha */
|
||||
{ 0, 1, 1, 0 }, { 0, 9, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||
}, { /* input: color-mapped-sRGB-gray */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-sRGB-rgb */
|
||||
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
|
||||
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||
{ 0, 4, 8, 0 }, { 0, 9, 8, 0 }, { 0, 9, 9, 0 }, { 0, 32, 9, 0 }
|
||||
}, { /* input: color-mapped-linear-gray */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-gray+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-rgb */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||
}
|
||||
};
|
||||
static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =
|
||||
{
|
||||
{ /* input: sRGB-gray */
|
||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||
{ 0, 0, 742, 0 }, { 0, 0, 742, 0 }, { 0, 0, 742, 0 }, { 0, 0, 742, 0 }
|
||||
}, { /* input: sRGB-gray+alpha */
|
||||
{ 0, 19, 6, 0 }, { 0, 255, 6, 25 }, { 0, 88, 6, 0 }, { 0, 255, 6, 25 },
|
||||
{ 0, 1012, 911, 0 }, { 0, 16026, 911, 6425 }, { 0, 1012, 911, 0 }, { 0, 16026, 911, 6425 }
|
||||
}, { /* input: sRGB-rgb */
|
||||
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
|
||||
{ 0, 0, 962, 0 }, { 0, 0, 962, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
|
||||
}, { /* input: sRGB-rgb+alpha */
|
||||
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 225, 25, 0 }, { 0, 255, 25, 67 },
|
||||
{ 0, 17534, 18491, 0 }, { 0, 15998, 2824, 6425 }, { 0, 14103, 13677, 0 }, { 0, 50115, 13677, 17219 }
|
||||
}, { /* input: linear-gray */
|
||||
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 },
|
||||
{ 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }
|
||||
}, { /* input: linear-gray+alpha */
|
||||
{ 0, 74, 74, 0 }, { 0, 255, 74, 25 }, { 0, 100, 74, 0 }, { 0, 255, 74, 25 },
|
||||
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }
|
||||
}, { /* input: linear-rgb */
|
||||
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 98, 0 }, { 0, 0, 98, 0 },
|
||||
{ 0, 0, 18664, 0 }, { 0, 0, 18664, 0 }, { 0, 0, 24998, 0 }, { 0, 0, 24998, 0 }
|
||||
}, { /* input: linear-rgb+alpha */
|
||||
{ 0, 181, 196, 0 }, { 0, 255, 61, 25 }, { 206, 192, 98, 0 }, { 0, 255, 98, 67 },
|
||||
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 49172, 24992, 17347 }
|
||||
}
|
||||
};
|
||||
/* END MACHINE GENERATED */
|
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 2015,2016 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@ -30,7 +30,30 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
|
||||
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
|
||||
*/
|
||||
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
|
||||
# define SKIP 77
|
||||
#else
|
||||
# define SKIP 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Since this program tests the ability to change the unknown chunk handling
|
||||
* these must be defined:
|
||||
*/
|
||||
#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||
defined(PNG_STDIO_SUPPORTED) &&\
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
|
||||
/* One of these must be defined to allow us to find out what happened. It is
|
||||
* still useful to set unknown chunk handling without either of these in order
|
||||
* to cause *known* chunks to be discarded. This can be a significant
|
||||
* efficiency gain, but it can't really be tested here.
|
||||
*/
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\
|
||||
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
@ -75,43 +98,74 @@ typedef png_byte *png_const_bytep;
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* Copied from libpng 1.7.0 png.h */
|
||||
#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2))
|
||||
|
||||
/* Copied from pngpriv.h */
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_CHUNK(b1,b2,b3,b4) \
|
||||
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
|
||||
#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2))
|
||||
#define PNG_U32(b1, b2, b3, b4)\
|
||||
(((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4))
|
||||
|
||||
#define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
|
||||
#define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_CHUNK( 73, 69, 78, 68)
|
||||
#define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
|
||||
#define png_gAMA PNG_CHUNK(103, 65, 77, 65)
|
||||
#define png_hIST PNG_CHUNK(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_CHUNK(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_CHUNK(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_CHUNK(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_CHUNK(112, 67, 65, 76)
|
||||
#define png_sCAL PNG_CHUNK(115, 67, 65, 76)
|
||||
#define png_pHYs PNG_CHUNK(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_CHUNK(115, 66, 73, 84)
|
||||
#define png_sPLT PNG_CHUNK(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_CHUNK(115, 82, 71, 66)
|
||||
#define png_sTER PNG_CHUNK(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_CHUNK(116, 69, 88, 116)
|
||||
#define png_tIME PNG_CHUNK(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_CHUNK(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_CHUNK(122, 84, 88, 116)
|
||||
#define png_vpAg PNG_CHUNK('v', 'p', 'A', 'g')
|
||||
/* Constants for known chunk types.
|
||||
*/
|
||||
#define png_IDAT PNG_U32( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
#define png_IHDR PNG_U32( 73, 72, 68, 82)
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||
#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */
|
||||
#define png_gIFx PNG_U32(103, 73, 70, 120)
|
||||
#define png_hIST PNG_U32(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_U32(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_U32(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_U32(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_U32(112, 67, 65, 76)
|
||||
#define png_pHYs PNG_U32(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_U32(115, 66, 73, 84)
|
||||
#define png_sCAL PNG_U32(115, 67, 65, 76)
|
||||
#define png_sPLT PNG_U32(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_U32(115, 82, 71, 66)
|
||||
#define png_sTER PNG_U32(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_U32(116, 69, 88, 116)
|
||||
#define png_tIME PNG_U32(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_U32(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_U32(122, 84, 88, 116)
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLARY(c ) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
#endif /* PNG_LIBPNG_VER < 10700 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define this not_the_cpp_this
|
||||
# define new not_the_cpp_new
|
||||
# define voidcast(type, value) static_cast<type>(value)
|
||||
#else
|
||||
# define voidcast(type, value) (value)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Unused formal parameter errors are removed using the following macro which is
|
||||
* expected to have no bad effects on performance.
|
||||
*/
|
||||
#ifndef UNUSED
|
||||
# if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# define UNUSED(param) (void)param;
|
||||
# else
|
||||
# define UNUSED(param)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Types of chunks not known to libpng */
|
||||
#define png_vpAg PNG_U32(118, 112, 65, 103)
|
||||
|
||||
/* Chunk information */
|
||||
#define PNG_INFO_tEXt 0x10000000U
|
||||
#define PNG_INFO_iTXt 0x20000000U
|
||||
@ -139,23 +193,128 @@ static struct
|
||||
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
|
||||
|
||||
/* Non-critical chunks that libpng handles */
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 },
|
||||
/* This is a mess but it seems to be the only way to do it - there is no way
|
||||
* to check for a definition outside a #if.
|
||||
*/
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
|
||||
# ifdef PNG_READ_bKGD_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM,
|
||||
# ifdef PNG_READ_cHRM_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
|
||||
# ifdef PNG_READ_gAMA_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST,
|
||||
# ifdef PNG_READ_hIST_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP,
|
||||
# ifdef PNG_READ_iCCP_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt,
|
||||
# ifdef PNG_READ_iTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs,
|
||||
# ifdef PNG_READ_oFFs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL,
|
||||
# ifdef PNG_READ_pCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs,
|
||||
# ifdef PNG_READ_pHYs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT,
|
||||
# ifdef PNG_READ_sBIT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL,
|
||||
# ifdef PNG_READ_sCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT,
|
||||
# ifdef PNG_READ_sPLT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB,
|
||||
# ifdef PNG_READ_sRGB_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt,
|
||||
# ifdef PNG_READ_tEXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME,
|
||||
# ifdef PNG_READ_tIME_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS,
|
||||
# ifdef PNG_READ_tRNS_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt,
|
||||
# ifdef PNG_READ_zTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, END, 0 },
|
||||
|
||||
/* No libpng handling */
|
||||
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
|
||||
@ -212,14 +371,16 @@ find_by_flag(png_uint_32 flag)
|
||||
static int
|
||||
ancillary(const char *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static int
|
||||
ancillaryb(const png_byte *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Type of an error_ptr */
|
||||
typedef struct
|
||||
@ -227,8 +388,11 @@ typedef struct
|
||||
jmp_buf error_return;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr, end_ptr;
|
||||
png_uint_32 before_IDAT;
|
||||
png_uint_32 after_IDAT;
|
||||
int error_count;
|
||||
int warning_count;
|
||||
int keep; /* the default value */
|
||||
const char *program;
|
||||
const char *file;
|
||||
const char *test;
|
||||
@ -261,9 +425,6 @@ clean_display(display *d)
|
||||
d->test);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Invalidate the test */
|
||||
d->test = init;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN)
|
||||
@ -289,7 +450,7 @@ display_rc(const display *d, int strict)
|
||||
}
|
||||
|
||||
/* libpng error and warning callbacks */
|
||||
PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
|
||||
PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message),
|
||||
static PNG_NORETURN)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
@ -298,7 +459,7 @@ PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
warning(png_structp png_ptr, const char *message)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
@ -308,7 +469,7 @@ warning(png_structp png_ptr, const char *message)
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_valid(display *d, png_const_infop info_ptr)
|
||||
get_valid(display *d, png_infop info_ptr)
|
||||
{
|
||||
png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0);
|
||||
|
||||
@ -317,7 +478,7 @@ get_valid(display *d, png_const_infop info_ptr)
|
||||
png_textp text;
|
||||
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
|
||||
|
||||
while (ntext-- > 0) switch (text[ntext].compression)
|
||||
while (ntext > 0) switch (text[--ntext].compression)
|
||||
{
|
||||
case -1:
|
||||
flags |= PNG_INFO_tEXt;
|
||||
@ -339,11 +500,88 @@ get_valid(display *d, png_const_infop info_ptr)
|
||||
return flags;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
static int PNGCBAPI
|
||||
read_callback(png_structp pp, png_unknown_chunkp pc)
|
||||
{
|
||||
/* This function mimics the behavior of png_set_keep_unknown_chunks by
|
||||
* returning '0' to keep the chunk and '1' to discard it.
|
||||
*/
|
||||
display *d = voidcast(display*, png_get_user_chunk_ptr(pp));
|
||||
int chunk = findb(pc->name);
|
||||
int keep, discard;
|
||||
|
||||
if (chunk < 0) /* not one in our list, so not a known chunk */
|
||||
keep = d->keep;
|
||||
|
||||
else
|
||||
{
|
||||
keep = chunk_info[chunk].keep;
|
||||
if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
{
|
||||
/* See the comments in png.h - use the default for unknown chunks,
|
||||
* do not keep known chunks.
|
||||
*/
|
||||
if (chunk_info[chunk].unknown)
|
||||
keep = d->keep;
|
||||
|
||||
else
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
}
|
||||
}
|
||||
|
||||
switch (keep)
|
||||
{
|
||||
default:
|
||||
fprintf(stderr, "%s(%s): %d: unrecognized chunk option\n", d->file,
|
||||
d->test, chunk_info[chunk].keep);
|
||||
display_exit(d);
|
||||
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
discard = 1/*handled; discard*/;
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
discard = 0/*not handled; keep*/;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Also store information about this chunk in the display, the relevant flag
|
||||
* is set if the chunk is to be kept ('not handled'.)
|
||||
*/
|
||||
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
|
||||
{
|
||||
png_uint_32 flag = chunk_info[chunk].flag;
|
||||
|
||||
if (pc->location & PNG_AFTER_IDAT)
|
||||
d->after_IDAT |= flag;
|
||||
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
}
|
||||
|
||||
/* However if there is no support to store unknown chunks don't ask libpng to
|
||||
* do it; there will be an png_error.
|
||||
*/
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
return discard;
|
||||
# else
|
||||
return 1; /*handled; discard*/
|
||||
# endif
|
||||
}
|
||||
#endif /* READ_USER_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_uint_32
|
||||
get_unknown(display *d, int def, png_const_infop info_ptr)
|
||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||
{
|
||||
/* Create corresponding 'unknown' flags */
|
||||
png_uint_32 flags = 0;
|
||||
|
||||
UNUSED(after_IDAT)
|
||||
|
||||
{
|
||||
png_unknown_chunkp unknown;
|
||||
int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown);
|
||||
@ -353,16 +591,16 @@ get_unknown(display *d, int def, png_const_infop info_ptr)
|
||||
int chunk = findb(unknown[num_unknown].name);
|
||||
|
||||
/* Chunks not known to pngunknown must be validated here; since they
|
||||
* must also be unknown to libpng the 'def' behavior should have been
|
||||
* used.
|
||||
* must also be unknown to libpng the 'display->keep' behavior should
|
||||
* have been used.
|
||||
*/
|
||||
if (chunk < 0) switch (def)
|
||||
if (chunk < 0) switch (d->keep)
|
||||
{
|
||||
default: /* impossible */
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n",
|
||||
d->file, d->test, def ? "discard" : "default",
|
||||
d->file, d->test, d->keep ? "discard" : "default",
|
||||
unknown[num_unknown].name);
|
||||
++(d->error_count);
|
||||
break;
|
||||
@ -388,14 +626,39 @@ get_unknown(display *d, int def, png_const_infop info_ptr)
|
||||
|
||||
return flags;
|
||||
}
|
||||
#else /* SAVE_UNKNOWN_CHUNKS */
|
||||
static png_uint_32
|
||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||
/* Otherwise this will return the cached values set by any user callback */
|
||||
{
|
||||
UNUSED(info_ptr);
|
||||
|
||||
if (after_IDAT)
|
||||
return d->after_IDAT;
|
||||
|
||||
else
|
||||
return d->before_IDAT;
|
||||
}
|
||||
|
||||
# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* The #defines above should mean this is never reached, it's just here as
|
||||
* a check to ensure the logic is correct.
|
||||
*/
|
||||
# error No store support and no user chunk support, this will not work
|
||||
# endif /* READ_USER_CHUNKS */
|
||||
#endif /* SAVE_UNKNOWN_CHUNKS */
|
||||
|
||||
static int
|
||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
display *d)
|
||||
display *d, int set_callback)
|
||||
{
|
||||
int i, def = PNG_HANDLE_CHUNK_AS_DEFAULT, npasses, ipass;
|
||||
int i, npasses, ipass;
|
||||
png_uint_32 height;
|
||||
|
||||
d->keep = PNG_HANDLE_CHUNK_AS_DEFAULT;
|
||||
d->before_IDAT = 0;
|
||||
d->after_IDAT = 0;
|
||||
|
||||
/* Some of these errors are permanently fatal and cause an exit here, others
|
||||
* are per-test and cause an error return.
|
||||
*/
|
||||
@ -421,6 +684,16 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
|
||||
png_init_io(d->png_ptr, fp);
|
||||
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This is only done if requested by the caller; it interferes with the
|
||||
* standard store/save mechanism.
|
||||
*/
|
||||
if (set_callback)
|
||||
png_set_read_user_chunk_fn(d->png_ptr, d, read_callback);
|
||||
# else
|
||||
UNUSED(set_callback)
|
||||
# endif
|
||||
|
||||
/* Handle each argument in turn; multiple settings are possible for the same
|
||||
* chunk and multiple calls will occur (the last one should override all
|
||||
* preceding ones).
|
||||
@ -460,13 +733,17 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
* in this case, so we just check the arguments! This could
|
||||
* be improved in the future by using the read callback.
|
||||
*/
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||
{
|
||||
png_byte name[5];
|
||||
|
||||
memcpy(name, chunk_info[chunk].name, 5);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -475,10 +752,13 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
case 7: /* default */
|
||||
if (memcmp(argv[i], "default", 7) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||
# endif
|
||||
def = option;
|
||||
|
||||
d->keep = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -487,14 +767,17 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
case 3: /* all */
|
||||
if (memcmp(argv[i], "all", 3) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||
def = option;
|
||||
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
if (chunk_info[chunk].all)
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
d->keep = option;
|
||||
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
if (chunk_info[chunk].all)
|
||||
chunk_info[chunk].keep = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -568,18 +851,18 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
png_read_end(d->png_ptr, d->end_ptr);
|
||||
|
||||
flags[0] = get_valid(d, d->info_ptr);
|
||||
flags[1] = get_unknown(d, def, d->info_ptr);
|
||||
flags[1] = get_unknown(d, d->info_ptr, 0/*before IDAT*/);
|
||||
|
||||
/* Only png_read_png sets PNG_INFO_IDAT! */
|
||||
flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |=
|
||||
PNG_INFO_IDAT;
|
||||
|
||||
flags[2] = get_valid(d, d->end_ptr);
|
||||
flags[3] = get_unknown(d, def, d->end_ptr);
|
||||
flags[3] = get_unknown(d, d->end_ptr, 1/*after IDAT*/);
|
||||
|
||||
clean_display(d);
|
||||
|
||||
return def;
|
||||
return d->keep;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -600,7 +883,7 @@ check_error(display *d, png_uint_32 flags, const char *message)
|
||||
|
||||
static void
|
||||
check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
png_uint_32 unknown, const char *position)
|
||||
png_uint_32 unknown, const char *position, int set_callback)
|
||||
{
|
||||
while (chunks)
|
||||
{
|
||||
@ -707,8 +990,9 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
if (errorx != NULL)
|
||||
{
|
||||
++(d->error_count);
|
||||
fprintf(stderr, "%s(%s): %s %s %s: %s\n",
|
||||
d->file, d->test, type, chunk_info[i].name, position, errorx);
|
||||
fprintf(stderr, "%s(%s%s): %s %s %s: %s\n", d->file, d->test,
|
||||
set_callback ? ",callback" : "",
|
||||
type, chunk_info[i].name, position, errorx);
|
||||
}
|
||||
|
||||
chunks &= ~flag;
|
||||
@ -717,7 +1001,7 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
|
||||
static void
|
||||
perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
png_uint_32 *default_flags, display *d)
|
||||
png_uint_32 *default_flags, display *d, int set_callback)
|
||||
{
|
||||
int def;
|
||||
png_uint_32 flags[2][4];
|
||||
@ -726,7 +1010,21 @@ perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
clear_keep();
|
||||
memcpy(flags[0], default_flags, sizeof flags[0]);
|
||||
|
||||
def = check(fp, argc, argv, flags[1], d);
|
||||
def = check(fp, argc, argv, flags[1], d, set_callback);
|
||||
|
||||
/* If IDAT is being handled as unknown the image read is skipped and all the
|
||||
* IDATs after the first end up in the end info struct, so in this case add
|
||||
* IDAT to the list of unknowns. (Do this after 'check' above sets the
|
||||
* chunk_info 'keep' fields.)
|
||||
*
|
||||
* Note that the flag setting has to be in the 'known' field to avoid
|
||||
* triggering the consistency check below and the flag must only be set if
|
||||
* there are multiple IDATs, so if the check above did find an unknown IDAT
|
||||
* after IDAT.
|
||||
*/
|
||||
if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT &&
|
||||
(flags[1][3] & PNG_INFO_IDAT) != 0)
|
||||
flags[0][2] |= PNG_INFO_IDAT;
|
||||
|
||||
/* Chunks should either be known or unknown, never both and this should apply
|
||||
* whether the chunk is before or after the IDAT (actually, the app can
|
||||
@ -761,9 +1059,9 @@ perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
* it or not.
|
||||
*/
|
||||
check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1],
|
||||
"before IDAT");
|
||||
"before IDAT", set_callback);
|
||||
check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3],
|
||||
"after IDAT");
|
||||
"after IDAT", set_callback);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -773,7 +1071,12 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
||||
if (setjmp(d->error_return) == 0)
|
||||
{
|
||||
d->test = test; /* allow use of d->error_return */
|
||||
perform_one_test(fp, argc, argv, default_flags, d);
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, d, 0);
|
||||
# endif
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, d, 1);
|
||||
# endif
|
||||
d->test = init; /* prevent use of d->error_return */
|
||||
}
|
||||
}
|
||||
@ -797,7 +1100,7 @@ usage(const char *program, const char *reason)
|
||||
fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] "
|
||||
"--default|{(CHNK|default|all)=(default|discard|if-safe|save)} "
|
||||
"testfile.png\n", reason, program);
|
||||
exit(2);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
int
|
||||
@ -845,11 +1148,6 @@ main(int argc, const char **argv)
|
||||
else if (default_tests) if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
|
||||
# ifndef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
fprintf(stderr, "%s: warning: no 'save' support so arguments ignored\n",
|
||||
d.program);
|
||||
# endif
|
||||
|
||||
/* The name of the test file is the last argument; remove it. */
|
||||
d.file = argv[--argc];
|
||||
|
||||
@ -857,24 +1155,40 @@ main(int argc, const char **argv)
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(d.file);
|
||||
exit(2);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* First find all the chunks, known and unknown, in the test file, a failure
|
||||
* here aborts the whole test.
|
||||
*
|
||||
* If 'save' is supported then the normal saving method should happen,
|
||||
* otherwise if 'read' is supported then the read callback will do the
|
||||
* same thing. If both are supported the 'read' callback won't be
|
||||
* instantiated by default. If 'save' is *not* supported then a user
|
||||
* callback is required even though we can call png_get_unknown_chunks.
|
||||
*/
|
||||
if (check(fp, 1, &count_argv, default_flags, &d) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
if (check(fp, 1, &count_argv, default_flags, &d,
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
0
|
||||
# else
|
||||
1
|
||||
# endif
|
||||
) != PNG_HANDLE_CHUNK_ALWAYS)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: internal error\n", d.program, d.file);
|
||||
exit(3);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Now find what the various supplied options cause to change: */
|
||||
if (!default_tests)
|
||||
{
|
||||
d.test = cmd; /* acts as a flag to say exit, do not longjmp */
|
||||
perform_one_test(fp, argc, argv, default_flags, &d);
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, &d, 0);
|
||||
# endif
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, &d, 1);
|
||||
# endif
|
||||
d.test = init;
|
||||
}
|
||||
|
||||
@ -932,14 +1246,14 @@ main(int argc, const char **argv)
|
||||
if (fclose(fsuccess) || err)
|
||||
{
|
||||
fprintf(stderr, "%s: write failed\n", touch_file);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch_file);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,12 +1263,24 @@ main(int argc, const char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
#else /* !(READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS) */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored because libpng was not built with unknown chunk support\n");
|
||||
return 0;
|
||||
" test ignored: no support to find out about unknown chunks\n");
|
||||
/* So the test is skipped: */
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */
|
||||
|
||||
#else /* !(SET_UNKNOWN_CHUNKS && READ) */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored: no support to modify unknown chunk handling\n");
|
||||
/* So the test is skipped: */
|
||||
return SKIP;
|
||||
}
|
||||
#endif /* SET_UNKNOWN_CHUNKS && READ*/
|
||||
|
115
contrib/libtests/readpng.c
Normal file
@ -0,0 +1,115 @@
|
||||
/* readpng.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||
* are no arguments on the command line, from stdin) then run a time test by
|
||||
* reading each file by row. The test does nothing with the read result and
|
||||
* does no transforms. The only output is a time as a floating point number of
|
||||
* seconds with 9 decimal digits.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Define the following to use this test against your installed libpng, rather
|
||||
* than the one being built here:
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
#else
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
static int
|
||||
read_png(FILE *fp)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep row = NULL, display = NULL;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, NULL, 0);
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
/* Failure to initialize these is harmless */
|
||||
row = malloc(rowbytes);
|
||||
display = malloc(rowbytes);
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
|
||||
{
|
||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
# else /* !READ_INTERLACING */
|
||||
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
|
||||
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
|
||||
# endif /* !READ_INTERLACING */
|
||||
int pass;
|
||||
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 y = height;
|
||||
|
||||
# ifndef PNG_READ_INTERLACING_SUPPORTED
|
||||
if (passes == PNG_INTERLACE_ADAM7_PASSES)
|
||||
y = PNG_PASS_ROWS(y, pass);
|
||||
# endif /* READ_INTERLACING */
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure to read to the end of the file: */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
free(row);
|
||||
free(display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* Exit code 0 on success. */
|
||||
return !read_png(stdin);
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2011,2012 John Cunningham Bowler
|
||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -634,7 +634,7 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
{
|
||||
png_fixed_point result;
|
||||
/* NOTE: your mileage may vary, a type is required below that can
|
||||
* hold 64 bits or more, if floating point is used a 64 bit or
|
||||
* hold 64 bits or more, if floating point is used a 64-bit or
|
||||
* better mantissa is required.
|
||||
*/
|
||||
long long int fp, fpround;
|
||||
@ -721,7 +721,7 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
}
|
||||
while (--count > 0);
|
||||
|
||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64 bit "
|
||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64-bit "
|
||||
"errors)\n", tested, overflow, passed, error, error64);
|
||||
return 0;
|
||||
}
|
||||
@ -799,13 +799,13 @@ int validation_gamma(int argc, char **argv)
|
||||
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
||||
i != 0 && png_log8bit(i) != floor(correct+.5))
|
||||
{
|
||||
fprintf(stderr, "8 bit log error: %d: got %u, expected %f\n",
|
||||
fprintf(stderr, "8-bit log error: %d: got %u, expected %f\n",
|
||||
i, png_log8bit(i), correct);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit log error = %f\n", maxerr);
|
||||
printf("maximum 8-bit log error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<65536; ++i)
|
||||
@ -821,14 +821,14 @@ int validation_gamma(int argc, char **argv)
|
||||
{
|
||||
if (error > .68) /* By experiment error is less than .68 */
|
||||
{
|
||||
fprintf(stderr, "16 bit log error: %d: got %u, expected %f"
|
||||
fprintf(stderr, "16-bit log error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_log16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit log error = %f\n", maxerr);
|
||||
printf("maximum 16-bit log error = %f\n", maxerr);
|
||||
|
||||
/* Now exponentiations. */
|
||||
maxerr = 0;
|
||||
@ -841,13 +841,13 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1883) /* By experiment. */
|
||||
{
|
||||
fprintf(stderr, "32 bit exp error: %d: got %u, expected %f"
|
||||
fprintf(stderr, "32-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 32 bit exp error = %f\n", maxerr);
|
||||
printf("maximum 32-bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
@ -859,13 +859,13 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .50002) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "8 bit exp error: %d: got %u, expected %f"
|
||||
fprintf(stderr, "8-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp8bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit exp error = %f\n", maxerr);
|
||||
printf("maximum 8-bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
@ -877,13 +877,13 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .524) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "16 bit exp error: %d: got %u, expected %f"
|
||||
fprintf(stderr, "16-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit exp error = %f\n", maxerr);
|
||||
printf("maximum 16-bit exp error = %f\n", maxerr);
|
||||
} /* !onlygamma */
|
||||
|
||||
/* Test the overall gamma correction. */
|
||||
@ -913,7 +913,7 @@ int validation_gamma(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 8 bit error %f\n", g, maxerr);
|
||||
printf("gamma %f: maximum 8-bit error %f\n", g, maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (j=0; j<65536; ++j)
|
||||
@ -932,7 +932,7 @@ int validation_gamma(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
|
||||
printf("gamma %f: maximum 16-bit error %f\n", g, maxerr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the simplified API tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngstest.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngstest.sh"
|
||||
for image in ${srcdir}/contrib/pngsuite/*.png
|
||||
do
|
||||
for opts in ""
|
||||
do
|
||||
if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngstest $opts $image"
|
||||
else
|
||||
echo " FAIL: pngstest $opts $image"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit $err
|
@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the unknown API tests
|
||||
err=0
|
||||
image="${srcdir}/pngtest.png"
|
||||
#
|
||||
# stream 4 is used for the output of the shell, pngtest-log.txt gets all the
|
||||
# normal program output.
|
||||
exec 4>&1 1>>pngtest-log.txt 2>&1
|
||||
|
||||
echo
|
||||
echo "============ test-pngunknown.sh =============="
|
||||
|
||||
echo "Running test-pngunknown.sh" >&4
|
||||
|
||||
for tests in \
|
||||
"discard default=discard"\
|
||||
"save default=save"\
|
||||
"if-safe default=if-safe"\
|
||||
"vpAg vpAg=if-safe"\
|
||||
"sTER sTER=if-safe"\
|
||||
"IDAT default=discard IDAT=save"\
|
||||
"sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save"
|
||||
do
|
||||
set $tests
|
||||
test="$1"
|
||||
shift
|
||||
|
||||
if ./pngunknown "$@" "$image" 4>&-
|
||||
then
|
||||
echo " PASS: test-pngunknown $test" >&4
|
||||
else
|
||||
echo " FAIL: test-pngunknown $test" >&4
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of gamma tests quietly
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngvalid-full.sh"
|
||||
for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16"
|
||||
do
|
||||
if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" "--gamma-$gamma"
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" "--gamma-$gamma"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of tests quietly, without the slow
|
||||
# gamma tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt
|
||||
echo "Running test-pngvalid-simple.sh"
|
||||
# The options to test are:
|
||||
#
|
||||
# standard tests with and without progressive reading and interlace
|
||||
# size images with and without progressive reading
|
||||
# transform tests (standard, non-interlaced only)
|
||||
#
|
||||
for opts in "--standard" "--standard --progressive-read" \
|
||||
"--standard --interlace" "--standard --progressive-read --interlace" \
|
||||
"--size" "--size --progressive-read" \
|
||||
"--transform"
|
||||
do
|
||||
if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" $opts
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" $opts
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
@ -1,8 +1,8 @@
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013,2016 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -10,19 +10,21 @@
|
||||
*
|
||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||
* are no arguments on the command line, from stdin) then run a time test by
|
||||
* reading each file by row. The test does nothing with the read result and
|
||||
* does no transforms. The only output is a time as a floating point number of
|
||||
* seconds with 9 decimal digits.
|
||||
* reading each file by row or by image (possibly with transforms in the latter
|
||||
* case). The only output is a time as a floating point number of seconds with
|
||||
* 9 decimal digits.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@ -35,36 +37,73 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
static int read_png(FILE *fp)
|
||||
/* The following is to support direct compilation of this file as C++ */
|
||||
#ifdef __cplusplus
|
||||
# define voidcast(type, value) static_cast<type>(value)
|
||||
#else
|
||||
# define voidcast(type, value) (value)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* 'CLOCK_PROCESS_CPUTIME_ID' is one of the clock timers for clock_gettime. It
|
||||
* need not be supported even when clock_gettime is available. It returns the
|
||||
* 'CPU' time the process has consumed. 'CPU' time is assumed to include time
|
||||
* when the CPU is actually blocked by a pending cache fill but not time
|
||||
* waiting for page faults. The attempt is to get a measure of the actual time
|
||||
* the implementation takes to read a PNG ignoring the potentially very large IO
|
||||
* overhead.
|
||||
*/
|
||||
#if defined (CLOCK_PROCESS_CPUTIME_ID) && defined(PNG_STDIO_SUPPORTED) &&\
|
||||
defined(PNG_EASY_ACCESS_SUPPORTED) &&\
|
||||
(PNG_LIBPNG_VER >= 10700 ? defined(PNG_READ_PNG_SUPPORTED) :\
|
||||
defined (PNG_SEQUENTIAL_READ_SUPPORTED) &&\
|
||||
defined(PNG_INFO_IMAGE_SUPPORTED))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep row = NULL, display = NULL;
|
||||
FILE *input;
|
||||
FILE *output;
|
||||
} io_data;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
static PNG_CALLBACK(void, read_and_copy,
|
||||
(png_structp png_ptr, png_bytep buffer, png_size_t cb))
|
||||
{
|
||||
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
if (fread(buffer, cb, 1, io->input) != 1)
|
||||
png_error(png_ptr, strerror(errno));
|
||||
|
||||
if (fwrite(buffer, cb, 1, io->output) != 1)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return 0;
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file PNG write failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
static void read_by_row(png_structp png_ptr, png_infop info_ptr,
|
||||
FILE *write_ptr, FILE *read_ptr)
|
||||
{
|
||||
/* These don't get freed on error, this is fine; the program immediately
|
||||
* exits.
|
||||
*/
|
||||
png_bytep row = NULL, display = NULL;
|
||||
io_data io_copy;
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
if (write_ptr != NULL)
|
||||
{
|
||||
/* Set up for a copy to the temporary file: */
|
||||
io_copy.input = read_ptr;
|
||||
io_copy.output = write_ptr;
|
||||
png_set_read_fn(png_ptr, &io_copy, read_and_copy);
|
||||
}
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = malloc(rowbytes);
|
||||
display = malloc(rowbytes);
|
||||
row = voidcast(png_bytep,malloc(rowbytes));
|
||||
display = voidcast(png_bytep,malloc(rowbytes));
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
@ -81,7 +120,8 @@ static int read_png(FILE *fp)
|
||||
png_uint_32 y = height;
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
* work, but this avoids memory thrashing for speed testing and is
|
||||
* somewhat representative of an application that works row-by-row.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
@ -91,9 +131,51 @@ static int read_png(FILE *fp)
|
||||
|
||||
/* Make sure to read to the end of the file: */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
|
||||
/* Free this up: */
|
||||
free(row);
|
||||
free(display);
|
||||
}
|
||||
|
||||
static PNG_CALLBACK(void, no_warnings, (png_structp png_ptr,
|
||||
png_const_charp warning))
|
||||
{
|
||||
(void)png_ptr;
|
||||
(void)warning;
|
||||
}
|
||||
|
||||
static int read_png(FILE *fp, png_int_32 transforms, FILE *write_file)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,
|
||||
no_warnings);
|
||||
png_infop info_ptr = NULL;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||
# endif
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
if (transforms < 0)
|
||||
read_by_row(png_ptr, info_ptr, write_file, fp);
|
||||
|
||||
else
|
||||
png_read_png(png_ptr, info_ptr, transforms, NULL/*params*/);
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -108,7 +190,7 @@ static int mytime(struct timespec *t)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perform_one_test(FILE *fp, int nfiles)
|
||||
static int perform_one_test(FILE *fp, int nfiles, png_int_32 transforms)
|
||||
{
|
||||
int i;
|
||||
struct timespec before, after;
|
||||
@ -120,7 +202,7 @@ static int perform_one_test(FILE *fp, int nfiles)
|
||||
{
|
||||
for (i=0; i<nfiles; ++i)
|
||||
{
|
||||
if (read_png(fp))
|
||||
if (read_png(fp, transforms, NULL/*write*/))
|
||||
{
|
||||
if (ferror(fp))
|
||||
{
|
||||
@ -184,120 +266,343 @@ static int add_one_file(FILE *fp, char *name)
|
||||
|
||||
if (ip != NULL)
|
||||
{
|
||||
int ch;
|
||||
for (;;)
|
||||
/* Read the file using libpng; this detects errors and also deals with
|
||||
* files which contain data beyond the end of the file.
|
||||
*/
|
||||
int ok = 0;
|
||||
fpos_t pos;
|
||||
|
||||
if (fgetpos(fp, &pos))
|
||||
{
|
||||
ch = getc(ip);
|
||||
if (ch == EOF) break;
|
||||
putc(ch, fp);
|
||||
/* Fatal error reading the start: */
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file fgetpos error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ferror(ip))
|
||||
if (read_png(ip, -1/*by row*/, fp/*output*/))
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: read error\n", name);
|
||||
return 0;
|
||||
if (ferror(ip))
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: read error\n", name);
|
||||
}
|
||||
|
||||
else
|
||||
ok = 1; /* read ok */
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "%s: file not added\n", name);
|
||||
|
||||
(void)fclose(ip);
|
||||
|
||||
/* An error in the output is fatal; exit immediately: */
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file write error\n");
|
||||
return 0;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ok)
|
||||
return 1;
|
||||
|
||||
/* Did not read the file successfully, simply rewind the temporary
|
||||
* file. This must happen after the ferror check above to avoid clearing
|
||||
* the error.
|
||||
*/
|
||||
if (fsetpos(fp, &pos))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file fsetpos error\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* file open error: */
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: open failed\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0; /* file not added */
|
||||
}
|
||||
|
||||
static void
|
||||
usage(FILE *fp)
|
||||
{
|
||||
if (fp != NULL) fclose(fp);
|
||||
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" timepng --assemble <assembly> {files}\n"
|
||||
" Read the files into <assembly>, output the count. Options are ignored.\n"
|
||||
" timepng --dissemble <assembly> <count> [options]\n"
|
||||
" Time <count> files from <assembly>, additional files may not be given.\n"
|
||||
" Otherwise:\n"
|
||||
" Read the files into a temporary file and time the decode\n"
|
||||
"Transforms:\n"
|
||||
" --by-image: read by image with png_read_png\n"
|
||||
" --<transform>: implies by-image, use PNG_TRANSFORM_<transform>\n"
|
||||
" Otherwise: read by row using png_read_row (to a single row buffer)\n"
|
||||
/* ISO C90 string length max 509 */);fprintf(stderr,
|
||||
"{files}:\n"
|
||||
" PNG files to copy into the assembly and time. Invalid files are skipped\n"
|
||||
" with appropriate error messages. If no files are given the list of files\n"
|
||||
" is read from stdin with each file name terminated by a newline\n"
|
||||
"Output:\n"
|
||||
" For --assemble the output is the name of the assembly file followed by the\n"
|
||||
" count of the files it contains; the arguments for --dissemble. Otherwise\n"
|
||||
" the output is the total decode time in seconds.\n");
|
||||
|
||||
exit(99);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ok = 0;
|
||||
FILE *fp = tmpfile();
|
||||
int err = 0;
|
||||
int nfiles = 0;
|
||||
int transforms = -1; /* by row */
|
||||
const char *assembly = NULL;
|
||||
FILE *fp;
|
||||
|
||||
if (fp != NULL)
|
||||
if (argc > 2 && strcmp(argv[1], "--assemble") == 0)
|
||||
{
|
||||
int err = 0;
|
||||
int nfiles = 0;
|
||||
|
||||
if (argc > 1)
|
||||
/* Just build the test file, argv[2] is the file name. */
|
||||
assembly = argv[2];
|
||||
fp = fopen(assembly, "wb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
int i;
|
||||
perror(assembly);
|
||||
fprintf(stderr, "timepng --assemble %s: could not open for write\n",
|
||||
assembly);
|
||||
usage(NULL);
|
||||
}
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
}
|
||||
|
||||
else if (argc > 3 && strcmp(argv[1], "--dissemble") == 0)
|
||||
{
|
||||
fp = fopen(argv[2], "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(argv[2]);
|
||||
fprintf(stderr, "timepng --dissemble %s: could not open for read\n",
|
||||
argv[2]);
|
||||
usage(NULL);
|
||||
}
|
||||
|
||||
nfiles = atoi(argv[3]);
|
||||
if (nfiles <= 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"timepng --dissemble <file> <count>: %s is not a count\n",
|
||||
argv[3]);
|
||||
exit(99);
|
||||
}
|
||||
#ifdef __COVERITY__
|
||||
else
|
||||
{
|
||||
nfiles &= PNG_UINT_31_MAX;
|
||||
}
|
||||
#endif
|
||||
|
||||
argv += 3;
|
||||
argc -= 3;
|
||||
}
|
||||
|
||||
else /* Else use a temporary file */
|
||||
{
|
||||
#ifndef __COVERITY__
|
||||
fp = tmpfile();
|
||||
#else
|
||||
/* Experimental. Coverity says tmpfile() is insecure because it
|
||||
* generates predictable names.
|
||||
*
|
||||
* It is possible to satisfy Coverity by using mkstemp(); however,
|
||||
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
|
||||
* implementation as well, and doesn't need the fix. Note that
|
||||
* the fix won't work on platforms that don't support mkstemp().
|
||||
*
|
||||
* https://www.securecoding.cert.org/confluence/display/c/
|
||||
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
|
||||
* says that most historic implementations of tmpfile() provide
|
||||
* only a limited number of possible temporary file names
|
||||
* (usually 26) before file names are recycled. That article also
|
||||
* provides a secure solution that unfortunately depends upon mkstemp().
|
||||
*/
|
||||
char tmpfile[] = "timepng-XXXXXX";
|
||||
int filedes;
|
||||
umask(0177);
|
||||
filedes = mkstemp(tmpfile);
|
||||
if (filedes < 0)
|
||||
fp = NULL;
|
||||
else
|
||||
{
|
||||
fp = fdopen(filedes,"w+");
|
||||
/* Hide the filename immediately and ensure that the file does
|
||||
* not exist after the program ends
|
||||
*/
|
||||
(void) unlink(tmpfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror("tmpfile");
|
||||
fprintf(stderr, "timepng: could not open the temporary file\n");
|
||||
exit(1); /* not a user error */
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the transforms: */
|
||||
while (argc > 1 && argv[1][0] == '-' && argv[1][1] == '-')
|
||||
{
|
||||
const char *opt = *++argv + 2;
|
||||
|
||||
--argc;
|
||||
|
||||
/* Transforms turn on the by-image processing and maybe set some
|
||||
* transforms:
|
||||
*/
|
||||
if (transforms == -1)
|
||||
transforms = PNG_TRANSFORM_IDENTITY;
|
||||
|
||||
if (strcmp(opt, "by-image") == 0)
|
||||
{
|
||||
/* handled above */
|
||||
}
|
||||
|
||||
# define OPT(name) else if (strcmp(opt, #name) == 0)\
|
||||
transforms |= PNG_TRANSFORM_ ## name
|
||||
|
||||
OPT(STRIP_16);
|
||||
OPT(STRIP_ALPHA);
|
||||
OPT(PACKING);
|
||||
OPT(PACKSWAP);
|
||||
OPT(EXPAND);
|
||||
OPT(INVERT_MONO);
|
||||
OPT(SHIFT);
|
||||
OPT(BGR);
|
||||
OPT(SWAP_ALPHA);
|
||||
OPT(SWAP_ENDIAN);
|
||||
OPT(INVERT_ALPHA);
|
||||
OPT(STRIP_FILLER);
|
||||
OPT(STRIP_FILLER_BEFORE);
|
||||
OPT(STRIP_FILLER_AFTER);
|
||||
OPT(GRAY_TO_RGB);
|
||||
OPT(EXPAND_16);
|
||||
OPT(SCALE_16);
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng %s: unrecognized transform\n", opt);
|
||||
usage(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the files: */
|
||||
if (argc > 1 && nfiles > 0)
|
||||
usage(fp); /* Additional files not valid with --dissemble */
|
||||
|
||||
else if (argc > 1)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
if (nfiles == INT_MAX)
|
||||
{
|
||||
if (add_one_file(fp, argv[i]))
|
||||
fprintf(stderr, "%s: skipped, too many files\n", argv[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (add_one_file(fp, argv[i]))
|
||||
++nfiles;
|
||||
}
|
||||
}
|
||||
|
||||
else if (nfiles == 0) /* Read from stdin withoout --dissemble */
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
size_t len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
filename[len-1] = 0;
|
||||
if (nfiles == INT_MAX)
|
||||
{
|
||||
fprintf(stderr, "%s: skipped, too many files\n", filename);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (add_one_file(fp, filename))
|
||||
++nfiles;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng: file name too long: ...%s\n",
|
||||
filename+len-32);
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stdin))
|
||||
{
|
||||
fprintf(stderr, "timepng: stdin: read error\n");
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform the test, or produce the --assemble output: */
|
||||
if (!err)
|
||||
{
|
||||
if (nfiles > 0)
|
||||
{
|
||||
if (assembly != NULL)
|
||||
{
|
||||
if (fflush(fp) && !ferror(fp) && fclose(fp))
|
||||
{
|
||||
perror(assembly);
|
||||
fprintf(stderr, "%s: close failed\n", assembly);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
printf("%s %d\n", assembly, nfiles);
|
||||
fflush(stdout);
|
||||
ok = !ferror(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ok = perform_one_test(fp, nfiles, transforms);
|
||||
(void)fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
int len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
filename[len-1] = 0;
|
||||
if (add_one_file(fp, filename))
|
||||
++nfiles;
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng: truncated file name ...%s\n",
|
||||
filename+len-32);
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stdin))
|
||||
{
|
||||
fprintf(stderr, "timepng: stdin: read error\n");
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!err)
|
||||
{
|
||||
if (nfiles > 0)
|
||||
ok = perform_one_test(fp, nfiles);
|
||||
|
||||
else
|
||||
fprintf(stderr, "usage: timepng {files} or ls files | timepng\n");
|
||||
}
|
||||
|
||||
(void)fclose(fp);
|
||||
usage(fp);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "timepng: could not open temporary file\n");
|
||||
(void)fclose(fp);
|
||||
|
||||
/* Exit code 0 on success. */
|
||||
return ok == 0;
|
||||
}
|
||||
#else /* !sufficient support */
|
||||
int main(void) { return 77; }
|
||||
#endif /* !sufficient support */
|
||||
|
135
contrib/neon/arm_init.c
Normal file
@ -0,0 +1,135 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "../../pngpriv.h"
|
||||
#define PNG_SRC_FILE PNG_SRC_FILE_arm_arm_init
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
* run-time checks for CPU features if at all possible. In the case of the ARM
|
||||
* NEON instructions there is no processor-specific way of detecting the
|
||||
* presence of the required support, therefore run-time detection is extremely
|
||||
* OS specific.
|
||||
*
|
||||
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_neon function. There
|
||||
* are a number of implementations in contrib/arm-neon, but the only one that
|
||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
#include PNG_ARM_NEON_FILE
|
||||
|
||||
#else /* PNG_ARM_NEON_FILE */
|
||||
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||
#endif /* PNG_ARM_NEON_FILE */
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
#endif
|
||||
|
||||
void
|
||||
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* The switch statement is compiled in for ARM_NEON_API, the call to
|
||||
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
|
||||
* the check is only performed if the API has not set the NEON option on
|
||||
* or off explicitly. In this case the check controls what happens.
|
||||
*
|
||||
* If the CHECK is not compiled in and the option is UNSET the behavior prior
|
||||
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
|
||||
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
|
||||
* as documented in png.h
|
||||
*/
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
||||
{
|
||||
case PNG_OPTION_UNSET:
|
||||
/* Allow the run-time check to execute if it has been enabled -
|
||||
* thus both API and CHECK can be turned on. If it isn't supported
|
||||
* this case will fall through to the 'default' below, which just
|
||||
* returns.
|
||||
*/
|
||||
#endif /* PNG_ARM_NEON_API_SUPPORTED */
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_neon = -1; /* not checked */
|
||||
|
||||
if (no_neon < 0)
|
||||
no_neon = !png_have_neon(pp);
|
||||
|
||||
if (no_neon)
|
||||
return;
|
||||
}
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
*
|
||||
* ./configure --with-libpng-prefix=foobar_
|
||||
*
|
||||
* Verify you have got this right by running the above command, doing a build
|
||||
* and examining pngprefix.h; it must contain a #define for every external
|
||||
* function you add. (Notice that this happens automatically for the
|
||||
* initialization function.)
|
||||
*/
|
||||
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
|
||||
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth3_neon;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth4_neon;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* READ */
|
10
contrib/neon/extensions.ac
Normal file
@ -0,0 +1,10 @@
|
||||
# To just this extension either copy the 'sinclude' line and the setting of
|
||||
# libpng_automake_extensions into contrib/extensions.am or link/copy the whole
|
||||
# file there. Do the same with the associated file extensions.am
|
||||
#
|
||||
# Include the ARM NEON extension:
|
||||
sinclude([contrib/neon/neon.ac])
|
||||
#
|
||||
# If any of the extensions require automake support (this is likely) automake
|
||||
# must include the file contrib/extensions.am
|
||||
libpng_automake_extensions="yes"
|
5
contrib/neon/extensions.am
Normal file
@ -0,0 +1,5 @@
|
||||
# To just this extension either copy the 'include' line into
|
||||
# contrib/extensions.am or link/copy the whole file there. Do the same with the
|
||||
# associated file extensions.ac
|
||||
# Include the ARM NEON extension:
|
||||
include %reldir%/neon/neon.am
|
@ -1,18 +1,36 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and the
|
||||
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../../pngpriv.h"
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
||||
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
|
||||
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||
* for the logic which sets PNG_USE_ARM_NEON_ASM:
|
||||
*/
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
#ifdef __ELF__
|
||||
# define ELF
|
||||
#else
|
||||
@ -29,6 +47,13 @@ ELF .size \name, . - \name
|
||||
.purgem endfunc
|
||||
.endm
|
||||
.text
|
||||
|
||||
/* Explicitly specifying alignment here because some versions of
|
||||
* GAS don't align code correctly. This is harmless in correctly
|
||||
* written versions of GAS.
|
||||
*/
|
||||
.align 2
|
||||
|
||||
.if \export
|
||||
.global \name
|
||||
.endif
|
||||
@ -223,3 +248,6 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||
#endif /* READ */
|
384
contrib/neon/filter_neon_intrinsics.c
Normal file
@ -0,0 +1,384 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../../pngpriv.h"
|
||||
#define PNG_SRC_FILE PNG_SRC_FILE_arm_filter_neon_intrinsics
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||
* checks for this (and will not compile unless it is done). This code uses
|
||||
* variants of png_aligncast to avoid compiler warnings.
|
||||
*/
|
||||
#define png_ptr(type,pointer) png_aligncast(type *,pointer)
|
||||
#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
|
||||
|
||||
/* The following relies on a variable 'temp_pointer' being declared with type
|
||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||
* warning; note that the code is safe because there never is an alias between
|
||||
* the input and output pointers.
|
||||
*/
|
||||
#define png_ldr(type,pointer)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
void
|
||||
png_read_filter_row_up_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint8x16_t qrp, qpp;
|
||||
|
||||
qrp = vld1q_u8(rp);
|
||||
qpp = vld1q_u8(pp);
|
||||
qrp = vaddq_u8(qrp, qpp);
|
||||
vst1q_u8(rp, qrp);
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub3_neon(png_alloc_size_t rowbytes, unsigned int bpp, png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
|
||||
uint8x16_t vtmp = vld1q_u8(rp);
|
||||
uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
uint8x8x2_t vrp = *vrpt;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop;)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
uint8x8x4_t vrp = *vrpt;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg3_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
}
|
||||
|
||||
static uint8x8_t
|
||||
paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
|
||||
{
|
||||
uint8x8_t d, e;
|
||||
uint16x8_t p1, pa, pb, pc;
|
||||
|
||||
p1 = vaddl_u8(a, b); /* a + b */
|
||||
pc = vaddl_u8(c, c); /* c * 2 */
|
||||
pa = vabdl_u8(b, c); /* pa */
|
||||
pb = vabdl_u8(a, c); /* pb */
|
||||
pc = vabdq_u16(p1, pc); /* pc */
|
||||
|
||||
p1 = vcleq_u16(pa, pb); /* pa <= pb */
|
||||
pa = vcleq_u16(pa, pc); /* pa <= pc */
|
||||
pb = vcleq_u16(pb, pc); /* pb <= pc */
|
||||
|
||||
p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
|
||||
|
||||
d = vmovn_u16(pb);
|
||||
e = vmovn_u16(p1);
|
||||
|
||||
d = vbsl_u8(d, b, c);
|
||||
e = vbsl_u8(e, a, d);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth3_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vlast = vtmp2;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vlast = vpp.val[3];
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(bpp)
|
||||
}
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* READ */
|
47
contrib/neon/neon.ac
Normal file
@ -0,0 +1,47 @@
|
||||
# LIBPNG EXTENSION: NEON
|
||||
#
|
||||
# ARM NEON (SIMD) support.
|
||||
#
|
||||
# This file contains configure.ac additions to libpng configure to enable
|
||||
# building of the ARM NEON filter optimizations.
|
||||
#
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]],
|
||||
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
|
||||
[no/off: disable the optimizations; check: use internal checking code]
|
||||
[(deprecated and poorly supported); api: disable by default, enable by]
|
||||
[a call to png_set_option; yes/on: turn on unconditionally.]
|
||||
[If not specified: determined by the compiler.]),
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
# disable the default enabling on __ARM_NEON__ systems:
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||
[Disable ARM Neon optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_arm_neon=no;;
|
||||
check)
|
||||
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||
[Check for ARM Neon support at run-time]);;
|
||||
api)
|
||||
AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
|
||||
[Turn on ARM Neon optimizations at run-time]);;
|
||||
yes|on)
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||
[Enable ARM Neon optimizations])
|
||||
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
|
||||
[you want the optimizations unconditionally pass -mfpu=neon]
|
||||
[to the compiler.]);;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
||||
esac])
|
||||
|
||||
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
|
||||
# where ARM optimizations were explicitly requested (this allows a fallback if a
|
||||
# future host CPU does not match 'arm*')
|
||||
|
||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||
[test "$enable_arm_neon" != 'no' &&
|
||||
case "$host_cpu" in
|
||||
arm*|aarch64*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
esac])
|
27
contrib/neon/neon.am
Normal file
@ -0,0 +1,27 @@
|
||||
# contrib/neon/neon.am
|
||||
#
|
||||
# This is an automake fragment included by the top-level Makefile.am if
|
||||
# contrib/neon/neon.ac is included in configure
|
||||
#
|
||||
# It builds the source files in this directory into ARM hardware support for
|
||||
# libpng.
|
||||
#
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += %D%/arm_init.c\
|
||||
%D%/filter_neon.S %D%/filter_neon_intrinsics.c
|
||||
|
||||
DFA_EXTENSION += ${srcdir}/%D%/neon.dfa
|
||||
|
||||
# This causes pngpriv.h to include the named header. It is VERY important to
|
||||
# understand that this MUST be defined and the header MUST define internal
|
||||
# 'extern' functions with PNG_INTERNAL_FUNCTION. This allows vendors to use
|
||||
# static library builds of libpng without clashing with the installed system
|
||||
# libpng; see the libpng-prefix option in configure.ac The value of this
|
||||
# #define is included in pnglibconf.h
|
||||
#
|
||||
# NOTE: you must include the double quotes in the value and you must therefore
|
||||
# support the whole thing with single quotes. If you need to use <> for a
|
||||
# header be aware that if you miss out the single quotes you will create a
|
||||
# random file.
|
||||
AM_CPPFLAGS += -DPNG_EXTENSION_HEADER='"%D%/neon.h"'
|
||||
endif
|
41
contrib/neon/neon.dfa
Normal file
@ -0,0 +1,41 @@
|
||||
# contrib/arm/neon.dfa
|
||||
#
|
||||
# This is a dfa fragment that is added to DFA_HARDWARE in Makefile.am and
|
||||
# consequently is inserted after scripts/pnglibconf.dfa to define extra,
|
||||
# hardware, options.
|
||||
#
|
||||
# The following are required in any fragment to record the copyright holder of
|
||||
# the *changes* and the appropriate email for bug reports. Note that the
|
||||
# copyright here is just for the specific configuration; additional files may
|
||||
# have additional and/or different copyrights.
|
||||
#
|
||||
# Later settings (e.g. in user.dfa) will override these settings.
|
||||
#
|
||||
setting USER_PRIVATEBUILD default "John Bowler"
|
||||
setting USER_BUG_REPORTS default "jbowler@acm.org"
|
||||
#
|
||||
# These options are specific to the ARM NEON hardware optimizations. At present
|
||||
# these optimizations depend on GCC specific pre-processing of an assembler (.S)
|
||||
# file so they probably won't work with other compilers.
|
||||
#
|
||||
# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by
|
||||
# the compiler, typically as a result of specifying
|
||||
# CC="gcc -mfpu=neon".)
|
||||
# 0: disable (even if the CPU has a NEON FPU.)
|
||||
# 1: check at run time (via ARM_NEON_{API,CHECK})
|
||||
# 2: switch on unconditionally (inadvisable - instead pass
|
||||
# -mfpu=neon to GCC in CC)
|
||||
# When building libpng avoid using any setting other than '0'; '1' is
|
||||
# set automatically when either 'API' or 'CHECK' are configured in,
|
||||
# '2' should not be necessary as -mfpu=neon will achieve the same
|
||||
# effect as well as applying NEON optimizations to the rest of the
|
||||
# libpng code.
|
||||
# NOTE: any setting other than '0' requires ALIGNED_MEMORY
|
||||
# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on
|
||||
# with png_set_option
|
||||
# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon
|
||||
# extensions are supported. This is poorly supported and
|
||||
# deprecated - use the png_set_option API.
|
||||
setting ARM_NEON_OPT
|
||||
option ARM_NEON_API disabled enables SET_OPTION sets ARM_NEON_OPT 1
|
||||
option ARM_NEON_CHECK disabled sets ARM_NEON_OPT 1
|
124
contrib/neon/neon.h
Normal file
@ -0,0 +1,124 @@
|
||||
/* Compile time options.
|
||||
* =====================
|
||||
* In a multi-arch build the compiler may compile the code several times for the
|
||||
* same object module, producing different binaries for different architectures.
|
||||
* When this happens configure-time setting of the target host options cannot be
|
||||
* done. An example is iOS vs Android compilation of ARM NEON support.
|
||||
*
|
||||
* NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
|
||||
* this is not possible with certain compilers (Oracle SUN OS CC), as a result
|
||||
* it is necessary to ensure that all extern functions that *might* be used
|
||||
* regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON
|
||||
* below is one example of this behavior because it is controlled by the
|
||||
* presence or not of -mfpu=neon on the GCC command line, it is possible to do
|
||||
* this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
|
||||
* do this.
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_OPT
|
||||
/* ARM NEON optimizations are being controlled by the compiler settings,
|
||||
* typically the target FPU. If the FPU supports NEON instructions then the
|
||||
* compiler will define __ARM_NEON and we can rely unconditionally on NEON
|
||||
* instructions not crashing, otherwise we must disable use of NEON
|
||||
* instructions.
|
||||
*
|
||||
* NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
|
||||
* can only be turned on automatically if that is supported too. If
|
||||
* PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
|
||||
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
||||
* off.
|
||||
*
|
||||
* Note that older versions of GCC defined __ARM_NEON__; this is no longer
|
||||
* supported. Also 32-bit ARM versions of GCC required the NEON FPU mode to
|
||||
* be turned on explicitly on the command line. If this is not done (on
|
||||
* 32-bit ARM) NEON code will not be included.
|
||||
*
|
||||
* To disable ARM_NEON optimizations entirely, and skip compiling the
|
||||
* associated assembler code, pass --enable-arm-neon=no to configure
|
||||
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
|
||||
*/
|
||||
# if defined(__ARM_NEON) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_ARM_NEON_OPT 2
|
||||
# else
|
||||
# define PNG_ARM_NEON_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
/* NEON optimizations are to be at least considered by libpng, so enable the
|
||||
* callbacks to do this.
|
||||
*/
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
|
||||
|
||||
/* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used
|
||||
* if possible - if __ARM_NEON is set and the compiler version is not known
|
||||
* to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can
|
||||
* be:
|
||||
*
|
||||
* 1 The intrinsics code (the default with __ARM_NEON)
|
||||
* 2 The hand coded assembler (the default without __ARM_NEON)
|
||||
*
|
||||
* It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however
|
||||
* this is *NOT* supported and may cease to work even after a minor revision
|
||||
* to libpng. It *is* valid to do this for testing purposes, e.g. speed
|
||||
* testing or a new compiler, but the results should be communicated to the
|
||||
* libpng implementation list for incorporation in the next minor release.
|
||||
*/
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
# ifdef __ARM_NEON
|
||||
# if defined(__clang__)
|
||||
/* At present it is unknown by the libpng developers which versions
|
||||
* of clang support the intrinsics, however some or perhaps all
|
||||
* versions do not work with the assembler so this may be
|
||||
* irrelevant, so just use the default (do nothing here.)
|
||||
*/
|
||||
# elif defined(__GNUC__)
|
||||
/* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to
|
||||
* work, so if this *is* GCC, or G++, look for a version >4.5
|
||||
*/
|
||||
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* no GNUC support */
|
||||
# endif /* __GNUC__ */
|
||||
# else /* !defined __ARM_NEON */
|
||||
/* The 'intrinsics' code simply won't compile without compiler support
|
||||
* and that support switches on __ARM_NEON, so use the assembler:
|
||||
*/
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __ARM_NEON */
|
||||
# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
|
||||
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
/* Use the intrinsics code by default. */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 1
|
||||
# endif
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
|
||||
#endif
|
||||
#endif /* SET_OPTION */
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,
|
||||
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
|
||||
png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
@ -14,7 +14,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@ -55,7 +56,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngset$(C) pngtrans$(C)
|
||||
|
||||
# Standard headers
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
@ -81,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# note: dependencies do not work on implicit rule lines
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@ -95,16 +96,16 @@ pngm2pnm$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pngm2pnm$(O)
|
||||
$(RM) pngm2pnm$(E)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/decoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -36,5 +36,7 @@ option FLOATING_ARITHMETIC off
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option READ_EXPAND on
|
||||
option READ_IMAGE on
|
||||
option READ_INTERLACING on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option USER_LIMITS on
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||
*
|
||||
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -18,7 +18,7 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_RELEASE_BUILD 1
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINRDPNGCONF_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
|
||||
The makefile builds a minimal write-only decoder with embedded libpng
|
||||
The makefile builds a minimal write-only encoder with embedded libpng
|
||||
and zlib.
|
||||
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
|
@ -14,7 +14,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@ -55,7 +56,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngwtran$(C) pngwutil$(C)
|
||||
|
||||
# Standard headers
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
@ -80,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@ -94,16 +95,16 @@ pnm2pngm$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pnm2pngm$(O)
|
||||
$(RM) pnm2pngm$(E)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/encoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -14,6 +14,10 @@ everything = off
|
||||
|
||||
option WRITE on
|
||||
|
||||
# These 2 options are required if you need to read PBM (P1 or P4) files.
|
||||
option WRITE_INVERT on
|
||||
option WRITE_PACK on
|
||||
|
||||
# You must choose fixed or floating point arithmetic:
|
||||
# option FLOATING_POINT on
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
||||
*
|
||||
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -18,7 +18,7 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_RELEASE_BUILD 1
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINWRPNGCONF_H */
|
||||
|
@ -30,7 +30,8 @@ XLIB = -L/usr/X11R6/lib -lX11
|
||||
#LIBS = $(XLIB)
|
||||
LIBS = $(XLIB) -lm #platforms that need libm
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1
|
||||
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@ -71,7 +72,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngset$(C) pngtrans$(C)
|
||||
|
||||
# Standard headers
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
|
||||
|
||||
# Machine generated headers
|
||||
PNGCONF=pnglibconf.h
|
||||
@ -96,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@ -110,16 +111,16 @@ rpng2-x$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) rpng2-x$(O)
|
||||
$(RM) rpng2-x$(E)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/preader/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -36,5 +36,6 @@ option STDIO on
|
||||
option READ_bKGD on
|
||||
option READ_GAMMA on
|
||||
option READ_EXPAND on
|
||||
option READ_INTERLACING on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option READ_GRAY_TO_RGB on
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||
*
|
||||
* Copyright (c) 2009, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -18,7 +18,7 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_RELEASE_BUILD 1
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINPRDPNGCONF_H */
|
||||
|
@ -8,9 +8,9 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
|
||||
#PNGPATH = /usr/local
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng16
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng16
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng17
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng17
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng17.a
|
||||
PNGINC = -I../..
|
||||
PNGLIB = -L../.. -lpng
|
||||
PNGLIBS = ../../libpng.a
|
||||
|
0
contrib/pngminus/png2pnm.bat
Normal file → Executable file
0
contrib/pngminus/png2pnm.sh
Normal file → Executable file
0
contrib/pngminus/pngminus.bat
Normal file → Executable file
0
contrib/pngminus/pngminus.sh
Normal file → Executable file
0
contrib/pngminus/pnm2png.bat
Normal file → Executable file
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
||||
* copyright (C) 1999,2015 by Willem van Schaik <willem@schaik.com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
@ -50,7 +51,8 @@
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha);
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha);
|
||||
void get_token(FILE *pnm_file, char *token);
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||
@ -176,7 +178,8 @@ void usage()
|
||||
fprintf (stderr, " or: ... | pnm2png [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n");
|
||||
fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr,
|
||||
" -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr, " -h | -? print this help-information\n");
|
||||
}
|
||||
|
||||
@ -184,32 +187,36 @@ void usage()
|
||||
* pnm2png
|
||||
*/
|
||||
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha)
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
png_uint_32 row_bytes;
|
||||
volatile png_uint_32 row_bytes;
|
||||
|
||||
char type_token[16];
|
||||
char width_token[16];
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
int color_type;
|
||||
unsigned long ul_width, ul_alpha_width;
|
||||
unsigned long ul_height, ul_alpha_height;
|
||||
unsigned long ul_maxval;
|
||||
png_uint_32 width, alpha_width;
|
||||
png_uint_32 height, alpha_height;
|
||||
volatile int color_type=1;
|
||||
unsigned long ul_width=0, ul_alpha_width=0;
|
||||
unsigned long ul_height=0, ul_alpha_height=0;
|
||||
unsigned long ul_maxval=0;
|
||||
volatile png_uint_32 width=0, height=0;
|
||||
volatile png_uint_32 alpha_width=0, alpha_height=0;
|
||||
png_uint_32 maxval;
|
||||
int bit_depth = 0;
|
||||
int channels;
|
||||
volatile int bit_depth = 0;
|
||||
int channels=0;
|
||||
int alpha_depth = 0;
|
||||
int alpha_present;
|
||||
int alpha_present=0;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
BOOL packed_bitmap = FALSE;
|
||||
#endif
|
||||
png_uint_32 tmp16;
|
||||
int i;
|
||||
|
||||
@ -222,9 +229,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
}
|
||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
raw = (type_token[1] == '4');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
bit_depth = 1;
|
||||
packed_bitmap = TRUE;
|
||||
#else
|
||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
||||
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
||||
#endif
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
@ -338,76 +357,108 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
channels = 3;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
channels = 4;
|
||||
#if 0
|
||||
else
|
||||
channels = 0; /* should not happen */
|
||||
channels = 0; /* cannot happen */
|
||||
#endif
|
||||
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap)
|
||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||
else
|
||||
#endif
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
if ((png_pixels = (png_byte *)
|
||||
malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* read data from PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
for (row = 0; row < (int) height; row++)
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap) {
|
||||
for (i = 0; i < (int) row_bytes; i++)
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_data (pnm_file, 8);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
for (col = 0; col < (int) width; col++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
} /* if packed_bitmap */
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
|
||||
NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap == TRUE)
|
||||
{
|
||||
png_set_packing (png_ptr);
|
||||
png_set_invert_mono (png_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -425,25 +476,28 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
/* if needed we will allocate memory for an new array of row-pointers */
|
||||
if (row_pointers == (unsigned char**) NULL)
|
||||
{
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
if ((row_pointers = (png_byte **)
|
||||
malloc (height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the individual row_pointers to point at the correct offsets */
|
||||
for (i = 0; i < (height); i++)
|
||||
for (i = 0; i < (int) height; i++)
|
||||
row_pointers[i] = png_pixels + i * row_bytes;
|
||||
|
||||
/* write out the entire image data in one call */
|
||||
png_write_image (png_ptr, row_pointers);
|
||||
|
||||
/* write the additional chuncks to the PNG file (not really needed) */
|
||||
/* write the additional chunks to the PNG file (not really needed) */
|
||||
png_write_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
@ -460,19 +514,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
void get_token(FILE *pnm_file, char *token)
|
||||
{
|
||||
int i = 0;
|
||||
int ret;
|
||||
|
||||
/* remove white-space */
|
||||
/* remove white-space and comment lines */
|
||||
do
|
||||
{
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == '#') {
|
||||
/* the rest of this line is a comment */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
}
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||
}
|
||||
if (ret == EOF) break;
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||
|
||||
/* read string */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == EOF) break;
|
||||
i++;
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||
|
||||
|
0
contrib/pngminus/pnm2png.sh
Normal file → Executable file
BIN
contrib/testpngs/gray-1-1.8-tRNS.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
contrib/testpngs/gray-1-1.8.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
contrib/testpngs/gray-1-linear-tRNS.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
contrib/testpngs/gray-1-linear.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
contrib/testpngs/gray-1-sRGB-tRNS.png
Normal file
After Width: | Height: | Size: 278 B |
BIN
contrib/testpngs/gray-1-sRGB.png
Normal file
After Width: | Height: | Size: 264 B |
BIN
contrib/testpngs/gray-1-tRNS.png
Normal file
After Width: | Height: | Size: 265 B |
BIN
contrib/testpngs/gray-1.png
Normal file
After Width: | Height: | Size: 251 B |
BIN
contrib/testpngs/gray-16-1.8-tRNS.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
contrib/testpngs/gray-16-1.8.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
contrib/testpngs/gray-16-linear-tRNS.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
contrib/testpngs/gray-16-linear.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
contrib/testpngs/gray-16-sRGB-tRNS.png
Normal file
After Width: | Height: | Size: 697 B |
BIN
contrib/testpngs/gray-16-sRGB.png
Normal file
After Width: | Height: | Size: 697 B |
BIN
contrib/testpngs/gray-16-tRNS.png
Normal file
After Width: | Height: | Size: 684 B |
BIN
contrib/testpngs/gray-16.png
Normal file
After Width: | Height: | Size: 684 B |
BIN
contrib/testpngs/gray-2-1.8-tRNS.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
contrib/testpngs/gray-2-1.8.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
contrib/testpngs/gray-2-linear-tRNS.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
contrib/testpngs/gray-2-linear.png
Normal file
After Width: | Height: | Size: 311 B |