Compare commits
1302 Commits
v1.5.0beta
...
v1.7.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
5c2d76fdef | ||
|
|
e4f124e335 | ||
|
|
1f84bd7000 | ||
|
|
b76ab1260d | ||
|
|
026b295698 | ||
|
|
eb8e19baa3 | ||
|
|
661bc6f6b0 | ||
|
|
6dae6d8f3b | ||
|
|
5b9a28f2b8 | ||
|
|
5f4b95e513 | ||
|
|
70850fce0c | ||
|
|
9d1ddbb78f | ||
|
|
f2aacefb3f | ||
|
|
4314d63792 | ||
|
|
7b3eefbcfd | ||
|
|
bb39dc545c | ||
|
|
520803d57e | ||
|
|
7f912dbeb5 | ||
|
|
ab1477d662 | ||
|
|
f0fb1746b0 | ||
|
|
f8dfd123e2 | ||
|
|
e6b710cb3f | ||
|
|
be85fa6027 | ||
|
|
43648b02bc | ||
|
|
75fde9e99a | ||
|
|
9a82547afe | ||
|
|
a9f44be8c2 | ||
|
|
e15b1e8136 | ||
|
|
fa63beaa34 | ||
|
|
c39be26f5a | ||
|
|
6ae34790cc | ||
|
|
8de49d0921 | ||
|
|
48cbba8e8e | ||
|
|
b257147015 | ||
|
|
73f826cb49 | ||
|
|
933bc842ac | ||
|
|
329d033d25 | ||
|
|
9c06d78468 | ||
|
|
b98681b49a | ||
|
|
53f7051b1b | ||
|
|
d099973c4f | ||
|
|
97a77a6f7b | ||
|
|
b2aba47a6d | ||
|
|
ed3ca0e3eb | ||
|
|
fd043e5d0d | ||
|
|
cc02f89eb2 | ||
|
|
14d0ca620e | ||
|
|
8010217201 | ||
|
|
702053d110 | ||
|
|
74a9c07fdd | ||
|
|
d0eef28ee1 | ||
|
|
3c1f6983c5 | ||
|
|
4a6c6df6c7 | ||
|
|
025d415838 | ||
|
|
810c99583b | ||
|
|
e9567514dd | ||
|
|
b593b3f035 | ||
|
|
0f08665bfb | ||
|
|
3744f94fd1 | ||
|
|
aa9dea57d7 | ||
|
|
ece07cfe9c | ||
|
|
dbb7e19fda | ||
|
|
e2098ba085 | ||
|
|
26849f4693 | ||
|
|
ad5a993954 | ||
|
|
6954141484 | ||
|
|
ba2dd33d9c | ||
|
|
134c5761fa | ||
|
|
865e14fd32 | ||
|
|
5d1df4fdf4 | ||
|
|
8d3453a22d | ||
|
|
4430b91363 | ||
|
|
dff6f4c4f0 | ||
|
|
432c174b64 | ||
|
|
5f5977e708 | ||
|
|
0a9f8eb272 | ||
|
|
cad0150d12 | ||
|
|
ee427ad39a | ||
|
|
01b813000a | ||
|
|
449db5a9c1 | ||
|
|
80b67e47e8 | ||
|
|
0a9f26e219 | ||
|
|
05ed18e7d1 | ||
|
|
edb3523a9b | ||
|
|
46cb5109bd | ||
|
|
5845d3eabd | ||
|
|
4a37149f66 | ||
|
|
fc58b17772 | ||
|
|
96b917056d | ||
|
|
0546e4e579 | ||
|
|
05af5cd8fb | ||
|
|
d630301d99 | ||
|
|
2ec8409046 | ||
|
|
905cc94e3d | ||
|
|
8f424b8270 | ||
|
|
cc46157421 | ||
|
|
14ca47b453 | ||
|
|
b1e7771d5e | ||
|
|
ff7b7ba060 | ||
|
|
1935d0738f | ||
|
|
04c1c078b9 | ||
|
|
8f4d67218e | ||
|
|
15f6fd3492 | ||
|
|
b45416921b | ||
|
|
040575c80b | ||
|
|
43309056ac | ||
|
|
bc2a57f657 | ||
|
|
56f22f4320 | ||
|
|
cd39adb561 | ||
|
|
b4f5c42092 | ||
|
|
e243a1fbd8 | ||
|
|
747b554a86 | ||
|
|
f229d4df3a | ||
|
|
96027d919f | ||
|
|
58f277c18e | ||
|
|
921648a997 | ||
|
|
23a30f8583 | ||
|
|
48015617d3 | ||
|
|
13a87d9682 | ||
|
|
c1217ee280 | ||
|
|
51d1e2be1b | ||
|
|
f7677a348e | ||
|
|
8fbd60ded2 | ||
|
|
b11b31aea2 | ||
|
|
51624965e2 | ||
|
|
ce9d8a3f48 | ||
|
|
eda53e5770 | ||
|
|
2bc76ffaf1 | ||
|
|
66efa24241 | ||
|
|
0c11b5f8e7 | ||
|
|
f5dcba6b9b | ||
|
|
c26d6e9aac | ||
|
|
42ed02ed9a | ||
|
|
31d66245ea | ||
|
|
d9d7a7e8f0 | ||
|
|
d15d124d6d | ||
|
|
dd6ecbe688 | ||
|
|
aa816c4444 | ||
|
|
209b3e4b79 | ||
|
|
f2715a558a | ||
|
|
845ee6af72 | ||
|
|
9ff37ea94f | ||
|
|
35f2e1768b | ||
|
|
945cb1f9be | ||
|
|
71db131882 | ||
|
|
bf7661f01b | ||
|
|
9066919600 | ||
|
|
1ffbe8c7c1 | ||
|
|
8d0215928d | ||
|
|
b5d0051dcb | ||
|
|
6038b80277 | ||
|
|
b57c1c9e6e | ||
|
|
0c98cc7023 | ||
|
|
6225b0e61e | ||
|
|
d072048925 | ||
|
|
7d4fbb2fbb | ||
|
|
42a2b556e9 | ||
|
|
e2ae0f2f2b | ||
|
|
d6cf3a3791 | ||
|
|
e741cd592e | ||
|
|
0ae4f7b705 | ||
|
|
29a6ba01a7 | ||
|
|
434801a39c | ||
|
|
79a141876a | ||
|
|
eeb1bb678d | ||
|
|
8e92cd51c6 | ||
|
|
363387c9c0 | ||
|
|
6f237b6bf0 | ||
|
|
a0ddf0b5f2 | ||
|
|
5541ea8aaf | ||
|
|
cf49919686 | ||
|
|
363ae65e2b | ||
|
|
cb129a6234 | ||
|
|
dee7577330 | ||
|
|
1c25b9b06b | ||
|
|
0a92b23c4b | ||
|
|
5408b613f8 | ||
|
|
b7e32059d3 | ||
|
|
faf38eea03 | ||
|
|
9eb125e927 | ||
|
|
203e6dd7cf | ||
|
|
16bb03b8b4 | ||
|
|
df44c4c4d9 | ||
|
|
4690b89eaa | ||
|
|
10c0693210 | ||
|
|
17ba5de88f | ||
|
|
7d5bf79d88 | ||
|
|
a4badc4b50 | ||
|
|
b0606ea043 | ||
|
|
566fb611b6 | ||
|
|
c737b7cf70 | ||
|
|
67dba43998 | ||
|
|
bce7988230 | ||
|
|
864270e18f | ||
|
|
74df4f1956 | ||
|
|
aa725a375c | ||
|
|
5578c3719e | ||
|
|
ce3c7330ba | ||
|
|
c8348f80d5 | ||
|
|
612d52afce | ||
|
|
3449169622 | ||
|
|
ead660ae1e | ||
|
|
04afaab56a | ||
|
|
781a90b358 | ||
|
|
61d7058b5b | ||
|
|
db6850b389 | ||
|
|
eda298bc01 | ||
|
|
516c9c97a6 | ||
|
|
0d4d0b4d32 | ||
|
|
5bffd6c6d5 | ||
|
|
816ff328d2 | ||
|
|
34dca8f8e8 | ||
|
|
3167541570 | ||
|
|
6437604a5e | ||
|
|
2dd49fbeae | ||
|
|
f1c0678c16 | ||
|
|
42369ccd85 | ||
|
|
572b078d8c | ||
|
|
40ca77a721 | ||
|
|
05cbe5ae28 | ||
|
|
5cdff4144e | ||
|
|
feecc898d9 | ||
|
|
3a1d63dc69 | ||
|
|
573a51143a | ||
|
|
6690011811 | ||
|
|
dde1f98626 | ||
|
|
aaf1179ec1 | ||
|
|
e044649282 | ||
|
|
a23f3dbcb6 | ||
|
|
a12d2328b4 | ||
|
|
95a8a665e4 | ||
|
|
da2194c0d5 | ||
|
|
1eb2c48458 | ||
|
|
8fb6c6a9b3 | ||
|
|
9c7f99c9cb | ||
|
|
99c7ad2904 | ||
|
|
e7b4d26ec1 | ||
|
|
c35f888c46 | ||
|
|
5635573cfc | ||
|
|
fea2a877c8 | ||
|
|
5bc90389bf | ||
|
|
2312167d51 | ||
|
|
edbcd02133 | ||
|
|
04336ba10f | ||
|
|
da1c5ca65a | ||
|
|
00c6a9a62c | ||
|
|
665031e834 | ||
|
|
0501c1c570 | ||
|
|
1531bd61a0 | ||
|
|
d9fc0622a1 | ||
|
|
6e4184249c | ||
|
|
04ab33560f | ||
|
|
0522f269e0 | ||
|
|
fcd301daed | ||
|
|
4f67e40898 | ||
|
|
f87ef8bcb5 | ||
|
|
a5bf4e3767 | ||
|
|
5d56786eff | ||
|
|
d7c22fb7ec | ||
|
|
939310bac1 | ||
|
|
29fca0d497 | ||
|
|
df477e4652 | ||
|
|
5a956a7a58 | ||
|
|
67ee8cee39 | ||
|
|
28d9339777 | ||
|
|
bc79d70965 | ||
|
|
40b2603687 | ||
|
|
ad41b8838a | ||
|
|
1d7f56ab64 | ||
|
|
3c1c95399b | ||
|
|
d332c67da7 | ||
|
|
b74fb4e49c | ||
|
|
a6f369b150 | ||
|
|
13831bc06e | ||
|
|
adf049e435 | ||
|
|
681c1fc02a | ||
|
|
ba6fbc57ba | ||
|
|
d1dceee2f7 | ||
|
|
94531034cc | ||
|
|
751a93f3ec | ||
|
|
0b3634bcc4 | ||
|
|
efaeadaa86 | ||
|
|
c4f94cbd08 | ||
|
|
26aad85204 | ||
|
|
c4081f05c8 | ||
|
|
eb26ee6602 | ||
|
|
90a87c8853 | ||
|
|
12924f33bd | ||
|
|
ec6d6fa51b | ||
|
|
1f0eaa046c | ||
|
|
6bdefdd977 | ||
|
|
405a398b3e | ||
|
|
8888ea4479 | ||
|
|
0b26ac5dee | ||
|
|
414769b415 | ||
|
|
5e934ba900 | ||
|
|
b72bc15e22 | ||
|
|
4c7e8208b6 | ||
|
|
baeb6d1e92 | ||
|
|
2ddb252d07 | ||
|
|
7455cbf47e | ||
|
|
87fadd5eee | ||
|
|
5b79cd52f4 | ||
|
|
36082cffcd | ||
|
|
e1bb124baa | ||
|
|
15ea1fa337 | ||
|
|
12fb29f951 | ||
|
|
8500b7720b | ||
|
|
e7ad104ac3 | ||
|
|
3b1f03084e | ||
|
|
680da02ade | ||
|
|
8e83631361 | ||
|
|
8501129c17 | ||
|
|
3706d730d1 | ||
|
|
925a60278e | ||
|
|
29fca795b9 | ||
|
|
bd2fa5def6 | ||
|
|
36251d3f76 | ||
|
|
d92c1fcd55 | ||
|
|
4af7710f94 | ||
|
|
7e97c182a8 | ||
|
|
e0bcbfd0fd | ||
|
|
17878c6e65 | ||
|
|
7006dc4c6a | ||
|
|
c4253c4683 | ||
|
|
4fa96a42f7 | ||
|
|
c2d8399581 | ||
|
|
18c5cfafeb | ||
|
|
36f5884359 | ||
|
|
e7acc6ac3d | ||
|
|
76b0459fdd | ||
|
|
ae41dc55a2 | ||
|
|
45bb9a62ba | ||
|
|
89c2f84287 | ||
|
|
ed9f84475d | ||
|
|
1eb188932b | ||
|
|
8596468e51 | ||
|
|
c32de8c64d | ||
|
|
6d8e090419 | ||
|
|
816e687de8 | ||
|
|
0a521d3785 | ||
|
|
d3feb52955 | ||
|
|
65f3ac192b | ||
|
|
4be12aa1e3 | ||
|
|
84b0da9c94 | ||
|
|
e6fb691c49 | ||
|
|
d4973837b2 | ||
|
|
dd81915d5b | ||
|
|
3615d03e05 | ||
|
|
e0a6c06bfd | ||
|
|
efc4b69767 | ||
|
|
7875d534cb | ||
|
|
92a1d46c8d | ||
|
|
7de02e722f | ||
|
|
61bd4f76ad | ||
|
|
8b67ee5d3d | ||
|
|
fc45f68623 | ||
|
|
a004e23a4c | ||
|
|
88bcdc269b | ||
|
|
aad7c828b2 | ||
|
|
5a9aca17df | ||
|
|
55e85c24b4 | ||
|
|
fcc0263191 | ||
|
|
1d8b75550f | ||
|
|
aff44028ba | ||
|
|
6d7705eedf | ||
|
|
d3a94802d8 | ||
|
|
2b7d730e27 | ||
|
|
bc6726bc04 | ||
|
|
1876366b17 | ||
|
|
c94b996af8 | ||
|
|
0e9f8ced1e | ||
|
|
7342fcaf92 | ||
|
|
92ef313c77 | ||
|
|
cb75699dff | ||
|
|
122a525c83 | ||
|
|
5e823c1fd5 | ||
|
|
8db19980fa | ||
|
|
ef02d563a3 | ||
|
|
b2068640d1 | ||
|
|
93254f66fc | ||
|
|
52093f1776 | ||
|
|
0654d63196 | ||
|
|
4e8aa822dc | ||
|
|
1c42276a39 | ||
|
|
c9e27d026d | ||
|
|
e7db181e5d | ||
|
|
f5c5e53bf5 | ||
|
|
ecb3ad035a | ||
|
|
fb5b3ac013 | ||
|
|
5b84901c55 | ||
|
|
57cbcf6b8f | ||
|
|
07772cba07 | ||
|
|
5c1905caae | ||
|
|
d58251b47e | ||
|
|
d3dcb463d6 | ||
|
|
3dbfd300ff | ||
|
|
ff36991ca2 | ||
|
|
5b3b54e3f6 | ||
|
|
ba55c0770b | ||
|
|
4e68aa7e40 | ||
|
|
76b62317b5 | ||
|
|
4dd0dc6399 | ||
|
|
8be28e3eb6 | ||
|
|
ac8375d000 | ||
|
|
65c0339b5c | ||
|
|
4daae30174 | ||
|
|
d5bc89ef11 | ||
|
|
fa7d7934f6 | ||
|
|
a92a212925 | ||
|
|
435cf87469 | ||
|
|
e51916c0f9 | ||
|
|
997b193f63 | ||
|
|
e29c4b9b93 | ||
|
|
8e25a61277 | ||
|
|
f573ff7792 | ||
|
|
1a16735ce7 | ||
|
|
d02d6a1c7d | ||
|
|
968c231cc8 | ||
|
|
bb5cb1476b | ||
|
|
115020d985 | ||
|
|
3e2263abf2 | ||
|
|
d71f09df4d | ||
|
|
0a456b5d16 | ||
|
|
d3261115a8 | ||
|
|
673a1166fe | ||
|
|
853afe631c | ||
|
|
fe85bafedf | ||
|
|
751561218f | ||
|
|
f0c19e6455 | ||
|
|
ccff383d44 | ||
|
|
f3f7e14727 | ||
|
|
3c2ae60f46 | ||
|
|
95ba417c82 | ||
|
|
b6e4d58e4b | ||
|
|
ef43c17bfe | ||
|
|
ad8b7b71b4 | ||
|
|
83bd94f1f4 | ||
|
|
63071acbd9 | ||
|
|
44271398bd | ||
|
|
90cd362a87 | ||
|
|
b293334e7a | ||
|
|
4ae297867d | ||
|
|
ec3ff78f70 | ||
|
|
6d62ef108a | ||
|
|
b6874f8062 | ||
|
|
8b8aacde83 | ||
|
|
bbd17bd7c4 | ||
|
|
b5cebba675 | ||
|
|
736f40f459 | ||
|
|
0c03fc6f75 | ||
|
|
e61e403d20 | ||
|
|
9d824eb166 | ||
|
|
75d5bfda5b | ||
|
|
9b979b177b | ||
|
|
7b9796539d | ||
|
|
0bc79772c8 | ||
|
|
a45ffbefb9 | ||
|
|
99ffac0838 | ||
|
|
6c98897a64 | ||
|
|
b17c75b222 | ||
|
|
d4e1ddb631 | ||
|
|
aab2aa196d | ||
|
|
03d6b482b5 | ||
|
|
4dcce66295 | ||
|
|
7a28724e6b | ||
|
|
a5bcab7854 | ||
|
|
0a007b743e | ||
|
|
e9ef47f69e | ||
|
|
0532aca928 | ||
|
|
5a77e672e1 | ||
|
|
c2891d0011 | ||
|
|
25e0f55586 | ||
|
|
ce775cc851 | ||
|
|
d0797f5b53 | ||
|
|
a5e5547679 | ||
|
|
4164c6f949 | ||
|
|
4b2237a6a4 | ||
|
|
cb47e20509 | ||
|
|
d3a0b23c1b | ||
|
|
ab38979670 | ||
|
|
628b632419 | ||
|
|
d404b6d488 | ||
|
|
38404a5996 | ||
|
|
05fc4ccd30 | ||
|
|
78bb9dafe1 | ||
|
|
4fca25504e | ||
|
|
9daf91ed5c | ||
|
|
fcd7c13ffd | ||
|
|
5bcd0a8c14 | ||
|
|
8d261262d9 | ||
|
|
c4a8214b77 | ||
|
|
4e47be74e9 | ||
|
|
314ef3e72b | ||
|
|
aee83b43d6 | ||
|
|
9a1e2232ba | ||
|
|
6da2f2d92a | ||
|
|
24145c8869 | ||
|
|
e6a8060a71 | ||
|
|
98f053edbd | ||
|
|
581d29d4c9 | ||
|
|
66b942ce16 | ||
|
|
86cf9b2e89 | ||
|
|
fb29e51dbd | ||
|
|
ab63dd0892 | ||
|
|
a7428d443c | ||
|
|
857dbbe7cc | ||
|
|
3fb7c07ea5 | ||
|
|
60d7c022e5 | ||
|
|
850769f787 | ||
|
|
5f0b9276ec | ||
|
|
733b131545 | ||
|
|
ef217b76a3 | ||
|
|
b0791f75ad | ||
|
|
039ad872fe | ||
|
|
903c64dce8 | ||
|
|
8f4edd07be | ||
|
|
be720edba7 | ||
|
|
140504b11a | ||
|
|
cd3b0cc4d9 | ||
|
|
06a9684cfa | ||
|
|
45599ad00f | ||
|
|
677819fe66 | ||
|
|
2232baa41b | ||
|
|
7dffa41643 | ||
|
|
550bab03fb | ||
|
|
413138a5ca | ||
|
|
74945f2f04 | ||
|
|
97039baa88 | ||
|
|
fd73d04515 | ||
|
|
141d9e3c20 | ||
|
|
0cb906d804 | ||
|
|
b704036531 | ||
|
|
6f55ee2ec5 | ||
|
|
6a1dc2329a | ||
|
|
59a6c379dd | ||
|
|
d2f0bc2d13 | ||
|
|
b011fe1c12 | ||
|
|
0eadc27cd6 | ||
|
|
700c55036c | ||
|
|
b2bee3374c | ||
|
|
cc2770850a | ||
|
|
fb27873021 | ||
|
|
590fb8c481 | ||
|
|
4e8d7ec5fc | ||
|
|
254a513fd1 | ||
|
|
ab1a573768 | ||
|
|
38a9d2763c | ||
|
|
07e1d34a84 | ||
|
|
36edbb5eee | ||
|
|
3fceee058f | ||
|
|
0640cc3d3a | ||
|
|
3f68453d4a | ||
|
|
0a048923ae | ||
|
|
5441e18988 | ||
|
|
db0ed3e62d | ||
|
|
8a7ec52c8b | ||
|
|
66e1b3abba | ||
|
|
cd116fa248 | ||
|
|
c261077788 | ||
|
|
55fbff358a | ||
|
|
1921e6db90 | ||
|
|
bb4f77cd95 | ||
|
|
5ca62c9f35 | ||
|
|
1591a4c9dc | ||
|
|
c36074e85a | ||
|
|
73904f52b4 | ||
|
|
0e128dfa2f | ||
|
|
9994f25733 | ||
|
|
593fc04096 | ||
|
|
cb0b29631f | ||
|
|
ed4d32baa4 | ||
|
|
d83530f45d | ||
|
|
cb3f42123f | ||
|
|
36fa2a0abd | ||
|
|
2d3fc1ca3b | ||
|
|
f70c7d02e9 | ||
|
|
d768d103cf | ||
|
|
44e26d4149 | ||
|
|
96cec0e1a3 | ||
|
|
a9b34191ae | ||
|
|
e9eeb743cb | ||
|
|
8ba34667a1 | ||
|
|
87952f0623 | ||
|
|
d12c02f020 | ||
|
|
f3d737dad1 | ||
|
|
492ef9c964 | ||
|
|
c7822514cc | ||
|
|
d273ad2d0f | ||
|
|
af855e415d | ||
|
|
6ee0edf880 | ||
|
|
00015a81dd | ||
|
|
e1018a5bbb | ||
|
|
c5bef946b1 | ||
|
|
c559bb58ed | ||
|
|
4753906826 | ||
|
|
88b77cc6f3 | ||
|
|
b3b7168077 | ||
|
|
1384c048e4 | ||
|
|
24fde6e00f | ||
|
|
33ced44f9e | ||
|
|
e6dc85bb0b | ||
|
|
20786be695 | ||
|
|
99778e17af | ||
|
|
cf78aee1c4 | ||
|
|
6cd31bbfce | ||
|
|
4bc9f8472c | ||
|
|
4a12f4a22a | ||
|
|
a1f9426399 | ||
|
|
9f1cd70774 | ||
|
|
d2795b7909 | ||
|
|
b75b24103d | ||
|
|
cb1aee2506 | ||
|
|
8d4ce1fed5 | ||
|
|
7abc130a81 | ||
|
|
5adc5a2ff8 | ||
|
|
b302c4721a | ||
|
|
537c146082 | ||
|
|
b6743ea08e | ||
|
|
61365b6d15 | ||
|
|
1b491cbda0 | ||
|
|
8abcf141fa | ||
|
|
b8e314072f | ||
|
|
6785856858 | ||
|
|
e99107b1aa | ||
|
|
f30f0e04e3 | ||
|
|
c3b3240a03 | ||
|
|
65a24d0638 | ||
|
|
a45f47c225 | ||
|
|
c683100e31 | ||
|
|
ec8296ab81 | ||
|
|
bdb0130aea | ||
|
|
5975f31ff0 | ||
|
|
205483d592 | ||
|
|
3bb8683a79 | ||
|
|
bef60dc624 | ||
|
|
8eb8833b74 | ||
|
|
b0525f83e1 | ||
|
|
ee1369b853 | ||
|
|
ea0c7b699e | ||
|
|
f83783115f | ||
|
|
ed8aab4d85 | ||
|
|
6bdea98992 | ||
|
|
4a392c74cf | ||
|
|
1ecd786d95 | ||
|
|
1345cbeea8 | ||
|
|
ab23d34dd9 | ||
|
|
907333884f | ||
|
|
6b3d50b2cd | ||
|
|
dcc3505c7b | ||
|
|
0d00d83ef0 | ||
|
|
47dc5f7b54 | ||
|
|
f2598a8b60 | ||
|
|
80de04e560 | ||
|
|
77fd083041 | ||
|
|
22b9a84314 | ||
|
|
f27592a0cd | ||
|
|
3f2339b551 | ||
|
|
eceff8b3c3 | ||
|
|
f3dd1cc51e | ||
|
|
d32a671dff | ||
|
|
ffc9e9503d | ||
|
|
38734eeb45 | ||
|
|
41b1ffdf36 | ||
|
|
eb7d7955e5 | ||
|
|
4411742328 | ||
|
|
7c969f347f | ||
|
|
d08b6bdbf7 | ||
|
|
0b5b4b456c | ||
|
|
1faed9c234 | ||
|
|
59010e53f4 | ||
|
|
cd11345693 | ||
|
|
9616ad9828 | ||
|
|
8ea598b1d1 | ||
|
|
93215674db | ||
|
|
67703b11fe | ||
|
|
a3791aabaa | ||
|
|
cad6798a8c | ||
|
|
c85f5f6db0 | ||
|
|
c36bb79352 | ||
|
|
63d059ab0b | ||
|
|
3aa94d69fb | ||
|
|
4d56296443 | ||
|
|
9b872f4cf9 | ||
|
|
5432c01ffd | ||
|
|
9c69360e97 | ||
|
|
6a6d79fc00 | ||
|
|
c83d421d9e | ||
|
|
2438825d77 | ||
|
|
a257f80d95 | ||
|
|
973c493e1b | ||
|
|
58bd925acc | ||
|
|
8625b394b5 | ||
|
|
47a007a945 | ||
|
|
3d3aae1697 | ||
|
|
2506e53400 | ||
|
|
25d2d47f86 | ||
|
|
4c0eaee5c6 | ||
|
|
cbbe9a5c01 | ||
|
|
7ccc2daf09 | ||
|
|
ef123cc005 | ||
|
|
254670338e | ||
|
|
bf3293a3cb | ||
|
|
4e7c47fb73 | ||
|
|
afea7d19e0 | ||
|
|
fca50dfab3 | ||
|
|
4e2e14addf | ||
|
|
0e15da5b94 | ||
|
|
2774238722 | ||
|
|
0012e9cd54 | ||
|
|
8d0bc0f026 | ||
|
|
81ce889435 | ||
|
|
135d17ce3e | ||
|
|
9962b84659 | ||
|
|
b0b058b767 | ||
|
|
f21a0d0eee | ||
|
|
d52cd11ed2 | ||
|
|
3bd489d315 | ||
|
|
cbabd9c7e1 | ||
|
|
f19abd6725 | ||
|
|
0a5c9c02fa | ||
|
|
155ce40218 | ||
|
|
71a10f2ca1 | ||
|
|
a861ed971e | ||
|
|
bb98bcba91 | ||
|
|
adaffe7761 | ||
|
|
cf7cce6da5 | ||
|
|
aa23159209 | ||
|
|
c63409b078 | ||
|
|
eac893b60b | ||
|
|
a63dbedead | ||
|
|
5c5db5a55f | ||
|
|
7bc25013f0 | ||
|
|
b86b4928d6 | ||
|
|
2cb633b915 | ||
|
|
47457a01f7 | ||
|
|
77c3bf17ca | ||
|
|
168a433352 | ||
|
|
1408c2afeb | ||
|
|
c9ae31c23a | ||
|
|
2ca8490a32 | ||
|
|
2368a92b2d | ||
|
|
498d19243c | ||
|
|
27bf8986f9 | ||
|
|
e03dd5bd64 | ||
|
|
5acd8fe9cb | ||
|
|
e2062f9fa0 | ||
|
|
9f45c8e6e1 | ||
|
|
00879b155a | ||
|
|
366eb49f99 | ||
|
|
4a5a1ec0b4 | ||
|
|
f3c51e4a28 | ||
|
|
b764c60a12 | ||
|
|
62e956e1dd | ||
|
|
d3edb3f27c | ||
|
|
e15a96b333 | ||
|
|
3200e1e088 | ||
|
|
033155ca21 | ||
|
|
e8edb5a809 | ||
|
|
4e230b087e | ||
|
|
a96117f52c | ||
|
|
fff1093227 | ||
|
|
9d23b40c24 | ||
|
|
5c92dec542 | ||
|
|
9dd1cdff66 | ||
|
|
20788d3b90 | ||
|
|
512cbf8ade | ||
|
|
59fa3e920c | ||
|
|
f5ea1b7095 | ||
|
|
64b863cd2a | ||
|
|
a7d604e681 | ||
|
|
977f6eba3d | ||
|
|
8f8061adba | ||
|
|
8409b8f6db | ||
|
|
f2e2833f28 | ||
|
|
332594dd06 | ||
|
|
7de3260017 | ||
|
|
e06092a24e | ||
|
|
57731529dc | ||
|
|
9830f98ff9 | ||
|
|
5aff745c15 | ||
|
|
3af77feaa3 | ||
|
|
fd20a5ae9b | ||
|
|
d3b76572c7 | ||
|
|
6e97410f66 | ||
|
|
b2888db940 | ||
|
|
56a739bf4e | ||
|
|
8f6628ed9f | ||
|
|
660c6e4d70 | ||
|
|
4c93a7cb6f | ||
|
|
9a462393e4 | ||
|
|
138142583e | ||
|
|
571db950d1 | ||
|
|
15c9be10b3 | ||
|
|
d5e3590df7 | ||
|
|
b54498edea | ||
|
|
ba851ccd9f | ||
|
|
6f1af78401 | ||
|
|
798b1613ab | ||
|
|
9fa9ebebc0 | ||
|
|
6735058024 | ||
|
|
9f044c17fa | ||
|
|
d02f246887 | ||
|
|
f1cf90238b | ||
|
|
845b74e6d4 | ||
|
|
e24196eeeb | ||
|
|
234e543afb | ||
|
|
49a56e7688 | ||
|
|
5f59c87604 | ||
|
|
23d3970929 | ||
|
|
27df3a44eb | ||
|
|
a451725242 | ||
|
|
d546f4399f | ||
|
|
38ef3a592c | ||
|
|
caed8f30ee | ||
|
|
2fe7f06a55 | ||
|
|
5b40b01319 | ||
|
|
b93e0326d2 | ||
|
|
2776d5e9e6 |
371
CMakeLists.txt
@@ -1,38 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 2.4.4)
|
# CMakeLists.txt
|
||||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
|
||||||
|
|
||||||
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
# Copyright (C) 2007-2015 Glenn Randers-Pehrson
|
||||||
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()
|
|
||||||
|
|
||||||
project(libpng C)
|
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
# Copyright (C) 2007-2010 Glenn Randers-Pehrson
|
|
||||||
|
|
||||||
# This code is released under the libpng license.
|
# This code is released under the libpng license.
|
||||||
# For conditions of distribution and use, see the disclaimer
|
# For conditions of distribution and use, see the disclaimer
|
||||||
# and license in png.h
|
# and license in png.h
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.4.4)
|
||||||
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
|
||||||
|
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
||||||
|
|
||||||
|
project(libpng C)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
set(PNGLIB_MAJOR 1)
|
set(PNGLIB_MAJOR 1)
|
||||||
set(PNGLIB_MINOR 5)
|
set(PNGLIB_MINOR 7)
|
||||||
set(PNGLIB_RELEASE 0)
|
set(PNGLIB_RELEASE 0)
|
||||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||||
@@ -47,8 +30,7 @@ if(NOT WIN32)
|
|||||||
PATHS /usr/lib /usr/local/lib
|
PATHS /usr/lib /usr/local/lib
|
||||||
)
|
)
|
||||||
if(NOT M_LIBRARY)
|
if(NOT M_LIBRARY)
|
||||||
message(STATUS
|
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||||
"math library 'libm' not found - floating point support disabled")
|
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
# not needed on windows
|
# not needed on windows
|
||||||
@@ -56,50 +38,14 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# COMMAND LINE OPTIONS
|
# COMMAND LINE OPTIONS
|
||||||
if(DEFINED PNG_SHARED)
|
option(PNG_SHARED "Build shared lib" ON)
|
||||||
option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
|
option(PNG_STATIC "Build static lib" ON)
|
||||||
else()
|
option(PNG_TESTS "Build libpng tests" ON)
|
||||||
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()
|
|
||||||
|
|
||||||
if(MINGW)
|
# Many more configuration options could be added here
|
||||||
option(PNG_TESTS "Build pngtest" NO)
|
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
||||||
else()
|
option(PNG_DEBUG "Build with debug output" OFF)
|
||||||
option(PNG_TESTS "Build pngtest" YES)
|
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
||||||
endif()
|
|
||||||
|
|
||||||
option(PNG_NO_CONSOLE_IO "FIXME" YES)
|
|
||||||
option(PNG_NO_STDIO "FIXME" YES)
|
|
||||||
option(PNG_DEBUG "Build with debug output" NO)
|
|
||||||
option(PNGARG "FIXME" YES)
|
|
||||||
#TODO:
|
|
||||||
# PNG_CONSOLE_IO_SUPPORTED
|
|
||||||
|
|
||||||
# maybe needs improving, but currently I don't know when we can enable what :)
|
|
||||||
set(png_asm_tmp "OFF")
|
|
||||||
if(NOT WIN32)
|
|
||||||
find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
|
|
||||||
if(uname_executable)
|
|
||||||
exec_program(${uname_executable}
|
|
||||||
ARGS --machine OUTPUT_VARIABLE uname_output)
|
|
||||||
if("uname_output" MATCHES "^.*i[1-9]86.*$")
|
|
||||||
set(png_asm_tmp "ON")
|
|
||||||
else("uname_output" MATCHES "^.*i[1-9]86.*$")
|
|
||||||
set(png_asm_tmp "OFF")
|
|
||||||
endif("uname_output" MATCHES "^.*i[1-9]86.*$")
|
|
||||||
endif(uname_executable)
|
|
||||||
else()
|
|
||||||
# this env var is normally only set on win64
|
|
||||||
set(TEXT "ProgramFiles(x86)")
|
|
||||||
if("$ENV{${TEXT}}" STREQUAL "")
|
|
||||||
set(png_asm_tmp "ON")
|
|
||||||
endif("$ENV{${TEXT}}" STREQUAL "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# SET LIBNAME
|
# SET LIBNAME
|
||||||
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||||
@@ -108,6 +54,9 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
|||||||
set(CMAKE_DEBUG_POSTFIX "d")
|
set(CMAKE_DEBUG_POSTFIX "d")
|
||||||
|
|
||||||
# Use the prebuilt pnglibconf.h file from the scripts folder
|
# 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
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
@@ -143,49 +92,30 @@ set(libpng_sources
|
|||||||
set(pngtest_sources
|
set(pngtest_sources
|
||||||
pngtest.c
|
pngtest.c
|
||||||
)
|
)
|
||||||
|
set(pngvalid_sources
|
||||||
|
contrib/libtests/pngvalid.c
|
||||||
|
)
|
||||||
|
set(pngstest_sources
|
||||||
|
contrib/libtests/pngstest.c
|
||||||
|
)
|
||||||
# SOME NEEDED DEFINITIONS
|
# SOME NEEDED DEFINITIONS
|
||||||
|
|
||||||
add_definitions(-DPNG_CONFIGURE_LIBPNG)
|
|
||||||
|
|
||||||
if(_AIX)
|
|
||||||
add_definitions(-D_ALL_SOURCE)
|
|
||||||
endif(_AIX)
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(PNG_SHARED OR NOT MSVC)
|
|
||||||
#if building msvc static this has NOT to be defined
|
|
||||||
add_definitions(-DZLIB_DLL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(PNG_CONSOLE_IO_SUPPORTED)
|
|
||||||
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PNG_NO_CONSOLE_IO)
|
|
||||||
add_definitions(-DPNG_NO_CONSOLE_IO)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PNG_NO_STDIO)
|
|
||||||
add_definitions(-DPNG_NO_STDIO)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PNG_DEBUG)
|
if(PNG_DEBUG)
|
||||||
add_definitions(-DPNG_DEBUG)
|
add_definitions(-DPNG_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT M_LIBRARY AND NOT WIN32)
|
|
||||||
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# NOW BUILD OUR TARGET
|
# NOW BUILD OUR TARGET
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||||
|
|
||||||
|
unset(PNG_LIB_TARGETS)
|
||||||
|
|
||||||
if(PNG_SHARED)
|
if(PNG_SHARED)
|
||||||
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
|
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
|
||||||
|
set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# msvc does not append 'lib' - do it here to have consistent name
|
# 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 PREFIX "lib")
|
||||||
@@ -195,9 +125,10 @@ if(PNG_SHARED)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
# does not work without changing name
|
# does not work without changing name
|
||||||
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
||||||
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
||||||
|
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# msvc does not append 'lib' - do it here to have consistent name
|
# 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_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
||||||
@@ -205,6 +136,28 @@ if(PNG_STATIC)
|
|||||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PNG_FRAMEWORK)
|
||||||
|
set(PNG_LIB_NAME_FRAMEWORK ${PNG_LIB_NAME}_framework)
|
||||||
|
add_library(${PNG_LIB_NAME_FRAMEWORK} SHARED ${libpng_sources})
|
||||||
|
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_FRAMEWORK})
|
||||||
|
set_target_properties(${PNG_LIB_NAME_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_LIB_NAME_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)
|
if(PNG_SHARED AND WIN32)
|
||||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||||
@@ -215,55 +168,102 @@ if(PNG_TESTS AND PNG_SHARED)
|
|||||||
add_executable(pngtest ${pngtest_sources})
|
add_executable(pngtest ${pngtest_sources})
|
||||||
target_link_libraries(pngtest ${PNG_LIB_NAME})
|
target_link_libraries(pngtest ${PNG_LIB_NAME})
|
||||||
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
||||||
|
#
|
||||||
|
add_executable(pngvalid ${pngvalid_sources})
|
||||||
|
target_link_libraries(pngvalid ${PNG_LIB_NAME})
|
||||||
|
add_test(pngvalid ./pngvalid)
|
||||||
|
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
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
||||||
|
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||||
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||||
|
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||||
|
|
||||||
# Set a variable with CMake code which:
|
# Set a variable with CMake code which:
|
||||||
# Creates a symlink from src to dest (if possible) or alternatively
|
# Creates a symlink from src to dest (if possible) or alternatively
|
||||||
# copies if different.
|
# copies if different.
|
||||||
macro(_png_generate_symlink_code CODE SRC DEST)
|
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||||
if(WIN32 AND NOT CYGWIN)
|
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||||
set(_png_gsc_message "Copying ${SRC} to ${DEST} if needed")
|
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||||
set(_png_gsc_operation "copy_if_different")
|
ADD_CUSTOM_COMMAND(
|
||||||
else()
|
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||||
set(_png_gsc_message "Symlinking ${SRC} to ${DEST}")
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||||
set(_png_gsc_operation "create_symlink")
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||||
endif()
|
DEPENDS ${PNG_LIB_TARGETS}
|
||||||
|
)
|
||||||
set(${CODE} "
|
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||||
message(STATUS \"${_png_gsc_message}\")
|
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||||
execute_process(COMMAND \${CMAKE_COMMAND} -E ${_png_gsc_operation}
|
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
||||||
\"${SRC}\" \"${DEST}\")
|
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()
|
endmacro()
|
||||||
|
|
||||||
|
# libpng is a library so default to 'lib'
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||||
|
set(CMAKE_INSTALL_LIBDIR lib)
|
||||||
|
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||||
|
|
||||||
# CREATE PKGCONFIG FILES
|
# CREATE PKGCONFIG FILES
|
||||||
# we use the same files like ./configure, so we have to set its vars
|
# we use the same files like ./configure, so we have to set its vars
|
||||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||||
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
|
# a UNIX look alike
|
||||||
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
set(libdir ${CMAKE_INSTALL_LIBDIR})
|
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
set(LIBS "-lz -lm")
|
set(LIBS "-lz -lm")
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||||
_png_generate_symlink_code(PNG_PC_INSTALL_CODE ${PNGLIB_NAME}.pc libpng.pc)
|
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
||||||
install(CODE ${PNG_PC_INSTALL_CODE})
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||||
_png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE ${PNGLIB_NAME}-config
|
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
||||||
libpng-config)
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
install(CODE ${PNG_CONFIG_INSTALL_CODE})
|
|
||||||
|
|
||||||
# SET UP LINKS
|
# SET UP LINKS
|
||||||
if(PNG_SHARED)
|
if(PNG_SHARED)
|
||||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||||
# VERSION 15.${PNGLIB_RELEASE}.1.5.0beta55
|
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta65
|
||||||
VERSION 15.${PNGLIB_RELEASE}.0
|
VERSION 17.${PNGLIB_RELEASE}.0
|
||||||
SOVERSION 15
|
SOVERSION 17
|
||||||
CLEAN_DIRECT_OUTPUT 1)
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
endif()
|
endif()
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
@@ -288,50 +288,38 @@ endif()
|
|||||||
|
|
||||||
# INSTALL
|
# INSTALL
|
||||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||||
if(PNG_SHARED)
|
install(TARGETS ${PNG_LIB_TARGETS}
|
||||||
install(TARGETS ${PNG_LIB_NAME}
|
${PNG_EXPORT_RULE}
|
||||||
${PNG_EXPORT_RULE}
|
RUNTIME DESTINATION bin
|
||||||
RUNTIME DESTINATION bin
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
|
||||||
# Create a symlink for libpng.dll.a => libpng14.dll.a on Cygwin
|
if(PNG_SHARED)
|
||||||
if(CYGWIN)
|
# Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
|
||||||
_png_generate_symlink_code(PNG_SHARED_IMPLIB_INSTALL_CODE
|
if(CYGWIN OR MINGW)
|
||||||
${PNGLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||||
libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||||
install(CODE ${PNG_SHARED_IMPLIB_INSTALL_CODE})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||||
install(FILES
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
endif(CYGWIN OR MINGW)
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||||
${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(FILES
|
endif(NOT WIN32)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
endif(PNG_SHARED)
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
${PNG_EXPORT_RULE}
|
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||||
if(NOT WIN32 OR CYGWIN)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
endif()
|
||||||
libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
|
||||||
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
|
||||||
install(FILES
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||||
@@ -339,10 +327,13 @@ if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
|||||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||||
endif()
|
endif()
|
||||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
||||||
DESTINATION bin)
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||||
|
DESTINATION bin)
|
||||||
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||||
# Install man pages
|
# Install man pages
|
||||||
if(NOT PNG_MAN_DIR)
|
if(NOT PNG_MAN_DIR)
|
||||||
@@ -351,14 +342,16 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
|||||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||||
# Install pkg-config files
|
# Install pkg-config files
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
DESTINATION bin)
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
DESTINATION bin)
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
DESTINATION bin)
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||||
|
DESTINATION bin)
|
||||||
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# On versions of CMake that support it, create an export file CMake
|
# On versions of CMake that support it, create an export file CMake
|
||||||
@@ -369,11 +362,9 @@ endif()
|
|||||||
|
|
||||||
# what's with libpng-manual.txt and all the extra files?
|
# what's with libpng-manual.txt and all the extra files?
|
||||||
|
|
||||||
|
|
||||||
# UNINSTALL
|
# UNINSTALL
|
||||||
# do we need this?
|
# do we need this?
|
||||||
|
|
||||||
|
|
||||||
# DIST
|
# DIST
|
||||||
# do we need this?
|
# do we need this?
|
||||||
|
|
||||||
|
|||||||
334
INSTALL
@@ -1,32 +1,69 @@
|
|||||||
|
|
||||||
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. Other sources of information about libpng
|
||||||
|
|
||||||
|
I. Simple installation
|
||||||
|
|
||||||
On Unix/Linux and similar systems, you can simply type
|
On Unix/Linux and similar systems, you can simply type
|
||||||
|
|
||||||
./configure [--prefix=/path]
|
./configure [--prefix=/path]
|
||||||
make check
|
make check
|
||||||
make install
|
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 configure does not work on your system and you have a reasonably
|
If you downloaded a GIT clone, you will need to run ./autogen.sh before
|
||||||
up-to-date set of tools, running ./autogen.sh before running ./configure
|
running ./configure, to create "configure" and "Makefile.in" which are
|
||||||
may fix the problem. You can also run the individual commands in
|
not included in the GIT repository.
|
||||||
autogen.sh with the --force option, if supported by your version of
|
|
||||||
the tools. To be really sure that you aren't using any of the included
|
Note that "configure" is only included in the "*.tar" distributions and not
|
||||||
pre-built scripts, you can do this:
|
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:
|
||||||
|
|
||||||
./configure --enable-maintainer-mode
|
./configure --enable-maintainer-mode
|
||||||
make maintainer-clean
|
make maintainer-clean
|
||||||
./autogen.sh
|
./autogen.sh --maintainer --clean
|
||||||
|
./autogen.sh --maintainer
|
||||||
./configure [--prefix=/path] [other options]
|
./configure [--prefix=/path] [other options]
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
make check
|
make check
|
||||||
|
|
||||||
|
III. Using scripts/makefile*
|
||||||
|
|
||||||
Instead, you can use one of the custom-built makefiles in the
|
Instead, you can use one of the custom-built makefiles in the
|
||||||
"scripts" directory
|
"scripts" directory
|
||||||
|
|
||||||
|
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||||
cp scripts/makefile.system makefile
|
cp scripts/makefile.system makefile
|
||||||
make test
|
make test
|
||||||
make install
|
make install
|
||||||
@@ -38,8 +75,28 @@ Or you can use one of the "projects" in the "projects" directory.
|
|||||||
|
|
||||||
Before installing libpng, you must first install zlib, if it
|
Before installing libpng, you must first install zlib, if it
|
||||||
is not already on your system. zlib can usually be found
|
is not already on your system. zlib can usually be found
|
||||||
wherever you got libpng. zlib can be placed in another directory,
|
wherever you got libpng; otherwise go to http://zlib.net. You can place
|
||||||
at the same level as libpng.
|
zlib in 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
|
If you want to use "cmake" (see www.cmake.org), type
|
||||||
|
|
||||||
@@ -47,13 +104,15 @@ If you want to use "cmake" (see www.cmake.org), type
|
|||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
If your system already has a preinstalled zlib you will still need
|
As when using the simple configure method described above, "/path" points to
|
||||||
to have access to the zlib.h and zconf.h include files that
|
the installation directory where you want to put the libpng "lib", "include",
|
||||||
correspond to the version of zlib that's installed.
|
and "bin" subdirectories.
|
||||||
|
|
||||||
|
V. Directory structure
|
||||||
|
|
||||||
You can rename the directories that you downloaded (they
|
You can rename the directories that you downloaded (they
|
||||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
|
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
||||||
or "zlib125") so that you have directories called "zlib" and "libpng".
|
or "zlib128") so that you have directories called "zlib" and "libpng".
|
||||||
|
|
||||||
Your directory structure should look like this:
|
Your directory structure should look like this:
|
||||||
|
|
||||||
@@ -61,8 +120,7 @@ Your directory structure should look like this:
|
|||||||
libpng (this directory)
|
libpng (this directory)
|
||||||
INSTALL (this file)
|
INSTALL (this file)
|
||||||
README
|
README
|
||||||
*.h
|
*.h, *.c => libpng source files
|
||||||
*.c
|
|
||||||
CMakeLists.txt => "cmake" script
|
CMakeLists.txt => "cmake" script
|
||||||
configuration files:
|
configuration files:
|
||||||
configure.ac, configure, Makefile.am, Makefile.in,
|
configure.ac, configure, Makefile.am, Makefile.in,
|
||||||
@@ -70,14 +128,10 @@ Your directory structure should look like this:
|
|||||||
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
||||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||||
contrib
|
contrib
|
||||||
gregbook
|
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||||
pngminim
|
pngminus, pngsuite, tools, visupng
|
||||||
pngminus
|
|
||||||
pngsuite
|
|
||||||
visupng
|
|
||||||
projects
|
projects
|
||||||
visualc71
|
cbuilder5, owatcom, visualc71, vstudio, xcode
|
||||||
vstudio
|
|
||||||
scripts
|
scripts
|
||||||
makefile.*
|
makefile.*
|
||||||
*.def (module definition files)
|
*.def (module definition files)
|
||||||
@@ -85,29 +139,31 @@ Your directory structure should look like this:
|
|||||||
pngtest.png
|
pngtest.png
|
||||||
etc.
|
etc.
|
||||||
zlib
|
zlib
|
||||||
README
|
README, *.h, *.c contrib, etc.
|
||||||
*.h
|
|
||||||
*.c
|
|
||||||
contrib
|
|
||||||
etc.
|
|
||||||
|
|
||||||
If the line endings in the files look funny, you may wish to get the other
|
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
|
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||||
endings) and zip (DOS style line endings) formats.
|
endings) and zip (DOS style line endings) formats.
|
||||||
|
|
||||||
|
VI. Building with project files
|
||||||
|
|
||||||
If you are building libpng with MSVC, you can enter the
|
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.
|
in README.txt.
|
||||||
|
|
||||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
||||||
then come back here and run "configure" or choose the appropriate
|
then come back here and run "configure" or choose the appropriate
|
||||||
makefile.sys in the scripts directory.
|
makefile.sys in the scripts directory.
|
||||||
|
|
||||||
|
VII. Building with makefiles
|
||||||
|
|
||||||
Copy the file (or files) that you need from the
|
Copy the file (or files) that you need from the
|
||||||
scripts directory into this directory, for example
|
scripts directory into this directory, for example
|
||||||
|
|
||||||
MSDOS example: copy scripts\makefile.msc makefile
|
MSDOS example: copy scripts\makefile.msc makefile
|
||||||
UNIX example: cp scripts/makefile.std 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
|
Read the makefile to see if you need to change any source or
|
||||||
target directories to match your preferences.
|
target directories to match your preferences.
|
||||||
@@ -130,6 +186,222 @@ do that, run "make install" in the zlib directory first if necessary).
|
|||||||
Some also allow you to run "make test-installed" after you have
|
Some also allow you to run "make test-installed" after you have
|
||||||
run "make install".
|
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.
|
||||||
|
|
||||||
|
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. Other sources of information about libpng:
|
||||||
|
|
||||||
Further information can be found in the README and libpng-manual.txt
|
Further information can be found in the README and libpng-manual.txt
|
||||||
files, in the individual makefiles, in png.h, and the manual pages
|
files, in the individual makefiles, in png.h, and the manual pages
|
||||||
libpng.3 and png.5.
|
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/libpng17, 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.
|
||||||
|
|
||||||
|
|||||||
48
LICENSE
@@ -10,21 +10,17 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.2.6, August 15, 2004, through 1.5.0beta55, November 21, 2010, are
|
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta65, September 16, 2015, are
|
||||||
Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
|
Copyright (c) 2000-2002, 2004, 2006-2015 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
|
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
with the following individuals added to the list of Contributing Authors
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
Simon-Pierre Cadieux
|
Simon-Pierre Cadieux
|
||||||
Eric S. Raymond
|
Eric S. Raymond
|
||||||
|
Mans Rullgard
|
||||||
|
Cosmin Truta
|
||||||
Gilles Vollant
|
Gilles Vollant
|
||||||
|
James Yu
|
||||||
|
|
||||||
and with the following additions to the disclaimer:
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
@@ -36,17 +32,17 @@ and with the following additions to the disclaimer:
|
|||||||
the user.
|
the user.
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||||
distributed according to the same disclaimer and license as libpng-0.96,
|
to the same disclaimer and license as libpng-0.96, with the following
|
||||||
with the following individuals added to the list of Contributing Authors:
|
individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
Tom Lane
|
Tom Lane
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
|
|
||||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
with the following individuals added to the list of Contributing Authors:
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
John Bowler
|
John Bowler
|
||||||
@@ -57,7 +53,7 @@ with the following individuals added to the list of Contributing Authors:
|
|||||||
Tom Tanner
|
Tom Tanner
|
||||||
|
|
||||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
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"
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
is defined as the following set of individuals:
|
is defined as the following set of individuals:
|
||||||
@@ -80,13 +76,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
|||||||
source code, or portions hereof, for any purpose, without fee, subject
|
source code, or portions hereof, for any purpose, without fee, subject
|
||||||
to the following restrictions:
|
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
|
2. Altered versions must be plainly marked as such and must not
|
||||||
be misrepresented as being the original source.
|
be misrepresented as being the original source.
|
||||||
|
|
||||||
3. This Copyright notice may not be removed or altered from any
|
3. This Copyright notice may not be removed or altered from any
|
||||||
source or altered source distribution.
|
source or altered source distribution.
|
||||||
|
|
||||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
fee, and encourage the use of this source code as a component to
|
fee, and encourage the use of this source code as a component to
|
||||||
@@ -94,18 +90,18 @@ supporting the PNG file format in commercial products. If you use this
|
|||||||
source code in a product, acknowledgment is not required but would be
|
source code in a product, acknowledgment is not required but would be
|
||||||
appreciated.
|
appreciated.
|
||||||
|
|
||||||
|
|
||||||
A "png_get_copyright" function is available, for convenient use in "about"
|
A "png_get_copyright" function is available, for convenient use in "about"
|
||||||
boxes and the like:
|
boxes and the like:
|
||||||
|
|
||||||
printf("%s",png_get_copyright(NULL));
|
printf("%s", png_get_copyright(NULL));
|
||||||
|
|
||||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||||
|
|
||||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
certification mark of the Open Source Initiative.
|
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
|
the additional disclaimers inserted at version 1.0.7.
|
||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
November 21, 2010
|
September 16, 2015
|
||||||
|
|||||||
353
Makefile.am
@@ -4,27 +4,75 @@
|
|||||||
|
|
||||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||||
|
|
||||||
# libpng does not follow GNU file name conventions
|
ACLOCAL_AMFLAGS = -I scripts
|
||||||
|
|
||||||
# "color-tests" requires automake 1.11.1 or later. Enable it if you like,
|
|
||||||
# to get red "FAIL" and green "PASS" notations during tests.
|
|
||||||
# AUTOMAKE_OPTIONS = foreign color-tests
|
|
||||||
AUTOMAKE_OPTIONS = foreign
|
|
||||||
|
|
||||||
# test programs - run on make check, make distcheck
|
# test programs - run on make check, make distcheck
|
||||||
check_PROGRAMS= pngtest pngvalid
|
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage
|
||||||
|
|
||||||
|
# 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_SOURCES = pngtest.c
|
||||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
pngvalid_SOURCES = pngvalid.c
|
|
||||||
|
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
TESTS = test-pngtest.sh pngvalid
|
|
||||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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-interlace-size\
|
||||||
|
tests/pngvalid-progressive-interlace-standard\
|
||||||
|
tests/pngvalid-progressive-interlace-transform\
|
||||||
|
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||||
|
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
|
||||||
|
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
|
||||||
|
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
|
||||||
|
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
|
||||||
|
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
|
||||||
|
tests/pngstest-error 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
|
||||||
|
|
||||||
|
# These tests are expected, and required, to fail:
|
||||||
|
XFAIL_TESTS = tests/pngstest-error
|
||||||
|
|
||||||
# man pages
|
# man pages
|
||||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||||
|
|
||||||
# generate the -config scripts if required
|
# generate the -config scripts if required
|
||||||
binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
||||||
EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
||||||
bin_SCRIPTS= @binconfigs@
|
bin_SCRIPTS= @binconfigs@
|
||||||
|
|
||||||
@@ -34,21 +82,33 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
|||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
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\
|
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\
|
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h \
|
||||||
|
pngusr.dfa
|
||||||
|
|
||||||
|
# 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
|
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||||
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_CPPFLAGS = @LIBPNG_DEFINES@
|
|
||||||
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
||||||
-version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
|
-version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
|
||||||
|
|
||||||
if HAVE_LD_VERSION_SCRIPT
|
if HAVE_LD_VERSION_SCRIPT
|
||||||
# Versioned symbols and restricted exports
|
# Versioned symbols and restricted exports
|
||||||
|
if HAVE_SOLARIS_LD
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers
|
||||||
|
else
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers
|
||||||
|
endif
|
||||||
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
|
||||||
else
|
else
|
||||||
# Only restricted exports when possible
|
# Only restricted exports when possible
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
||||||
endif
|
endif
|
||||||
@@ -63,25 +123,41 @@ nodist_pkginclude_HEADERS= pnglibconf.h
|
|||||||
pkgconfigdir = @pkgconfigdir@
|
pkgconfigdir = @pkgconfigdir@
|
||||||
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
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= \
|
EXTRA_DIST= \
|
||||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||||
$(TESTS) \
|
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||||
CMakeLists.txt example.c libpng-manual.txt
|
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= dfn.c dfn?.out pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
||||||
pngwin.def check.new pnglibconf.* symbols.new \
|
check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \
|
||||||
|
pnglibconf.out pnglibconf.c pnglibconf.dfn pnglibconf.pre \
|
||||||
$(SCRIPT_CLEANFILES)
|
$(SCRIPT_CLEANFILES)
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
||||||
config.sub configure depcomp install-sh ltmain.sh missing
|
config.sub configure depcomp install-sh ltmain.sh missing
|
||||||
|
|
||||||
SUFFIXES = .chk .dfn .out
|
# PNG_COPTS give extra options for the C compiler to be used on all compilation
|
||||||
|
# steps (unless targe_CFLAGS is specified; that will take precedence over
|
||||||
|
# AM_CFLAGS)
|
||||||
|
PNG_COPTS = @PNG_COPTS@
|
||||||
|
AM_CFLAGS = ${PNG_COPTS}
|
||||||
|
|
||||||
|
# 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 .out
|
||||||
|
|
||||||
$(PNGLIB_BASENAME).pc: libpng.pc
|
$(PNGLIB_BASENAME).pc: libpng.pc
|
||||||
cp libpng.pc $@
|
cp libpng.pc $@
|
||||||
@@ -90,7 +166,11 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
|||||||
cp libpng-config $@
|
cp libpng-config $@
|
||||||
|
|
||||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||||
scripts/symbols.out scripts/pngwin.out: png.h pngconf.h scripts/pnglibconf.h.prebuilt
|
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
|
libpng.sym: scripts/sym.out
|
||||||
rm -f $@
|
rm -f $@
|
||||||
@@ -98,107 +178,196 @@ libpng.sym: scripts/sym.out
|
|||||||
libpng.vers: scripts/vers.out
|
libpng.vers: scripts/vers.out
|
||||||
rm -f $@
|
rm -f $@
|
||||||
cp $? $@
|
cp $? $@
|
||||||
pngwin.def: scripts/pngwin.out
|
|
||||||
|
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 config.h
|
||||||
rm -f $@
|
rm -f $@
|
||||||
cp $? $@
|
$(AWK) 's==0 && NR>1{print prev}\
|
||||||
|
s==0{prev=$$0}\
|
||||||
|
s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\
|
||||||
|
s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\
|
||||||
|
END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\
|
||||||
|
s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8
|
||||||
|
mv pnglibconf.tf8 $@
|
||||||
|
|
||||||
|
pngprefix.h: scripts/intprefix.out
|
||||||
|
rm -f pngprefix.tf1
|
||||||
|
$(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1
|
||||||
|
mv pngprefix.tf1 $@
|
||||||
|
else
|
||||||
pnglibconf.h: pnglibconf.out
|
pnglibconf.h: pnglibconf.out
|
||||||
rm -f $@
|
rm -f $@
|
||||||
cp $? $@
|
cp $? $@
|
||||||
scripts/pnglibconf.h.prebuilt:
|
|
||||||
|
pngprefix.h: # is empty
|
||||||
|
:>$@
|
||||||
|
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 "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
|
@exit 1
|
||||||
|
|
||||||
# The following is necessary to ensure that the local pnglibconf.h is used, not
|
# 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
|
# an installed one (this can happen immediately after on a clean system if
|
||||||
# 'make test' is the first thing the user does.)
|
# 'make test' is the first thing the user does.) Only files which include
|
||||||
pngvalid.o pngtest.o: pnglibconf.h
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# interfering with the symbol file format.
|
||||||
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
||||||
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
||||||
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'
|
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
|
||||||
|
-DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE
|
||||||
|
|
||||||
.dfn.out:
|
if DO_PNG_PREFIX
|
||||||
rm -f $@ dfn.c dfn?.out
|
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||||
test -d scripts || mkdir scripts
|
endif
|
||||||
echo '#include "$<"' >dfn.c
|
|
||||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) @LIBPNG_DEFINES@\
|
|
||||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) dfn.c > dfn1.out
|
|
||||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC-\(.*\)-PNG_DEFN_END.*$$|\1|p'\
|
|
||||||
dfn1.out >dfn2.out
|
|
||||||
$(SED) -e 's| *@@@ *||g' -e 's| *$$||' dfn2.out >dfn3.out
|
|
||||||
rm -f dfn.c dfn[12].out
|
|
||||||
mv dfn3.out $@
|
|
||||||
|
|
||||||
# The .dfn file for pnglibconf.h is machine generated
|
.c.out:
|
||||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk
|
rm -f $@ $*.tf[12]
|
||||||
rm -f $@ dfn?.out
|
test -d scripts || mkdir scripts || test -d scripts
|
||||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\
|
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||||
${srcdir}/scripts/pnglibconf.dfa $(DFA_XTRA) 1>&2
|
$(AM_CPPFLAGS) $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
|
||||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||||
rm dfn1.out
|
rm -f $*.tf1
|
||||||
mv dfn2.out $@
|
mv $*.tf2 $@
|
||||||
|
|
||||||
|
# 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\
|
||||||
|
$(DFA_EXTENSION) ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||||
|
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||||
|
rm $*.tf4
|
||||||
|
mv $*.tf5 $@
|
||||||
|
|
||||||
# Symbol checks (.def and .out files should match)
|
# Symbol checks (.def and .out files should match)
|
||||||
scripts/pngwin.chk: scripts/checksym.awk scripts/pngwin.def scripts/pngwin.out
|
|
||||||
scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out
|
scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out
|
||||||
|
|
||||||
.out.chk:
|
.out.chk:
|
||||||
rm -f $@ symbols.new
|
rm -f $@ $*.new
|
||||||
$(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\
|
$(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\
|
||||||
$< >&2
|
of="$*.new" $< >&2
|
||||||
mv symbols.new $@
|
mv $*.new $@
|
||||||
|
|
||||||
# used on demand to regenerate the standard header, CPPFLAGS should
|
# used on demand to regenerate the standard header, CPPFLAGS should
|
||||||
# be empty - no non-standard defines
|
# be empty - no non-standard defines
|
||||||
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk
|
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||||
rm -f $@ dfn?.out
|
rm -f $@ pnglibconf.tf[67]
|
||||||
test -z "$(CPPFLAGS)"
|
test -z "$(CPPFLAGS)" -a -z "$(AM_CPPFLAGS)"
|
||||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
echo "com libpng @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\
|
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\
|
||||||
logunsupported=1 - ${srcdir}/scripts/pnglibconf.dfa 1>&2
|
logunsupported=1 version=search ${srcdir}/pngconf.h -\
|
||||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||||
rm dfn1.out
|
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\
|
||||||
mv dfn2.out $@
|
pnglibconf.tf6 1>&2
|
||||||
|
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
|
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h
|
||||||
|
|
||||||
test: check-am
|
test: check-am
|
||||||
|
|
||||||
# Extra checks
|
# Extra checks
|
||||||
check: scripts/symbols.chk scripts/pngwin.chk
|
check: scripts/symbols.chk
|
||||||
|
|
||||||
# Don't distribute the generated script files
|
# Don't distribute the generated script files
|
||||||
dist-hook:
|
dist-hook:
|
||||||
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
|
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
|
||||||
|
|
||||||
# install the .../include headers as links to the new ones
|
# Make links between installed files with release-specific names and the generic
|
||||||
install-data-hook:
|
# file names. If this install rule is run the generic names will be deleted and
|
||||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
# recreated - this has obvious issues for systems with multiple installations.
|
||||||
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
|
|
||||||
|
|
||||||
# do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
|
install-header-links:
|
||||||
install-exec-hook:
|
@set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \
|
||||||
cd $(DESTDIR)$(bindir); rm -f libpng-config
|
rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done
|
||||||
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
|
||||||
@set -x;\
|
uninstall-header-links:
|
||||||
cd $(DESTDIR)$(libdir);\
|
cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS)
|
||||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
|
|
||||||
rm -f libpng.$$ext;\
|
install-libpng-pc:
|
||||||
if test -f $(PNGLIB_BASENAME).$$ext; then\
|
@set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \
|
||||||
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
|
$(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc
|
||||||
fi;\
|
|
||||||
|
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
|
done
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-library-links:
|
||||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
@set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\
|
||||||
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
|
rm -f "libpng.$$ext"; done
|
||||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
|
||||||
rm -f $(DESTDIR)$(libdir)/libpng.a
|
install-libpng-config:
|
||||||
rm -f $(DESTDIR)$(libdir)/libpng.la
|
@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)
|
||||||
|
|||||||
1375
Makefile.in
72
README
@@ -1,11 +1,11 @@
|
|||||||
README for libpng version 1.5.0beta55 - November 21, 2010 (shared library 15.0)
|
README for libpng version 1.7.0beta65 - September 16, 2015 (shared library 17.0)
|
||||||
See the note about version numbers near the top of png.h
|
See the note about version numbers near the top of png.h
|
||||||
|
|
||||||
See INSTALL for instructions on how to install libpng.
|
See INSTALL for instructions on how to install libpng.
|
||||||
|
|
||||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
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
|
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
|
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
|
png_uint_32, which will affect shared-library applications that use
|
||||||
this function.
|
this function.
|
||||||
|
|
||||||
To avoid problems with changes to the internals of png_info_struct,
|
To avoid problems with changes to the internals of png info_struct,
|
||||||
new APIs have been made available in 0.95 to avoid direct application
|
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
|
access to info_ptr. These functions are the png_set_<chunk> and
|
||||||
png_get_<chunk> functions. These functions should be used when
|
png_get_<chunk> functions. These functions should be used when
|
||||||
accessing/storing the info_struct data, rather than manipulating it
|
accessing/storing the info_struct data, rather than manipulating it
|
||||||
directly, to avoid such problems in the future.
|
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
|
that access the info struct directly incompatible with the new
|
||||||
library. However, it is strongly suggested that new programs use
|
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
be a transitional release, members of the png_struct and the
|
||||||
be converted to the new format, to facilitate upgrades in the future.
|
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
|
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 can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||||
you are so inclined.
|
you are so inclined.
|
||||||
|
|
||||||
zlib should be available at the same place that libpng is, or at.
|
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
|
||||||
|
|
||||||
You may also want a copy of the PNG specification. It is available
|
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
|
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/documents/
|
||||||
|
|
||||||
This code is currently being archived at libpng.sf.net in the
|
This code is currently being archived at libpng.sf.net in the
|
||||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
||||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
in any of those places, e-mail me, and I'll help you find it.
|
||||||
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
|
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,
|
them to me. Also, I'd appreciate any make files or project files,
|
||||||
@@ -105,7 +116,7 @@ based in a large way on Guy's and Andreas' earlier work), and the PNG
|
|||||||
development group.
|
development group.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at
|
Send comments/corrections/commendations to png-mng-implement at
|
||||||
lists.sourceforge.net (subscription required; visit
|
lists.sourceforge.net (subscription required; visit
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
to subscribe) or to glennrp at users.sourceforge.net
|
to subscribe) or to glennrp at users.sourceforge.net
|
||||||
|
|
||||||
@@ -114,19 +125,16 @@ given in previous versions of this document. He and Andreas will
|
|||||||
read mail addressed to the png-implement list, however.
|
read mail addressed to the png-implement list, however.
|
||||||
|
|
||||||
Please do not send general questions about PNG. Send them to
|
Please do not send general questions about PNG. Send them to
|
||||||
the (png-list at ccrc.wustl.edu, subscription required, write to
|
png-mng-misc at lists.sf.net (subscription required; visit
|
||||||
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
|
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
||||||
On the other hand,
|
subscribe). If you have a question about something
|
||||||
please do not send libpng questions to that address, send them to me
|
|
||||||
or to the png-implement list. I'll
|
|
||||||
get them in the end anyway. If you have a question about something
|
|
||||||
in the PNG specification that is related to using libpng, send it
|
in the PNG specification that is related to using libpng, send it
|
||||||
to me. Send me any questions that start with "I was using libpng,
|
to me. Send me any questions that start with "I was using libpng,
|
||||||
and ...". If in doubt, send questions to me. I'll bounce them
|
and ...". If in doubt, send questions to me. I'll bounce them
|
||||||
to others, if necessary.
|
to others, if necessary.
|
||||||
|
|
||||||
Please do not send suggestions on how to change PNG. We have
|
Please do not send suggestions on how to change PNG. We have
|
||||||
been discussing PNG for nine 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
|
finished. If you have suggestions for libpng, however, I'll
|
||||||
gladly listen. Even if your suggestion is not used immediately,
|
gladly listen. Even if your suggestion is not used immediately,
|
||||||
it may be used later.
|
it may be used later.
|
||||||
@@ -170,23 +178,25 @@ Files in this distribution:
|
|||||||
pngwrite.c => High-level write functions
|
pngwrite.c => High-level write functions
|
||||||
pngwtran.c => Write data transformations
|
pngwtran.c => Write data transformations
|
||||||
pngwutil.c => Write utility functions
|
pngwutil.c => Write utility functions
|
||||||
|
arm => Contains optimized code for the ARM platform
|
||||||
contrib => Contributions
|
contrib => Contributions
|
||||||
|
examples => Example programs
|
||||||
gregbook => source code for PNG reading and writing, from
|
gregbook => source code for PNG reading and writing, from
|
||||||
Greg Roelofs' "PNG: The Definitive Guide",
|
Greg Roelofs' "PNG: The Definitive Guide",
|
||||||
O'Reilly, 1999
|
O'Reilly, 1999
|
||||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
libtests => Test programs
|
||||||
pngminus => Simple pnm2png and png2pnm programs
|
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||||
pngsuite => Test images
|
programs demonstrating use of pngusr.dfa
|
||||||
visupng => Contains a MSVC workspace for VisualPng
|
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
|
projects => Contains project files and workspaces for
|
||||||
building a DLL
|
building a DLL
|
||||||
cbuilder5 => Contains a Borland workspace for building
|
owatcom => Contains a WATCOM project for building libpng
|
||||||
libpng and zlib
|
|
||||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
|
||||||
workspace for building libpng and zlib
|
|
||||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||||
workspace for building libpng and zlib
|
workspace for building libpng and zlib
|
||||||
xcode => Contains an Apple xcode
|
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||||
workspace for building libpng and zlib
|
workspace for building libpng and zlib
|
||||||
scripts => Directory containing scripts for building libpng:
|
scripts => Directory containing scripts for building libpng:
|
||||||
(see scripts/README.txt for the list of scripts)
|
(see scripts/README.txt for the list of scripts)
|
||||||
|
|||||||
2
TODO
@@ -6,10 +6,12 @@ Better C++ wrapper/full C++ implementation?
|
|||||||
Fix problem with C++ and EXTERN "C".
|
Fix problem with C++ and EXTERN "C".
|
||||||
cHRM transformation.
|
cHRM transformation.
|
||||||
Remove setjmp/longjmp usage in favor of returning error codes.
|
Remove setjmp/longjmp usage in favor of returning error codes.
|
||||||
|
Palette creation.
|
||||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||||
Improved dithering.
|
Improved dithering.
|
||||||
Multi-lingual error and warning message support.
|
Multi-lingual error and warning message support.
|
||||||
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
||||||
|
Make profile checking optional via a png_set_something() call.
|
||||||
Man pages for function calls.
|
Man pages for function calls.
|
||||||
Better documentation.
|
Better documentation.
|
||||||
Better filter selection
|
Better filter selection
|
||||||
|
|||||||
8949
aclocal.m4
vendored
251
autogen.sh
@@ -1,34 +1,225 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# a quick hack script to generate necessary files from
|
|
||||||
# auto* tools.
|
|
||||||
#
|
#
|
||||||
# WARNING: if you run this you will change the versions
|
# Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure
|
||||||
# of the tools which are used and, maybe, required!
|
# control files.
|
||||||
|
#
|
||||||
|
# The first time this is run on a GIT checkout the only files that exist are
|
||||||
|
# configure.ac and Makefile.am; all of the autotools support scripts are
|
||||||
|
# missing. They are instantiated with autoreconf --force --install.
|
||||||
|
#
|
||||||
|
# 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 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 (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.
|
||||||
|
#
|
||||||
|
clean=
|
||||||
|
maintainer=
|
||||||
|
while test $# -gt 0
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--maintainer)
|
||||||
|
maintainer=1;;
|
||||||
|
|
||||||
# You can define your own replacements in your environment.
|
--clean)
|
||||||
# $AUTOCONF, $AUTOMAKE, $AUTOHEADER, $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
|
clean=1;;
|
||||||
|
|
||||||
touch Makefile.am configure.ac
|
*)
|
||||||
{
|
exec >&2
|
||||||
LT=${LIBTOOLIZE-libtoolize}
|
echo "$0: usage: ./autogen.sh"
|
||||||
echo "running $LT" >&2
|
if test -d .git
|
||||||
$LT --force --copy --automake
|
then
|
||||||
} && {
|
echo " ./autogen.sh generates the configure script and"
|
||||||
AL=${ACLOCAL-aclocal}
|
echo " Makefile.in, or refreshes them after changes to Makefile.am"
|
||||||
echo "running $AL" >&2
|
echo " or configure.ac. You may prefer to just run autoreconf."
|
||||||
$AL
|
elif test -z "$maintainer"
|
||||||
} && {
|
then
|
||||||
AH=${AUTOHEADER-autoheader}
|
echo " DO NOT RUN THIS SCRIPT."
|
||||||
echo "running $AH [ignore the warnings]" >&2
|
echo " If you need to change Makefile.am or configure.ac then you"
|
||||||
$AH
|
echo " also need to run ./configure --enable-maintainer-mode and"
|
||||||
} && {
|
echo " use the appropriate autotools, *NOT* this script, to update"
|
||||||
AM=${AUTOMAKE-automake}
|
echo " everything, please check the documentation of autoreconf."
|
||||||
echo "running $AM" >&2
|
echo " WARNING: libpng is intentionally generated with a known,"
|
||||||
$AM --force-missing --foreign -a -c
|
echo " fixed, set of autotools. It is known *NOT* to work with"
|
||||||
} && {
|
echo " the collection of autotools distributed on highly reputable"
|
||||||
AC=${AUTOCONF-autoconf}
|
echo " operating systems."
|
||||||
echo "running $AC" >&2
|
echo " Remember: autotools is GNU software, you are expected to"
|
||||||
$AC
|
echo " pay for support."
|
||||||
} &&
|
else
|
||||||
echo "autogen complete" >&2 ||
|
echo " You have run autogen.sh with --maintainer enabled and you"
|
||||||
echo "ERROR: autogen.sh failed, autogen is incomplete" >&2
|
echo " are not using a GIT distribution, then you have given an"
|
||||||
|
echo " unrecognized argument. This is not good. --maintainer"
|
||||||
|
echo " switches off any assumptions that you might not know what"
|
||||||
|
echo " you are doing."
|
||||||
|
fi
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# First check for a set of the autotools files; if absent then this is assumed
|
||||||
|
# to be a GIT version and the local autotools must be used. If present this
|
||||||
|
# is a tarball distribution and the script should not be used. If partially
|
||||||
|
# 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\
|
||||||
|
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\
|
||||||
|
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
||||||
|
|
||||||
|
libpng_autotools_dirs="autom4te.cache" # not required
|
||||||
|
#
|
||||||
|
# The configure generated files:
|
||||||
|
libpng_configure_files="Makefile config.h config.log config.status\
|
||||||
|
libpng-config libpng.pc libtool stamp-h1"
|
||||||
|
|
||||||
|
libpng_configure_dirs=".deps"
|
||||||
|
#
|
||||||
|
# We must remove the configure generated files as well as the autotools
|
||||||
|
# generated files if autotools are regenerated because otherwise if configure
|
||||||
|
# has been run without "--enable-maintainer-mode" make can do a partial update
|
||||||
|
# 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(){
|
||||||
|
rm -rf $libpng_configure_files $libpng_configure_dirs
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# Clean: remove everything (this is to help with testing)
|
||||||
|
if test -n "$clean"
|
||||||
|
then
|
||||||
|
clean_configure
|
||||||
|
if test -n "$maintainer"
|
||||||
|
then
|
||||||
|
clean_autotools
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Validate the distribution.
|
||||||
|
libpng_autotools_file_found=
|
||||||
|
libpng_autotools_file_missing=
|
||||||
|
for file in $libpng_autotools_files
|
||||||
|
do
|
||||||
|
if test -f "$file"
|
||||||
|
then
|
||||||
|
libpng_autotools_file_found=1
|
||||||
|
else
|
||||||
|
libpng_autotools_file_missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# Presence of one of these does not *invalidate* missing, but absence
|
||||||
|
# invalidates found.
|
||||||
|
for file in $libpng_libtool_files
|
||||||
|
do
|
||||||
|
if test ! -f "$file"
|
||||||
|
then
|
||||||
|
libpng_autotools_file_missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# The cache directory doesn't matter - it will be regenerated and does not exist
|
||||||
|
# anyway in a tarball.
|
||||||
|
#
|
||||||
|
# Either everything is missing or everything is there, the --maintainer option
|
||||||
|
# just changes this so that the mode is set to generate all the files.
|
||||||
|
mode=
|
||||||
|
if test -z "$libpng_autotools_file_found" -o -n "$maintainer"
|
||||||
|
then
|
||||||
|
mode="autoreconf"
|
||||||
|
else
|
||||||
|
if test -n "$libpng_autotools_file_missing"
|
||||||
|
then
|
||||||
|
mode="broken"
|
||||||
|
else
|
||||||
|
mode="configure"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# So:
|
||||||
|
case "$mode" in
|
||||||
|
autoreconf)
|
||||||
|
# Clean in case configure files exist
|
||||||
|
clean_configure
|
||||||
|
clean_autotools
|
||||||
|
# Everything must be initialized, so use --force
|
||||||
|
if autoreconf --warnings=all --force --install
|
||||||
|
then
|
||||||
|
missing=
|
||||||
|
for file in $libpng_autotools_files
|
||||||
|
do
|
||||||
|
test -f "$file" || missing=1
|
||||||
|
done
|
||||||
|
# ignore the cache directory
|
||||||
|
test -z "$missing" || {
|
||||||
|
exec >&2
|
||||||
|
echo "autoreconf was run, but did not produce all the expected"
|
||||||
|
echo "files. It is likely that your autotools installation is"
|
||||||
|
echo "not compatible with that expected by libpng."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
exec >&2
|
||||||
|
echo "autoreconf failed: your version of autotools is incompatible"
|
||||||
|
echo "with this libpng version. Please use a distributed archive"
|
||||||
|
echo "(which includes the autotools generated files) and run configure"
|
||||||
|
echo "instead."
|
||||||
|
exit 1
|
||||||
|
fi;;
|
||||||
|
|
||||||
|
configure)
|
||||||
|
if test -d .git
|
||||||
|
then
|
||||||
|
exec >&2
|
||||||
|
echo "ERROR: running autoreconf on an initialized sytem"
|
||||||
|
echo " This is not necessary; it is only necessary to remake the"
|
||||||
|
echo " autotools generated files if Makefile.am or configure.ac"
|
||||||
|
echo " change and make does the right thing with:"
|
||||||
|
echo
|
||||||
|
echo " ./configure --enable-maintainer-mode."
|
||||||
|
echo
|
||||||
|
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 " compatibility with prior releases."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exec >&2
|
||||||
|
echo "autogen.sh is intended only to generate 'configure' on systems"
|
||||||
|
echo "that do not have it. You have a complete 'configure', if you"
|
||||||
|
echo "need to change Makefile.am or configure.ac you also need to"
|
||||||
|
echo "run configure with the --enable-maintainer-mode option."
|
||||||
|
exit 1
|
||||||
|
fi;;
|
||||||
|
|
||||||
|
broken)
|
||||||
|
exec >&2
|
||||||
|
echo "Your system has a partial set of autotools generated files."
|
||||||
|
echo "autogen.sh is unable to proceed. The full set of files is"
|
||||||
|
echo "contained in the libpng 'tar' distribution archive and you do"
|
||||||
|
echo "not need to run autogen.sh if you use it."
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|||||||
1561
config.guess
vendored
86
config.h.in
@@ -1,86 +0,0 @@
|
|||||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
|
||||||
#undef HAVE_DLFCN_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
|
||||||
#undef HAVE_INTTYPES_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `m' library (-lm). */
|
|
||||||
#undef HAVE_LIBM
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `z' library (-lz). */
|
|
||||||
#undef HAVE_LIBZ
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <malloc.h> header file. */
|
|
||||||
#undef HAVE_MALLOC_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
|
||||||
#undef HAVE_MEMORY_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `memset' function. */
|
|
||||||
#undef HAVE_MEMSET
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `pow' function. */
|
|
||||||
#undef HAVE_POW
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdint.h> header file. */
|
|
||||||
#undef HAVE_STDINT_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
|
||||||
#undef HAVE_STDLIB_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <strings.h> header file. */
|
|
||||||
#undef HAVE_STRINGS_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <string.h> header file. */
|
|
||||||
#undef HAVE_STRING_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
|
||||||
#undef HAVE_SYS_STAT_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
|
||||||
#undef HAVE_SYS_TYPES_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
|
||||||
#undef HAVE_UNISTD_H
|
|
||||||
|
|
||||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
|
||||||
*/
|
|
||||||
#undef LT_OBJDIR
|
|
||||||
|
|
||||||
/* Name of package */
|
|
||||||
#undef PACKAGE
|
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
|
||||||
#undef PACKAGE_BUGREPORT
|
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
|
||||||
#undef PACKAGE_NAME
|
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
|
||||||
#undef PACKAGE_STRING
|
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
|
||||||
#undef PACKAGE_TARNAME
|
|
||||||
|
|
||||||
/* Define to the home page for this package. */
|
|
||||||
#undef PACKAGE_URL
|
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
|
||||||
#undef PACKAGE_VERSION
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
|
||||||
#undef STDC_HEADERS
|
|
||||||
|
|
||||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
|
||||||
#undef TM_IN_SYS_TIME
|
|
||||||
|
|
||||||
/* Version number of package */
|
|
||||||
#undef VERSION
|
|
||||||
|
|
||||||
/* Define to empty if `const' does not conform to ANSI C. */
|
|
||||||
#undef const
|
|
||||||
|
|
||||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
|
||||||
#undef size_t
|
|
||||||
1686
config.sub
vendored
351
configure.ac
@@ -14,66 +14,271 @@ dnl Makefile.am to upgrade the package name.
|
|||||||
dnl This is here to prevent earlier autoconf from being used, it
|
dnl This is here to prevent earlier autoconf from being used, it
|
||||||
dnl should not be necessary to regenerate configure if the time
|
dnl should not be necessary to regenerate configure if the time
|
||||||
dnl stamps are correct
|
dnl stamps are correct
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ([2.68])
|
||||||
|
|
||||||
dnl Version number stuff here:
|
dnl Version number stuff here:
|
||||||
|
|
||||||
AC_INIT([libpng], [1.5.0beta55], [png-mng-implement@lists.sourceforge.net])
|
AC_INIT([libpng],[1.7.0beta65],[png-mng-implement@lists.sourceforge.net])
|
||||||
AM_INIT_AUTOMAKE
|
AC_CONFIG_MACRO_DIR([scripts])
|
||||||
dnl stop configure from automagically running automake
|
|
||||||
|
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||||
|
# color-tests requires automake 1.11 or later
|
||||||
|
# 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
|
||||||
|
# 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
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
PNGLIB_VERSION=1.5.0beta55
|
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||||
|
dnl version; aclocal.m4 will generate a failure if you use a prior version of
|
||||||
|
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.7.0beta65
|
||||||
PNGLIB_MAJOR=1
|
PNGLIB_MAJOR=1
|
||||||
PNGLIB_MINOR=5
|
PNGLIB_MINOR=7
|
||||||
PNGLIB_RELEASE=0
|
PNGLIB_RELEASE=0
|
||||||
|
|
||||||
dnl End of version number stuff
|
dnl End of version number stuff
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([pngget.c])
|
AC_CONFIG_SRCDIR([pngget.c])
|
||||||
AM_CONFIG_HEADER(config.h)
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
|
AC_LANG([C])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_LD
|
AM_PROG_AS
|
||||||
|
LT_PATH_LD
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AC_CHECK_TOOL(SED, sed, :)
|
AC_PROG_AWK
|
||||||
AC_CHECK_TOOL(AWK, awk, :)
|
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
|
|
||||||
|
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_INIT([win32-dll])
|
||||||
|
LT_PREREQ([2.4.4])
|
||||||
|
|
||||||
|
# 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([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
|
||||||
|
AC_ARG_VAR(PNG_COPTS,
|
||||||
|
[additional flags for the C compiler, use this for options that would]
|
||||||
|
[cause configure itself to fail])
|
||||||
|
AC_ARG_ENABLE(werror,
|
||||||
|
AS_HELP_STRING([[[--enable-werror[=OPT]]]],
|
||||||
|
[Pass -Werror or the given argument to the compiler if it is supported]),
|
||||||
|
[test "$enable_werror" = "yes" && enable_werror="-Werror"
|
||||||
|
if test "$enable_werror" != "no"; then
|
||||||
|
sav_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$enable_werror $CFLAGS"
|
||||||
|
AC_MSG_CHECKING([if the compiler allows $enable_werror])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([
|
||||||
|
[int main(int argc, char **argv){]
|
||||||
|
[return argv[argc-1][0];]
|
||||||
|
[}]])],
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
PNG_COPTS="$PNG_COPTS $enable_werror",
|
||||||
|
AC_MSG_RESULT(no))
|
||||||
|
CFLAGS="$sav_CFLAGS"
|
||||||
|
fi],)
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
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.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
# Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
|
||||||
AC_TYPE_SIZE_T
|
# behaviors and the result were, anyway, not used by earlier versions of libpng.
|
||||||
AC_STRUCT_TM
|
AC_C_RESTRICT
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions; these need to be in order, least demanding to
|
||||||
AC_FUNC_STRTOD
|
# most because the -l directives are added to the head of the list at each
|
||||||
AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc]))
|
# check.
|
||||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) )
|
# ANSI-C functions: all are required but they don't have to be implemented in
|
||||||
AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
|
# 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]))
|
||||||
|
|
||||||
LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG
|
# floor and ceil are required for FLOATING_POINT, but they can be turned off on
|
||||||
LIBPNG_DEFINES=$LIBPNG_DEFINES
|
# the configure command line (and they are independent.) Default is to 'on'
|
||||||
AC_SUBST(LIBPNG_DEFINES)
|
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_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`
|
||||||
|
if test "$SLD"; then
|
||||||
|
have_solaris_ld=yes
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
else
|
||||||
|
have_solaris_ld=no
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
|
||||||
|
|
||||||
AC_MSG_CHECKING([if libraries can be versioned])
|
AC_MSG_CHECKING([if libraries can be versioned])
|
||||||
# Special case for PE/COFF platforms: ld reports
|
# Special case for PE/COFF platforms: ld reports
|
||||||
# support for version-script, but doesn't actually
|
# support for version-script, but doesn't actually
|
||||||
# DO anything with it.
|
# DO anything with it.
|
||||||
case $host in
|
case $host in
|
||||||
*cygwin* | *mingw32* )
|
*cygwin* | *mingw32* | *interix* )
|
||||||
have_ld_version_script=no
|
have_ld_version_script=no
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
|
|
||||||
|
if test "$have_solaris_ld" = "yes"; then
|
||||||
|
GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
|
||||||
|
else
|
||||||
|
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$GLD"; then
|
if test "$GLD"; then
|
||||||
have_ld_version_script=yes
|
have_ld_version_script=yes
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
@@ -90,9 +295,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
|||||||
if test "$have_ld_version_script" = "yes"; then
|
if test "$have_ld_version_script" = "yes"; then
|
||||||
AC_MSG_CHECKING([for symbol prefix])
|
AC_MSG_CHECKING([for symbol prefix])
|
||||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
| ${DFNCPP-${CC-gcc -E}} - 2>&1 \
|
||||||
| ${EGREP-grep} "^PREFIX=" \
|
| ${EGREP-grep} "^PREFIX=" \
|
||||||
| ${SED-sed} "s:^PREFIX=::"`
|
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||||
AC_SUBST(SYMBOL_PREFIX)
|
AC_SUBST(SYMBOL_PREFIX)
|
||||||
AC_MSG_RESULT($SYMBOL_PREFIX)
|
AC_MSG_RESULT($SYMBOL_PREFIX)
|
||||||
fi
|
fi
|
||||||
@@ -106,31 +311,87 @@ AC_SUBST(PNGLIB_RELEASE)
|
|||||||
# Additional arguments (and substitutions)
|
# Additional arguments (and substitutions)
|
||||||
# Allow the pkg-config directory to be set
|
# Allow the pkg-config directory to be set
|
||||||
AC_ARG_WITH(pkgconfigdir,
|
AC_ARG_WITH(pkgconfigdir,
|
||||||
AC_HELP_STRING([--with-pkgconfigdir],
|
AS_HELP_STRING([[[--with-pkgconfigdir]]],
|
||||||
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
|
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
|
||||||
[pkgconfigdir=${withval}],
|
[pkgconfigdir=${withval}],
|
||||||
[pkgconfigdir='${libdir}/pkgconfig'])
|
[pkgconfigdir='${libdir}/pkgconfig'])
|
||||||
|
|
||||||
AC_SUBST([pkgconfigdir])
|
AC_SUBST([pkgconfigdir])
|
||||||
AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
|
AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
|
||||||
|
|
||||||
# Make the *-config binary config scripts optional
|
# Make the *-config binary config scripts optional
|
||||||
AC_ARG_WITH(binconfigs,
|
AC_ARG_WITH(binconfigs,
|
||||||
AC_HELP_STRING([--with-binconfigs],
|
AS_HELP_STRING([[[--with-binconfigs]]],
|
||||||
[Generate shell libpng-config scripts as well as pkg-config data]
|
[Generate shell libpng-config scripts as well as pkg-config data]
|
||||||
[@<:@default=yes@:>@]),
|
[@<:@default=yes@:>@]),
|
||||||
[if test "${withval}" = no; then
|
[if test "${withval}" = no; then
|
||||||
binconfigs=
|
binconfigs=
|
||||||
AC_MSG_NOTICE([libpng-config scripts will not be built])
|
AC_MSG_NOTICE([[libpng-config scripts will not be built]])
|
||||||
else
|
else
|
||||||
binconfigs='${binconfigs}'
|
binconfigs='${binconfigs}'
|
||||||
fi],
|
fi],
|
||||||
[binconfigs='${binconfigs}'])
|
[binconfigs='${binconfigs}'])
|
||||||
AC_SUBST([binconfigs])
|
AC_SUBST([binconfigs])
|
||||||
|
|
||||||
|
# Support for prefixes to the API function names; this will generate defines
|
||||||
|
# at the start of the build to rename exported library functions
|
||||||
|
AC_ARG_WITH(libpng-prefix,
|
||||||
|
AS_HELP_STRING([[[--with-libpng-prefix]]],
|
||||||
|
[prefix libpng exported function (API) names with the given value]),
|
||||||
|
[if test "${withval:-no}" != "no"; then
|
||||||
|
AC_SUBST([PNG_PREFIX], [${withval}])
|
||||||
|
fi])
|
||||||
|
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||||
|
|
||||||
|
# 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]))
|
||||||
|
|
||||||
|
# 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
|
# Config files, substituting as above
|
||||||
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
AC_CONFIG_FILES([Makefile libpng.pc])
|
||||||
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
|
||||||
[chmod +x libpng-config])
|
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
4
contrib/README.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
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.
|
||||||
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
|
||||||
|
* http://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.
|
||||||
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')
|
||||||
24
contrib/examples/README.txt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
This directory (contrib/examples) contains examples of libpng usage.
|
||||||
|
|
||||||
|
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
|
||||||
|
|
||||||
|
To the extent possible under law, the authors have waived all copyright and
|
||||||
|
related or neighboring rights to this work. This work is published from:
|
||||||
|
United States.
|
||||||
|
|
||||||
|
The files may be used freely in any way. The intention is that appropriate
|
||||||
|
parts of the files be used in other libpng-using programs without any need for
|
||||||
|
the authors of the using code to seek copyright or license from the original
|
||||||
|
authors.
|
||||||
|
|
||||||
|
The source code and comments in this directory are the original work of the
|
||||||
|
people named below. No other person or organization has made contributions to
|
||||||
|
the work in this directory.
|
||||||
|
|
||||||
|
ORIGINAL AUTHORS
|
||||||
|
The following people have contributed to the code in this directory. None
|
||||||
|
of the people below claim any rights with regard to the contents of this
|
||||||
|
directory.
|
||||||
|
|
||||||
|
John Bowler <jbowler@acm.org>
|
||||||
185
contrib/examples/iccfrompng.c
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
/*- iccfrompng
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Extract any icc profiles found in the given PNG files. This is a simple
|
||||||
|
* 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
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Compile and link against libpng and zlib, plus anything else required on the
|
||||||
|
* system you use.
|
||||||
|
*
|
||||||
|
* To use supply a list of PNG files containing iCCP chunks, the chunks will be
|
||||||
|
* extracted to a similarly named file with the extension replaced by 'icc',
|
||||||
|
* which will be overwritten without warning.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#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";
|
||||||
|
|
||||||
|
static png_bytep
|
||||||
|
extract(FILE *fp, png_uint_32 *proflen)
|
||||||
|
{
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||||
|
png_infop info_ptr = NULL;
|
||||||
|
png_bytep result = NULL;
|
||||||
|
|
||||||
|
/* Initialize for error or no profile: */
|
||||||
|
*proflen = 0;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "iccfrompng: version library mismatch?\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
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_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
{
|
||||||
|
png_charp name;
|
||||||
|
int compression_type;
|
||||||
|
png_bytep profile;
|
||||||
|
|
||||||
|
if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile,
|
||||||
|
proflen) & PNG_INFO_iCCP)
|
||||||
|
{
|
||||||
|
result = malloc(*proflen);
|
||||||
|
if (result != NULL)
|
||||||
|
memcpy(result, profile, *proflen);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "OOM allocating profile buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
result = no_profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
extract_one_file(const char *filename)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
FILE *fp = fopen(filename, "rb");
|
||||||
|
|
||||||
|
if (fp != NULL)
|
||||||
|
{
|
||||||
|
png_uint_32 proflen = 0;
|
||||||
|
png_bytep profile = extract(fp, &proflen);
|
||||||
|
|
||||||
|
if (profile != NULL && profile != no_profile)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *output;
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *ep = strrchr(filename, '.');
|
||||||
|
|
||||||
|
if (ep != NULL)
|
||||||
|
len = ep-filename;
|
||||||
|
|
||||||
|
else
|
||||||
|
len = strlen(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
output = malloc(len + 5);
|
||||||
|
if (output != NULL)
|
||||||
|
{
|
||||||
|
FILE *of;
|
||||||
|
|
||||||
|
memcpy(output, filename, len);
|
||||||
|
strcpy(output+len, ".icc");
|
||||||
|
|
||||||
|
of = fopen(output, "wb");
|
||||||
|
if (of != NULL)
|
||||||
|
{
|
||||||
|
if (fwrite(profile, proflen, 1, of) == 1 &&
|
||||||
|
fflush(of) == 0 &&
|
||||||
|
fclose(of) == 0)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
printf("%s -> %s\n", filename, output);
|
||||||
|
/* Success return */
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: error writing profile\n", output);
|
||||||
|
if (remove(output))
|
||||||
|
fprintf(stderr, "%s: could not remove file\n", output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: failed to open output file\n", output);
|
||||||
|
|
||||||
|
free(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: OOM allocating string!\n", filename);
|
||||||
|
|
||||||
|
free(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (verbose && profile == no_profile)
|
||||||
|
printf("%s has no profile\n", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: could not open file\n", filename);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int extracted = 0;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[i], "-q") == 0)
|
||||||
|
verbose = 0;
|
||||||
|
|
||||||
|
else if (extract_one_file(argv[i]))
|
||||||
|
extracted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Exit code is true if any extract succeeds */
|
||||||
|
return extracted == 0;
|
||||||
|
}
|
||||||
|
#endif /* READ && STDIO && iCCP */
|
||||||
371
contrib/examples/pngpixel.c
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
/*- pngpixel
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||||
|
* 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 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
|
||||||
|
* then printed on stdout.
|
||||||
|
*
|
||||||
|
* The code illustrates how to do this on interlaced as well as non-interlaced
|
||||||
|
* images. Normally you would call png_set_interlace_handling() to have libpng
|
||||||
|
* deal with the interlace for you, but that obliges you to buffer half of the
|
||||||
|
* image to assemble the interlaced rows. In this code
|
||||||
|
* png_set_interlace_handling() is not called and, instead, the code handles the
|
||||||
|
* interlace passes directly looking for the required pixel.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <setjmp.h> /* required for error handling */
|
||||||
|
|
||||||
|
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||||
|
* ensure the code picks up the local libpng implementation:
|
||||||
|
*/
|
||||||
|
#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,
|
||||||
|
unsigned int bit_depth, unsigned int channels)
|
||||||
|
{
|
||||||
|
/* PNG images can be up to 2^31 pixels wide, but this means they can be up to
|
||||||
|
* 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34
|
||||||
|
* bytes wide. Since the row fitted into memory, however, the following must
|
||||||
|
* work:
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
row += bit_offset_lo >> 3;
|
||||||
|
bit_offset_lo &= 0x07;
|
||||||
|
|
||||||
|
/* PNG pixels are packed into bytes to put the first pixel in the highest
|
||||||
|
* bits of the byte and into two bytes for 16-bit values with the high 8 bits
|
||||||
|
* first, so:
|
||||||
|
*/
|
||||||
|
switch (bit_depth)
|
||||||
|
{
|
||||||
|
case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01;
|
||||||
|
case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03;
|
||||||
|
case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f;
|
||||||
|
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
|
||||||
|
* libpng itself:
|
||||||
|
*/
|
||||||
|
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a pixel from a row returned by libpng; determine the row format, find
|
||||||
|
* the pixel, and print the relevant information to stdout.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||||
|
png_uint_32 x)
|
||||||
|
{
|
||||||
|
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
switch (png_get_color_type(png_ptr, info_ptr))
|
||||||
|
{
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
printf("GRAY %u\n", component(row, x, 0, bit_depth, 1));
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* The palette case is slightly more difficult - the palette and, if
|
||||||
|
* present, the tRNS ('transparency', though the values are really
|
||||||
|
* opacity) data must be read to give the full picture:
|
||||||
|
*/
|
||||||
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
|
{
|
||||||
|
PNG_CONST int index = component(row, x, 0, bit_depth, 1);
|
||||||
|
png_colorp palette = NULL;
|
||||||
|
int num_palette = 0;
|
||||||
|
|
||||||
|
if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) &
|
||||||
|
PNG_INFO_PLTE) && num_palette > 0 && palette != NULL)
|
||||||
|
{
|
||||||
|
png_bytep trans_alpha = NULL;
|
||||||
|
int num_trans = 0;
|
||||||
|
if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans,
|
||||||
|
NULL) & PNG_INFO_tRNS) && num_trans > 0 &&
|
||||||
|
trans_alpha != NULL)
|
||||||
|
printf("INDEXED %u = %d %d %d %d\n", index,
|
||||||
|
palette[index].red, palette[index].green,
|
||||||
|
palette[index].blue,
|
||||||
|
index < num_trans ? trans_alpha[index] : 255);
|
||||||
|
|
||||||
|
else /* no transparency */
|
||||||
|
printf("INDEXED %u = %d %d %d\n", index,
|
||||||
|
palette[index].red, palette[index].green,
|
||||||
|
palette[index].blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
printf("INDEXED %u = invalid index\n", index);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3),
|
||||||
|
component(row, x, 1, bit_depth, 3),
|
||||||
|
component(row, x, 2, bit_depth, 3));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
|
printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2),
|
||||||
|
component(row, x, 1, bit_depth, 2));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
|
printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4),
|
||||||
|
component(row, x, 1, bit_depth, 4),
|
||||||
|
component(row, x, 2, bit_depth, 4),
|
||||||
|
component(row, x, 3, bit_depth, 4));
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_error(png_ptr, "pngpixel: invalid color type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
/* This program uses the default, <setjmp.h> based, libpng error handling
|
||||||
|
* mechanism, therefore any local variable that exists before the call to
|
||||||
|
* setjmp and is changed after the call to setjmp returns successfully must
|
||||||
|
* be declared with 'volatile' to ensure that their values don't get
|
||||||
|
* destroyed by longjmp:
|
||||||
|
*/
|
||||||
|
volatile int result = 1/*fail*/;
|
||||||
|
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
long x = atol(argv[1]);
|
||||||
|
long y = atol(argv[2]);
|
||||||
|
FILE *f = fopen(argv[3], "rb");
|
||||||
|
volatile png_bytep row = NULL;
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
{
|
||||||
|
/* libpng requires a callback function for handling errors; this
|
||||||
|
* callback must not return. The default callback function uses a
|
||||||
|
* stored <setjmp.h> style jmp_buf which is held in a png_struct and
|
||||||
|
* writes error messages to stderr. Creating the png_struct is a
|
||||||
|
* little tricky; just copy the following code.
|
||||||
|
*/
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
|
if (info_ptr != NULL)
|
||||||
|
{
|
||||||
|
/* Declare stack variables to hold pointers to locally allocated
|
||||||
|
* data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Initialize the error control buffer: */
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)) == 0)
|
||||||
|
{
|
||||||
|
png_uint_32 width, height;
|
||||||
|
int bit_depth, color_type, interlace_method,
|
||||||
|
compression_method, filter_method;
|
||||||
|
png_bytep row_tmp;
|
||||||
|
|
||||||
|
/* Now associate the recently opened (FILE*) with the default
|
||||||
|
* libpng initialization functions. Sometimes libpng is
|
||||||
|
* compiled without stdio support (it can be difficult to do
|
||||||
|
* in some environments); in that case you will have to write
|
||||||
|
* your own read callback to read data from the (FILE*).
|
||||||
|
*/
|
||||||
|
png_init_io(png_ptr, f);
|
||||||
|
|
||||||
|
/* And read the first part of the PNG file - the header and
|
||||||
|
* all the information up to the first pixel.
|
||||||
|
*/
|
||||||
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* This fills in enough information to tell us the width of
|
||||||
|
* each row in bytes, allocate the appropriate amount of
|
||||||
|
* space. In this case png_malloc is used - it will not
|
||||||
|
* return if memory isn't available.
|
||||||
|
*/
|
||||||
|
row = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||||
|
info_ptr));
|
||||||
|
|
||||||
|
/* To avoid the overhead of using a volatile auto copy row_tmp
|
||||||
|
* to a local here - just use row for the png_free below.
|
||||||
|
*/
|
||||||
|
row_tmp = row;
|
||||||
|
|
||||||
|
/* All the information we need is in the header is returned by
|
||||||
|
* png_get_IHDR, if this fails we can now use 'png_error' to
|
||||||
|
* signal the error and return control to the setjmp above.
|
||||||
|
*/
|
||||||
|
if (png_get_IHDR(png_ptr, info_ptr, &width, &height,
|
||||||
|
&bit_depth, &color_type, &interlace_method,
|
||||||
|
&compression_method, &filter_method))
|
||||||
|
{
|
||||||
|
int passes, pass;
|
||||||
|
|
||||||
|
/* png_set_interlace_handling returns the number of
|
||||||
|
* passes required as well as turning on libpng's
|
||||||
|
* handling, but since we do it ourselves this is
|
||||||
|
* necessary:
|
||||||
|
*/
|
||||||
|
switch (interlace_method)
|
||||||
|
{
|
||||||
|
case PNG_INTERLACE_NONE:
|
||||||
|
passes = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PNG_INTERLACE_ADAM7:
|
||||||
|
passes = PNG_INTERLACE_ADAM7_PASSES;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_error(png_ptr, "pngpixel: unknown interlace");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now read the pixels, pass-by-pass, row-by-row: */
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass=0; pass<passes; ++pass)
|
||||||
|
{
|
||||||
|
png_uint_32 ystart, xstart, ystep, xstep;
|
||||||
|
png_uint_32 py;
|
||||||
|
|
||||||
|
if (interlace_method == PNG_INTERLACE_ADAM7)
|
||||||
|
{
|
||||||
|
/* Sometimes the whole pass is empty because the
|
||||||
|
* image is too narrow or too short. libpng
|
||||||
|
* expects to be called for each row that is
|
||||||
|
* present in the pass, so it may be necessary to
|
||||||
|
* skip the loop below (over py) if the image is
|
||||||
|
* too narrow.
|
||||||
|
*/
|
||||||
|
if (PNG_PASS_COLS(width, pass) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* We need the starting pixel and the offset
|
||||||
|
* between each pixel in this pass; use the macros
|
||||||
|
* in png.h:
|
||||||
|
*/
|
||||||
|
xstart = PNG_PASS_START_COL(pass);
|
||||||
|
ystart = PNG_PASS_START_ROW(pass);
|
||||||
|
xstep = PNG_PASS_COL_OFFSET(pass);
|
||||||
|
ystep = PNG_PASS_ROW_OFFSET(pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ystart = xstart = 0;
|
||||||
|
ystep = xstep = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To find the pixel, loop over 'py' for each pass
|
||||||
|
* reading a row and then checking to see if it
|
||||||
|
* contains the pixel.
|
||||||
|
*/
|
||||||
|
for (py = ystart; py < height; py += ystep)
|
||||||
|
{
|
||||||
|
png_uint_32 px, ppx;
|
||||||
|
|
||||||
|
/* png_read_row takes two pointers. When libpng
|
||||||
|
* handles the interlace the first is filled in
|
||||||
|
* pixel-by-pixel, and the second receives the same
|
||||||
|
* pixels but they are replicated across the
|
||||||
|
* unwritten pixels so far for each pass. When we
|
||||||
|
* do the interlace, however, they just contain
|
||||||
|
* the pixels from the interlace pass - giving
|
||||||
|
* both is wasteful and pointless, so we pass a
|
||||||
|
* NULL pointer.
|
||||||
|
*/
|
||||||
|
png_read_row(png_ptr, row_tmp, NULL);
|
||||||
|
|
||||||
|
/* Now find the pixel if it is in this row; there
|
||||||
|
* are, of course, much better ways of doing this
|
||||||
|
* than using a for loop:
|
||||||
|
*/
|
||||||
|
if (y == py) for (px = xstart, ppx = 0;
|
||||||
|
px < width; px += xstep, ++ppx) if (x == px)
|
||||||
|
{
|
||||||
|
/* 'ppx' is the index of the pixel in the row
|
||||||
|
* buffer.
|
||||||
|
*/
|
||||||
|
print_pixel(png_ptr, info_ptr, row_tmp, ppx);
|
||||||
|
|
||||||
|
/* Now terminate the loops early - we have
|
||||||
|
* found and handled the required data.
|
||||||
|
*/
|
||||||
|
goto pass_loop_end;
|
||||||
|
} /* x loop */
|
||||||
|
} /* y loop */
|
||||||
|
} /* pass loop */
|
||||||
|
|
||||||
|
/* Finally free the temporary buffer: */
|
||||||
|
pass_loop_end:
|
||||||
|
row = NULL;
|
||||||
|
png_free(png_ptr, row_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "pngpixel: png_get_IHDR failed");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Else libpng has raised an error. An error message has
|
||||||
|
* already been output, so it is only necessary to clean up
|
||||||
|
* locally allocated data:
|
||||||
|
*/
|
||||||
|
if (row != NULL)
|
||||||
|
{
|
||||||
|
/* The default implementation of png_free never errors out
|
||||||
|
* (it just crashes if something goes wrong), but the safe
|
||||||
|
* way of using it is still to clear 'row' before calling
|
||||||
|
* png_free:
|
||||||
|
*/
|
||||||
|
png_bytep row_tmp = row;
|
||||||
|
row = NULL;
|
||||||
|
png_free(png_ptr, row_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_destroy_info_struct(png_ptr, &info_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: out of memory allocating png_info\n");
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: out of memory allocating png_struct\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: %s: could not open file\n", argv[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Wrong number of arguments */
|
||||||
|
fprintf(stderr, "pngpixel: usage: pngpixel x y png-file\n");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* READ && SEQUENTIAL_READ */
|
||||||
95
contrib/examples/pngtopng.c
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*- pngtopng
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||||
|
* 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 a PNG and write it out in a fixed format, using the 'simplified API'
|
||||||
|
* that was introduced in libpng-1.6.0.
|
||||||
|
*
|
||||||
|
* This sample code is just the code from the top of 'example.c' with some error
|
||||||
|
* handling added. See example.c for more comments.
|
||||||
|
*/
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.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:
|
||||||
|
*/
|
||||||
|
#include "../../png.h"
|
||||||
|
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
|
||||||
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
int result = 1;
|
||||||
|
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
png_image image;
|
||||||
|
|
||||||
|
/* Only the image structure version number needs to be set. */
|
||||||
|
memset(&image, 0, sizeof image);
|
||||||
|
image.version = PNG_IMAGE_VERSION;
|
||||||
|
|
||||||
|
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||||
|
{
|
||||||
|
png_bytep buffer;
|
||||||
|
|
||||||
|
/* Change this to try different formats! If you set a colormap format
|
||||||
|
* then you must also supply a colormap below.
|
||||||
|
*/
|
||||||
|
image.format = PNG_FORMAT_RGBA;
|
||||||
|
|
||||||
|
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 */))
|
||||||
|
{
|
||||||
|
if (png_image_write_to_file(&image, argv[2],
|
||||||
|
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||||
|
NULL/*colormap*/))
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||||
|
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Failed to read the first argument: */
|
||||||
|
fprintf(stderr, "pngtopng: %s: %s\n", argv[1], image.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Wrong number of arguments */
|
||||||
|
fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
|
||||||
|
|
||||||
|
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
|
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
RM = rm -f
|
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")]
|
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||||
# [-ansi, -pedantic and -W can also be used]
|
# [-ansi, -pedantic and -W can also be used]
|
||||||
LDFLAGS = $(MINGW_LDFLAGS)
|
LDFLAGS = $(MINGW_LDFLAGS)
|
||||||
@@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
%.pic$(O): %.c
|
%.pic$(O): %.c
|
||||||
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
PNGINC = -I/usr/local/include/libpng15
|
PNGINC = -I/usr/local/include/libpng17
|
||||||
PNGLIB = -L/usr/local/lib -lpng15 # dynamically linked against libpng
|
PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
|
||||||
#PNGLIB = /usr/local/lib/libpng15.a # statically linked against libpng
|
#PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
|
||||||
# or:
|
# or:
|
||||||
#PNGINC = -I../..
|
#PNGINC = -I../..
|
||||||
#PNGLIB = -L../.. -lpng
|
#PNGLIB = -L../.. -lpng
|
||||||
@@ -53,7 +53,8 @@ CC = cc
|
|||||||
LD = cc
|
LD = cc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
# ABI must be the same as that used to build libpng.
|
# ABI must be the same as that used to build libpng.
|
||||||
ABI=
|
ABI =
|
||||||
|
CPPFLAGS =
|
||||||
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
||||||
LDFLAGS = $(ABI)
|
LDFLAGS = $(ABI)
|
||||||
O = .o
|
O = .o
|
||||||
@@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|||||||
@@ -26,14 +26,14 @@
|
|||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
#PNGDIR = /usr/local/lib
|
#PNGDIR = /usr/local/lib
|
||||||
#PNGINC = -I/usr/local/include/libpng15
|
#PNGINC = -I/usr/local/include/libpng17
|
||||||
#PNGLIBd = -L$(PNGDIR) -lpng15 # dynamically linked, installed libpng
|
#PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
|
||||||
#PNGLIBs = $(PNGDIR)/libpng15.a # statically linked, installed libpng
|
#PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
|
||||||
# or:
|
# or:
|
||||||
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
||||||
#PNGDIR = ../libpng
|
#PNGDIR = ../libpng
|
||||||
PNGINC = -I$(PNGDIR)
|
PNGINC = -I$(PNGDIR)
|
||||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng15 # dynamically linked
|
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
|
||||||
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
||||||
|
|
||||||
ZDIR = /usr/local/lib
|
ZDIR = /usr/local/lib
|
||||||
@@ -64,7 +64,8 @@ WLIBSs = $(PNGLIBs) $(ZLIBs)
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
RM = rm -f
|
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")]
|
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||||
# [-ansi, -pedantic and -W can also be used]
|
# [-ansi, -pedantic and -W can also be used]
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
@@ -92,7 +93,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# "c:\windows\command.com /e:4096" as the program command line and set the
|
# "c:\windows\command.com /e:4096" as the program command line and set the
|
||||||
# working directory to this directory. Then double-click to open the new
|
# working directory to this directory. Then double-click to open the new
|
||||||
# DOS-prompt window with a bigger environment and retry the commands above.
|
# DOS-prompt window with a bigger environment and retry the commands above.
|
||||||
#
|
#
|
||||||
# This makefile assumes libpng and zlib have already been built or downloaded
|
# This makefile assumes libpng and zlib have already been built or downloaded
|
||||||
# and are in subdirectories at the same level as the current subdirectory
|
# and are in subdirectories at the same level as the current subdirectory
|
||||||
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
|
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
|
||||||
@@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB)
|
|||||||
CC = cl
|
CC = cl
|
||||||
LD = link
|
LD = link
|
||||||
RM = del
|
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")]
|
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
|
||||||
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
||||||
O = .obj
|
O = .obj
|
||||||
@@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ BUILD INSTRUCTIONS
|
|||||||
unpacked the source code.
|
unpacked the source code.
|
||||||
|
|
||||||
For MSVC, set up the necessary environment variables by invoking
|
For MSVC, set up the necessary environment variables by invoking
|
||||||
|
|
||||||
%devstudio%\vc\bin\vcvars32.bat
|
%devstudio%\vc\bin\vcvars32.bat
|
||||||
|
|
||||||
where where %devstudio% is the installation directory for MSVC /
|
where where %devstudio% is the installation directory for MSVC /
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ $ if zpath .eqs. ""
|
|||||||
$ then
|
$ then
|
||||||
$ write sys$output "zlib include not found. Exiting..."
|
$ write sys$output "zlib include not found. Exiting..."
|
||||||
$ exit 2
|
$ exit 2
|
||||||
$ endif
|
$ endif
|
||||||
$!
|
$!
|
||||||
$ if pngpath .eqs. ""
|
$ if pngpath .eqs. ""
|
||||||
$ then
|
$ then
|
||||||
$ write sys$output "libpng include not found. Exiting..."
|
$ write sys$output "libpng include not found. Exiting..."
|
||||||
$ exit 2
|
$ exit 2
|
||||||
$ endif
|
$ endif
|
||||||
$!
|
$!
|
||||||
$! Look for the compiler used.
|
$! Look for the compiler used.
|
||||||
$!
|
$!
|
||||||
|
|||||||
@@ -55,8 +55,9 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "png.h" /* libpng header; includes zlib.h */
|
#include "png.h" /* libpng header */
|
||||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||||
|
|
||||||
/* future versions of libpng will provide this macro: */
|
/* future versions of libpng will provide this macro: */
|
||||||
@@ -214,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
|||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
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);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -229,8 +234,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
|||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
|
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
png_set_scale_16(png_ptr);
|
||||||
|
# else
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
|||||||
png_uint_32 row_num, int pass);
|
png_uint_32 row_num, int pass);
|
||||||
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
|
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_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||||
|
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
|||||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
||||||
readpng2_error_handler, NULL);
|
readpng2_error_handler, readpng2_warning_handler);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
|
||||||
@@ -136,29 +137,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
|||||||
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
||||||
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
||||||
{
|
{
|
||||||
/* These byte strings were copied from png.h. If a future libpng
|
/* These byte strings were copied from png.h. If a future version
|
||||||
* version recognizes more chunks, add them to this list. If a
|
* of readpng2.c recognizes more chunks, add them to this list.
|
||||||
* future version of readpng2.c recognizes more chunks, delete them
|
*/
|
||||||
* from this list. */
|
static PNG_CONST png_byte chunks_to_process[] = {
|
||||||
static /* const */ png_byte chunks_to_ignore[] = {
|
98, 75, 71, 68, '\0', /* bKGD */
|
||||||
99, 72, 82, 77, '\0', /* cHRM */
|
103, 65, 77, 65, '\0', /* gAMA */
|
||||||
104, 73, 83, 84, '\0', /* hIST */
|
115, 82, 71, 66, '\0', /* sRGB */
|
||||||
105, 67, 67, 80, '\0', /* iCCP */
|
};
|
||||||
105, 84, 88, 116, '\0', /* iTXt */
|
|
||||||
111, 70, 70, 115, '\0', /* oFFs */
|
|
||||||
112, 67, 65, 76, '\0', /* pCAL */
|
|
||||||
112, 72, 89, 115, '\0', /* pHYs */
|
|
||||||
115, 66, 73, 84, '\0', /* sBIT */
|
|
||||||
115, 67, 65, 76, '\0', /* sCAL */
|
|
||||||
115, 80, 76, 84, '\0', /* sPLT */
|
|
||||||
115, 84, 69, 82, '\0', /* sTER */
|
|
||||||
116, 69, 88, 116, '\0', /* tEXt */
|
|
||||||
116, 73, 77, 69, '\0', /* tIME */
|
|
||||||
122, 84, 88, 116, '\0' /* zTXt */
|
|
||||||
};
|
|
||||||
|
|
||||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
/* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
|
||||||
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
|
png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||||
|
NULL, -1);
|
||||||
|
|
||||||
|
/* But do not ignore chunks in the "chunks_to_process" list */
|
||||||
|
png_set_keep_unknown_chunks(png_ptr,
|
||||||
|
0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
|
||||||
|
sizeof(chunks_to_process)/5);
|
||||||
}
|
}
|
||||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||||
|
|
||||||
@@ -311,8 +306,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
|
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
png_set_scale_16(png_ptr);
|
||||||
|
# else
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
@@ -447,6 +448,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
/* all done */
|
/* all done */
|
||||||
|
|
||||||
|
(void)info_ptr; /* Unused */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +470,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)
|
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 */
|
/* 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;
|
return image_data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,8 +252,8 @@ int main(int argc, char **argv)
|
|||||||
else {
|
else {
|
||||||
bgstr = *argv;
|
bgstr = *argv;
|
||||||
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
if (strlen(bgstr) != 7 || bgstr[0] != '#')
|
||||||
++error;
|
++error;
|
||||||
else
|
else
|
||||||
have_bg = TRUE;
|
have_bg = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
"(unexpectedly) while reading PNG image file\n");
|
"(unexpectedly) while reading PNG image file\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
} else /* if (error) */ {
|
} else /* if (error) */ {
|
||||||
// will print error message below
|
/* will print error message below */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,12 @@
|
|||||||
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
|
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
|
||||||
paste bugs
|
paste bugs
|
||||||
- 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options
|
- 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,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
@@ -95,7 +97,7 @@
|
|||||||
|
|
||||||
#define PROGNAME "rpng2-x"
|
#define PROGNAME "rpng2-x"
|
||||||
#define LONGNAME "Progressive PNG Viewer for 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 RESNAME "rpng2" /* our X resource application name */
|
||||||
#define RESCLASS "Rpng" /* our X resource class name */
|
#define RESCLASS "Rpng" /* our X resource class name */
|
||||||
|
|
||||||
@@ -111,6 +113,19 @@
|
|||||||
#include <X11/Xos.h>
|
#include <X11/Xos.h>
|
||||||
#include <X11/keysym.h> /* defines XK_* macros */
|
#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
|
#ifdef VMS
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -456,40 +471,47 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||||
readpng2_version_info();
|
readpng2_version_info();
|
||||||
fprintf(stderr, "\n"
|
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
|
#ifdef FEATURE_LOOP
|
||||||
" %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n"
|
" [-loop [sec]]"
|
||||||
#else
|
|
||||||
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
|
|
||||||
#endif
|
#endif
|
||||||
|
" file.png\n\n");
|
||||||
|
fprintf(stderr,
|
||||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\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"
|
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||||
" bg \tdesired background color in 7-character hex RGB format\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 (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||||
"\t\t used with transparent images; overrides -bgpat\n"
|
"\t\t used with transparent images; overrides -bgpat\n"
|
||||||
" pat \tdesired background pattern number (0-%d); used with\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
|
#ifdef FEATURE_LOOP
|
||||||
|
fprintf(stderr,
|
||||||
" -loop\tloops through background images after initial display\n"
|
" -loop\tloops through background images after initial display\n"
|
||||||
"\t\t is complete (depends on -bgpat)\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
|
#endif
|
||||||
|
fprintf(stderr,
|
||||||
" dur \tduration in microseconds to wait after displaying each\n"
|
" dur \tduration in microseconds to wait after displaying each\n"
|
||||||
"\t\t row (for demo purposes)\n"
|
"\t\t row (for demo purposes)\n"
|
||||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||||
"\t\t download of image (~36 Kbps)\n"
|
"\t\t download of image (~36 Kbps)\n"
|
||||||
" -pause\tpauses after displaying each pass until mouse clicked\n"
|
" -pause\tpauses after displaying each pass until mouse clicked\n"
|
||||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||||
"is displayed) to quit.\n"
|
"is displayed) to quit.\n");
|
||||||
"\n", PROGNAME,
|
|
||||||
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(infile = fopen(filename, "rb"))) {
|
if (!(infile = fopen(filename, "rb"))) {
|
||||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||||
++error;
|
++error;
|
||||||
@@ -591,7 +613,7 @@ int main(int argc, char **argv)
|
|||||||
"(unexpectedly) while reading PNG image file\n");
|
"(unexpectedly) while reading PNG image file\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
} else /* if (error) */ {
|
} else /* if (error) */ {
|
||||||
// will print error message below
|
/* will print error message below */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -735,6 +757,8 @@ int main(int argc, char **argv)
|
|||||||
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
|
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
|
||||||
rpng2_x_cleanup();
|
rpng2_x_cleanup();
|
||||||
|
|
||||||
|
(void)argc; /* Unused */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1826,6 +1850,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow,
|
|||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)startcol;
|
||||||
|
(void)width;
|
||||||
|
|
||||||
} /* end function rpng2_x_redisplay_image() */
|
} /* end function rpng2_x_redisplay_image() */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdlib.h> /* for exit() prototype */
|
#include <stdlib.h> /* for exit() prototype */
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
#include "png.h" /* libpng header, includes setjmp.h */
|
||||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
102
contrib/libtests/gentests.sh
Executable file
@@ -0,0 +1,102 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 John Cunningham Bowler
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# and license in png.h
|
||||||
|
#
|
||||||
|
# Generate a set of PNG test images. The images are generated in a
|
||||||
|
# sub-directory called 'tests' by default, however a command line argument will
|
||||||
|
# change that name. The generation requires a built version of makepng in the
|
||||||
|
# current directory.
|
||||||
|
#
|
||||||
|
usage(){
|
||||||
|
exec >&2
|
||||||
|
echo "$0 [<directory>]"
|
||||||
|
echo ' Generate a set of PNG test files in "directory" ("tests" by default)'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mp="$PWD/makepng"
|
||||||
|
test -x "$mp" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$0: the 'makepng' program must exist"
|
||||||
|
echo " in the directory within which this program:"
|
||||||
|
echo " $mp"
|
||||||
|
echo " is executed"
|
||||||
|
usage
|
||||||
|
}
|
||||||
|
|
||||||
|
# Just one argument: the directory
|
||||||
|
testdir="tests"
|
||||||
|
test $# -gt 1 && {
|
||||||
|
testdir="$1"
|
||||||
|
shift
|
||||||
|
}
|
||||||
|
test $# -eq 0 || usage
|
||||||
|
|
||||||
|
# Take care not to clobber something
|
||||||
|
if test -e "$testdir"
|
||||||
|
then
|
||||||
|
test -d "$testdir" || usage
|
||||||
|
else
|
||||||
|
# mkdir -p isn't portable, so do the following
|
||||||
|
mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This fails in a very satisfactory way if it's not accessible
|
||||||
|
cd "$testdir"
|
||||||
|
:>"test$$.png" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$testdir: directory not writable"
|
||||||
|
usage
|
||||||
|
}
|
||||||
|
rm "test$$.png" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$testdir: you have create but not write privileges here."
|
||||||
|
echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"."
|
||||||
|
echo " You need to remove this yourself. Try a different directory."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now call makepng ($mp) to create every file we can think of with a
|
||||||
|
# reasonable name
|
||||||
|
doit(){
|
||||||
|
for gamma in "" --sRGB --linear --1.8
|
||||||
|
do
|
||||||
|
case "$gamma" in
|
||||||
|
"")
|
||||||
|
gname=;;
|
||||||
|
--sRGB)
|
||||||
|
gname="-srgb";;
|
||||||
|
--linear)
|
||||||
|
gname="-lin";;
|
||||||
|
--1.8)
|
||||||
|
gname="-18";;
|
||||||
|
*)
|
||||||
|
gname="-$gamma";;
|
||||||
|
esac
|
||||||
|
"$mp" $gamma "$1" "$2" "test-$1-$2$gname.png"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#
|
||||||
|
for ct in gray palette
|
||||||
|
do
|
||||||
|
for bd in 1 2 4 8
|
||||||
|
do
|
||||||
|
doit "$ct" "$bd"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
#
|
||||||
|
doit "gray" "16"
|
||||||
|
#
|
||||||
|
for ct in gray-alpha rgb rgb-alpha
|
||||||
|
do
|
||||||
|
for bd in 8 16
|
||||||
|
do
|
||||||
|
doit "$ct" "$bd"
|
||||||
|
done
|
||||||
|
done
|
||||||
1490
contrib/libtests/makepng.c
Normal file
1686
contrib/libtests/pngimage.c
Normal file
3853
contrib/libtests/pngstest.c
Normal file
1261
contrib/libtests/pngunknown.c
Normal file
11625
contrib/libtests/pngvalid.c
Normal file
121
contrib/libtests/readpng.c
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/* 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
|
||||||
|
|
||||||
|
#if PNG_LIBPNG_VER < 10700
|
||||||
|
/* READ_INTERLACING was used instead of READ_DEINTERLACE. */
|
||||||
|
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
# define PNG_READ_DEINTERLACE_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#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);
|
||||||
|
|
||||||
|
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_DEINTERLACE_SUPPORTED
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
# else
|
||||||
|
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
|
||||||
|
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
|
||||||
|
# endif
|
||||||
|
int pass;
|
||||||
|
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass = 0; pass < passes; ++pass)
|
||||||
|
{
|
||||||
|
png_uint_32 y = height;
|
||||||
|
|
||||||
|
# ifndef PNG_READ_DEINTERLACE_SUPPORTED
|
||||||
|
if (passes == PNG_INTERLACE_ADAM7_PASSES)
|
||||||
|
y = PNG_PASS_ROWS(y, pass);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
999
contrib/libtests/tarith.c
Normal file
@@ -0,0 +1,999 @@
|
|||||||
|
|
||||||
|
/* tarith.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* Test internal arithmetic functions of libpng.
|
||||||
|
*
|
||||||
|
* This code must be linked against a math library (-lm), but does not require
|
||||||
|
* libpng or zlib to work. Because it includes the complete source of 'png.c'
|
||||||
|
* it tests the code with whatever compiler options are used to build it.
|
||||||
|
* Changing these options can substantially change the errors in the
|
||||||
|
* calculations that the compiler chooses!
|
||||||
|
*/
|
||||||
|
#define _POSIX_SOURCE 1
|
||||||
|
#define _ISOC99_SOURCE 1
|
||||||
|
|
||||||
|
/* Obtain a copy of the code to be tested (plus other things), disabling
|
||||||
|
* stuff that is not required.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "../../pngpriv.h"
|
||||||
|
|
||||||
|
#define png_error png_warning
|
||||||
|
|
||||||
|
void png_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "validation: %s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define png_fixed_error png_fixed_warning
|
||||||
|
|
||||||
|
void png_fixed_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "overflow in: %s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define png_set_error_fn(pp, ep, efp, wfp) ((void)0)
|
||||||
|
#define png_malloc(pp, s) malloc(s)
|
||||||
|
#define png_malloc_warn(pp, s) malloc(s)
|
||||||
|
#define png_malloc_base(pp, s) malloc(s)
|
||||||
|
#define png_calloc(pp, s) calloc(1, (s))
|
||||||
|
#define png_free(pp, s) free(s)
|
||||||
|
|
||||||
|
#define png_safecat(b, sb, pos, str) (pos)
|
||||||
|
#define png_format_number(start, end, format, number) (start)
|
||||||
|
|
||||||
|
#define crc32(crc, pp, s) (crc)
|
||||||
|
#define inflateReset(zs) Z_OK
|
||||||
|
|
||||||
|
#define png_create_struct(type) (0)
|
||||||
|
#define png_destroy_struct(pp) ((void)0)
|
||||||
|
#define png_create_struct_2(type, m, mm) (0)
|
||||||
|
#define png_destroy_struct_2(pp, f, mm) ((void)0)
|
||||||
|
|
||||||
|
#undef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
#undef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
|
#undef PNG_USER_MEM_SUPPORTED
|
||||||
|
|
||||||
|
#include "../../png.c"
|
||||||
|
|
||||||
|
/* Validate ASCII to fp routines. */
|
||||||
|
static int verbose = 0;
|
||||||
|
|
||||||
|
int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int showall = 0;
|
||||||
|
double max_error=2; /* As a percentage error-in-last-digit/.5 */
|
||||||
|
double max_error_abs=17; /* Used when precision is DBL_DIG */
|
||||||
|
double max = 0;
|
||||||
|
double max_abs = 0;
|
||||||
|
double test = 0; /* Important to test this. */
|
||||||
|
int precision = 5;
|
||||||
|
int nonfinite = 0;
|
||||||
|
int finite = 0;
|
||||||
|
int ok = 0;
|
||||||
|
int failcount = 0;
|
||||||
|
int minorarith = 0;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
if (strcmp(*++argv, "-a") == 0)
|
||||||
|
showall = 1;
|
||||||
|
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
max_error = atof(*++argv);
|
||||||
|
}
|
||||||
|
else if (strcmp(*argv, "-E") == 0 && argc > 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
max_error_abs = atof(*++argv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
png_size_t index;
|
||||||
|
int state, failed = 0;
|
||||||
|
char buffer[64];
|
||||||
|
|
||||||
|
if (isfinite(test))
|
||||||
|
++finite;
|
||||||
|
else
|
||||||
|
++nonfinite;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||||
|
|
||||||
|
/* Check for overflow in the buffer by setting a marker. */
|
||||||
|
memset(buffer, 71, sizeof buffer);
|
||||||
|
|
||||||
|
png_ascii_from_fp(0, buffer, precision+10, test, precision);
|
||||||
|
|
||||||
|
/* Allow for a three digit exponent, this stuff will fail if
|
||||||
|
* the exponent is bigger than this!
|
||||||
|
*/
|
||||||
|
if (buffer[precision+7] != 71)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||||
|
precision, buffer, (unsigned long)strlen(buffer));
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Following are used for the number parser below and must be
|
||||||
|
* initialized to zero.
|
||||||
|
*/
|
||||||
|
state = 0;
|
||||||
|
index = 0;
|
||||||
|
if (!isfinite(test))
|
||||||
|
{
|
||||||
|
/* Expect 'inf' */
|
||||||
|
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||||
|
test < 0 && strcmp(buffer, "-inf"))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
||||||
|
precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||||
|
buffer[index] != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
||||||
|
precision, buffer, buffer[index]);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but negative value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_ZERO(state));
|
||||||
|
assert(!PNG_FP_IS_POSITIVE(state));
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_ZERO(state) && !(test == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but zero value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||||
|
assert(!PNG_FP_IS_POSITIVE(state));
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but postive value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||||
|
assert(!PNG_FP_IS_ZERO(state));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Check the result against the original. */
|
||||||
|
double out = atof(buffer);
|
||||||
|
double change = fabs((out - test)/test);
|
||||||
|
double allow = .5/pow(10,
|
||||||
|
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||||
|
|
||||||
|
/* NOTE: if you hit this error case are you compiling with gcc
|
||||||
|
* and -O0? Try -O2 - the errors can accumulate if the FP
|
||||||
|
* code above is not optimized and may drift outside the .5 in
|
||||||
|
* DBL_DIG allowed. In any case a small number of errors may
|
||||||
|
* occur (very small ones - 1 or 2%) because of rounding in the
|
||||||
|
* calculations, either in the conversion API or in atof.
|
||||||
|
*/
|
||||||
|
if (change >= allow && (isfinite(out) ||
|
||||||
|
fabs(test/DBL_MAX) <= 1-allow))
|
||||||
|
{
|
||||||
|
double percent = (precision >= DBL_DIG) ? max_error_abs : max_error;
|
||||||
|
double allowp = (change-allow)*100/allow;
|
||||||
|
|
||||||
|
if (precision >= DBL_DIG)
|
||||||
|
{
|
||||||
|
if (max_abs < allowp) max_abs = allowp;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (max < allowp) max = allowp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showall || allowp >= percent)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"%.*g[%d] -> '%s' -> %.*g number changed (%g > %g (%d%%))\n",
|
||||||
|
DBL_DIG, test, precision, buffer, DBL_DIG, out, change, allow,
|
||||||
|
(int)round(allowp));
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++minorarith;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed)
|
||||||
|
++failcount;
|
||||||
|
else
|
||||||
|
++ok;
|
||||||
|
|
||||||
|
skip:
|
||||||
|
/* Generate a new number and precision. */
|
||||||
|
precision = rand();
|
||||||
|
if (precision & 1) test = -test;
|
||||||
|
precision >>= 1;
|
||||||
|
|
||||||
|
/* Generate random numbers. */
|
||||||
|
if (test == 0 || !isfinite(test))
|
||||||
|
test = precision+1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Derive the exponent from the previous rand() value. */
|
||||||
|
int exponent = precision % (DBL_MAX_EXP - DBL_MIN_EXP) + DBL_MIN_EXP;
|
||||||
|
int tmp;
|
||||||
|
test = frexp(test * rand(), &tmp);
|
||||||
|
test = ldexp(test, exponent);
|
||||||
|
precision >>= 8; /* arbitrary */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This limits the precision to 32 digits, enough for standard
|
||||||
|
* IEEE implementations which have at most 15 digits.
|
||||||
|
*/
|
||||||
|
precision = (precision & 0x1f) + 1;
|
||||||
|
}
|
||||||
|
while (--count);
|
||||||
|
|
||||||
|
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
||||||
|
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
||||||
|
printf(" Error with >=%d digit precision %.2f%%\n", DBL_DIG, max_abs);
|
||||||
|
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Observe that valid FP numbers have the forms listed in the PNG extensions
|
||||||
|
* specification:
|
||||||
|
*
|
||||||
|
* [+,-]{integer,integer.fraction,.fraction}[{e,E}[+,-]integer]
|
||||||
|
*
|
||||||
|
* Test each of these in turn, including invalid cases.
|
||||||
|
*/
|
||||||
|
typedef enum checkfp_state
|
||||||
|
{
|
||||||
|
start, fraction, exponent, states
|
||||||
|
} checkfp_state;
|
||||||
|
|
||||||
|
/* The characters (other than digits) that characterize the states: */
|
||||||
|
static const char none[] = "";
|
||||||
|
static const char hexdigits[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const char *start; /* Characters valid at the start */
|
||||||
|
const char *end; /* Valid characters that end the state */
|
||||||
|
const char *tests; /* Characters to test after 2 digits seen */
|
||||||
|
}
|
||||||
|
state_characters[states] =
|
||||||
|
{
|
||||||
|
/* start: */ { "+-.", ".eE", "+-.e*0369" },
|
||||||
|
/* fraction: */ { none, "eE", "+-.E#0147" },
|
||||||
|
/* exponent: */ { "+-", none, "+-.eE^0258" }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char number[1024]; /* Buffer for number being tested */
|
||||||
|
int limit; /* Command line limit */
|
||||||
|
int verbose; /* Shadows global variable */
|
||||||
|
int ctimes; /* Number of numbers tested */
|
||||||
|
int cmillions; /* Count of millions of numbers */
|
||||||
|
int cinvalid; /* Invalid strings checked */
|
||||||
|
int cnoaccept; /* Characters not accepted */
|
||||||
|
}
|
||||||
|
checkfp_command;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int cnumber; /* Index into number string */
|
||||||
|
checkfp_state check_state; /* Current number state */
|
||||||
|
int at_start; /* At start (first character) of state */
|
||||||
|
int cdigits_in_state; /* Digits seen in that state */
|
||||||
|
int limit; /* Limit on same for checking all chars */
|
||||||
|
int state; /* Current parser state */
|
||||||
|
int is_negative; /* Number is negative */
|
||||||
|
int is_zero; /* Number is (still) zero */
|
||||||
|
int number_was_valid; /* Previous character validity */
|
||||||
|
}
|
||||||
|
checkfp_control;
|
||||||
|
|
||||||
|
static int check_all_characters(checkfp_command *co, checkfp_control c);
|
||||||
|
|
||||||
|
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||||
|
const char *tests);
|
||||||
|
|
||||||
|
static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||||
|
{
|
||||||
|
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||||
|
*/
|
||||||
|
png_size_t index = 0;
|
||||||
|
const char test = (char)ch;
|
||||||
|
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||||
|
const int character_accepted = (index == 1);
|
||||||
|
|
||||||
|
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||||
|
c.is_zero = 0;
|
||||||
|
|
||||||
|
if (c.check_state == start && c.at_start && ch == '-')
|
||||||
|
c.is_negative = 1;
|
||||||
|
|
||||||
|
if (isprint(ch))
|
||||||
|
co->number[c.cnumber++] = (char)ch;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
co->number[c.cnumber++] = '<';
|
||||||
|
co->number[c.cnumber++] = hexdigits[(ch >> 4) & 0xf];
|
||||||
|
co->number[c.cnumber++] = hexdigits[ch & 0xf];
|
||||||
|
co->number[c.cnumber++] = '>';
|
||||||
|
}
|
||||||
|
co->number[c.cnumber] = 0;
|
||||||
|
|
||||||
|
if (co->verbose > 1)
|
||||||
|
fprintf(stderr, "%s\n", co->number);
|
||||||
|
|
||||||
|
if (++(co->ctimes) == 1000000)
|
||||||
|
{
|
||||||
|
if (co->verbose == 1)
|
||||||
|
fputc('.', stderr);
|
||||||
|
co->ctimes = 0;
|
||||||
|
++(co->cmillions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!number_is_valid)
|
||||||
|
++(co->cinvalid);
|
||||||
|
|
||||||
|
if (!character_accepted)
|
||||||
|
++(co->cnoaccept);
|
||||||
|
|
||||||
|
/* This should never fail (it's a serious bug if it does): */
|
||||||
|
if (index != 0 && index != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
||||||
|
(unsigned long)index);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate the new state, note that the PNG_FP_IS_ macros all return
|
||||||
|
* false unless the number is valid.
|
||||||
|
*/
|
||||||
|
if (PNG_FP_IS_NEGATIVE(c.state) !=
|
||||||
|
(number_is_valid && !c.is_zero && c.is_negative))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: negative when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PNG_FP_IS_ZERO(c.state) != (number_is_valid && c.is_zero))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: zero when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PNG_FP_IS_POSITIVE(c.state) !=
|
||||||
|
(number_is_valid && !c.is_zero && !c.is_negative))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: positive when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Testing a digit */
|
||||||
|
if (isdigit(ch))
|
||||||
|
{
|
||||||
|
if (!character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: digit '%c' not accepted\n", co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!number_is_valid)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: saw a digit (%c) but number not valid\n",
|
||||||
|
co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++c.cdigits_in_state;
|
||||||
|
c.at_start = 0;
|
||||||
|
c.number_was_valid = 1;
|
||||||
|
|
||||||
|
/* Continue testing characters in this state. Either test all of
|
||||||
|
* them or, if we have already seen one digit in this state, just test a
|
||||||
|
* limited set.
|
||||||
|
*/
|
||||||
|
if (c.cdigits_in_state < 1)
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
|
||||||
|
else
|
||||||
|
return check_some_characters(co, c,
|
||||||
|
state_characters[c.check_state].tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A non-digit; is it allowed here? */
|
||||||
|
else if (((ch == '+' || ch == '-') && c.check_state != fraction &&
|
||||||
|
c.at_start) ||
|
||||||
|
(ch == '.' && c.check_state == start) ||
|
||||||
|
((ch == 'e' || ch == 'E') && c.number_was_valid &&
|
||||||
|
c.check_state != exponent))
|
||||||
|
{
|
||||||
|
if (!character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: character '%c' not accepted\n", co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The number remains valid after start of fraction but nowhere else. */
|
||||||
|
if (number_is_valid && (c.check_state != start || ch != '.'))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: saw a non-digit (%c) but number valid\n",
|
||||||
|
co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.number_was_valid = number_is_valid;
|
||||||
|
|
||||||
|
/* Check for a state change. When changing to 'fraction' if the number
|
||||||
|
* is valid at this point set the at_start to false to allow an exponent
|
||||||
|
* 'e' to come next.
|
||||||
|
*/
|
||||||
|
if (c.check_state == start && ch == '.')
|
||||||
|
{
|
||||||
|
c.check_state = fraction;
|
||||||
|
c.at_start = !number_is_valid;
|
||||||
|
c.cdigits_in_state = 0;
|
||||||
|
c.limit = co->limit;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (c.check_state < exponent && (ch == 'e' || ch == 'E'))
|
||||||
|
{
|
||||||
|
c.check_state = exponent;
|
||||||
|
c.at_start = 1;
|
||||||
|
c.cdigits_in_state = 0;
|
||||||
|
c.limit = co->limit;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Else it was a sign, and the state doesn't change. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ch != '-' && ch != '+')
|
||||||
|
{
|
||||||
|
fprintf(stderr, "checkfp: internal error (1)\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.at_start = 0;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Testing an invalid character */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: character '%c' [0x%.2x] accepted\n", co->number,
|
||||||
|
ch, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number_is_valid != c.number_was_valid)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
||||||
|
ch, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do nothing - the parser has stuck; return success and keep going with
|
||||||
|
* the next character.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful return (the caller will try the next character.) */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_all_characters(checkfp_command *co, checkfp_control c)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
||||||
|
{
|
||||||
|
if (!check_one_character(co, c, ch))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||||
|
const char *tests)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
--(c.limit);
|
||||||
|
|
||||||
|
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
||||||
|
{
|
||||||
|
if (c.limit > 0) for (i=0; tests[i]; ++i)
|
||||||
|
{
|
||||||
|
if (!check_one_character(co, c, tests[i]))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* At the end check all the characters. */
|
||||||
|
else
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int validation_checkfp(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
checkfp_command command;
|
||||||
|
checkfp_control control;
|
||||||
|
|
||||||
|
command.number[0] = 0;
|
||||||
|
command.limit = 3;
|
||||||
|
command.verbose = verbose;
|
||||||
|
command.ctimes = 0;
|
||||||
|
command.cmillions = 0;
|
||||||
|
command.cinvalid = 0;
|
||||||
|
command.cnoaccept = 0;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
{
|
||||||
|
++argv;
|
||||||
|
if (argc > 1 && strcmp(*argv, "-l") == 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
command.limit = atoi(*++argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
control.cnumber = 0;
|
||||||
|
control.check_state = start;
|
||||||
|
control.at_start = 1;
|
||||||
|
control.cdigits_in_state = 0;
|
||||||
|
control.limit = command.limit;
|
||||||
|
control.state = 0;
|
||||||
|
control.is_negative = 0;
|
||||||
|
control.is_zero = 1;
|
||||||
|
control.number_was_valid = 0;
|
||||||
|
|
||||||
|
result = check_all_characters(&command, control);
|
||||||
|
|
||||||
|
printf("checkfp: %s: checked %d,%.3d,%.3d,%.3d strings (%d invalid)\n",
|
||||||
|
result ? "pass" : "FAIL", command.cmillions / 1000,
|
||||||
|
command.cmillions % 1000, command.ctimes / 1000, command.ctimes % 1000,
|
||||||
|
command.cinvalid);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int validation_muldiv(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int tested = 0;
|
||||||
|
int overflow = 0;
|
||||||
|
int error = 0;
|
||||||
|
int error64 = 0;
|
||||||
|
int passed = 0;
|
||||||
|
int randbits = 0;
|
||||||
|
png_uint_32 randbuffer;
|
||||||
|
png_fixed_point a;
|
||||||
|
png_int_32 times, div;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find out about the random number generator. */
|
||||||
|
randbuffer = RAND_MAX;
|
||||||
|
while (randbuffer != 0) ++randbits, randbuffer >>= 1;
|
||||||
|
printf("Using random number generator that makes %d bits\n", randbits);
|
||||||
|
for (div=0; div<32; div += randbits)
|
||||||
|
randbuffer = (randbuffer << randbits) ^ rand();
|
||||||
|
|
||||||
|
a = 0;
|
||||||
|
times = div = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
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
|
||||||
|
* better mantissa is required.
|
||||||
|
*/
|
||||||
|
long long int fp, fpround;
|
||||||
|
unsigned long hi, lo;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
/* Check the values, png_64bit_product can only handle positive
|
||||||
|
* numbers, so correct for that here.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
long u1, u2;
|
||||||
|
int n = 0;
|
||||||
|
if (a < 0) u1 = -a, n = 1; else u1 = a;
|
||||||
|
if (times < 0) u2 = -times, n = !n; else u2 = times;
|
||||||
|
png_64bit_product(u1, u2, &hi, &lo);
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
/* -x = ~x+1 */
|
||||||
|
lo = ((~lo) + 1) & 0xffffffff;
|
||||||
|
hi = ~hi;
|
||||||
|
if (lo == 0) ++hi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = a;
|
||||||
|
fp *= times;
|
||||||
|
if ((fp & 0xffffffff) != lo || ((fp >> 32) & 0xffffffff) != hi)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "png_64bit_product %d * %d -> %lx|%.8lx not %llx\n",
|
||||||
|
a, times, hi, lo, fp);
|
||||||
|
++error64;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (div != 0)
|
||||||
|
{
|
||||||
|
/* Round - this is C round to zero. */
|
||||||
|
if ((fp < 0) != (div < 0))
|
||||||
|
fp -= div/2;
|
||||||
|
else
|
||||||
|
fp += div/2;
|
||||||
|
|
||||||
|
fp /= div;
|
||||||
|
fpround = fp;
|
||||||
|
/* Assume 2's complement here: */
|
||||||
|
ok = fpround <= PNG_UINT_31_MAX &&
|
||||||
|
fpround >= -1-(long long int)PNG_UINT_31_MAX;
|
||||||
|
if (!ok) ++overflow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
||||||
|
fp, ok ? "ok" : "overflow");
|
||||||
|
|
||||||
|
++tested;
|
||||||
|
if (png_muldiv(&result, a, times, div) != ok)
|
||||||
|
{
|
||||||
|
++error;
|
||||||
|
if (ok)
|
||||||
|
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
||||||
|
times, div, fp);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
||||||
|
times, div, result, fp);
|
||||||
|
}
|
||||||
|
else if (ok && result != fpround)
|
||||||
|
{
|
||||||
|
++error;
|
||||||
|
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
||||||
|
fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++passed;
|
||||||
|
|
||||||
|
/* Generate three new values, this uses rand() and rand() only returns
|
||||||
|
* up to RAND_MAX.
|
||||||
|
*/
|
||||||
|
/* CRUDE */
|
||||||
|
a += times;
|
||||||
|
times += div;
|
||||||
|
div = randbuffer;
|
||||||
|
randbuffer = (randbuffer << randbits) ^ rand();
|
||||||
|
}
|
||||||
|
while (--count > 0);
|
||||||
|
|
||||||
|
printf("%d tests including %d overflows, %d passed, %d failed (%d 64-bit "
|
||||||
|
"errors)\n", tested, overflow, passed, error, error64);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When FP is on this just becomes a speed test - compile without FP to get real
|
||||||
|
* validation.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||||
|
#define LN2 .000010576586617430806112933839 /* log(2)/65536 */
|
||||||
|
#define L2INV 94548.46219969910586572651 /* 65536/log(2) */
|
||||||
|
|
||||||
|
/* For speed testing, need the internal functions too: */
|
||||||
|
static png_uint_32 png_log8bit(unsigned x)
|
||||||
|
{
|
||||||
|
if (x > 0)
|
||||||
|
return (png_uint_32)floor(.5-log(x/255.)*L2INV);
|
||||||
|
|
||||||
|
return 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_32 png_log16bit(png_uint_32 x)
|
||||||
|
{
|
||||||
|
if (x > 0)
|
||||||
|
return (png_uint_32)floor(.5-log(x/65535.)*L2INV);
|
||||||
|
|
||||||
|
return 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_32 png_exp(png_uint_32 x)
|
||||||
|
{
|
||||||
|
return (png_uint_32)floor(.5 + exp(x * -LN2) * 0xffffffffU);
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_byte png_exp8bit(png_uint_32 log)
|
||||||
|
{
|
||||||
|
return (png_byte)floor(.5 + exp(log * -LN2) * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_16 png_exp16bit(png_uint_32 log)
|
||||||
|
{
|
||||||
|
return (png_uint_16)floor(.5 + exp(log * -LN2) * 65535);
|
||||||
|
}
|
||||||
|
#endif /* FLOATING_ARITHMETIC */
|
||||||
|
|
||||||
|
int validation_gamma(int argc, char **argv)
|
||||||
|
{
|
||||||
|
double gamma[9] = { 2.2, 1.8, 1.52, 1.45, 1., 1/1.45, 1/1.52, 1/1.8, 1/2.2 };
|
||||||
|
double maxerr;
|
||||||
|
int i, silent=0, onlygamma=0;
|
||||||
|
|
||||||
|
/* Silence the output with -s, just test the gamma functions with -g: */
|
||||||
|
while (--argc > 0)
|
||||||
|
if (strcmp(*++argv, "-s") == 0)
|
||||||
|
silent = 1;
|
||||||
|
else if (strcmp(*argv, "-g") == 0)
|
||||||
|
onlygamma = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!onlygamma)
|
||||||
|
{
|
||||||
|
/* First validate the log functions: */
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<256; ++i)
|
||||||
|
{
|
||||||
|
double correct = -log(i/255.)/log(2.)*65536;
|
||||||
|
double error = png_log8bit(i) - correct;
|
||||||
|
|
||||||
|
if (i != 0 && fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
|
||||||
|
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",
|
||||||
|
i, png_log8bit(i), correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 8-bit log error = %f\n", maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<65536; ++i)
|
||||||
|
{
|
||||||
|
double correct = -log(i/65535.)/log(2.)*65536;
|
||||||
|
double error = png_log16bit(i) - correct;
|
||||||
|
|
||||||
|
if (i != 0 && fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
|
||||||
|
if (i == 0 && png_log16bit(i) != 0xffffffff ||
|
||||||
|
i != 0 && png_log16bit(i) != floor(correct+.5))
|
||||||
|
{
|
||||||
|
if (error > .68) /* By experiment error is less than .68 */
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Now exponentiations. */
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * (65536. * 65536);
|
||||||
|
double error = png_exp(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > 1883) /* By experiment. */
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * 255;
|
||||||
|
double error = png_exp8bit(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > .50002) /* By experiment */
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * 65535;
|
||||||
|
double error = png_exp16bit(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > .524) /* By experiment */
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
} /* !onlygamma */
|
||||||
|
|
||||||
|
/* Test the overall gamma correction. */
|
||||||
|
for (i=0; i<9; ++i)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
double g = gamma[i];
|
||||||
|
png_fixed_point gfp = floor(g * PNG_FP_1 + .5);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("Test gamma %f\n", g);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (j=0; j<256; ++j)
|
||||||
|
{
|
||||||
|
double correct = pow(j/255., g) * 255;
|
||||||
|
png_byte out = png_gamma_8bit_correct(j, gfp);
|
||||||
|
double error = out - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (out != floor(correct+.5))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "8bit %d ^ %f: got %d expected %f error %f\n",
|
||||||
|
j, g, out, correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("gamma %f: maximum 8-bit error %f\n", g, maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (j=0; j<65536; ++j)
|
||||||
|
{
|
||||||
|
double correct = pow(j/65535., g) * 65535;
|
||||||
|
png_uint_16 out = png_gamma_16bit_correct(j, gfp);
|
||||||
|
double error = out - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > 1.62)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "16bit %d ^ %f: got %d expected %f error %f\n",
|
||||||
|
j, g, out, correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("gamma %f: maximum 16-bit error %f\n", g, maxerr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************** VALIDATION TESTS ********************************/
|
||||||
|
/* Various validation routines are included herein, they require some
|
||||||
|
* definition for png_warning and png_error, seetings of VALIDATION:
|
||||||
|
*
|
||||||
|
* 1: validates the ASCII to floating point conversions
|
||||||
|
* 2: validates png_muldiv
|
||||||
|
* 3: accuracy test of fixed point gamma tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The following COUNT (10^8) takes about 1 hour on a 1GHz Pentium IV
|
||||||
|
* processor.
|
||||||
|
*/
|
||||||
|
#define COUNT 1000000000
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int count = COUNT;
|
||||||
|
|
||||||
|
while (argc > 1)
|
||||||
|
{
|
||||||
|
if (argc > 2 && strcmp(argv[1], "-c") == 0)
|
||||||
|
{
|
||||||
|
count = atoi(argv[2]);
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(argv[1], "-v") == 0)
|
||||||
|
{
|
||||||
|
++verbose;
|
||||||
|
--argc;
|
||||||
|
++argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0 && argc > 1)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[1], "ascii") == 0)
|
||||||
|
return validation_ascii_to_fp(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "checkfp") == 0)
|
||||||
|
return validation_checkfp(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "muldiv") == 0)
|
||||||
|
return validation_muldiv(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "gamma") == 0)
|
||||||
|
return validation_gamma(argc-1, argv+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bad argument: */
|
||||||
|
fprintf(stderr,
|
||||||
|
"usage: tarith [-v] [-c count] {ascii,muldiv,gamma} [args]\n");
|
||||||
|
fprintf(stderr, " arguments: ascii [-a (all results)] [-e error%%]\n");
|
||||||
|
fprintf(stderr, " checkfp [-l max-number-chars]\n");
|
||||||
|
fprintf(stderr, " muldiv\n");
|
||||||
|
fprintf(stderr, " gamma -s (silent) -g (only gamma; no log)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
303
contrib/libtests/timepng.c
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
/* timepng.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.
|
||||||
|
*/
|
||||||
|
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <time.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_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
{
|
||||||
|
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
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);
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
int pass;
|
||||||
|
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass = 0; pass < passes; ++pass)
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mytime(struct timespec *t)
|
||||||
|
{
|
||||||
|
/* Do the timing using clock_gettime and the per-process timer. */
|
||||||
|
if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, t))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
perror("CLOCK_PROCESS_CPUTIME_ID");
|
||||||
|
fprintf(stderr, "timepng: could not get the time\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int perform_one_test(FILE *fp, int nfiles)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct timespec before, after;
|
||||||
|
|
||||||
|
/* Clear out all errors: */
|
||||||
|
rewind(fp);
|
||||||
|
|
||||||
|
if (mytime(&before))
|
||||||
|
{
|
||||||
|
for (i=0; i<nfiles; ++i)
|
||||||
|
{
|
||||||
|
if (read_png(fp))
|
||||||
|
{
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "file %d: error reading PNG data\n", i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "file %d: error from libpng\n", i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (mytime(&after))
|
||||||
|
{
|
||||||
|
/* Work out the time difference and print it - this is the only output,
|
||||||
|
* so flush it immediately.
|
||||||
|
*/
|
||||||
|
unsigned long s = after.tv_sec - before.tv_sec;
|
||||||
|
long ns = after.tv_nsec - before.tv_nsec;
|
||||||
|
|
||||||
|
if (ns < 0)
|
||||||
|
{
|
||||||
|
--s;
|
||||||
|
ns += 1000000000;
|
||||||
|
|
||||||
|
if (ns < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: bad clock from kernel\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%lu.%.9ld\n", s, ns);
|
||||||
|
fflush(stdout);
|
||||||
|
if (ferror(stdout))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: error writing output\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful return */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int add_one_file(FILE *fp, char *name)
|
||||||
|
{
|
||||||
|
FILE *ip = fopen(name, "rb");
|
||||||
|
|
||||||
|
if (ip != NULL)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
ch = getc(ip);
|
||||||
|
if (ch == EOF) break;
|
||||||
|
putc(ch, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(ip))
|
||||||
|
{
|
||||||
|
perror(name);
|
||||||
|
fprintf(stderr, "%s: read error\n", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)fclose(ip);
|
||||||
|
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file write error\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
perror(name);
|
||||||
|
fprintf(stderr, "%s: open failed\n", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ok = 0;
|
||||||
|
FILE *fp = tmpfile();
|
||||||
|
|
||||||
|
if (fp != NULL)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
int nfiles = 0;
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
if (add_one_file(fp, argv[i]))
|
||||||
|
++nfiles;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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 (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);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "timepng: could not open temporary file\n");
|
||||||
|
|
||||||
|
/* Exit code 0 on success. */
|
||||||
|
return ok == 0;
|
||||||
|
}
|
||||||
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
|
||||||
253
contrib/neon/filter_neon.S
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
|
||||||
|
/* filter_neon.S - NEON optimised filter functions
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
# define ELF @
|
||||||
|
#endif
|
||||||
|
|
||||||
|
.arch armv7-a
|
||||||
|
.fpu neon
|
||||||
|
|
||||||
|
.macro func name, export=0
|
||||||
|
.macro endfunc
|
||||||
|
ELF .size \name, . - \name
|
||||||
|
.endfunc
|
||||||
|
.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
|
||||||
|
ELF .type \name, STT_FUNC
|
||||||
|
.func \name
|
||||||
|
\name:
|
||||||
|
.endm
|
||||||
|
|
||||||
|
func png_read_filter_row_sub4_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vadd.u8 d0, d3, d4
|
||||||
|
vadd.u8 d1, d0, d5
|
||||||
|
vadd.u8 d2, d1, d6
|
||||||
|
vadd.u8 d3, d2, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r3, r3, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_sub3_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r2, #3
|
||||||
|
mov r12, #12
|
||||||
|
vld1.8 {q11}, [r0], r12
|
||||||
|
1:
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vadd.u8 d0, d3, d22
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vadd.u8 d1, d0, d5
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], r12
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r2
|
||||||
|
vadd.u8 d2, d1, d6
|
||||||
|
vst1.32 {d1[0]}, [r1], r2
|
||||||
|
vadd.u8 d3, d2, d7
|
||||||
|
vst1.32 {d2[0]}, [r1], r2
|
||||||
|
vst1.32 {d3[0]}, [r1], r2
|
||||||
|
subs r3, r3, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_up_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
1:
|
||||||
|
vld1.8 {q0}, [r1,:128]
|
||||||
|
vld1.8 {q1}, [r2,:128]!
|
||||||
|
vadd.u8 q0, q0, q1
|
||||||
|
vst1.8 {q0}, [r1,:128]!
|
||||||
|
subs r3, r3, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_avg4_neon, export=1
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||||
|
vhadd.u8 d0, d3, d16
|
||||||
|
vadd.u8 d0, d0, d4
|
||||||
|
vhadd.u8 d1, d0, d17
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vhadd.u8 d2, d1, d18
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vhadd.u8 d3, d2, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r12, r12, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_avg3_neon, export=1
|
||||||
|
push {r4,lr}
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r4, #3
|
||||||
|
mov lr, #12
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
1:
|
||||||
|
vld1.8 {q10}, [r2], lr
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vhadd.u8 d0, d3, d20
|
||||||
|
vext.8 d17, d20, d21, #3
|
||||||
|
vadd.u8 d0, d0, d22
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vhadd.u8 d1, d0, d17
|
||||||
|
vext.8 d18, d20, d21, #6
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r4
|
||||||
|
vhadd.u8 d2, d1, d18
|
||||||
|
vst1.32 {d1[0]}, [r1], r4
|
||||||
|
vext.8 d19, d21, d21, #1
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vhadd.u8 d3, d2, d19
|
||||||
|
vst1.32 {d2[0]}, [r1], r4
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst1.32 {d3[0]}, [r1], r4
|
||||||
|
subs r12, r12, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
pop {r4,pc}
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
.macro paeth rx, ra, rb, rc
|
||||||
|
vaddl.u8 q12, \ra, \rb @ a + b
|
||||||
|
vaddl.u8 q15, \rc, \rc @ 2*c
|
||||||
|
vabdl.u8 q13, \rb, \rc @ pa
|
||||||
|
vabdl.u8 q14, \ra, \rc @ pb
|
||||||
|
vabd.u16 q15, q12, q15 @ pc
|
||||||
|
vcle.u16 q12, q13, q14 @ pa <= pb
|
||||||
|
vcle.u16 q13, q13, q15 @ pa <= pc
|
||||||
|
vcle.u16 q14, q14, q15 @ pb <= pc
|
||||||
|
vand q12, q12, q13 @ pa <= pb && pa <= pc
|
||||||
|
vmovn.u16 d28, q14
|
||||||
|
vmovn.u16 \rx, q12
|
||||||
|
vbsl d28, \rb, \rc
|
||||||
|
vbsl \rx, \ra, d28
|
||||||
|
.endm
|
||||||
|
|
||||||
|
func png_read_filter_row_paeth4_neon, export=1
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
vmov.i8 d20, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||||
|
paeth d0, d3, d16, d20
|
||||||
|
vadd.u8 d0, d0, d4
|
||||||
|
paeth d1, d0, d17, d16
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
paeth d2, d1, d18, d17
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
paeth d3, d2, d19, d18
|
||||||
|
vmov d20, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r12, r12, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_paeth3_neon, export=1
|
||||||
|
push {r4,lr}
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
vmov.i8 d4, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r4, #3
|
||||||
|
mov lr, #12
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
1:
|
||||||
|
vld1.8 {q10}, [r2], lr
|
||||||
|
paeth d0, d3, d20, d4
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vadd.u8 d0, d0, d22
|
||||||
|
vext.8 d17, d20, d21, #3
|
||||||
|
paeth d1, d0, d17, d20
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r4
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vext.8 d18, d20, d21, #6
|
||||||
|
paeth d2, d1, d18, d17
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
vst1.32 {d1[0]}, [r1], r4
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vext.8 d19, d21, d21, #1
|
||||||
|
paeth d3, d2, d19, d18
|
||||||
|
vst1.32 {d2[0]}, [r1], r4
|
||||||
|
vmov d4, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst1.32 {d3[0]}, [r1], r4
|
||||||
|
subs r12, r12, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
||||||
to build minimal decoder, encoder, and progressive reader applications.
|
to build minimal decoder, encoder, and progressive reader applications.
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
|||||||
on the make command line.
|
on the make command line.
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||||
and build the png2pnm application there.
|
and build the png2pnm application there.
|
||||||
|
|||||||
@@ -4,15 +4,18 @@
|
|||||||
#CC=cc
|
#CC=cc
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
STRIP=strip
|
|
||||||
|
|
||||||
# If awk fails try
|
# If awk fails try
|
||||||
# make AWK=nawk
|
# make AWK=nawk
|
||||||
|
|
||||||
|
# If cpp fails try
|
||||||
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
RM=rm -f
|
RM=rm -f
|
||||||
COPY=cp
|
COPY=cp
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1
|
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
@@ -79,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
|||||||
|
|
||||||
# note: dependencies do not work on implicit rule lines
|
# note: dependencies do not work on implicit rule lines
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
@@ -87,23 +90,22 @@ all: pngm2pnm$(E)
|
|||||||
|
|
||||||
pngm2pnm$(E): $(OBJS)
|
pngm2pnm$(E): $(OBJS)
|
||||||
$(LD) -o pngm2pnm$(E) $(OBJS)
|
$(LD) -o pngm2pnm$(E) $(OBJS)
|
||||||
$(STRIP) pngm2pnm$(E)
|
|
||||||
|
|
||||||
# The DFA_XTRA setting turns all libpng options off then
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
# turns on those required for this minimal build.
|
# turns on those required for this minimal build.
|
||||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
# both the build of pnglibconf.h and, subsequently, when
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
# building libpng itself.
|
# building libpng itself.
|
||||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
$(RM) pnglibconf.h pnglibconf.dfn
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
DFA_XTRA="pngusr.dfa" $@
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) clean
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) pngm2pnm$(O)
|
$(RM) pngm2pnm$(O)
|
||||||
$(RM) pngm2pnm$(E)
|
$(RM) pngm2pnm$(E)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pngminim/decoder/pngusr.dfa
|
# pngminim/decoder/pngusr.dfa
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
#
|
#
|
||||||
# This code is released under the libpng license.
|
# This code is released under the libpng license.
|
||||||
# For conditions of distribution and use, see the disclaimer
|
# For conditions of distribution and use, see the disclaimer
|
||||||
@@ -36,4 +36,6 @@ option FLOATING_ARITHMETIC off
|
|||||||
option SETJMP on
|
option SETJMP on
|
||||||
option STDIO on
|
option STDIO on
|
||||||
option READ_EXPAND on
|
option READ_EXPAND on
|
||||||
option READ_16_TO_8 on
|
option READ_DEINTERLACE 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
|
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2007, 2010 Glenn Randers-Pehrson
|
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
* affect the API (so are not recorded in pnglibconf.h)
|
* 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 */
|
#endif /* MINRDPNGCONF_H */
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
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.
|
and zlib.
|
||||||
|
|
||||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||||
on the make command line.
|
on the make command line.
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||||
and build the pnm2png application there.
|
and build the pnm2png application there.
|
||||||
|
|||||||
@@ -4,15 +4,18 @@
|
|||||||
#CC=cc
|
#CC=cc
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
STRIP=strip
|
|
||||||
|
|
||||||
# If awk fails try
|
# If awk fails try
|
||||||
# make AWK=nawk
|
# make AWK=nawk
|
||||||
|
|
||||||
|
# If cpp fails try
|
||||||
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
RM=rm -f
|
RM=rm -f
|
||||||
COPY=cp
|
COPY=cp
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1
|
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
@@ -78,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
@@ -86,23 +89,22 @@ all: pnm2pngm$(E)
|
|||||||
|
|
||||||
pnm2pngm$(E): $(OBJS)
|
pnm2pngm$(E): $(OBJS)
|
||||||
$(LD) -o pnm2pngm$(E) $(OBJS)
|
$(LD) -o pnm2pngm$(E) $(OBJS)
|
||||||
$(STRIP) pnm2pngm$(E)
|
|
||||||
|
|
||||||
# The DFA_XTRA setting turns all libpng options off then
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
# turns on those required for this minimal build.
|
# turns on those required for this minimal build.
|
||||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
# both the build of pnglibconf.h and, subsequently, when
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
# building libpng itself.
|
# building libpng itself.
|
||||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
$(RM) pnglibconf.h pnglibconf.dfn
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
DFA_XTRA="pngusr.dfa" $@
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) clean
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) pnm2pngm$(O)
|
$(RM) pnm2pngm$(O)
|
||||||
$(RM) pnm2pngm$(E)
|
$(RM) pnm2pngm$(E)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pngminim/encoder/pngusr.dfa
|
# pngminim/encoder/pngusr.dfa
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
#
|
#
|
||||||
# This code is released under the libpng license.
|
# This code is released under the libpng license.
|
||||||
# For conditions of distribution and use, see the disclaimer
|
# For conditions of distribution and use, see the disclaimer
|
||||||
@@ -14,6 +14,10 @@ everything = off
|
|||||||
|
|
||||||
option WRITE on
|
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:
|
# You must choose fixed or floating point arithmetic:
|
||||||
# option FLOATING_POINT on
|
# option FLOATING_POINT on
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2007, 2010 Glenn Randers-Pehrson
|
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
* affect the API (so are not recorded in pnglibconf.h)
|
* 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 */
|
#endif /* MINWRPNGCONF_H */
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ on the make command line.
|
|||||||
|
|
||||||
Edit makefile if required, to find your X library and include files,
|
Edit makefile if required, to find your X library and include files,
|
||||||
then
|
then
|
||||||
|
|
||||||
make ZLIBSRC=directory
|
make ZLIBSRC=directory
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/gregbook
|
If you prefer to use the shared libraries, go to contrib/gregbook
|
||||||
and build the rpng2-x application there.
|
and build the rpng2-x application there.
|
||||||
|
|||||||
@@ -4,11 +4,13 @@
|
|||||||
#CC=cc
|
#CC=cc
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
STRIP=strip
|
|
||||||
|
|
||||||
# If awk fails try
|
# If awk fails try
|
||||||
# make AWK=nawk
|
# make AWK=nawk
|
||||||
|
|
||||||
|
# If cpp fails try
|
||||||
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
RM=rm -f
|
RM=rm -f
|
||||||
COPY=cp
|
COPY=cp
|
||||||
|
|
||||||
@@ -28,7 +30,8 @@ XLIB = -L/usr/X11R6/lib -lX11
|
|||||||
#LIBS = $(XLIB)
|
#LIBS = $(XLIB)
|
||||||
LIBS = $(XLIB) -lm #platforms that need libm
|
LIBS = $(XLIB) -lm #platforms that need libm
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. $(XINC) -O1
|
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
@@ -94,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
|||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
@@ -102,23 +105,22 @@ all: $(PROGDOCS) rpng2-x$(E)
|
|||||||
|
|
||||||
rpng2-x$(E): $(OBJS)
|
rpng2-x$(E): $(OBJS)
|
||||||
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
||||||
$(STRIP) rpng2-x$(E)
|
|
||||||
|
|
||||||
# The DFA_XTRA setting turns all libpng options off then
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
# turns on those required for this minimal build.
|
# turns on those required for this minimal build.
|
||||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
# both the build of pnglibconf.h and, subsequently, when
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
# building libpng itself.
|
# building libpng itself.
|
||||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
$(RM) pnglibconf.h pnglibconf.dfn
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
DFA_XTRA="pngusr.dfa" $@
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
srcdir=$(PNGSRC) clean
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) rpng2-x$(O)
|
$(RM) rpng2-x$(O)
|
||||||
$(RM) rpng2-x$(E)
|
$(RM) rpng2-x$(E)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# pngminim/preader/pngusr.dfa
|
# pngminim/preader/pngusr.dfa
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Glenn Randers-Pehrson
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
#
|
#
|
||||||
# This code is released under the libpng license.
|
# This code is released under the libpng license.
|
||||||
# For conditions of distribution and use, see the disclaimer
|
# For conditions of distribution and use, see the disclaimer
|
||||||
@@ -36,5 +36,6 @@ option STDIO on
|
|||||||
option READ_bKGD on
|
option READ_bKGD on
|
||||||
option READ_GAMMA on
|
option READ_GAMMA on
|
||||||
option READ_EXPAND on
|
option READ_EXPAND on
|
||||||
option READ_16_TO_8 on
|
option READ_DEINTERLACE on
|
||||||
|
option READ_STRIP_16_TO_8 on
|
||||||
option READ_GRAY_TO_RGB on
|
option READ_GRAY_TO_RGB on
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009, 2010 Glenn Randers-Pehrson
|
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
* affect the API (so are not recorded in pnglibconf.h)
|
* 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 */
|
#endif /* MINPRDPNGCONF_H */
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ LD=$(CC)
|
|||||||
RM=rm -f
|
RM=rm -f
|
||||||
|
|
||||||
#PNGPATH = /usr/local
|
#PNGPATH = /usr/local
|
||||||
#PNGINC = -I$(PNGPATH)/include/libpng12
|
#PNGINC = -I$(PNGPATH)/include/libpng17
|
||||||
#PNGLIB = -L$(PNGPATH)/lib -lpng12
|
#PNGLIB = -L$(PNGPATH)/lib -lpng17
|
||||||
#PNGLIBS = $(PNGPATH)/lib/libpng12.a
|
#PNGLIBS = $(PNGPATH)/lib/libpng17.a
|
||||||
PNGINC = -I../..
|
PNGINC = -I../..
|
||||||
PNGLIB = -L../.. -lpng
|
PNGLIB = -L../.. -lpng
|
||||||
PNGLIBS = ../../libpng.a
|
PNGLIBS = ../../libpng.a
|
||||||
@@ -23,9 +23,9 @@ ZINC = -I../../../zlib
|
|||||||
ZLIB = -L../../../zlib -lz
|
ZLIB = -L../../../zlib -lz
|
||||||
ZLIBS = ../../../zlib/libz.a
|
ZLIBS = ../../../zlib/libz.a
|
||||||
|
|
||||||
CFLAGS=-O3 $(PNGINC) $(ZINC)
|
CFLAGS=$(PNGINC) $(ZINC)
|
||||||
LDFLAGS=$(PNGLIB) $(ZLIB)
|
LDLIBS=$(PNGLIB) $(ZLIB)
|
||||||
LDFLAGSS=$(PNGLIBS) $(ZLIBS)
|
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
L=.a
|
L=.a
|
||||||
@@ -40,19 +40,19 @@ png2pnm$(O): png2pnm$(C)
|
|||||||
$(CC) -c $(CFLAGS) png2pnm$(C)
|
$(CC) -c $(CFLAGS) png2pnm$(C)
|
||||||
|
|
||||||
png2pnm$(E): png2pnm$(O)
|
png2pnm$(E): png2pnm$(O)
|
||||||
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm
|
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
||||||
|
|
||||||
png2pnm-static$(E): png2pnm$(O)
|
png2pnm-static$(E): png2pnm$(O)
|
||||||
$(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm
|
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
||||||
|
|
||||||
pnm2png$(O): pnm2png$(C)
|
pnm2png$(O): pnm2png$(C)
|
||||||
$(CC) -c $(CFLAGS) pnm2png$(C)
|
$(CC) -c $(CFLAGS) pnm2png$(C)
|
||||||
|
|
||||||
pnm2png$(E): pnm2png$(O)
|
pnm2png$(E): pnm2png$(O)
|
||||||
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm
|
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
||||||
|
|
||||||
pnm2png-static$(E): pnm2png$(O)
|
pnm2png-static$(E): pnm2png$(O)
|
||||||
$(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm
|
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) png2pnm$(O)
|
$(RM) png2pnm$(O)
|
||||||
|
|||||||
0
contrib/pngminus/png2pnm.bat
Normal file → Executable file
@@ -18,6 +18,7 @@
|
|||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
@@ -144,7 +145,7 @@ int main(int argc, char *argv[])
|
|||||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
|
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +404,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
if (bit_depth == 16){
|
if (bit_depth == 16){
|
||||||
dep_16 = (long) *pix_ptr++;
|
dep_16 = (long) *pix_ptr++;
|
||||||
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
|
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||||
}
|
}
|
||||||
|
|||||||
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
@@ -3,6 +3,7 @@
|
|||||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
||||||
*
|
*
|
||||||
* version 1.0 - 1999.10.15 - First version.
|
* 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
|
* Permission to use, copy, modify, and distribute this software and
|
||||||
* its documentation for any purpose and without fee is hereby granted,
|
* its documentation for any purpose and without fee is hereby granted,
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
@@ -49,7 +51,8 @@
|
|||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
void usage ();
|
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);
|
void get_token(FILE *pnm_file, char *token);
|
||||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
png_uint_32 get_data (FILE *pnm_file, int depth);
|
||||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||||
@@ -175,7 +178,8 @@ void usage()
|
|||||||
fprintf (stderr, " or: ... | pnm2png [options]\n");
|
fprintf (stderr, " or: ... | pnm2png [options]\n");
|
||||||
fprintf (stderr, "Options:\n");
|
fprintf (stderr, "Options:\n");
|
||||||
fprintf (stderr, " -i[nterlace] write png-file with interlacing on\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");
|
fprintf (stderr, " -h | -? print this help-information\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,29 +187,36 @@ void usage()
|
|||||||
* pnm2png
|
* 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_struct *png_ptr = NULL;
|
||||||
png_info *info_ptr = NULL;
|
png_info *info_ptr = NULL;
|
||||||
png_byte *png_pixels = NULL;
|
png_byte *png_pixels = NULL;
|
||||||
png_byte **row_pointers = NULL;
|
png_byte **row_pointers = NULL;
|
||||||
png_byte *pix_ptr = NULL;
|
png_byte *pix_ptr = NULL;
|
||||||
png_uint_32 row_bytes;
|
volatile png_uint_32 row_bytes;
|
||||||
|
|
||||||
char type_token[16];
|
char type_token[16];
|
||||||
char width_token[16];
|
char width_token[16];
|
||||||
char height_token[16];
|
char height_token[16];
|
||||||
char maxval_token[16];
|
char maxval_token[16];
|
||||||
int color_type;
|
volatile int color_type=1;
|
||||||
png_uint_32 width, alpha_width;
|
unsigned long ul_width=0, ul_alpha_width=0;
|
||||||
png_uint_32 height, alpha_height;
|
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;
|
png_uint_32 maxval;
|
||||||
int bit_depth = 0;
|
volatile int bit_depth = 0;
|
||||||
int channels;
|
int channels=0;
|
||||||
int alpha_depth = 0;
|
int alpha_depth = 0;
|
||||||
int alpha_present;
|
int alpha_present=0;
|
||||||
int row, col;
|
int row, col;
|
||||||
BOOL raw, alpha_raw = FALSE;
|
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;
|
png_uint_32 tmp16;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -218,20 +229,36 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
}
|
}
|
||||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
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');
|
raw = (type_token[1] == '4');
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
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;
|
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'))
|
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||||
{
|
{
|
||||||
raw = (type_token[1] == '5');
|
raw = (type_token[1] == '5');
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
get_token(pnm_file, width_token);
|
get_token(pnm_file, width_token);
|
||||||
sscanf (width_token, "%lu", &width);
|
sscanf (width_token, "%lu", &ul_width);
|
||||||
|
width = (png_uint_32) ul_width;
|
||||||
get_token(pnm_file, height_token);
|
get_token(pnm_file, height_token);
|
||||||
sscanf (height_token, "%lu", &height);
|
sscanf (height_token, "%lu", &ul_height);
|
||||||
|
height = (png_uint_32) ul_height;
|
||||||
get_token(pnm_file, maxval_token);
|
get_token(pnm_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
|
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@@ -248,11 +275,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
raw = (type_token[1] == '6');
|
raw = (type_token[1] == '6');
|
||||||
color_type = PNG_COLOR_TYPE_RGB;
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
get_token(pnm_file, width_token);
|
get_token(pnm_file, width_token);
|
||||||
sscanf (width_token, "%lu", &width);
|
sscanf (width_token, "%lu", &ul_width);
|
||||||
|
width = (png_uint_32) ul_width;
|
||||||
get_token(pnm_file, height_token);
|
get_token(pnm_file, height_token);
|
||||||
sscanf (height_token, "%lu", &height);
|
sscanf (height_token, "%lu", &ul_height);
|
||||||
|
height = (png_uint_32) ul_height;
|
||||||
get_token(pnm_file, maxval_token);
|
get_token(pnm_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@@ -287,15 +317,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
{
|
{
|
||||||
alpha_raw = (type_token[1] == '5');
|
alpha_raw = (type_token[1] == '5');
|
||||||
get_token(alpha_file, width_token);
|
get_token(alpha_file, width_token);
|
||||||
sscanf (width_token, "%lu", &alpha_width);
|
sscanf (width_token, "%lu", &ul_alpha_width);
|
||||||
|
alpha_width=(png_uint_32) ul_alpha_width;
|
||||||
if (alpha_width != width)
|
if (alpha_width != width)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
get_token(alpha_file, height_token);
|
get_token(alpha_file, height_token);
|
||||||
sscanf (height_token, "%lu", &alpha_height);
|
sscanf (height_token, "%lu", &ul_alpha_height);
|
||||||
|
alpha_height = (png_uint_32) ul_alpha_height;
|
||||||
if (alpha_height != height)
|
if (alpha_height != height)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
get_token(alpha_file, maxval_token);
|
get_token(alpha_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
alpha_depth = 1;
|
alpha_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@@ -324,76 +357,108 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
channels = 3;
|
channels = 3;
|
||||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
channels = 4;
|
channels = 4;
|
||||||
|
#if 0
|
||||||
else
|
else
|
||||||
channels = 0; /* should not happen */
|
channels = 0; /* cannot happen */
|
||||||
|
#endif
|
||||||
|
|
||||||
alpha_present = (channels - 1) % 2;
|
alpha_present = (channels - 1) % 2;
|
||||||
|
|
||||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
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;
|
return FALSE;
|
||||||
|
|
||||||
/* read data from PNM file */
|
/* read data from PNM file */
|
||||||
pix_ptr = png_pixels;
|
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)
|
for (i = 0; i < (channels - alpha_present); i++)
|
||||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
{
|
||||||
else
|
if (raw)
|
||||||
if (bit_depth <= 8)
|
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
|
||||||
else
|
else
|
||||||
{
|
if (bit_depth <= 8)
|
||||||
tmp16 = get_value (pnm_file, bit_depth);
|
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
else
|
||||||
pix_ptr++;
|
{
|
||||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
tmp16 = get_value (pnm_file, bit_depth);
|
||||||
pix_ptr++;
|
*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) /* read alpha-channel from pgm file */
|
||||||
{
|
{
|
||||||
if (alpha_raw)
|
if (alpha_raw)
|
||||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||||
else
|
|
||||||
if (alpha_depth <= 8)
|
|
||||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
|
||||||
else
|
else
|
||||||
{
|
if (alpha_depth <= 8)
|
||||||
tmp16 = get_value (alpha_file, bit_depth);
|
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
else
|
||||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
{
|
||||||
}
|
tmp16 = get_value (alpha_file, bit_depth);
|
||||||
} /* if alpha */
|
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||||
|
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||||
|
}
|
||||||
|
} /* if alpha */
|
||||||
|
} /* if packed_bitmap */
|
||||||
} /* end for col */
|
} /* end for col */
|
||||||
} /* end for row */
|
} /* end for row */
|
||||||
|
|
||||||
/* prepare the standard PNG structures */
|
/* 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)
|
if (!png_ptr)
|
||||||
{
|
{
|
||||||
|
free (png_pixels);
|
||||||
|
png_pixels = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
info_ptr = png_create_info_struct (png_ptr);
|
info_ptr = png_create_info_struct (png_ptr);
|
||||||
if (!info_ptr)
|
if (!info_ptr)
|
||||||
{
|
{
|
||||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||||
|
free (png_pixels);
|
||||||
|
png_pixels = NULL;
|
||||||
return FALSE;
|
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 */
|
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||||
if (setjmp (png_jmpbuf(png_ptr)))
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,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 needed we will allocate memory for an new array of row-pointers */
|
||||||
if (row_pointers == (unsigned char**) NULL)
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the individual row_pointers to point at the correct offsets */
|
/* 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;
|
row_pointers[i] = png_pixels + i * row_bytes;
|
||||||
|
|
||||||
/* write out the entire image data in one call */
|
/* write out the entire image data in one call */
|
||||||
png_write_image (png_ptr, row_pointers);
|
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);
|
png_write_end (png_ptr, info_ptr);
|
||||||
|
|
||||||
/* clean up after the write, and free any memory allocated */
|
/* 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)
|
if (row_pointers != (unsigned char**) NULL)
|
||||||
free (row_pointers);
|
free (row_pointers);
|
||||||
@@ -446,19 +514,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
void get_token(FILE *pnm_file, char *token)
|
void get_token(FILE *pnm_file, char *token)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* remove white-space */
|
/* remove white-space and comment lines */
|
||||||
do
|
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] == ' '));
|
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||||
|
|
||||||
/* read string */
|
/* read string */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
ret = fgetc(pnm_file);
|
||||||
|
if (ret == EOF) break;
|
||||||
i++;
|
i++;
|
||||||
token[i] = (unsigned char) fgetc (pnm_file);
|
token[i] = (unsigned char) ret;
|
||||||
}
|
}
|
||||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||||
|
|
||||||
@@ -510,6 +591,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
|||||||
{
|
{
|
||||||
static png_uint_32 mask = 0;
|
static png_uint_32 mask = 0;
|
||||||
png_byte token[16];
|
png_byte token[16];
|
||||||
|
unsigned long ul_ret_value;
|
||||||
png_uint_32 ret_value;
|
png_uint_32 ret_value;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -518,7 +600,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
|||||||
mask = (mask << 1) | 0x01;
|
mask = (mask << 1) | 0x01;
|
||||||
|
|
||||||
get_token (pnm_file, (char *) token);
|
get_token (pnm_file, (char *) token);
|
||||||
sscanf ((const char *) token, "%lu", &ret_value);
|
sscanf ((const char *) token, "%lu", &ul_ret_value);
|
||||||
|
ret_value = (png_uint_32) ul_ret_value;
|
||||||
|
|
||||||
ret_value &= mask;
|
ret_value &= mask;
|
||||||
|
|
||||||
|
|||||||
0
contrib/pngminus/pnm2png.sh
Normal file → Executable file
@@ -1,14 +1,15 @@
|
|||||||
|
|
||||||
pngsuite
|
pngsuite
|
||||||
--------
|
--------
|
||||||
(c) Willem van Schaik, 1999
|
(c) Willem van Schaik, 1999, 2011, 2012
|
||||||
|
Two images are by Glenn Randers-Pehrson, 2012
|
||||||
|
|
||||||
Permission to use, copy, and distribute these images for any purpose and
|
Permission to use, copy, modify, and distribute these images for any
|
||||||
without fee is hereby granted.
|
purpose and without fee is hereby granted.
|
||||||
|
|
||||||
The 15 "bas*.png" images are part of the much larger PngSuite test-set of
|
The 15 "bas*.png" images are part of the much larger PngSuite test-set of
|
||||||
images, available for developers of PNG supporting software. The
|
images, available for developers of PNG supporting software. The
|
||||||
complete set, available at http:/www.schaik.com/pngsuite/, contains
|
complete set, available at http:/www.schaik.com/pngsuite/, contains
|
||||||
a variety of images to test interlacing, gamma settings, ancillary
|
a variety of images to test interlacing, gamma settings, ancillary
|
||||||
chunks, etc.
|
chunks, etc.
|
||||||
|
|
||||||
@@ -38,6 +39,8 @@ can use them to test the proper functioning of PNG software.
|
|||||||
basn6a08.png 8-bit RGBA
|
basn6a08.png 8-bit RGBA
|
||||||
basn6a16.png 16-bit RGBA
|
basn6a16.png 16-bit RGBA
|
||||||
|
|
||||||
|
ftbbn0g01.png 1-bit grayscale, black bKGD
|
||||||
|
ftbbn0g02.png 2-bit grayscale, black bKGD
|
||||||
ftbbn0g04.png 4-bit grayscale, black bKGD
|
ftbbn0g04.png 4-bit grayscale, black bKGD
|
||||||
ftbbn2c16.png 16-bit truecolor, black bKGD
|
ftbbn2c16.png 16-bit truecolor, black bKGD
|
||||||
ftbbn3p08.png 8-bit paletted, black bKGD
|
ftbbn3p08.png 8-bit paletted, black bKGD
|
||||||
@@ -48,11 +51,11 @@ can use them to test the proper functioning of PNG software.
|
|||||||
ftbwn3p08.png 8-bit paletted, white bKGD
|
ftbwn3p08.png 8-bit paletted, white bKGD
|
||||||
ftbyn3p08.png 8-bit paletted, yellow bKGD
|
ftbyn3p08.png 8-bit paletted, yellow bKGD
|
||||||
ftp0n0g08.png 8-bit grayscale, opaque
|
ftp0n0g08.png 8-bit grayscale, opaque
|
||||||
ftp0n2c08.png 8-bit truecolor, opaque
|
ftp0n2c08.png 8-bit truecolor, opaque
|
||||||
ftp0n3p08.png 8-bit paletted, opaque
|
ftp0n3p08.png 8-bit paletted, opaque
|
||||||
ftp1n3p08.png 8-bit paletted, no bKGD
|
ftp1n3p08.png 8-bit paletted, no bKGD
|
||||||
|
|
||||||
Here is the correct result of typing "pngtest -m *.png" in
|
Here is the correct result of typing "pngtest -m bas*.png" in
|
||||||
this directory:
|
this directory:
|
||||||
|
|
||||||
Testing basn0g01.png: PASS (524 zero samples)
|
Testing basn0g01.png: PASS (524 zero samples)
|
||||||
|
|||||||
BIN
contrib/pngsuite/ftbbn0g01.png
Normal file
|
After Width: | Height: | Size: 176 B |
BIN
contrib/pngsuite/ftbbn0g02.png
Normal file
|
After Width: | Height: | Size: 197 B |
|
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
26
contrib/tools/README.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
This directory (contrib/tools) contains tools used by the authors of libpng.
|
||||||
|
|
||||||
|
Code and data placed in this directory is not required to build libpng,
|
||||||
|
however the code in this directory has been used to generate data or code in
|
||||||
|
the body of the libpng source. The source code identifies where this has
|
||||||
|
been done. Code in this directory may not compile on all operating systems
|
||||||
|
that libpng supports.
|
||||||
|
|
||||||
|
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
|
||||||
|
|
||||||
|
To the extent possible under law, the authors have waived all copyright and
|
||||||
|
related or neighboring rights to this work. This work is published from:
|
||||||
|
United States.
|
||||||
|
|
||||||
|
The files may be used freely in any way.
|
||||||
|
|
||||||
|
The source code and comments in this directory are the original work of the
|
||||||
|
people named below. No other person or organization has made contributions to
|
||||||
|
the work in this directory.
|
||||||
|
|
||||||
|
ORIGINAL AUTHORS
|
||||||
|
The following people have contributed to the code in this directory. None
|
||||||
|
of the people below claim any rights with regard to the contents of this
|
||||||
|
directory.
|
||||||
|
|
||||||
|
John Bowler <jbowler@acm.org>
|
||||||
102
contrib/tools/checksum-icc.c
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/* checksum-icc.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013 John Cunningham Bowler
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* Generate crc32 and adler32 checksums of the given input files, used to
|
||||||
|
* generate check-codes for use when matching ICC profiles within libpng.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
read_one_file(FILE *ip, const char *name)
|
||||||
|
{
|
||||||
|
uLong length = 0;
|
||||||
|
uLong a32 = adler32(0, NULL, 0);
|
||||||
|
uLong c32 = crc32(0, NULL, 0);
|
||||||
|
Byte header[132];
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
int ch = getc(ip);
|
||||||
|
Byte b;
|
||||||
|
|
||||||
|
if (ch == EOF) break;
|
||||||
|
|
||||||
|
b = (Byte)ch;
|
||||||
|
|
||||||
|
if (length < sizeof header)
|
||||||
|
header[length] = b;
|
||||||
|
|
||||||
|
++length;
|
||||||
|
a32 = adler32(a32, &b, 1);
|
||||||
|
c32 = crc32(c32, &b, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(ip))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Success */
|
||||||
|
printf("PNG_ICC_CHECKSUM(0x%8.8lx, 0x%8.8lx,\n PNG_MD5("
|
||||||
|
"0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x,"
|
||||||
|
" 0x%2.2x%2.2x%2.2x%2.2x), %d,\n"
|
||||||
|
" \"%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d\", %lu, \"%s\")\n",
|
||||||
|
(unsigned long)a32, (unsigned long)c32,
|
||||||
|
header[84], header[85], header[86], header[87],
|
||||||
|
header[88], header[89], header[90], header[91],
|
||||||
|
header[92], header[93], header[94], header[95],
|
||||||
|
header[96], header[97], header[98], header[99],
|
||||||
|
# define u16(x) (header[x] * 256 + header[x+1])
|
||||||
|
# define u32(x) (u16(x) * 65536 + u16(x+2))
|
||||||
|
u32(64), u16(24), u16(26), u16(28), u16(30), u16(32), u16(34),
|
||||||
|
(unsigned long)length, name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
printf("/* adler32, crc32, MD5[16], intent, date, length, file-name */\n");
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
FILE *ip = fopen(argv[i], "rb");
|
||||||
|
|
||||||
|
if (ip == NULL || !read_one_file(ip, argv[i]))
|
||||||
|
{
|
||||||
|
err = 1;
|
||||||
|
perror(argv[i]);
|
||||||
|
fprintf(stderr, "%s: read error\n", argv[i]);
|
||||||
|
printf("/* ERROR: %s */\n", argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)fclose(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!read_one_file(stdin, "-"))
|
||||||
|
{
|
||||||
|
err = 1;
|
||||||
|
perror("stdin");
|
||||||
|
fprintf(stderr, "stdin: read error\n");
|
||||||
|
printf("/* ERROR: stdin */\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
437
contrib/tools/chunkhash.c
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
/* chunkhash.c -- build a perfect hash code for the chunk names on stdin.
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Feed this program all the known chunks that libpng must recognize. It will
|
||||||
|
* generate an appropriate hash key for the macro in pngpriv.h To generate the
|
||||||
|
* list of chunks currently defined in png.h do this:
|
||||||
|
*
|
||||||
|
* sed -n -e 's/^#define png_\(....\) PNG_U32.*$/\1/p' png.h
|
||||||
|
*
|
||||||
|
* An alternative to using this program is to pipe the output of the above
|
||||||
|
* through gperf, however the code generated by perf is somewhat more verbose
|
||||||
|
* and it doesn't generate as good a result (however it's a heck of a lot faster
|
||||||
|
* than this program!)
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <png.h> /* for the libpng types for this platform */
|
||||||
|
|
||||||
|
/* The machine generated file is checked in, so this works and it obtains the
|
||||||
|
* definition of the PNG_CHUNK_HASH macro. To change this definition only ever
|
||||||
|
* alter the strings below!
|
||||||
|
*/
|
||||||
|
#include "chunkhash.h"
|
||||||
|
|
||||||
|
/* The best_ variables are local variables defined in the functions below. When
|
||||||
|
* used in libpng code, however, they are just constants.
|
||||||
|
*/
|
||||||
|
#define PNG_CHUNK_HASH_MASK best_mask
|
||||||
|
#define PNG_CHUNK_HASH_C0 best_c[0]
|
||||||
|
#define PNG_CHUNK_HASH_C1 best_c[1]
|
||||||
|
#define PNG_CHUNK_HASH_C2 best_c[2]
|
||||||
|
#define PNG_CHUNK_HASH_C3 best_c[3]
|
||||||
|
|
||||||
|
/* These strings contain the C text to copy into the new version of
|
||||||
|
* contrib/tools/chunkhash.c
|
||||||
|
*/
|
||||||
|
static const char *strings[] = {
|
||||||
|
"/* chunkhash.h -- a perfect hash code for the chunk names in png.h",
|
||||||
|
" *",
|
||||||
|
" * Last changed in libpng 1.7.0 [(PENDING RELEASE)]",
|
||||||
|
" *",
|
||||||
|
" * THIS IS A MACHINE GENERATED FILE. See contrib/tools/chunkhash.c for",
|
||||||
|
" * copyright and other information.",
|
||||||
|
" *",
|
||||||
|
" * USAGE: To include the PNG_CHUNK_HASH macro and associated definitions:",
|
||||||
|
" *",
|
||||||
|
" * #define PNG_CHUNKHASH_DEFS",
|
||||||
|
" * #include \"contrib/tools/chunkhash.h\"",
|
||||||
|
" *",
|
||||||
|
" * To define the png_chunk_hash array used by the macro:",
|
||||||
|
" *",
|
||||||
|
" * #define PNG_CHUNKHASH_CODE",
|
||||||
|
" * #include \"contrib/tools/chunkhash.h\"",
|
||||||
|
" *",
|
||||||
|
" * One or both of the defines must be given except when building chunkhash",
|
||||||
|
" * itself.",
|
||||||
|
" */",
|
||||||
|
"#ifdef PNG_CHUNKHASH_DEFS",
|
||||||
|
"#ifndef PNG_CHUNKHASH_H",
|
||||||
|
"#define PNG_CHUNKHASH_H",
|
||||||
|
"/* A perfect hash code - returns a value 0..(PNG_KNOWN_CHUNK_COUNT-1) and is",
|
||||||
|
" * generated by the ridiculously simple program in contrib/tools/chunkhash.c",
|
||||||
|
" *",
|
||||||
|
" * The hash code used here multiplies each byte by a different constant to",
|
||||||
|
" * return a single number:",
|
||||||
|
" *",
|
||||||
|
" * b0 * c[0] + b1 * [c1] + b2 * c[2] + b3 * c[3]",
|
||||||
|
" *",
|
||||||
|
" * The values of the constants are found by search using the a table of",
|
||||||
|
" * primes, including 0, and may be (in fact are at present) 0 for some of the",
|
||||||
|
" * bytes, the compiler is expected to optimize multiply by zero, or one!",
|
||||||
|
" *",
|
||||||
|
" * The lookup table reduces the sparse result of the hash calculation to the",
|
||||||
|
" * correct index values. The chunks are indexed in the string order of the",
|
||||||
|
" * png_uint_32 chunk names.",
|
||||||
|
" */",
|
||||||
|
0, /* HEADER definitions go here */
|
||||||
|
"",
|
||||||
|
"extern const png_byte png_chunk_hash[PNG_CHUNK_HASH_MASK+1];",
|
||||||
|
"#endif /* !PNG_CHUNKHASH_H */",
|
||||||
|
"#endif /* PNG_CHUNKHASH_DEFS */",
|
||||||
|
"",
|
||||||
|
"#ifndef PNG_CHUNK_HASH",
|
||||||
|
"#define PNG_CHUNK_HASH(chunk) (png_chunk_hash[PNG_CHUNK_HASH_MASK & (\\",
|
||||||
|
" ((chunk) >> 24) * PNG_CHUNK_HASH_C0 +\\",
|
||||||
|
" ((chunk) >> 16) * PNG_CHUNK_HASH_C1 +\\",
|
||||||
|
" ((chunk) >> 8) * PNG_CHUNK_HASH_C2 +\\",
|
||||||
|
" ((chunk) ) * PNG_CHUNK_HASH_C3)])",
|
||||||
|
"#endif",
|
||||||
|
"",
|
||||||
|
"#ifdef PNG_CHUNKHASH_CODE",
|
||||||
|
"#ifndef PNG_CHUNKHASH_C",
|
||||||
|
"#define PNG_CHUNKHASH_C",
|
||||||
|
"const png_byte png_chunk_hash[PNG_CHUNK_HASH_MASK+1] = {",
|
||||||
|
0, /* png.c definitions go here */
|
||||||
|
"};",
|
||||||
|
"#endif /* !PNG_CHUNKHASH_C */",
|
||||||
|
"#endif /* PNG_CHUNKHASH_CODE */",
|
||||||
|
0 /* end of file */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CHUNK_COUNT_MAX 32
|
||||||
|
/* If necessary this is easy to increase; just don't use a png_uint_32
|
||||||
|
* bitmask below, however it doesn't seem likely that the limit will be hit
|
||||||
|
* any time soon.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const png_byte
|
||||||
|
chunk_hash[256] =
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||||
|
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||||
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
|
||||||
|
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
|
||||||
|
79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
|
||||||
|
98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
|
||||||
|
114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
|
||||||
|
129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
|
||||||
|
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
|
||||||
|
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
|
||||||
|
174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
|
||||||
|
189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
|
||||||
|
204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
|
||||||
|
219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
|
||||||
|
234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248,
|
||||||
|
249, 250, 251, 252, 253, 254, 255
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
error(const char *string)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "chunkhash: %s\n", string);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a hash code for the given chunk; this is the same as the pngpriv.h
|
||||||
|
* macro, but parameterized. The names of the parameters have to be chosen to
|
||||||
|
* match the above #defines.
|
||||||
|
*/
|
||||||
|
static png_uint_32
|
||||||
|
test_hash(png_uint_32 chunk, const unsigned int *best_c, png_uint_32 best_mask)
|
||||||
|
{
|
||||||
|
# define png_chunk_hash chunk_hash /* prevents lookup */
|
||||||
|
return PNG_CHUNK_HASH(chunk);
|
||||||
|
# undef png_chunk_hash
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_chunks(const png_uint_32 *chunks, unsigned int nchunks, png_uint_32 first,
|
||||||
|
png_uint_32 last, const unsigned int *best_c, png_uint_32 best_mask,
|
||||||
|
const png_byte *lut)
|
||||||
|
{
|
||||||
|
/* 'last' is the last code to print plus 1, this is used to detect duplicates
|
||||||
|
* (which should not happen - if there are any it's an internal error!)
|
||||||
|
*/
|
||||||
|
if (nchunks > 0)
|
||||||
|
{
|
||||||
|
/* Recursive algorithm; find the hash code of the next chunk, then print
|
||||||
|
* all remaining chunks with codes in the range first..code (including
|
||||||
|
* duplicates) and after print all remaining chunks with codes in the
|
||||||
|
* range (code+1)..last
|
||||||
|
*/
|
||||||
|
const png_uint_32 chunk = *chunks++;
|
||||||
|
# define png_chunk_hash lut
|
||||||
|
const png_uint_32 code = PNG_CHUNK_HASH(chunk);
|
||||||
|
# undef png_chunk_hash
|
||||||
|
|
||||||
|
--nchunks;
|
||||||
|
|
||||||
|
/* The code might be out of the print range */
|
||||||
|
if (code >= first && code <= last)
|
||||||
|
{
|
||||||
|
if (code >= first) /* not time yet */
|
||||||
|
print_chunks(chunks, nchunks, first, code, best_c, best_mask, lut);
|
||||||
|
|
||||||
|
printf("#define PNG_CHUNK_%c%c%c%c_TAG %lu%s\n", (char)(chunk>>24),
|
||||||
|
(char)(chunk>>16), (char)(chunk>>8), (char)chunk,
|
||||||
|
(unsigned long)code, code == last ? " /* DUPLICATE */" : "");
|
||||||
|
|
||||||
|
if (code < last) /* still some to go */
|
||||||
|
print_chunks(chunks, nchunks, code+1, last, best_c, best_mask, lut);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
print_chunks(chunks, nchunks, first, last, best_c, best_mask, lut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int primes[] =
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
|
||||||
|
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
|
||||||
|
151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
|
||||||
|
233, 239, 241, 251
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NPRIMES ((sizeof primes)/(sizeof primes[0]))
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
/* Stdin should just contain chunk names, one per line */
|
||||||
|
png_uint_32 best_mask;
|
||||||
|
unsigned int best_c[4];
|
||||||
|
png_uint_32 chunks[CHUNK_COUNT_MAX];
|
||||||
|
png_byte known_chunk_count;
|
||||||
|
|
||||||
|
/* Not required; stop GCC whining: */
|
||||||
|
memset(best_c, 0xab, sizeof best_c);
|
||||||
|
best_mask = 0x12345678;
|
||||||
|
|
||||||
|
{
|
||||||
|
png_uint_32 this_chunk = 0;
|
||||||
|
png_byte n_chunks = 0;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
int ch = getchar();
|
||||||
|
|
||||||
|
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
|
||||||
|
{
|
||||||
|
if (this_chunk > 0xffffffU)
|
||||||
|
error("chunk name too long");
|
||||||
|
|
||||||
|
this_chunk = (this_chunk << 8) + (unsigned)ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this_chunk > 0)
|
||||||
|
{
|
||||||
|
if (this_chunk <= 0xffffffU)
|
||||||
|
error("chunk name too short");
|
||||||
|
|
||||||
|
if (n_chunks >= CHUNK_COUNT_MAX)
|
||||||
|
error("too many chunks (check CHUNK_COUNT_MAX)");
|
||||||
|
|
||||||
|
chunks[n_chunks++] = this_chunk;
|
||||||
|
this_chunk = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 22 is the number of chunks currently defined (excluding fRAc), at any
|
||||||
|
* time it should also be in PNG_KNOWN_CHUNK_COUNT, but this run of
|
||||||
|
* chunkhash may be trying to add a chunk so allow bigger numbers.
|
||||||
|
*/
|
||||||
|
# ifdef PNG_KNOWN_CHUNK_COUNT
|
||||||
|
# define CHUNK_COUNT_MIN PNG_KNOWN_CHUNK_COUNT
|
||||||
|
# else
|
||||||
|
# define CHUNK_COUNT_MIN 26
|
||||||
|
# endif
|
||||||
|
if (n_chunks < CHUNK_COUNT_MIN)
|
||||||
|
error("too few chunks (expecting at least 26)");
|
||||||
|
|
||||||
|
known_chunk_count = n_chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Exhaustive search of the hash parameters - in fact this isn't very slow at
|
||||||
|
* all.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
unsigned int i1, c_zero = 0, c_one = 0;
|
||||||
|
|
||||||
|
for (i1=0; i1<NPRIMES; ++i1)
|
||||||
|
{
|
||||||
|
unsigned int i2;
|
||||||
|
unsigned int c[4];
|
||||||
|
|
||||||
|
fprintf(stderr, "TEST: %u\n", primes[i1]);
|
||||||
|
c[0] = primes[i1];
|
||||||
|
|
||||||
|
for (i2=0; i2<NPRIMES; ++i2)
|
||||||
|
{
|
||||||
|
unsigned int i3;
|
||||||
|
|
||||||
|
c[1] = primes[i2];
|
||||||
|
|
||||||
|
for (i3=0; i3<NPRIMES; ++i3)
|
||||||
|
{
|
||||||
|
unsigned int i4;
|
||||||
|
|
||||||
|
c[2] = primes[i3];
|
||||||
|
|
||||||
|
for (i4=0; i4<NPRIMES; ++i4)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
png_uint_32 hash_mask = 0xffU;
|
||||||
|
png_uint_32 hashes[CHUNK_COUNT_MAX];
|
||||||
|
|
||||||
|
c[3] = primes[i4];
|
||||||
|
|
||||||
|
while (hash_mask > 0xfU)
|
||||||
|
{
|
||||||
|
for (i=0; i<known_chunk_count; ++i)
|
||||||
|
{
|
||||||
|
unsigned int j;
|
||||||
|
png_uint_32 hash = test_hash(chunks[i], c, hash_mask);
|
||||||
|
|
||||||
|
for (j=0; j<i; ++j) if (hashes[j] == hash) goto next_i4;
|
||||||
|
|
||||||
|
hashes[i] = hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
hash_mask >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
next_i4:
|
||||||
|
if (hash_mask < 0xffU)
|
||||||
|
{
|
||||||
|
/* This worked */
|
||||||
|
unsigned int best, c0 = 0, c1 = 0;
|
||||||
|
|
||||||
|
hash_mask <<= 1;
|
||||||
|
hash_mask += 1;
|
||||||
|
|
||||||
|
for (i=0; i<4; ++i)
|
||||||
|
{
|
||||||
|
if (c[i] == 0)
|
||||||
|
++c0;
|
||||||
|
|
||||||
|
else if (c[i] == 1)
|
||||||
|
++c1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hash_mask == best_mask)
|
||||||
|
best = (c0 > c_zero) || (c0 == c_zero && c1 > c_one);
|
||||||
|
|
||||||
|
else
|
||||||
|
best = (hash_mask < best_mask);
|
||||||
|
|
||||||
|
if (best)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "{%u,%u,%u,%u} & 0x%lx\n",
|
||||||
|
c[0], c[1], c[2], c[3],
|
||||||
|
(unsigned long)hash_mask);
|
||||||
|
|
||||||
|
c_zero = c0;
|
||||||
|
c_one = c1;
|
||||||
|
best_mask = hash_mask;
|
||||||
|
memcpy(best_c, c, sizeof best_c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* i4 */
|
||||||
|
} /* i3 */
|
||||||
|
} /* i2 */
|
||||||
|
} /* i1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate the LUT (png_chunk_hash) */
|
||||||
|
{
|
||||||
|
png_byte b;
|
||||||
|
png_byte lut[256];
|
||||||
|
|
||||||
|
/* A failure returns PNG_KNOWN_CHUNK_COUNT: */
|
||||||
|
memset(lut, known_chunk_count, sizeof lut);
|
||||||
|
|
||||||
|
for (b=0; b<known_chunk_count; ++b)
|
||||||
|
lut[test_hash(chunks[b], best_c, best_mask)] = b;
|
||||||
|
|
||||||
|
/* Validate the pngpriv.h hash function. */
|
||||||
|
# define png_chunk_hash lut
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i=0; i<known_chunk_count; ++i)
|
||||||
|
{
|
||||||
|
png_uint_32 chunk = chunks[i];
|
||||||
|
|
||||||
|
if (PNG_CHUNK_HASH(chunk) != i)
|
||||||
|
error("internal error: hash didn't work!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# undef lut
|
||||||
|
|
||||||
|
/* Print all the results, first the stuff for pngpriv.h */
|
||||||
|
{
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
|
while (strings[i] != 0)
|
||||||
|
puts(strings[i++]);
|
||||||
|
|
||||||
|
printf("#define PNG_CHUNK_HASH_MASK 0x%lxU\n",
|
||||||
|
(unsigned long)best_mask);
|
||||||
|
printf("#define PNG_CHUNK_HASH_C0 %u\n", best_c[0]);
|
||||||
|
printf("#define PNG_CHUNK_HASH_C1 %u\n", best_c[1]);
|
||||||
|
printf("#define PNG_CHUNK_HASH_C2 %u\n", best_c[2]);
|
||||||
|
printf("#define PNG_CHUNK_HASH_C3 %u\n", best_c[3]);
|
||||||
|
|
||||||
|
/* Print the hash codes of all the chunks */
|
||||||
|
putchar('\n');
|
||||||
|
print_chunks(chunks, known_chunk_count, 0, 0xffffffff, best_c,
|
||||||
|
best_mask, lut);
|
||||||
|
putchar('\n');
|
||||||
|
printf("#define PNG_KNOWN_CHUNK_COUNT %u\n", known_chunk_count);
|
||||||
|
|
||||||
|
while (strings[++i] != 0)
|
||||||
|
puts(strings[i]);
|
||||||
|
|
||||||
|
/* Now print the LUT */
|
||||||
|
fputs(" ", stdout);
|
||||||
|
{
|
||||||
|
unsigned int j;
|
||||||
|
|
||||||
|
for (j=0; j<=best_mask; ++j)
|
||||||
|
{
|
||||||
|
printf("%d", lut[j]);
|
||||||
|
|
||||||
|
if ((j % 16) == 15 && j < best_mask)
|
||||||
|
printf(",\n ");
|
||||||
|
|
||||||
|
else if (j < best_mask)
|
||||||
|
printf(", ");
|
||||||
|
|
||||||
|
else
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And the trailing text */
|
||||||
|
while (strings[++i] != 0)
|
||||||
|
puts(strings[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
97
contrib/tools/chunkhash.h
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/* chunkhash.h -- a perfect hash code for the chunk names in png.h
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||||
|
*
|
||||||
|
* THIS IS A MACHINE GENERATED FILE. See contrib/tools/chunkhash.c for
|
||||||
|
* copyright and other information.
|
||||||
|
*
|
||||||
|
* USAGE: To include the PNG_CHUNK_HASH macro and associated definitions:
|
||||||
|
*
|
||||||
|
* #define PNG_CHUNKHASH_DEFS
|
||||||
|
* #include "contrib/tools/chunkhash.h"
|
||||||
|
*
|
||||||
|
* To define the png_chunk_hash array used by the macro:
|
||||||
|
*
|
||||||
|
* #define PNG_CHUNKHASH_CODE
|
||||||
|
* #include "contrib/tools/chunkhash.h"
|
||||||
|
*
|
||||||
|
* One or both of the defines must be given except when building chunkhash
|
||||||
|
* itself.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_CHUNKHASH_DEFS
|
||||||
|
#ifndef PNG_CHUNKHASH_H
|
||||||
|
#define PNG_CHUNKHASH_H
|
||||||
|
/* A perfect hash code - returns a value 0..(PNG_KNOWN_CHUNK_COUNT-1) and is
|
||||||
|
* generated by the ridiculously simple program in contrib/tools/chunkhash.c
|
||||||
|
*
|
||||||
|
* The hash code used here multiplies each byte by a different constant to
|
||||||
|
* return a single number:
|
||||||
|
*
|
||||||
|
* b0 * c[0] + b1 * [c1] + b2 * c[2] + b3 * c[3]
|
||||||
|
*
|
||||||
|
* The values of the constants are found by search using the a table of
|
||||||
|
* primes, including 0, and may be (in fact are at present) 0 for some of the
|
||||||
|
* bytes, the compiler is expected to optimize multiply by zero, or one!
|
||||||
|
*
|
||||||
|
* The lookup table reduces the sparse result of the hash calculation to the
|
||||||
|
* correct index values. The chunks are indexed in the string order of the
|
||||||
|
* png_uint_32 chunk names.
|
||||||
|
*/
|
||||||
|
#define PNG_CHUNK_HASH_MASK 0x3fU
|
||||||
|
#define PNG_CHUNK_HASH_C0 103
|
||||||
|
#define PNG_CHUNK_HASH_C1 1
|
||||||
|
#define PNG_CHUNK_HASH_C2 0
|
||||||
|
#define PNG_CHUNK_HASH_C3 1
|
||||||
|
|
||||||
|
#define PNG_CHUNK_IDAT_TAG 0
|
||||||
|
#define PNG_CHUNK_IEND_TAG 1
|
||||||
|
#define PNG_CHUNK_IHDR_TAG 2
|
||||||
|
#define PNG_CHUNK_PLTE_TAG 3
|
||||||
|
#define PNG_CHUNK_bKGD_TAG 4
|
||||||
|
#define PNG_CHUNK_cHRM_TAG 5
|
||||||
|
#define PNG_CHUNK_fRAc_TAG 6
|
||||||
|
#define PNG_CHUNK_gAMA_TAG 7
|
||||||
|
#define PNG_CHUNK_gIFg_TAG 8
|
||||||
|
#define PNG_CHUNK_gIFt_TAG 9
|
||||||
|
#define PNG_CHUNK_gIFx_TAG 10
|
||||||
|
#define PNG_CHUNK_hIST_TAG 11
|
||||||
|
#define PNG_CHUNK_iCCP_TAG 12
|
||||||
|
#define PNG_CHUNK_iTXt_TAG 13
|
||||||
|
#define PNG_CHUNK_oFFs_TAG 14
|
||||||
|
#define PNG_CHUNK_pCAL_TAG 15
|
||||||
|
#define PNG_CHUNK_pHYs_TAG 16
|
||||||
|
#define PNG_CHUNK_sBIT_TAG 17
|
||||||
|
#define PNG_CHUNK_sCAL_TAG 18
|
||||||
|
#define PNG_CHUNK_sPLT_TAG 19
|
||||||
|
#define PNG_CHUNK_sRGB_TAG 20
|
||||||
|
#define PNG_CHUNK_sTER_TAG 21
|
||||||
|
#define PNG_CHUNK_tEXt_TAG 22
|
||||||
|
#define PNG_CHUNK_tIME_TAG 23
|
||||||
|
#define PNG_CHUNK_tRNS_TAG 24
|
||||||
|
#define PNG_CHUNK_zTXt_TAG 25
|
||||||
|
|
||||||
|
#define PNG_KNOWN_CHUNK_COUNT 26
|
||||||
|
|
||||||
|
extern const png_byte png_chunk_hash[PNG_CHUNK_HASH_MASK+1];
|
||||||
|
#endif /* !PNG_CHUNKHASH_H */
|
||||||
|
#endif /* PNG_CHUNKHASH_DEFS */
|
||||||
|
|
||||||
|
#ifndef PNG_CHUNK_HASH
|
||||||
|
#define PNG_CHUNK_HASH(chunk) (png_chunk_hash[PNG_CHUNK_HASH_MASK & (\
|
||||||
|
((chunk) >> 24) * PNG_CHUNK_HASH_C0 +\
|
||||||
|
((chunk) >> 16) * PNG_CHUNK_HASH_C1 +\
|
||||||
|
((chunk) >> 8) * PNG_CHUNK_HASH_C2 +\
|
||||||
|
((chunk) ) * PNG_CHUNK_HASH_C3)])
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_CHUNKHASH_CODE
|
||||||
|
#ifndef PNG_CHUNKHASH_C
|
||||||
|
#define PNG_CHUNKHASH_C
|
||||||
|
const png_byte png_chunk_hash[PNG_CHUNK_HASH_MASK+1] = {
|
||||||
|
26, 3, 26, 26, 26, 26, 26, 13, 26, 26, 26, 16, 26, 26, 26, 26,
|
||||||
|
26, 24, 12, 26, 18, 26, 26, 26, 26, 20, 26, 17, 26, 26, 25, 15,
|
||||||
|
26, 8, 14, 26, 26, 22, 26, 26, 1, 19, 5, 21, 26, 26, 9, 26,
|
||||||
|
26, 26, 10, 7, 26, 11, 26, 0, 26, 2, 23, 26, 26, 4, 26, 6
|
||||||
|
};
|
||||||
|
#endif /* !PNG_CHUNKHASH_C */
|
||||||
|
#endif /* PNG_CHUNKHASH_CODE */
|
||||||
188
contrib/tools/cvtcolor.c
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
/*-
|
||||||
|
* convert.c
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Convert 8-bit sRGB or 16-bit linear values to another format.
|
||||||
|
*/
|
||||||
|
#define _ISOC99_SOURCE 1
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <fenv.h>
|
||||||
|
|
||||||
|
#include "sRGB.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(const char *prog)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: usage: %s [-linear|-sRGB] [-gray|-color] component{1,4}\n",
|
||||||
|
prog, prog);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
component(const char *prog, const char *arg, int issRGB)
|
||||||
|
{
|
||||||
|
char *ep;
|
||||||
|
unsigned long c = strtoul(arg, &ep, 0);
|
||||||
|
|
||||||
|
if (ep <= arg || *ep || c > 65535 || (issRGB && c > 255))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s: invalid component value (%lu)\n", prog, arg, c);
|
||||||
|
usage(prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
const char *prog = *argv++;
|
||||||
|
int to_linear = 0, to_gray = 0, to_color = 0;
|
||||||
|
int channels = 0;
|
||||||
|
double c[4];
|
||||||
|
|
||||||
|
/* FE_TONEAREST is the IEEE754 round to nearest, preferring even, mode; i.e.
|
||||||
|
* everything rounds to the nearest value except that '.5' rounds to the
|
||||||
|
* nearest even value.
|
||||||
|
*/
|
||||||
|
fesetround(FE_TONEAREST);
|
||||||
|
|
||||||
|
c[3] = c[2] = c[1] = c[0] = 0;
|
||||||
|
|
||||||
|
while (--argc > 0 && **argv == '-')
|
||||||
|
{
|
||||||
|
const char *arg = 1+*argv++;
|
||||||
|
|
||||||
|
if (strcmp(arg, "sRGB") == 0)
|
||||||
|
to_linear = 0;
|
||||||
|
|
||||||
|
else if (strcmp(arg, "linear") == 0)
|
||||||
|
to_linear = 1;
|
||||||
|
|
||||||
|
else if (strcmp(arg, "gray") == 0)
|
||||||
|
to_gray = 1, to_color = 0;
|
||||||
|
|
||||||
|
else if (strcmp(arg, "color") == 0)
|
||||||
|
to_gray = 0, to_color = 1;
|
||||||
|
|
||||||
|
else
|
||||||
|
usage(prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (argc)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
usage(prog);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
c[3] = component(prog, argv[3], to_linear);
|
||||||
|
++channels;
|
||||||
|
case 3:
|
||||||
|
c[2] = component(prog, argv[2], to_linear);
|
||||||
|
++channels;
|
||||||
|
case 2:
|
||||||
|
c[1] = component(prog, argv[1], to_linear);
|
||||||
|
++channels;
|
||||||
|
case 1:
|
||||||
|
c[0] = component(prog, argv[0], to_linear);
|
||||||
|
++channels;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_linear)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int components = channels;
|
||||||
|
|
||||||
|
if ((components & 1) == 0)
|
||||||
|
--components;
|
||||||
|
|
||||||
|
for (i=0; i<components; ++i) c[i] = linear_from_sRGB(c[i] / 255);
|
||||||
|
if (components < channels)
|
||||||
|
c[components] = c[components] / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i<4; ++i) c[i] /= 65535;
|
||||||
|
|
||||||
|
if ((channels & 1) == 0)
|
||||||
|
{
|
||||||
|
double alpha = c[channels-1];
|
||||||
|
|
||||||
|
if (alpha > 0)
|
||||||
|
for (i=0; i<channels-1; ++i) c[i] /= alpha;
|
||||||
|
else
|
||||||
|
for (i=0; i<channels-1; ++i) c[i] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_gray)
|
||||||
|
{
|
||||||
|
if (channels < 3)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: too few channels (%d) for -gray\n",
|
||||||
|
prog, channels);
|
||||||
|
usage(prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
c[0] = YfromRGB(c[0], c[1], c[2]);
|
||||||
|
channels -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_color)
|
||||||
|
{
|
||||||
|
if (channels > 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: too many channels (%d) for -color\n",
|
||||||
|
prog, channels);
|
||||||
|
usage(prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
c[3] = c[1]; /* alpha, if present */
|
||||||
|
c[2] = c[1] = c[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_linear)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if ((channels & 1) == 0)
|
||||||
|
{
|
||||||
|
double alpha = c[channels-1];
|
||||||
|
for (i=0; i<channels-1; ++i) c[i] *= alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<channels; ++i) c[i] = nearbyint(c[i] * 65535);
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* to sRGB */
|
||||||
|
{
|
||||||
|
int i = (channels+1)&~1;
|
||||||
|
while (--i >= 0)
|
||||||
|
c[i] = sRGB_from_linear(c[i]);
|
||||||
|
|
||||||
|
for (i=0; i<channels; ++i) c[i] = nearbyint(c[i] * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i<channels; ++i) printf(" %g", c[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||